Is this Normal for Texturing?
In my engine I have the front of my polygons rendered and textured. But when I go behind the polygons I see the back side is textured also? Is this normal if not what would I have to turn on to disable it? I already have these states running.
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);
It is?
Quote:Originally posted by PowerMacX
I think you can use
glCull(GL_BACK)
(Not sure, have to check)
One step ahead already have it enabled no difference. I am starting to think henryj is right.
It works just fine... you must be doing something else wrong.
Code:
#include <stdlib.h>
#if defined(__APPLE_CC__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
GLubyte texture[16] =
{
255, 0, 0, 255,
0, 255, 0, 255,
0, 0, 255, 255,
255, 255, 0, 255
};
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static GLdouble angle = 0.0;
angle += 0.001;
if (angle > 6.283185308)
{
angle -= 6.283185308;
}
glLoadIdentity();
gluLookAt(5.0, 5.0, 0.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
glRotatef(180 * angle / 3.141592654, 0, 1, 0);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(-1, -1);
glTexCoord2f(1, 0);
glVertex2f(1, -1);
glTexCoord2f(1, 1);
glVertex2f(1, 1);
glTexCoord2f(0, 1);
glVertex2f(-1, 1);
glEnd();
glutSwapBuffers();
}
void reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLdouble)width/(GLdouble)height, 0.01, 100);
glMatrixMode(GL_MODELVIEW);
}
void idle(void)
{
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
(void)glutCreateWindow("GLUT Program");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glEnable(GL_TEXTURE_2D);
glEnable(GL_CULL_FACE);
glBindTexture(GL_TEXTURE_2D, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 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_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glutMainLoop();
return EXIT_SUCCESS;
}
Well when I go behind the skybox the polygon disappears. When I go under my 3D terrain the polygons aren't their per se, but I see the textures that are being rendered on the front of them. I am using GL_TRIANGLES_STRIP and the order should be this
0,1
2,3
moving left to right ->
or
1,3
0,2
moving left to right ->
because I am doing the first one.
And these are the functions I have called
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
0,1
2,3
moving left to right ->
or
1,3
0,2
moving left to right ->
because I am doing the first one.
And these are the functions I have called
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
Just a wild off-topic thought...is it possible to map two different textures to each face of a polygon?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Normal Mapping Precision on iOS | OptimisticMonkey | 6 | 7,385 |
Apr 13, 2011 11:35 PM Last Post: OptimisticMonkey |
|
| Getting the Normal for a polygon. | Jaden | 3 | 4,670 |
May 1, 2009 01:47 PM Last Post: Nosredna |
|
| Vector (Normal) Map blending operations? | kelvin | 10 | 5,897 |
Mar 16, 2007 04:31 PM Last Post: OneSadCookie |
|
| drawing or displaying vertex normal | shru_ani | 3 | 3,004 |
Oct 29, 2006 06:04 AM Last Post: shru_ani |
|
| Gouraud vs Normal maps for dinamic terrains | sohta | 6 | 3,406 |
Oct 11, 2006 12:55 AM Last Post: sohta |
|

