SDL and OPENGL

What would be a good method of allowing an application to draw with SDL or OPENGL? I vaguely understand the concept of not using them at the same time, so what would be a good way to have a program capable of doing either method? Most of my surfaces have dimensions that are not a power of 2. I am using c++.

What would be a good method of allowing an application to draw with SDL or OPENGL? I vaguely understand the concept of not using them at the same time, so what would be a good way to have a program capable of doing either method? Most of my surfaces have dimensions that are not a power of 2. I am using c++.

Hello!

If you use SDL 1.3 you can use an OpenGL backend. So it’d be used transparently.

But if you are needing more of the OpenGL commands, and/or want to use strictly OpenGL for drawing, it’s a little more in-depth.
The concept is that you use SDL to create the window, load the images, process the events, etc. And then you use OpenGL to create a texture from the SDL surface, and then anything drawing related would be done through OpenGL.

There are some examples in the wiki documentation, and there are some great examples included in the source code.

You also had a good point about the dimensions not being a power of two. The way around that is to increase the size of the surface to the nearest power of two. Then you divide the old size by the new:
w = oldw / neww
h = oldh / newh

w and h need to be floating point.

Then when you draw your texture you would use the results (the w and h) to specify how much of the texture to use. That way it will ignore the added blank area.

Those are general pointers. I don’t have anything more specific right now.

I hope it was helpful.