J'ai installé glut.h
dans mes blocs de code. J'ai écrit un programme qui devrait produire une ligne rouge sur fond noir. Mais seulement la fenêtre apparaît. Ce code fonctionne bien sur un autre PC. Quel est le problème? Est-ce le problème de mon propre ordinateur portable?La programmation n'affiche que la fenêtre
#include<windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include<stdlib.h>
#include<stdio.h>
#define ROUND(x) ((int)(x+0.5))
float xa=0,xb=50,y,m,ya=0,yb=50;
void display (void)
{
int dx=xb-xa,dy=yb-ya,steps,k;
float xIncrement,yIncrement,x=xa,y=ya;
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 0.0, 0.0);
if(abs(dx)>abs(dy))
steps=abs(dx);
else steps=abs(dy);
xIncrement=dx/(float)steps;
yIncrement=dy/(float)steps;
glBegin(GL_POINTS);
glVertex2s(ROUND(x),ROUND(y));
for(k=0; k<steps; k++)
{
x+=xIncrement;
y+=yIncrement;
glVertex2s(ROUND(x),ROUND(y));
}
glEnd();
glFlush();
}
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glOrtho(-100.0, 100.0, -100.0, 100.0, -1.0, 1.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow ("DDA algorithm");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
TNX beaucoup. Tu sauves ma journée, bt pourquoi ce code fonctionne dans d'autres pc? - Vallentin –
Il y a beaucoup de facteurs, donc c'est difficile à dire spécifiquement quelle est la cause. Mon ordinateur portable montrait également la ligne rouge, mais lorsque j'ai redimensionné l'écran, il est devenu vide. – Vallentin