GL 3.0 basecde Beta for Windws and Linux(GLX)

Started by
5 comments, last by trexmaster78 15 years, 4 months ago
Hey everybody, after a long time with no news (we've been pretty busy with other projects) here's a new basecode! As OpenGL 3.0 drivers for NVidia cards are out for Windows and Linux now I've set something up for you: a sample for setting up an OpenGL 3.0 context. This code is not completely finished yet and lacks loads of comments (especially in the GLX window part), but its there for you to test and criticize! You need to have the appropriate drivers installed to run the code: Windows: Forceware 177.89 or later, GL 3.0 enabled with nvemulate as explained on the NVidia page Linux: Forceware 177.61 from the same nvidia page. Download it here and tell me what you think. There's a project file for: Linux - Code::Blocks: Lesson01GLX.cbp, you need libXxf86vm-dev installed Windows - Visual C++ Express: Lessn01Win.vcproj Please tell me about everything you don't like, don't understand, do like or whatever [smile]. Cheers Carsten (aka Caste) @ NeHe Team [Edited by - Caste on October 27, 2008 5:09:35 PM]
Advertisement
Hello, I've posted that in the Alternative Game Libraries forum but I figured that since you've made a GL3 base code I might as well also ask here.

I was wondering how do you set up an OpenGL 3.0 rendering context with SDL v1.2.x (I know it'll be taken care of by SDL 1.3.x, but that isn't available yet) ?

As far as I know, here's what I'd do :
- create the window with SDL_SetVideoMode()
- get the window handle with GetActiveWindow()
- get the context handle with GetDC()
- (re)init the context in GL3 mode with wglCreateContextAttribsARB()
- maybe make it the current rendering context with wglMakeContextCurrentARB()

Which would give something like that :
SDL_SetVideoMode (width, height, 32, SDL_HWSURFACE|SDL_OPENGL);HDC context = GetDC(GetActiveWindow());int attribs []= {		 WGL_CONTEXT_MAJOR_VERSION_ARB, 3,		 WGL_CONTEXT_MINOR_VERSION_ARB, 0,		 WGL_CONTEXT_FLAGS_ARB, 0, 0                };HGLRC GL_context = wglCreateContextAttribsARB(context, 0, attribs);wglMakeContextCurrentARB (context, context, GL_context);


Should this work ?

PS : I've seen the thread in SDL's mailing list and Sam Latinga's answer saying they'll implement GL3 context support in SDL 1.3 sometime soon. What I'm looking for is a temporary solution while waiting for that.
The way you suggested is the way I would do it. It was me that asked the mailing list about GL 3 support in 1.3, but I looked at the commits the other day and as far as I can see hasn't been done yet. Perhaps I will prod the mailing list once more ;)
Member of the NeHe team.
Quote:Original post by Kazade
The way you suggested is the way I would do it.


Thanks, I think that I'll try it before the end of the week. I'll let you know how that goes.

Quote:Original post by Kazade
It was me that asked the mailing list about GL 3 support in 1.3, but I looked at the commits the other day and as far as I can see hasn't been done yet. Perhaps I will prod the mailing list once more ;)


I took a look at the context creation functions that are defined in SDL/src/video/(driver)/sdl_(driver)opengl.c (replace (driver) by the driver's name, i.e win32 for Windows for example). Here it is :
SDL_GLContextWIN_GL_CreateContext(_THIS, SDL_Window * window){    HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;    HGLRC context;    context = _this->gl_data->wglCreateContext(hdc);    if (!context) {        SDL_SetError("Could not create GL context");        return NULL;    }    if (WIN_GL_MakeCurrent(_this, window, context) < 0) {        WIN_GL_DeleteContext(_this, context);        return NULL;    }    WIN_GL_InitExtensions(_this, hdc);    return context;}


Looks like it'd be the right place to make the changes necessary to support GL3, but those haven't been made yet [grin]
It just needs a way to pass the attributes to the function, maybe that could be done through the userdata member of the SDL_Window struct (if that isn't used somewhere else for something else).

While I'm here, I also have a question concerning your basecode. I see that you're setting up the attributes for the context like that :
int attribs[] = {		 WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.0 context		 WGL_CONTEXT_MINOR_VERSION_ARB, 0,		 //and it shall be forward compatible so that we can only use up to date functionality		 WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,	0}; //zero indicates the end of the array

But NVidia's developer page concerning the GL3 driver says that Forward-compatible and Debug contexts aren't supported yet. So unless the page isn't up-to-date, those attributes won't work on any Nvidia card and WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB must be replaced by 0. Right ?

PS : I think I'm gonne subscribe to SDL's mailing list since I've got so many questions about it [lol]
Quote:But NVidia's developer page concerning the GL3 driver says that Forward-compatible and Debug contexts aren't supported yet. So unless the page isn't up-to-date, those attributes won't work on any Nvidia card and WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB must be replaced by 0. Right ?


Well partially right, yes.. It is not yet supported thats true, but atm it just does nothing.. you get a fully compatible GL3 context and once it is implemented in the drivers you'll be notified if you use deprecated functionality.

So.. leave it where it is [wink]
Looking at the mailing list it seems like Sam has implemented some GL3 changes into SDL 1.3 it might be worth checking out the branch to test it.
Member of the NeHe team.
Hmmm... I can't see any new commits to SVN concerning the video part of SDL's source code.

Maybe he's made the modifications on a local copy and hasn't submitted them yet. However, he seems to need a snippet of 3.0 specific GL code easy to paste in his code in order to test the context created.

This topic is closed to new replies.

Advertisement