【发布时间】:2016-03-16 11:08:29
【问题描述】:
我正在学习如何使用 openGL,但我只找到使用 SDL 函数来管理窗口和事件的教程。
这是我在本教程中编写的代码:
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Mon premier programme OpenGL !",NULL);
SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
bool continuer = true;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = false;
}
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3ub(255,0,0); glVertex2d(-0.75,-0.75);
glColor3ub(0,255,0); glVertex2d(0,0.75);
glColor3ub(0,0,255); glVertex2d(0.75,-0.75);
glEnd();
glFlush();
SDL_GL_SwapBuffers();
}
SDL_Quit();
return 0;
}
我可以使用 SDL 函数来管理 windows,但我会使用 openGL 事件处理程序。
有人知道如何更换和使用吗?
谢谢
【问题讨论】:
-
“openGL 事件处理程序”...什么?比如...GLUT,也许吧?
-
使用 GLUT 进行 OpenGL 用户输入的一个教程是 these course notes:网上还有很多。