reshape.c
来自「opengl source code download」· C语言 代码 · 共 51 行
C
51 行
#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()
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 300, 300);
auxInitWindow ("Simple OpengGL Sample");
glClearColor (0.0, 0.0, 0.0, 0.0);
}
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);
auxWireSphere(0.5f);
// auxWireSphere(50.f);
glFlush();
}
void main()
{
myInit();
auxReshapeFunc(myReshape);
auxMainLoop(myDispaly);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?