RenderGL()
setup()
Hi guys, I had tried out a lot of the tutorials online nehe and others, even books too. But I just cannot get this enviroment mapping to work. I am using Borland C++ Builder 3 to code so pls kindly help me. Thank You.
Code:
//Place your OpenGL drawing code here
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//Drawing of Background
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-3.5f,-2.5f,-3.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 3.5f,-2.5f,-3.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( 3.5f, 2.5f,-3.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-3.5f, 2.5f,-3.0f);
glEnd();
glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, texture);
//Drawing of Ball
glTranslatef(Config->Ball->Position.X,Config->Ball->Position.Y,0.0f);
glRotatef(rsph,0.0f,1.0f,0.0f);
glColor3f(1.0f,1.0f,0.0f);
GLUquadricObj* q = gluNewQuadric();
gluQuadricDrawStyle(q,GLU_FILL);
gluQuadricNormals(q,GLU_SMOOTH);
gluSphere( q, Config->Ball->Radius, 30, 30);
rsph+=0.8f;
setup()
Code:
glEnable (GL_DEPTH_TEST);
glEnable (GL_LIGHTING);
glLightModelfv (GL_LIGHT_MODEL_AMBIENT, ambient_light);
glLightfv (GL_LIGHT0, GL_DIFFUSE, source_light);
glLightfv (GL_LIGHT0, GL_POSITION, light_pos);
glEnable (GL_LIGHT0);
glEnable (GL_COLOR_MATERIAL);
glColorMaterial (GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glEnable (GL_CULL_FACE);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glEnable(GL_TEXTURE_2D);
bitmapData = LoadBitmapFile("texture\\scenary.bmp", &bitmapInfoHeader);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);
glFlush();
Hi guys, I had tried out a lot of the tutorials online nehe and others, even books too. But I just cannot get this enviroment mapping to work. I am using Borland C++ Builder 3 to code so pls kindly help me. Thank You.