SDL + OpenGL Texture Loading |
SDL + OpenGL Texture Loading |
Daniel K. O.
Guest
|
Benjamin Li escreveu:
Unfortunatelly it doesn't crash here. Could you provide your image.bmp, just to check if it isn't the culprit?
Last time I had to use SDL + raw OpenGL, I did something like this for textures: 1) img = IMG_Load(). 2) tex = SDL_CreateRGBSurface(..., 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000) to obtain a 32-bit GL_RGBA-compatible surface. I think you would need to revert the mask for "SDL_BYTEORDER == SDL_BIG_ENDIAN" systems. 3) SDL_SetAlpha(img, 0, 0), then SDL_BlitSurface(img, 0, tex, 0), to make SDL convert "img" to "tex" format. 4) glPixelStorei() to properly set GL_UNPACK_ROW_LENGTH to tex->pitch (I didn't need this for my textures, I'm not sure it's necessary). 5) glTexImage2D(GL_TEXTURE_2D, 0, 4, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex->pixels). -- Daniel K. O. |
|||||||||||||||
|
SDL + OpenGL Texture Loading |
Vardar Sahin
Guest
|
Does you image have a dimension of a power of 2 like 16x16 or 64x64?
OpenGl texture must/should have a dimesnion ofa ower of 2 2007/3/16, Daniel K. O. <danielko.listas at gmail.com>:
An HTML attachment was scrubbed... URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070317/2d731075/attachment.htm |
|||||||||||||||||||||||
|
SDL + OpenGL Texture Loading |
Benjamin Li
Guest
|
Daniel K. O. <danielko.listas <at> gmail.com> writes:
Well, thanks for the response. It turns out that the image I was trying to usewas indexed, which caused the problem. After switching the image type, it works perfectly.
-Ben |
|||||||||||||||
|