Bonjour a tous ...
Je suis debutant mais vraiment debutante avec les outils de c++
J'aimerais avoir de l'aide avec le code opengl pour afficher un cube car
je ne maitrice pas vraiment opengl c'est nouveau pour moi...

le programme compile mais rien ne s'affiche ...et je ne sais pas pourquoi
Si une personne peut m'aide j'apprecirais énormement...Merci pour l'aide

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 
#include <GL/openglut.h>
 
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
 
/*
 * This macro is only intended to be used on arrays, of course.
 */
#define NUMBEROF(x) ((sizeof(x))/(sizeof(x[0])))
 
/*
 * These global variables control which object is drawn,
 * and how it is drawn.  No object uses all of these
 * variables.
 */
static int function_index;
static int slices = 16;
static int stacks = 16;
static double irad = .25;
static double orad = 1.0;
static int depth = 4;
static const double offset[ 3 ] = { 0, 0, 0 };
 
typedef struct
{
    const char * const name;
    void (*solid) (void);
    void (*wire)  (void);
} entry;
 
#define ENTRY(e) {#e, drawSolid##e, drawWire##e}
 
static void shapesPrintf (int row, int col, const char *fmt, ...)
{
    static char buf[256];
    int viewport[4];
 
    va_list args;
 
    va_start(args, fmt);
    (void) vsprintf (buf, fmt, args);
    va_end(args);
 
    glGetIntegerv(GL_VIEWPORT,viewport);
 
    glPushMatrix();
    glLoadIdentity();
 
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0,viewport[2],0,viewport[3],-1,1);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
}
 
static void
resize(int width, int height)
{
    const float ar = (float) width / (float) height;
 
    glViewport(0, 0, width, height);
 
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    if( ar > .5 )
        glFrustum( -ar, ar, -1.0, 1.0, 2.0, 100.0 );
    else
        glFrustum( -1.0, 1.0, -1/ar, 1/ar, 2.0, 100.0 );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
}
 
static void
display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_LIGHTING);
    glColor3d(1,0,0);
    glPushMatrix();
    glTranslated(0,1.2,-6);
    glPopMatrix();
 
    glPushMatrix();
    glTranslated(0,-1.2,-6);
 
    glPopMatrix();
 
    glDisable(GL_LIGHTING);
    glColor3d(0.1,0.1,0.4);
 
    shapesPrintf (1, 3, "Shape PgUp PgDn: %s");
    shapesPrintf (2, 3, " Slices +-: %d   Stacks <>: %d", slices, stacks);
    shapesPrintf (3, 3, " nSides +-: %d   nRings <>: %d", slices, stacks);
    shapesPrintf (4, 3, " Depth  (): %d", depth);
    shapesPrintf (5, 3, " Outer radius  Up  Down : %f", orad);
    shapesPrintf (6, 3, " Inner radius Left Right: %f", irad);
}
 
 
const GLfloat light_ambient[]  = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[]  = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
 
const GLfloat mat_ambient[]    = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[]    = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[]   = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
 
/* Program entry point */
 
int
main(int argc, char *argv[])
{
 
    glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
 
    glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
 
 
    return EXIT_SUCCESS;
}