Results 1 to 3 of 3

Thread: SDL_Image, Opengl Textures & Alpha

  1. #1

    SDL_Image, Opengl Textures & Alpha

    Hi

    Ive; written some code to load a tga file using SDL_Image and then produce a opengl texture from that. The problem I'm getting this that the alpha channel doens't seem to be coming through. the I render with the Blend functions off the texture renders OK , but with blending all I get is a black screen. :?

    Here is the code

    Code:
     Surface:= nil;
     TempSurface := IMG_Load(PChar(Filename));
     if TempSurface <> nil then
     begin
       SDL_FlipRectV&#40;TempSurface, nil&#41;; // so the texture isn't upside down
       Surface &#58;= SDL_CreateRGBSurface&#40;SDL_SWSURFACE, Width, Height, TempSurface.format.BitsPerPixel,
         TempSurface.format.RMask,TempSurface.format.GMask,TempSurface.format.BMask,TempSurface.format.AMask&#41;;
       SDL_BlitSurface&#40;TempSurface, nil, Surface, nil&#41;;
       SDL_FreeSurface&#40;TempSurface&#41;;
      glEnable&#40;GL_TEXTURE_2D&#41;;
      glGenTextures&#40;1, @FTextureID&#41;;
      glBindTexture&#40;GL_TEXTURE_2D, FTextureID&#41;;
      glTexParameteri&#40;GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST&#41;;
      glTexParameteri&#40;GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST&#41;;
      glTexImage2D&#40;GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Surface.pixels&#41;;
     end;
    I keep the surface around becuase I will probably update is everynow and then and refresh the texture.

    Can any one see any obvious problems?

    Dean
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

  2. #2

    Re: SDL_Image, Opengl Textures & Alpha

    Quote Originally Posted by technomage
    Can any one see any obvious problems?
    No, but i suggest you to use PNG instead of TGA.
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  3. #3

    SDL_Image, Opengl Textures & Alpha

    PNG seems to be working, I've given up on tga

    Cheers
    <A HREF="http://www.myhpf.co.uk/banner.asp?friend=139328">
    <br /><IMG SRC="http://www.myhpf.co.uk/banners/60x468.gif" BORDER="0">
    <br /></A>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •