Hi!
I have a problem with SDL and OpenGL.
I wrote a code to convert SDL Surfaces to OpenGL textures.
Now I have a function to Draw a rect(with opengl) on a SDL_Surface.
That's the code to draw a rect:
void DrawRect(SDL_Rect *rect, GLuint texture)
{
float x = rect->x;
float y = rect->y;
float w = rect->w;
float h = rect->h;
// Bind the texture to which subsequent calls refer to
glBindTexture( GL_TEXTURE_2D, texture );
glBegin( GL_QUADS );
//Bottom-left vertex (corner)
glTexCoord2i( 0, 0 );
glVertex3f( x, y+h, 0.0f );
//Bottom-right vertex (corner)
glTexCoord2i( 1, 0 );
glVertex3f( x+w, y+h, 0.0f );
//Top-right vertex (corner)
glTexCoord2i( 1, 1 );
glVertex3f( x+w, y, 0.0f );
//Top-left vertex (corner)
glTexCoord2i( 0, 1 );
glVertex3f( x, y, 0.0f );
glEnd();
}
So... Now, where are the drawed Quads?! I know how to get them to sdl:
SDL_GL_SwapBuffers();
The problem is, I want to put these Quads into a surface or anything like that, so I can make multiple layers and put them together in another surface named screen.
Then I want to show only the surface screen in the window.
Is this possible?
How can I draw the quad to a SDL_Surface or a GLuint(texture), so I can combine them later?
I hope someone can help me ;)
Yours
OpenSDL