Color inversion and missing functions

Hi, I am new to SDL (v 1.2.15) and have two problems with this code:

Code:

#include <SDL.h>

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.

Hello I have 0 experience with openGL but aside from openGL to use other
image types in SDL you need the image extension

http://lazyfoo.net/SDL_tutorials/lesson03/index.phpOn Wed, Jun 6, 2012 at 12:47 AM, telandor 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

Hello I have 0 experience with openGL but aside from openGL to use other
image types in SDL you need the image extension

http://lazyfoo.net/SDL_tutorials/lesson03/index.php

You don’t “need it”, it just simplifies some things. You can load your own
images or even generate images using the CPU if you so choose to. OpenGL
doesn’t have that kind of restriction, and neither does using SDL+OpenGL.

PatrickOn Wed, Jun 6, 2012 at 9:54 AM, Aaron NA wrote:

On Wed, Jun 6, 2012 at 12:47 AM, telandor 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