Results 1 to 7 of 7

Thread: Basics of TEXTURE MAPPING

  1. #1

    Basics of TEXTURE MAPPING

    System: Windows XP
    Compiler/IDE: Lazarus (latest update)
    API: OpenGL

    Hey all,

    I need some serious help. :roll:
    For a long time I thought games didn't need to look realistic to be good games, so everything I made was made of cubes and triangles, coloured with the very simple glColor3f(r,b,g) call.

    Then I realised on the many forums in this website that people do truly stunningly realistic things using textures. So I read about bumpmapping, mipmapping, megatextures and many more techniques which made me NEED to learn how to do all of that.

    A few months ago, I went through two tutorials on the internet about texture mapping (including Nehe's 6th tutorial on that topic) but I never managed to get a single picture on my screen, and had so many problems that I gave up.
    Some of the problems I had can be found on this thread:
    http://www.pascalgamedevelopment.com...er=asc&start=0 (look at the last posts rather than the early ones)
    which I started thinking I'd find a solution.

    I have decided now to resume my efforts and learn about texture mapping, which I believe is the first step to the other more complex techniques of mapping.

    I would like to ask all of you
    - if you know tutorials on the subject, on the internet, which DO work
    - if you know, after reading the thread given above, what I did wrong in my previous attempts
    - if you have a simple and well commented program which I could learn from

    In short, if you can please help me out learning about texture mapping and/or other better techniques to fill polygons with pictures.

    Thanks a lot!

  2. #2

    Basics of TEXTURE MAPPING

    I'll list phases you're going to need in order to use textures with OpenGL (as it's seen on GLEngine http://www.freewebs.com/loknar/ You can find data loading functions for BMP, PNG, JPG and GIF there):

    Code:
    - glEnable(GL_TEXTURE_2D);
    - Allocate memory for texture data (array that contains pixel data for example RGB format)
    - glGenTextures(1,@TextureIndex);
    - glBindTexture(GL_TEXTURE_2D,TextureIndex);
    - glTexParameteri(GL_TEXTURE_2D, 
      GL_TEXTURE_MAG_FILTER,TextureQuality);
      (where TextureQuality can be either GL_LINEAR or GL_NEAREST)
    - glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, 
      TextureQuality)
    - glTexImage2D(GL_TEXTURE_2D, 0, n, tex.sizeX, tex.sizeY, 0,
          Format, GL_UNSIGNED_BYTE, tex.Data)
      (where format can be for example GL_RGB or GL_RGBA
      and n meaning number of values per pixel)
    - Free texture memory
    - Enjoy  :wink: 
    - Call glBindTexture(GL_TEXTURE_2D,TextureIndex);
      to recall your texture or value 0 to not use any.
    Edit: Also, texture sizes matter to graphics card! Image of 500x500 may show white completely where 128x512 or 1024x1024 will show as they are power of 2. Scrap glaux unit for being severely outdated.. aand finally use glTexCoord2f for each vertex to actually see the image.

  3. #3

    Basics of TEXTURE MAPPING

    Look on my page, just now I porting of my Final3D engine, he has finished class for working with texture. Class has a lot of function for load, store and bind to face as simple Bind or for Multitexture bind to face.

    I use DevIL lib with a lot of picture file formats like this:

    Supports loading of:
    .bmp;.cut;.dcx;.dds;.ico;.gif;.jpg;.lbm;.lif;.mdl; .pcd;.pcx;.pic;.png;.pnm;.sd;.psp;.raw;.sgi;.tga;. tif;.wal;.act;.pal;.hdr;

    Supports saving of:
    .bmp;.dds;.jpg;.pcx;.png;.pnm;.raw;.sgi;.tga;.tif; .pal;.hdr;;

    http://openil.sourceforge.net/download.php
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  4. #4

    Basics of TEXTURE MAPPING

    Andygfx, IlovePascal asked for help, not for you to advertise about the countless in- and export possibilities of your engine.

  5. #5

    Basics of TEXTURE MAPPING

    Quote Originally Posted by Traveler
    Andygfx, IlovePascal asked for help, not for you to advertise about the countless in- and export possibilities of your engine.
    Sorry, it's not ADRVERTISE of my engine, i know from my experiencies that best way for learning is reading other working code. My code is FREE.

    IlovePascal: .... " - if you have a simple and well commented program which I could learn from " ....
    C2D X6800, 4GBRAM, NV8800GTX, Vista x64 Ultimate

  6. #6

    Basics of TEXTURE MAPPING

    I'm sorry but I did not get that from your reply. Perhaps next time you could mention the units and/or functions, within your engine, that he should look into.

    In any case, perhaps the lessons and samples from www.sulaco.co.za are more helpfull. The Transparent TGA files and Fog example on the first page should get you on your way real quick.

  7. #7

    Basics of TEXTURE MAPPING

    cool, ill have a read through all of this
    cheers

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
  •