GLUT or SDL ?

I have been using GLUT when using OpenGl and C++. I see that lots of people use SDL instead. Should I switch to SDL before I get any farther with GLUT?

Thanks

How I came across this was I am trying to make a 2d Tilemap engine with OpenGl Support. I have the setting up and drawing working, but I have to have a separate BMP for every tile and there doesn’t seem to be a way to split textures with GLUT.

However I don’t want to just switch to something easier. I am doing this to build programs and games to make a portfolio.

SDL is something that utilizes OpenGL and isn’t just a competitor is it?

but I have to have a separate BMP for every tile and there doesn’t seem to be a way to split textures with GLUT.

There’s lots of ways of doing it, GLUT doesn’t stop you. Either constrain the tile UVs to select a small part of your tile sheet and use one texture or break it up yourself. Heck, use texture copies if it pleases you.

oh, thanks.

Which do you think I should use though?

Also could you provide some pseudo code dealing with splitting it up?

I know I could so something like “glTexCoord2f(0.1f,0.1f);”
and only display the part for the tile, but to me it seems this would waste not only ram but cycles to stretch and render it.

You are asking two independent questions – GLUT, SDL, or for that matter, GLX/WGL, glfw, sfml are all ways to create an openGL context and window. You will find everyone here has their favorite but all are basically the same in their final result. see Post283457 for instance. None really deal directly with textures – they defer that to SDL_image or libpng or DevIL etc.

glTexCoord2f(0.1f,0.1f); would work fine with only loss of some RAM but the concern about cycles is not an issue with openGL hardware. Neither GLUT or SDL libraries “cut-n-paste” a section of a texture at will just to save memory. You could probably do this very easily yourself just before you upload the texture to GPU memory with glTexImage2D. Or possibly take a look in detail at glTexSubImage2D.

SDL is just a library that helps get you started by simplifying common tasks. If it’s using bitmaps, then you might be using the platform specific rendering api, for windows this is GDI. GDI might not support rendering only a piece(tile) of the image. Best to use OpenGL instead of GDI to render for a 2d tile map engine. Also there are more optimizations available when working with OpenGL :smiley: