When OpenGL is plattform independend, but the Initialisation is not, then
OpenGL Initialisation should be part of SDL, but no more.
Dierk Ohlerich
@Dierk_Ohlerich
When OpenGL is plattform independend, but the Initialisation is not, then
OpenGL Initialisation should be part of SDL, but no more.
Dierk Ohlerich
@Dierk_Ohlerich
a small snippet of code to show how I get OpenGL to point to a window
with GTK:
Note that you can actually do this with SDL under X11, using the
system-dependent window hooks in SDL_syswm.h:
/*
For an example of working with the system-dependent window hooks, see
the ‘scrap’ example in the demos archive.
Display *dpy; XVisualInfo *vi; GLXContext glx_context;
dpy = GDK_WINDOW_XDISPLAY( window->window );
vi = glXChooseVisual( dpy, DefaultScreen(dpy), dblBuf );
if (vi == NULL) { vi = glXChooseVisual( dpy, DefaultScreen(dpy), snglBuf); if(vi == NULL) { FATAL("ERROR: glXChooseVisual failed.\n"); MyGLErrorExit(); } else DEBUGMSG(0,"Got a single-buffered display.\n"); } else DEBUGMSG(0, "Got a double-buffered display.\n");
if (vi->c_class != TrueColor)
DEBUGMSG(0, “Non-TrueColor visual selected\n”);
DEBUGMSG(0, "Selected visual = %ld\n",vi->visualid );
glx_context = glXCreateContext( dpy, vi, None, GL_TRUE);
then in my render loop:
glXMakeCurrent( paneInfo.dpy,GDK_WINDOW_XWINDOW(paneInfo.myDrawArea->window),paneInfo.glx_context);
vector<Thing*> &reqList = GetList( WE_Render ); for( u_int i = 0; i < reqList.size(); i++ ) { DEBUGMSG(0, "Rendering the %s\n", reqList[i]->GetID() ); reqList[i]->Render( paneNumber ); }
glXSwapBuffers(paneInfo.dpy,GDK_WINDOW_XWINDOW(paneInfo.myDrawArea->window));
jeff
“Dierk Ohlerich” <d_ohlerich at vcc.de> writes:
When OpenGL is plattform independend, but the Initialisation is not, then
OpenGL Initialisation should be part of SDL, but no more.
OpenGL initialization is perfectly platform independant…glut is made
for pretty much every platform I know of that runs OpenGL
and if glut isnt, all you need to do is pass a context or LPB to
OpenGL
j