OpenGL不绘图
我使用GLFW作为OpenGL项目的GUI。我正在使用我的红皮书和测试代码,第一部分代码根本不起作用。我想说这是一个GLFW问题,因为我在JOGL中没有这个问题。
#include <iostream>
#include "GL/glfw.h"
#ifndef MAIN
#define MAIN
#include "GL/gl.h"
#include "GL/glu.h"
#endif
using namespace std;
int main()
{
int running = GL_TRUE;
glfwInit();
if( !glfwOpenWindow( 300,300, 0,0,0,0,0,0, GLFW_WINDOW ) )
{
glfwTerminate();
return 0;
}
while( running )
{
//GL Code here
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
glfwSwapBuffers();
// Check if ESC key was pressed or window was closed
running = !glfwGetKey( GLFW_KEY_ESC ) &&
glfwGetWindowParam( GLFW_OPENED );
}
glfwTerminate();
return 0;
}
没有找到相关结果
已邀请:
2 个回复
踩什不
修复了代码:
淑灯