⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clip.c

📁 opengl source code download
💻 C
字号:
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>

void myInit();
void CALLBACK myReshape(GLsizei w,GLsizei h);
void CALLBACK myDispaly(void);

void myInit()
{
	const GLdouble equation0[4] = {10,0,0,0};
	const GLdouble equation1[4] = {0,-10,0,-2};

    auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
    auxInitPosition (0, 0, 300, 300);
    auxInitWindow ("Simple OpengGL Sample");
    glClearColor (0.0, 0.0, 0.0, 0.0);

	glEnable(GL_CLIP_PLANE0);
	glClipPlane(GL_CLIP_PLANE0, &equation0);
	glEnable(GL_CLIP_PLANE1);
	glClipPlane(GL_CLIP_PLANE1, &equation1);
}

void CALLBACK myReshape(GLsizei w,GLsizei h)
{
    if (!h) return;
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    if (w <= h)
    glOrtho(-1.0, 1.0, -1.0*(GLfloat)h/(GLfloat)w, 
        1.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0);
    else
    glOrtho(-1.0*(GLfloat)w/(GLfloat)h, 
        1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}

void CALLBACK myDispaly(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 1.0, 1.0);
//	glRotatef(60.f,1.f,1.f,1.f);
	auxWireTeapot(0.5f);
//	auxSolidSphere(0.5f);
    glFlush();
}


void main()
{
    myInit();
	auxReshapeFunc(myReshape);
	auxMainLoop(myDispaly);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -