Automatic Texture-Coordinate Generation
Hi, i am begining my adventure with OpenGl. I''ve read a tutorial about texture mapping, but there is no tutorial how to map a texture on object with many vertex. For example a Sphere...
How to automaticaly map texture on it? I know i should use GlTexGen(), but have problems with that...
Here is a code how i load a texture and how i create a sphere...
procedure LoadGLTextures;
var
texture1: PTAUX_RGBImageRec;
begin
// Load Texture
texture1 := auxDIBImageLoadA(''C:\earth.bmp'');
if (not Assigned(texture1)) then
Halt(1);
// Create Texture
glGenTextures(1, texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, texture1^.sizeX, texture1^.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, texture1^.data);
end;
function InitGL:bool; // All Setup For OpenGL Goes Here
var
Kula: GLUquadricObj;
begin
LoadGLTextures(); // Load The Texture(s)
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
ListaCial:= glGenLists(1);
Kula:=gluNewQuadric();
gluQuadricDrawStyle(Kula, GLU_FILL); //* smooth shaded */
gluQuadricNormals(Kula, GLU_SMOOTH);
glNewList(ListaCial, GL_COMPILE);
gluSphere(Kula,1,75,20);
glEndList();
initGL:=true;
end;
I will be very greatfull is someone tells me what should i add to my code to map texture on sphere.
Regards,
Wodzu
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement