Pourquoi ne puis-je rien afficher avec ce code?OpenGL Rien ne s'affiche
#include <iostream>
#include "GL/glfw.h"
#ifndef MAIN
#define MAIN
#include "GL/gl.h"
#include "GL/glu.h"
#endif
using namespace std;
void display();
int main()
{
int running = GL_TRUE;
glfwInit();
if(!glfwOpenWindow(640,480, 0,0,0,0,0,0, GLFW_WINDOW))
{
glfwTerminate();
return 0;
}
while(running)
{
//GL Code here
display();
glfwSwapBuffers();
// Check if ESC key was pressed or window was closed
running = !glfwGetKey(GLFW_KEY_ESC) &&
glfwGetWindowParam(GLFW_OPENED);
}
glfwTerminate();
return 0;
}
void display()
{
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0,0,640,480);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, 0, -2);
glBegin(GL_POLYGON);
glColor3f(1.0, 0.2, 0.2);
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();
}
Oui; J'avais l'impression que la fenêtre d'affichage est prise en charge automatiquement. –
Je pense que votre impression est correcte;) Je ne suis pas sûr si cela fait partie de la spécification OpenGL mais au moins sur Windows lorsque vous créez votre contexte de rendu, la fenêtre sera définie pour correspondre à la fenêtre. –
Ce code ne fonctionne pas avec glTranslate. –