The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Bad OpenGL context handling.
Joonas Lahtinen
Guest

Hi,
While developing one application I came across with the following odd
behavior. This simple testcase fails, even I don't see any reason it should,
except SDL's incorrect managing of the OpenGL context. Many other functions,
like glBegin etc. do work on the second round of initializing SDL's video
capabilities again. So, is there something I'm doing wrong or is it just a
bug?

/* begin main.c */
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
#include "SDL_opengl.h"

void mess_with_video()
{
if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
abort();
if(SDL_GL_LoadLibrary(NULL) == -1)
abort();
const GLubyte*(*func)(GLenum);
if((func = SDL_GL_GetProcAddress("glGetString")) == NULL)
abort();
if(func(GL_EXTENSIONS) == NULL)
{
printf("Failed...\n");
abort();
}

SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

int main(int argc, char* argv[])
{
if(SDL_Init(0) == -1)
return 1;
mess_with_video();
mess_with_video();
SDL_Quit();
return 0;
}
/* end main.c */

Regards, Joonas.
--
Joonas "dolphin" Lahtinen <joonas at linuxgamepublishing.com>
Bad OpenGL context handling.
Richard J Hancock
Guest

In this test case, you are not setting up a GL context. Without a
context, the functions behaviour is undefined. The fact that glBegin
and glEnd work is not a true test since a context is not needed to tell
a system you are ready to draw.

HTH,
Richard

On Fri, 2006-01-06 at 11:17 +0200, Joonas Lahtinen wrote:
Quote:
Hi,
While developing one application I came across with the following odd
behavior. This simple testcase fails, even I don't see any reason it should,
except SDL's incorrect managing of the OpenGL context. Many other functions,
like glBegin etc. do work on the second round of initializing SDL's video
capabilities again. So, is there something I'm doing wrong or is it just a
bug?

/* begin main.c */
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
#include "SDL_opengl.h"

void mess_with_video()
{
if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1)
abort();
if(SDL_GL_LoadLibrary(NULL) == -1)
abort();
const GLubyte*(*func)(GLenum);
if((func = SDL_GL_GetProcAddress("glGetString")) == NULL)
abort();
if(func(GL_EXTENSIONS) == NULL)
{
printf("Failed...\n");
abort();
}

SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

int main(int argc, char* argv[])
{
if(SDL_Init(0) == -1)
return 1;
mess_with_video();
mess_with_video();
SDL_Quit();
return 0;
}
/* end main.c */

Regards, Joonas.
Bad OpenGL context handling.
Ryan C. Gordon
Guest

Quote:
if(SDL_GL_LoadLibrary(NULL) == -1)
abort();
const GLubyte*(*func)(GLenum);
if((func = SDL_GL_GetProcAddress("glGetString")) == NULL)
abort();

Call SDL_SetVideoMode() after SDL_GL_LoadLibrary() and before
SDL_GL_GetProcAddress().

--ryan.
Bad OpenGL context handling.
Joonas Lahtinen
Guest

On Friday 06 January 2006 15:18, Ryan C. Gordon wrote:
Quote:
Quote:
if(SDL_GL_LoadLibrary(NULL) == -1)
abort();
const GLubyte*(*func)(GLenum);
if((func = SDL_GL_GetProcAddress("glGetString")) == NULL)
abort();

Call SDL_SetVideoMode() after SDL_GL_LoadLibrary() and before
SDL_GL_GetProcAddress().

I'm not willing to have any window yet by the time I do this. Obviously this
means I will have to handle the context on my own, right?

Regards, Joonas
Quote:

--ryan.


_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

--
Joonas "dolphin" Lahtinen <joonas at linuxgamepublishing.com>