I don’t know how to describe my problem. Perhaps someone’s answered my question alreadly. If so, please tell me which post I can refer to, THX.
What happen to me is the clipping planes more than six will have no effect. The default clipping plane defined in gl.h is from GL_CLIP_PLANE0 to GL_CLIP_PLANE5, whose corresponding address are from 0x3000 to 0x3005. And when I assign a plane equation to 0x3006, it has no effect at all.
The openGL documentation says any kind of openGL supports much more than 6 clipping plane. The GL_MAX_CLIP_PLANES also indicates that. But where they are?
#include <stdio.h>
#include <GL/glut.h>
//Just like setup() in Processing. But it doesn’t support drawing inside.
//If want to draw a static picture,
void init(int w, int h)
{
float ratio = 1.0 * w / h;
glClearColor(1.0, 1.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45,ratio,1,1000);
}
float angle=0.0;
GLdouble plane0Eq[4] = {0.2, 0.3, 0.4, 0};
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glRotatef(angle,angle,angle,0.0);
glClipPlane(0x3006, plane0Eq);//Change the address here into 0x3000.
glEnable(0x3006);//here
glColor4f(0.2, 0.2, 0.2, 0.4);
glutSolidSphere(1.4, 40, 40);
glDisable(0x3006);[b]//And here[/b]
glColor3f(0.3, 0.3, 0.3);
glutWireSphere(1.4, 40, 40);
glDisable(GL_BLEND);
glPopMatrix();
glutSwapBuffers();
angle+=0.1;
}
void changeSize(int w, int h) {
if(h == 0) h = 1;
float ratio = 1.0* w / h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45,ratio,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt( 0.0, 0.0, 5.0,
0.0, 0.0, -1.0,
0.0f, 1.0f, 0.0f);
}
int main(int argc, char** argv)
{
int width = 300;
int height = 300;
glutInit(&argc,argv); // Passes from ARGC & ARGV
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(width, height);
glutInitWindowPosition(100,100);
glutCreateWindow("Clipping");
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc(changeSize);
init(width, height);
glutMainLoop();
}
Thank you.