123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|399|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> draw texture with SDL/OpenGL

Wed, 18 Nov 2009, 13:41
JL235
I'm currently trying to build a small 2D library for a language called Occam-Pi. This is to be used as a one off for a small demo. It has bindings for SDL and OpenGL so I've just ported over my OpenGL from various Erlang, Ruby and Java projects. However when I'm drawing textures I am getting a white rectangle instead. The texture is a power of two and AFAIK all of my code is correct (it's copied from working code). It's only 200 lines and I've spent literally about 5 or 6 hours trying to figure out where it's not working.

So I was wondering if someone could please write the absolute bare bones minimum amount of code needed to draw a texture to the screen in SDL with OpenGL. No thrills, just a window with a texture in the middle. The idea being that I'd port this across and if it works then my original code is borked. If it doesn't work then the languages bindings might be to blame (I've tested on multiple PCs so the language and my code are the only common factors).

Please also use a bmp for your image and load it via an SDL surface using the SDL loadBMP function because this is the only (working) image loader I can find for this language.
Wed, 18 Nov 2009, 15:11
Phoenix
I can't be bothered to code up a complete example, but I suspect that you may be missing calls to set magnification/minification filters:

Try sticking that after your call to glTexImage2D, or actually anywhere just after you've bound the texture.
Wed, 18 Nov 2009, 15:30
Cower
It might be easier to identify what you're doing wrong if you posted the code where you upload the texture and the code where you draw the textured primitive (i.e., a quad or triangle).

I don't have SDL set up right now, so putting together a barebones example would be less than trivial (getting SDL to work nicely on Mac OS is sort of trial and error due to the fact that it wants to be a Unix-style library and Mac OS uses frameworks [library bundles that make distribution easier, but are also not portable since nobody else supports them]).
Wed, 18 Nov 2009, 18:27
JL235
WOOT! Thank you Phoenix, that's sorted it.

Although I have lots of new issues, but I should be able to work through them.