[SDL] SDL and OpenGL textures
Scott Harper
lareon at comcast.net
Wed May 12 14:32:01 PDT 2004
Just so you know, don't forget to to a "glEnable(GL_TEXTURE_2D);" before
you actually RENDER the object you're texturing... I uh... Just forgot
to do that, and spent about an HOUR looking for the reason it wasn't
working right... -.-;;;
--Scott
Samuel wrote:
>go to nehe.gamedev.net and try the tutorials. there are SDL/Linux ports at the
>bottom of the tutorial.
>
>also when doing textures in GL you must make sure that the texture is a factor
>of 2
>
>512x512, 256x256, 64x64, ...
>
>here check out this snipit
>
><code>
>
>int LoadTextures ()
>{
> int status = FALSE;
>
> SDL_Surface *textureImage;
>
> /* load the bitmap, check for errors,
> * quit if bmp not found */
> if ((textureImage = SDL_LoadBMP ("texture.bmp")))
> {
> status = TRUE;
>
> /* setup the texture image */
> glGenTextures (1, &texture);
> glBindTexture (GL_TEXTURE_2D, texture);
>
> /* map out the texture image */
> glTexImage2D (GL_TEXTURE_2D,
> 0,
> 3,
> textureImage->w,
> textureImage->h,
> 0, GL_BGR, GL_UNSIGNED_BYTE, textureImage->pixels);
>
> /* filter the texture image with linear filtering */
> glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
> glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
>
> /* free texture memory */
> SDL_FreeSurface (textureImage);
> }
> return status;
>}
>
></code>
>
>On Tuesday 20 April 2004 08:37 am, Ralf Berger wrote:
>
>
>>Hello,
>>
>>is somebody able to give me a pointer to a code-sniplet where a texture is
>>mapped to an OpenGL 3D surface (GL_QUADS)? The texture should be an
>>SDL_Surface.
>>
>>I've already messed around with the examples from the testgl.c file and the
>>NeHe-Tutorial (lesson 6) with no success. With the testgl.c code I'm able
>>to load arbitrary images and use the SDL_Surface texture in the 2D-mode
>>only, but was not able to map the same texture to on of the cube surfaces.
>>
>>Since no OpenGL and no SDL error is reported, I'm a little bit lost in
>>confusion! Any help will be appreciated.
>>
>>Regards
>>Ralf
>>_____________________________________________________________________
>>Der WEB.DE Virenschutz schuetzt Ihr Postfach vor dem Wurm Netsky.A-P!
>>Kostenfrei fuer alle FreeMail Nutzer. http://f.web.de/?mc=021157
>>
>>
>>_______________________________________________
>>SDL mailing list
>>SDL at libsdl.org
>>http://www.libsdl.org/mailman/listinfo/sdl
>>
>>
>
>
>
More information about the SDL
mailing list