| saifjournal ( @ 2005-10-30 22:55:00 |
| Current mood: | geeky |
| Entry tags: | code texture mapping opengl |
Some Code - GLUT Application, Simple Texture Mapping
Coding - Finally
Trying to code a small glut application which will load two small shaders to perform displacement mapping. Finally got a small glut program working. pitiful result for a couple of hours work. But there was some funny issue with the texture setup.
This is the code I had for texture setup :
glGenTextures(1,&texName);
glBindTexture(GL_TEXTURE_2D,texName);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,8,8,0,G
NMap was a 4x4x3 arrays of ints which held the texture ( just plane blue square where I had used 1 as the blue component). No matter what I did, I ended up with a blank screen. The problem was this. OpenGL maps ints to color values in such a way that only the maximum value stored by an int to 1 and the minimum value stored by it is mapped to -1 (or 0 if its an unsigned int) ... for example, for a 4 byte signed int, the value 2147483647 is mapped to 1.0 and the negative of that is mapped to -1. So, the value 1 which I was using is so teeny that it was just being mapped to 0 and I was getting the blank screen ! ... one hour to figure that out ... and I had help from John.
GLUT API Version 3
http://www.opengl.org/resources/librari
Parallax Mapping - ATI
http://www.ati.com/developer/gdc/Tatarc
Another one on Parallax Mapping from ATI
http://www.ati.com/developer/SIGGRA
Overview of Bump Mapping from Delphi3D
http://www.delphi3d.net/articles/viewar