Knowing my REAL OpenGL version - RESOLVED

Started by
29 comments, last by 21st Century Moose 9 years, 6 months ago

That is bad advice, aks9. There's nothing to learn when it comes to context creation, other than what a nightmare it can be if you have older (or buggy) drivers. I just look at the whole thing as risky, since if you take that code with you to other projects, one day one of the people trying the game/program out will simply not be able to run it because their driver requires a workaround.

You can do the same exact things with SDL or any other library, except you will have less grief during the process. Most of the time, anyways.

See 2:

http://richg42.blogspot.no/2014/05/things-that-drive-me-nuts-about-opengl.html

Really, why do this:

http://dantefalcone.name/tutorials/1a-windows-win32-window-and-3d-context-creation/

When SDL does it all for you in 10 lines of code. And it will work on every platform. ;)

EDIT: I downvoted you aks9, but I can't undo it. :( Your post is helpful, so I'm sorry.

Advertisement

"Father, forgive them, for they do not know what they are doing." sad.png

That is bad advice, aks9. There's nothing to learn when it comes to context creation, other than what a nightmare it can be if you have older (or buggy) drivers.

This is a typical agnostic claim. Everything is a source of knowledge. A rendering context creation is the first thing one should learn when starting with computer graphics.

But OK, I don't have time or will to argue about that.

Could you post a link, example or whatever to illustrate "the nightmare"? I've been creating GL contexts by myself about 18 years already and never had a problem. The problems could arise if you create GL 3.0+ context and hope everyone support it. Well, that is not a problem of drivers. Older drivers cannot assume what might happen in the future.

If the drivers are buggy, there is no workaround for the problem!

I just look at the whole thing as risky, since if you take that code with you to other projects, one day one of the people trying the game/program out will simply not be able to run it because their driver requires a workaround.

I really don't understand this.What kind of workaround? The way how a GL context is created is defined by the specification. Why risky?

You can do the same exact things with SDL or any other library, except you will have less grief during the process. Most of the time, anyways.

I want to have control in my hands so no intermediary stuff is welcome. It is harder at the start, but the filling of freedom is priceless.

This link is totally out of context. The guy is frustrated by something, but give no arguments for his claims.

Considering platform specific APIs for porting OpenGL, there was an initiative to make them unique. Khronos started development of EGL, but it is not adopted for desktop OpenGL yet.

EDIT: I downvoted you aks9, but I can't undo it. sad.png Your post is helpful, so I'm sorry.

Don't be sorry. That was your opinion and you have right to express it through (down)voting. Points means really nothing to me.

Forums should be the way to share knowledge and opinions. Some of them are true, some not. I hope right advices still prevail on the behalf of users.

Actually, for me it was because I was doing the same thing as you. But it didn't work on my brothers school-provided laptop. It had an older Intel model, and nothing I did worked. In the end I just gave up and used an existing library.

Thanks so much for your suggestions, Aks9 and Kaptein!

Before seeing your suggestions on Pixel format, Aks9, I gave SDL a quick spin. I used the following example code:

https://github.com/meandmark/SDLOpenGLIntro/tree/sdl2

Inside GameApp.cpp I modified the context creation to use a paticular version:


void GameApp::InitializeSDL(Uint32 width, Uint32 height, Uint32 flags)
{
    int error;
    
    error = SDL_Init(SDL_INIT_EVERYTHING);
    // Turn on double buffering.
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    // Set Context version number.
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); 
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); 
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); 

    // Create the window
    mainWindow = SDL_CreateWindow("SDL2 OpenGL Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
    mainGLContext = SDL_GL_CreateContext(mainWindow);
                        
}

I even tried older versions (like 2.0) and NSight still insists my OpenGL version is 3.0.

I would try your suggestions regarding PixelFormat, Aks9, but if SDL is failing to set the version it seems to me something else might be going on.

I wonder if I should call shenanigans on NSight, or on my graphics hardware.. really this is so frustrating!

I answered a similar question a while ago: http://www.gamedev.net/topic/661317-help-with-using-wgl/?view=findpost&p=5182765

It shows all the necessary steps to properly create a context:

create a dummy window

select a pixelformat

create a GL rendering context

call glewInit()

destroy the GL rendering context

destroy window

then create a new window

choose a ARB pixel format

select the pixel format

create a ARB rendering context

You should then be good to go.

However, it could be that NSight has a bug in it...

I even tried older versions (like 2.0) and NSight still insists my OpenGL version is 3.0.

What does glGetString(GL_VERSION) say?

That should returned the highest GL version supported by the driver.

Specification is clear:

The attribute names WGL_CONTEXT_MAJOR_VERSION_ARB and WGL_CONTEXT_MINOR_VERSION_ARB request an OpenGL context supporting the specified version of the API. If successful, the context returned must be backwards compatible with the context requested.

So, if you require GL 2.0 context, you could legitimately get GL 4.4 compatibility profile, since it is backward compatible with 2.0.

P.S. My browser or the engine that powers up this site, or both in a combination, are "lucid". All I typed down was in the same font and size, but the outcome is ridiculous. dry.png


This is a typical agnostic claim.
... the fuck?

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

create a dummy window
select a pixelformat
create a GL rendering context
call glewInit()
destroy the GL rendering context
destroy window

then create a new window
choose a ARB pixel format
select the pixel format

create a ARB rendering context

I am not even sure this is 100% legitimate, although I guess that it will probably work (or, possibly, it will "work").

There is no good reason why creating a context should require an already existing one (there's no good reason for a couple of things related to OpenGL contexts, though), but to the letter of the rulebook, you can only legitimately call GL and WGL functions if you have a valid context, and any function pointers that you have obtained are valid for only that context, thus they become invalid once you delete the context (although WGL guarantees as a "non-standard feature" that function pointers for contexts that have the same pixel format are all the same and interchangeable).

Which means that the sequence delete dummy context - delete dummy window - create new window - call WGL function to create new context is at least in theory bad mojo. I don't know if it factually matters, but my context creation code (which seems to work fine) only deletes the dummy stuff after creating the real one (and only initializes all function pointers on that one, all it does with the dummy context is pull the function pointer for wglCreateContextAttribsARB). In theory, destroying a context could unload the shared library your function pointers refer to (I highly doubt that, but who can tell) or it could do some other undefined or implementation-defined stuff, like give you a 3.x compatibility context or such when you create another context (or, a black screen).

That said, context creation is ugly stuff, avoid it if you have any possibility of doing so. I didn't want an external dependency like SDL back then, and also shared contexts looked like an attractive thing (what a mistake!), so all in all this looked like a valid reason to write my own. Father they do not know what they are doing, indeed.

Don't do that. Just use a library that works.

Thanks for all the suggestions and analysis, guys.

What does glGetString(GL_VERSION) say?

I used this information: https://www.opengl.org/wiki/Get_Context_Info

My headers don't seem to include the above function so I use this:

glGetIntegerv(GL_MAJOR_VERSION,*);

glGetIntegerv(GL_MINOR_VERSION,*);

Both of them return 4, (although I haven't tried this when using context initialization with SDL, will give that a shot). So it looks like it is creating an OpenGL 4.4 context, but I don't fully trust anything at the moment, with all these contradictory results.

I think I need to start more thoroughly questioning NSight and where it is reading its version information. Not sure what else it could be...

Could it possibly be my OpenGL headers that are somehow screwing things up?

Could it possibly be my OpenGL headers that are somehow screwing things up?

They shouldn't affect NSight. But are you using the latest headers anyway? You need glext.h & wglext.h https://www.opengl.org/registry/

This topic is closed to new replies.

Advertisement