PDA

View Full Version : Rendering mess (white box texture error)



blessman11
04-17-2011, 02:56 PM
I've got a weird issue were my class renders an error texture (the white box), when I initialize it with my constructor globally. However the same error doesn't happen when I initialize it in my Display function. How is this possible?

I'm guessing I have to initialize it in an init function but I don't want to loose my constructor.


C_Visual_Obj qMenu((GLboolean) 1,
guiSmile_txtID,
(GLboolean)0,//frame state
1.0f,//frame size
300.0f,//position
100.0f,
0.0f, 0.0f,//V1
100.0f,0.0f,//V2
100.0f,50.f,//V3
0.0f,50.f,//V4
Anime_Static);
void display(void)
{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0,0.0,0.0,1.0);

//STATE: MENU

qMenu.Draw();

carsten neumann
04-18-2011, 12:24 PM
Does your constructor make OpenGL calls? If so, you need to have a valid OpenGL context at the time the c'tor runs. Creating the object as a global variable means it is created before main() and you don't have a context.
One way to work around that is to make the global variable a pointer and create the object on the heap after the OpenGL context is created.