I am using Visual C++ Express Edition on Windows, and I am look at the windows task manager and I noticed that every second, in the process tab the memory of my C++ program increases about 8 K when I am not even doing anything. Also, I've noticed that if I comment my whole drawing code with glEnd and glBegin, it stop adding that 8 K per second but adds 4 K every time I move the mouse. I am using OpenGL for drawing and SDL for windows management. Please note, I loaded one texture and I am drawing in 2D. My code is as follows:
while (!done)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
{
done = true;
break;
}
case SDL_KEYDOWN:
{
if (event.key.keysym.sym == SDLK_ESCAPE)
{
done = true;
}
break;
}
case SDL_VIDEORESIZE:
{
glViewport(0,0,event.resize.w, event.resize.h);
SDL_GL_SwapBuffers();
break;
}
}
}
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(1.0f,1.0f,1.0f);
glVertex2f(400.0, 160.0);
glVertex2f(320.0, 440.0);
glVertex2f(480.0, 440.0);
glEnd();
glEnable( GL_TEXTURE_2D );
// Bind the texture to which subsequent calls refer to
glBindTexture( GL_TEXTURE_2D, ret );
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBegin( GL_QUADS );
glColor3f(1.0f,1.0f,1.0f);
//Bottom-left vertex (corner)
glTexCoord2d( 0, 0 );
glVertex3f( 100.f, 100.f, 0.0f );
//Bottom-right vertex (corner)
glTexCoord2d( 0.5, 0 );
glVertex3f( 228.f, 100.f, 0.f );
//Top-right vertex (corner)
glTexCoord2d( 0.5, 1 );
glVertex3f( 228.f, 228.f, 0.f );
//Top-left vertex (corner)
glTexCoord2d( 0, 1 );
glVertex3f( 100.f, 228.f, 0.f );
glEnd();
glDisable( GL_TEXTURE_2D );
glDisable (GL_BLEND);
glClearColor(0.7f, 0.9f, 1.0f, 1.0f);
SDL_GL_SwapBuffers();
SDL_Delay(1000/30);
}
I do know immediate mode is deprecated, I don't know if this is the problem but I cannot grasp Vertex Buffer Objects. If anyone would want to help me translate my current code into VBOs, that would be nice. I just need actual example code for me to learn how to do it, like an actual game using it.
Another thing, I've noticed that all SDL programs I use change the cursor. Does anyone know how to fix that?