🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

glBindTexture...SDL_Surface...?

Started by
0 comments, last by Deranged 19 years, 10 months ago
To help me focus on 3d programming ive always used SDL_Surface to hold my texture objects, like this SDL_Surface *texture; ... texture = SDL_LoadBMP("sometexture.bmp"); Then i just use the glTexImage2d before the rendering, and i realize this is slow but im still learning. I am now trying to get further and optimize my code, so i tryed to use the glBindTexture, well, it doesnt really like me feeding it an sdl_surface, so i tryed turning the texture into a GLuint, but then the SDL_LoadBMP command gets cranky... How can use the sdl_loadbmp and be able to bind the texture it loads?
---------------------------------------------think outside the quadLogic GamesI realized I stay on the pc too long when my wireless mouse died after replacing the batteries...twice
Advertisement
This should work

        int LoadBmp(char* filename, GLuint* data)        {            SDL_Surface* bmpFile = SDL_LoadBMP(filename);                h = bmpFile->h;            w = bmpFile->w;                glPixelStorei(GL_UNPACK_ALIGNMENT,4); 		            glGenTextures(1,&data);            glBindTexture(GL_TEXTURE_2D,data);             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 		            gluBuild2DMipmaps(GL_TEXTURE_2D,3,bmpFile->w, bmpFile->h,GL_BGR_EXT, GL_UNSIGNED_BYTE,bmpFile->pixels);            SDL_FreeSurface(bmpFile);                return 0;        }

This topic is closed to new replies.

Advertisement