4

I've got a simple application showing a custom frame buffer (it is sort of an emulator of the frame buffer functionality) using OpenGL:

void GLWidget::resizeGL( int w, int h )
{
    glViewport( 0, 0, w, h );
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrtho( 0, w, 0, h, -1, 1 );
}

void GLWidget::paintGL()
{
    if( pScreen != 0 )
    {
        glRasterPos2i( 0, 2 * pScreen->height );
        glPixelZoom( 2, -2 );
        glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
        glDrawPixels( pScreen->width, pScreen->height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pScreen->pixels );
    }
}

Really, this is all I want to do it, no shaders, no fancy tricks, just the double zoom and show. This code is years old and while porting it to Windows I've noticed that it wont compile anymore. First I thought it's a Windows specific thing but then I realized it's actually the new OpenGL Windows 7 comes with (unlike Arch Linux I'm using on daily basis).

So what to do about that? I really don't feel like installing a custom math library for the matrix stuff, I can't believe the latest OpenGL can't "just show the buffer".

Miro Kropacek
  • 2,742
  • 4
  • 26
  • 41
  • 1
    OpenGL doesn't exist to "just show the buffer". That's a bad use of the API, because it requires very slow operations. – Nicol Bolas Jul 18 '13 at 23:21
  • Well, I'm open to suggestions. But nothing like "insert and update an image within a label" kind of solutions, please. – Miro Kropacek Jul 19 '13 at 00:10
  • Then there are no solutions for you. Modern OpenGL is not that kind of API. Maybe you should look into something higher level. – Nicol Bolas Jul 19 '13 at 00:32
  • Is it not possible to [create a legacy OpenGL context](https://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)) on Windows 7? – user1118321 Jul 19 '13 at 05:33
  • 1
    What are the compiler errors? OpenGL is very backwards compatible, I don't think you ever _have_ to replace deprecated functions. – Andreas Haferburg Jul 19 '13 at 06:00
  • you should be able to use Compatibility profile and use even old opengl version 1.1. See similar post here: http://stackoverflow.com/questions/12072799/an-alternative-to-gldrawpixels-in-opengl-3-0 – fen Jul 19 '13 at 06:49
  • @AndreasHaferburg: yes, this is what I thought, too. The errors are normal "function undeclared", as they were really erased. If there's a magic #define which would set OpenGL to the legacy mode, I'm all ears. To be honest, I'm not very experienced in OpenGL, esp. the new stuff with shaders and quads. – Miro Kropacek Jul 19 '13 at 11:31

1 Answers1

2

I'll have to answer this for myself. After a long research, I finally found the case. This answer gives perfect explanation what's going on. Also, I somehow missed this in the Qt download section:

The Windows offline installers are by default ANGLE based.

what leads to even more sophisticated explanation, in short:

Qt 5 on Windows can be configured to use either OpenGL drivers, or DirectX drivers through the ANGLE library.

I'm surprised that so few (one?) SO answers mention this. A lot of scary stuff about contexts, quads, shaders but the solution is really simple. Hopefully it will help someone.

Community
  • 1
  • 1
Miro Kropacek
  • 2,742
  • 4
  • 26
  • 41