首页 > 代码库 > 细分和边界
细分和边界
代码如下:
#include <windows.h>//#include <GLUT/glut.h>#include <GL/glut.h>#include <math.h>#include <iostream>using namespace std;#define GL_PI 3.1415fvoid RenderScene(){ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); GLboolean bEdgeflag; glBegin(GL_TRIANGLES); glEdgeFlag(bEdgeflag); glVertex2f(-20.0f,0.0f); glEdgeFlag(true); glVertex2f(20.0f,0.0f); glVertex2f(0.0f,40.0f); glVertex2f(-20.0f,0.0f); glVertex2f(-60.0f,-20.0f); glEdgeFlag(bEdgeflag); glVertex2f(-20.0f,-40.0f); glEdgeFlag(true); glVertex2f(-20.0f,-40.0f); glVertex2f(0.0f,-80.0f); glEdgeFlag(bEdgeflag); glVertex2f(20.0f,-40.0f); glEdgeFlag(true); glVertex2f(20.0f,-40.0f); glVertex2f(60.0f,-20.0f); glEdgeFlag(bEdgeflag); glVertex2f(20.0f,0.0f); glEdgeFlag(true); glEdgeFlag(bEdgeflag); glVertex2f(-20.0f,0.0f); glVertex2f(-20.0f,-40.0f); glVertex2f(20.0f,0.0f); glVertex2f(-20.0f,-40.0f); glVertex2f(20.0f,-40.0f); glVertex2f(20.0f,0.0f); glEdgeFlag(true); glEnd(); glutSwapBuffers();}void ChangeSize(GLsizei w,GLsizei h){ if(h==0) h = 1; GLfloat aspectRatio = (GLfloat)w/(GLfloat)h; glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if(w<=h) glOrtho(-100,100,-100/aspectRatio,100/aspectRatio,100.0,-100.0); else glOrtho(-100*aspectRatio,100*aspectRatio,-100,100,100.0,-100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}void SetupRC(){ glClearColor(0.0f,0.0f,0.0f,1.0f); glColor3f(1.0f,0.0f,0.0f);}int main(int argc, char *argv[]){ glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH); glutInitWindowSize(800,600); glutCreateWindow("Simple"); glutDisplayFunc(RenderScene); glutReshapeFunc(ChangeSize); SetupRC(); glutMainLoop(); return 0;}
细分和边界
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。