IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenGL Discussion :

Probléme d'affichage d'un VBO


Sujet :

OpenGL

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Homme Profil pro
    Inscrit en
    Décembre 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Décembre 2013
    Messages : 7
    Par défaut Probléme d'affichage d'un VBO
    Bonjour tout le monde,

    Je débute en OpenGL. J'aimerai faire un générateur de terrain similaire a celui ci : http://fearyourself.developpez.com/t...TexTerrainGen/
    Mais avec des VBO.

    Pour cela, j'utilise l'image : http://img4.hostingpics.net/pics/77067711in.png

    Et voici mon code :
    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
    #include <GL/glut.h>
    #include <stdlib.h>
    #include <math.h>
    #include <stdio.h>
    /*
    	COMPILATION :
    		gcc ./Main.c -o ./Main.out -lGL -lglut -lGLU `sdl-config --cflags --libs` -lSDL_image
    */
    #define BUFFER_OFFSET(a) ((char*)NULL + (a))
     
    static void affichage(GLfloat *tabCouleur);
    static unsigned char* chargementImage(int *width, int *height);
    static void clavier();
    static Uint32 getpixel(SDL_Surface *surface, int x, int y);
    void makeVBO(unsigned char *matrice, int width, int height);
    GLfloat * initCouleur(int width, int height, GLfloat r, GLfloat v, GLfloat b);
     
    static GLuint id;
    static GLfloat *tabVertex = NULL;
    static GLfloat posCamZ = 0.0;
    static GLfloat angleZ = 0.0;
    static GLfloat angleX = 0.0;
    static GLfloat Z = 0.0;
    static GLfloat posCamX = 0.0;
    static GLfloat posCamY = 0.0;
     
    //Génération du tableau de couleur
    GLfloat * initCouleur(int width, int height, GLfloat r, GLfloat v, GLfloat b)
    {
    	GLfloat *tabCouleur = NULL;
    	tabCouleur = calloc((width * height)*3, sizeof(tabCouleur));
    	int i = 0, rank = 0;
    	for(i=0; i < (((width * height)*3)-1); i++)
    	{
    		if(rank == 0)
    		{
    			tabCouleur[i] = r;
    			rank++;
    		}
    		else if(rank == 1)
    		{
    			tabCouleur[i] = v;
    			rank++;
    		}
    		else
    		{
    			rank = 0;
    			tabCouleur[i] = b;
    		}
    	}
    	return tabCouleur;
    	free(tabCouleur);
    }
     
    //Génération du VBO qu'on va afficher
    void makeVBO(unsigned char *matrice, int width, int height)
    {
    	GLfloat *matriceVertex = NULL;
    	int i = 0, rank = 0, loopLargeur = width - 1;
    	GLfloat x=0.0, y=0.0, z=0.0;
    	matriceVertex = calloc((width * height)*3, sizeof *matriceVertex);
    	for(i=0; i < ((width*height)*3); i++)
    	{
    		//Pour remplir x
    		if(rank == 0)
    		{
    			matriceVertex[i] = x;
    			rank++;
    			x += 3;
    			//printf("i:%d x:%f", i, matriceVertex[i]);
    		}
    		//Pour remplir y
    		else if(rank == 1)
    		{
    			matriceVertex[i] = (GLfloat)matrice[i];
    			rank++;
    			//printf(" y:%f", matriceVertex[i]);
    		}
    		//Pour remplir z
    		else
    		{
    			matriceVertex[i] = z;
    			rank = 0;
    			//printf(" z:%f\n", matriceVertex[i]);
    		}
    		if(!(x < width*3))
    		{
    			z += 3.0;
    			x = 0.0;
    		}
    	}
    	glGenBuffers(1, &id);
    	glBindBuffer(GL_ARRAY_BUFFER, id);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(matriceVertex), matriceVertex, GL_STATIC_DRAW);
    	glBufferSubData(GL_ARRAY_BUFFER, 0, ((width * height)*3) * sizeof(matriceVertex), matriceVertex);
    	glBindBuffer(GL_ARRAY_BUFFER, 0);
    	fprintf(stdout, "Mise en place du VBO : %d vertex\n", (width * height));
    	free(matriceVertex);
    }
     
    Uint32 getpixel(SDL_Surface *surface, int x, int y)
    {
      int bpp = surface->format->BytesPerPixel;
      Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
      switch(bpp)
    	{
    		case 1:
     		 	return *p;
      	case 2:
          return *(Uint16 *)p;
        case 3:
          if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
          	return p[0] << 16 | p[1] << 8 | p[2];
          else
            return p[0] | p[1] << 8 | p[2] << 16;
        case 4:
          return *(Uint32 *)p;
        default:
          return 0;
        }
    }
     
    //Chargement de mon image dans un tableau
    unsigned char* chargementImage(int *width, int *height)
    {
    	SDL_Surface * s = NULL;
    	s = IMG_Load("in.bmp");	
    	unsigned char *surfaceMonochrome;
    	int i=0, j=0;
    	surfaceMonochrome = calloc(s->w * s->h, sizeof *surfaceMonochrome);
    	Uint8 r, g ,b;
    	if(s == NULL)
    	{
    		fprintf(stderr, "Erreur lors du chargement de l'image : in.bmp\n");
    		return NULL;
    	}
    	else
    	{
    		fprintf(stdout, "Chargement de l'image : in.bmp\n");
    		fprintf(stdout, "Largeur : %dpx\nHauteur : %dpx\n", s->w, s->h);
    		*width = s->w;
    		*height = s->h;
    		SDL_LockSurface(s);
    		for(i=0; i < s->w; i++)
    		{
    			for(j=0; j < s->h; j++)
    			{
    				SDL_GetRGB(getpixel(s, i, j), s->format, &r, &g, &b);
    				surfaceMonochrome[j * s->w + i]	= (char)((r + g + b) / 3);
    			}
    		}
    		SDL_UnlockSurface(s);
    		free(surfaceMonochrome);
    		return surfaceMonochrome;
    	}
    }
     
    // Une demande d'affichage vient d'être générée 
    void affichage(GLfloat *tabCouleur)
    {
    	/* On efface l'écran avec la couleur du fond et le Z-Buffer */
    	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     
    	//Gestion de la camera
    	glLoadIdentity();
    	glRotatef(angleZ, 0, 1, 0);
    	glRotatef(angleX, 1, 0, 0);
    	glTranslatef(0, 0, Z);
    	gluLookAt (10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0);
     
    	//Dessin du VBO
    	glEnableClientState(GL_VERTEX_ARRAY);
    	glEnableClientState(GL_COLOR_ARRAY);
    	glBindBuffer(GL_ARRAY_BUFFER, id);
    	glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0));
    	glColorPointer(3, GL_FLOAT, 0, tabCouleur);
    	//glDrawElements(GL_LINE_STRIP, 33*33, GL_UNSIGNED_INT, 0);
    	glDrawArrays(GL_LINE_STRIP, 0, 33*33);
    	glDisableClientState(GL_COLOR_ARRAY);
    	glDisableClientState(GL_VERTEX_ARRAY);
    }
     
    //Gestion des événements clavier
    void clavier()
    {
    	SDL_Event event;
    	SDL_WaitEvent(&event);
    	switch(event.type)
    	{
    		case SDL_QUIT:
    			exit(1);
    		break;
    		case SDL_KEYDOWN:
    			switch(event.key.keysym.sym)
    			{
    				case SDLK_UP:
    					Z += 10;
    				break;
    				case SDLK_DOWN:
    					Z -= 10;
    				break;
    				case SDLK_LEFT:
    						angleZ -= 10;
    				break;
    				case SDLK_RIGHT:
    						angleZ += 10;
    				break;
    				case 'z':
    						angleX -= 10;
    				break;
    				case 's':
    						angleX += 10;
    				break;
    				case 'q':
    						exit(1);
    				break;
    			}
    	}
    }
     
    int main(int argc, char **argv)
    {
    	int done=1;
    	SDL_Event event;
    	SDL_Surface* screen;
    	int widthImage, heightImage;
    	int newx, newy, tmpx,tmpy, curmx,curmy;
    	GLfloat rapport = ((float) (800))/ ((float) (600));
    	GLfloat *tabCouleur;
    	unsigned char *matrice;
    	if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    			printf("Unable to initialize SDL: %s\n", SDL_GetError());
    				return 1;
    	}
    	SDL_WM_SetCaption("Affichage du terrain",NULL);
    	screen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);
    	if(screen==NULL)
    		return EXIT_FAILURE;
     
    	//Chargement de l'image
    	matrice = chargementImage(&widthImage, &heightImage);
    	//Création du tableau de couleur
    	tabCouleur = initCouleur(widthImage, heightImage, 0.0, 255.0, 0.0);
    	//Création du VBO
    	makeVBO(matrice, widthImage, heightImage);
    	glEnable(GL_DEPTH_TEST);
    	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
    	glViewport(0,0,800,600);
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluPerspective(40,rapport,1.0,100.0);
    	glMatrixMode(GL_MODELVIEW);
    	glClearColor(0.0,0.0,0.0,0.0);
     	while(done) 
    	{
    		//Affichage
    		affichage(tabCouleur);
    		clavier();
    		SDL_GL_SwapBuffers();
    	}
    	/*Quitter*/
    	SDL_Quit();
    	return EXIT_SUCCESS;
    }
    Je n'arrive pas a comprendre pourquoi mon VBO refuse de s'afficher lorsque je fais mon glDrawArrays. J'ai même le droit a un segmentation fault lorsque j'utilise la ligne du dessus : glDrawElements(GL_LINE_STRIP, 33*33, GL_UNSIGNED_INT, 0);

    Merci d'avance pour votre aide,

  2. #2
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 156
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 156
    Billets dans le blog
    151
    Par défaut
    Bonjour,

    Vous n'indiquez pas de tableau d'index, du coup, la fonction crash, car elle accède à quelque chose qui n'est pas activé.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

  3. #3
    Membre du Club
    Homme Profil pro
    Inscrit en
    Décembre 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Décembre 2013
    Messages : 7
    Par défaut
    Bonjour,

    J'ai suivis votre conseil pour le tableau d'indice, et en effet, mon code ne crash plus quand j'utilise glDrawElements.
    Voici mon nouveau code :
    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
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
    #include <GL/glut.h>
    #include <stdlib.h>
    #include <math.h>
    #include <stdio.h>
    /*
    	COMPILATION :
    		gcc ./Main.c -o ./Main.out -lGL -lglut -lGLU `sdl-config --cflags --libs` -lSDL_image
    */
    #define BUFFER_OFFSET(a) ((char*)NULL + (a))
     
    static void affichage(GLfloat *tabCouleur);
    static unsigned char* chargementImage(int *width, int *height);
    static void clavier();
    static Uint32 getpixel(SDL_Surface *surface, int x, int y);
    void makeVBO(unsigned char *matrice, int width, int height);
    GLfloat * initCouleur(int width, int height, GLfloat r, GLfloat v, GLfloat b);
     
    static GLuint id;
    static GLfloat *tabVertex = NULL;
    static GLfloat posCamZ = 0.0;
    static GLfloat angleZ = 0.0;
    static GLfloat angleX = 0.0;
    static GLfloat Z = 0.0;
    static GLfloat posCamX = 0.0;
    static GLfloat posCamY = 0.0;
     
    //Génération du tableau de couleur
    GLfloat * initCouleur(int width, int height, GLfloat r, GLfloat v, GLfloat b)
    {
    	GLfloat *tabCouleur = NULL;
    	tabCouleur = calloc((width * height)*3, sizeof(tabCouleur));
    	int i = 0, rank = 0;
    	for(i=0; i < (((width * height)*3)-1); i++)
    	{
    		if(rank == 0)
    		{
    			tabCouleur[i] = r;
    			rank++;
    		}
    		else if(rank == 1)
    		{
    			tabCouleur[i] = v;
    			rank++;
    		}
    		else
    		{
    			rank = 0;
    			tabCouleur[i] = b;
    		}
    	}
    	return tabCouleur;
    	free(tabCouleur);
    }
     
    //Génération du VBO qu'on va afficher
    void makeVBO(unsigned char *matrice, int width, int height)
    {
    	GLfloat *matriceVertex = NULL;
    	int i = 0, rank = 0, loopLargeur = width - 1, j=0;
    	GLfloat x=0.0, y=0.0, z=0.0;
    	matriceVertex = calloc((width * height)*3, sizeof *matriceVertex);
    	for(i=0, j=0; i < ((width*height)*3); i+=3, j++)
    	{
    		matriceVertex[i] = x;
    		matriceVertex[i+1] = (GLfloat)matrice[j];
    		matriceVertex[i+2] = z;
    		x+=3;
    		if(!(x < width*3))
    		{
    			z += 3.0;
    			x = 0.0;
    		}
    	}
    	for(j=0; j < ((width*height)*3); j++)
    		printf("%d: %lf\n", j, matriceVertex[j]);
     
    	glGenBuffers(1, &id);
    	glBindBuffer(GL_ARRAY_BUFFER, id);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(matriceVertex), matriceVertex, GL_STATIC_DRAW);
    	glBufferSubData(GL_ARRAY_BUFFER, 0, ((width * height)*3) * sizeof(matriceVertex), matriceVertex);
    	glBindBuffer(GL_ARRAY_BUFFER, 0);
    	fprintf(stdout, "Mise en place du VBO : %d vertex\n", (width * height));
    	free(matrice);
    	free(matriceVertex);
    }
     
    Uint32 getpixel(SDL_Surface *surface, int x, int y)
    {
      int bpp = surface->format->BytesPerPixel;
      Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
      switch(bpp)
    	{
    		case 1:
     		 	return *p;
      	case 2:
          return *(Uint16 *)p;
        case 3:
          if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
          	return p[0] << 16 | p[1] << 8 | p[2];
          else
            return p[0] | p[1] << 8 | p[2] << 16;
        case 4:
          return *(Uint32 *)p;
        default:
          return 0;
        }
    }
     
    //Chargement de mon image dans un tableau
    unsigned char* chargementImage(int *width, int *height)
    {
    	SDL_Surface * s = NULL;
    	s = IMG_Load("in.bmp");	
    	unsigned char *surfaceMonochrome;
    	int i=0, j=0;
    	surfaceMonochrome = calloc(s->w * s->h, sizeof *surfaceMonochrome);
    	Uint8 r, g ,b;
    	if(s == NULL)
    	{
    		fprintf(stderr, "Erreur lors du chargement de l'image : in.bmp\n");
    		return NULL;
    	}
    	else
    	{
    		fprintf(stdout, "Chargement de l'image : in.bmp\n");
    		fprintf(stdout, "Largeur : %dpx\nHauteur : %dpx\n", s->w, s->h);
    		*width = s->w;
    		*height = s->h;
    		SDL_LockSurface(s);
    		for(i=0; i < s->w; i++)
    		{
    			for(j=0; j < s->h; j++)
    			{
    				SDL_GetRGB(getpixel(s, i, j), s->format, &r, &g, &b);
    				surfaceMonochrome[j * s->w + i]	= (char)((r + g + b) / 3);
    			}
    		}
    		SDL_UnlockSurface(s);
    		return surfaceMonochrome;
    	}
    }
     
    // Une demande d'affichage vient d'être générée 
    void affichage(GLfloat *tabCouleur)
    {
    	/* On efface l'écran avec la couleur du fond et le Z-Buffer */
    	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     
    	int i=0;
    	unsigned int index[33*33];
    	for(i=0; i < 33*33; i++)
    		index[i] = i;
     
    	//Gestion de la camera
    	glLoadIdentity();
    	glRotatef(angleZ, 0, 1, 0);
    	glRotatef(angleX, 1, 0, 0);
    	glTranslatef(0, 0, Z);
    	gluLookAt (10.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0);
     
    	//Dessin du VBO
    	glEnableClientState(GL_VERTEX_ARRAY);
    	glEnableClientState(GL_COLOR_ARRAY);
    	glBindBuffer(GL_ARRAY_BUFFER, id);
    	glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0));
    	glColorPointer(3, GL_FLOAT, 0, tabCouleur);
    	glDrawElements(GL_TRIANGLE_STRIP, 33*33, GL_UNSIGNED_INT, index);
    	//glDrawArrays(GL_LINE_STRIP, 0, 33*33);
    	glDisableClientState(GL_COLOR_ARRAY);
    	glDisableClientState(GL_VERTEX_ARRAY);
    }
     
    //Gestion des événements clavier
    void clavier()
    {
    	SDL_Event event;
    	SDL_WaitEvent(&event);
    	switch(event.type)
    	{
    		case SDL_QUIT:
    			exit(1);
    		break;
    		case SDL_KEYDOWN:
    			switch(event.key.keysym.sym)
    			{
    				case SDLK_UP:
    					Z += 10;
    				break;
    				case SDLK_DOWN:
    					Z -= 10;
    				break;
    				case SDLK_LEFT:
    						angleZ -= 10;
    				break;
    				case SDLK_RIGHT:
    						angleZ += 10;
    				break;
    				case 'z':
    						angleX -= 10;
    				break;
    				case 's':
    						angleX += 10;
    				break;
    				case 'q':
    						exit(1);
    				break;
    			}
    	}
    }
     
    int main(int argc, char **argv)
    {
    	int done=1;
    	SDL_Event event;
    	SDL_Surface* screen;
    	int widthImage, heightImage;
    	int newx, newy, tmpx,tmpy, curmx,curmy;
    	GLfloat rapport = ((float) (800))/ ((float) (600));
    	GLfloat *tabCouleur;
    	unsigned char *matrice;
    	if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    			printf("Unable to initialize SDL: %s\n", SDL_GetError());
    				return 1;
    	}
    	SDL_WM_SetCaption("Affichage du terrain",NULL);
    	screen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);
    	if(screen==NULL)
    		return EXIT_FAILURE;
     
    	//Chargement de l'image
    	matrice = chargementImage(&widthImage, &heightImage);
    	//Création du tableau de couleur
    	tabCouleur = initCouleur(widthImage, heightImage, 0.0, 255.0, 0.0);
    	//Création du VBO
    	makeVBO(matrice, widthImage, heightImage);
    	glEnable(GL_DEPTH_TEST);
    	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16);
    	glViewport(0,0,800,600);
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluPerspective(40,rapport,1.0,100.0);
    	glMatrixMode(GL_MODELVIEW);
    	glClearColor(0.0,0.0,0.0,0.0);
     	while(done) 
    	{
    		//Affichage
    		affichage(tabCouleur);
    		clavier();
    		SDL_GL_SwapBuffers();
    	}
    	/*Quitter*/
    	SDL_Quit();
    	return EXIT_SUCCESS;
    }
    En revanche, j'ai toujours le droit a un écran noire alors que je suis censé afficher mes triangles.

  4. #4
    Responsable 2D/3D/Jeux


    Avatar de LittleWhite
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Mai 2008
    Messages
    27 156
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Mai 2008
    Messages : 27 156
    Billets dans le blog
    151
    Par défaut
    Cet outil gDEBugger vous permettra de vérifier si les données sont bien envoyé à la carte graphique.

    Là, je ne vois pas ce qui pourrait poser problème
    gDEBugger vous permettra de mieux le situer, notamment de vérifier si les index sont bons ainsi que les données.
    Vous souhaitez participer à la rubrique 2D/3D/Jeux ? Contactez-moi

    Ma page sur DVP
    Mon Portfolio

    Qui connaît l'erreur, connaît la solution.

Discussions similaires

  1. [2D/3D] [OpenGL] Problème d'affichage avec VBO
    Par _Adri dans le forum Qt
    Réponses: 1
    Dernier message: 13/01/2015, 20h10
  2. [VBO] Problème d'affichage de texture
    Par Lung dans le forum OpenGL
    Réponses: 2
    Dernier message: 22/04/2009, 08h16
  3. [Kylix] problème d'affichage
    Par scalvi dans le forum EDI
    Réponses: 1
    Dernier message: 18/06/2003, 10h07
  4. Réponses: 1
    Dernier message: 06/03/2003, 11h57
  5. probléme d'affichage d'une fiche
    Par sb dans le forum Composants VCL
    Réponses: 7
    Dernier message: 29/08/2002, 09h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo