Alex Barry | 6 Jun 2012 16:43
Picon

Re: _SDL_main error and missing functions

For your first, there's a good chance that you're not taking endianness into account for your colour stuff.  Here is how I did it (thanks to many people here on the mailing list);  https://github.com/mrozbarry/bitfighter-experiments/blob/master/bitfighter1.0/sdlutil.cpp#L349 


Second, your best bet is probably SDL_image, an add-on library to SDL, found here:  http://www.libsdl.org/projects/SDL_image/ 

I hope that helps,
-Alex

On Wed, Jun 6, 2012 at 3:47 AM, telandor <ricowidmer <at> gmx.ch> wrote:
Hi, I am new to SDL (v 1.2.15) and have two problems with this code:




Code:


#include

void Mesh::createTextures() {
   SDL_Init(SDL_INIT_EVERYTHING);
   SDL_Surface *surface;
   surface = SDL_LoadBMP("..\\..\\resources\\textures\\bla.bmp");
   int mode;
   if (surface->format->BytesPerPixel == 3) { // RGB 24bit
      mode = GL_RGB;
   } else if (surface->format->BytesPerPixel == 4) { // RGBA 32bit
      mode = GL_RGBA;
   }
   glGenTextures(1, &_textureID);
   glBindTexture(GL_TEXTURE_2D, _textureID);
   glTexImage2D(GL_TEXTURE_2D, 0, mode, surface->w, surface->h, 0, mode, GL_UNSIGNED_BYTE, surface->pixels);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}




First:
A texture which is completely red is shown blue. When I change the second mode to GL_BGR though OpenGL renders nothing.

Second:
How can I load other images than BMP? I can only find the function SDL_LoadBMP().

I hope anybody can help me out with this.

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Gmane