Bonjour,

j'ai un petit probleme avec les Vertex Buffer. J'alloue un tableau assez gros que j'initialise a 0. J'initialise ensuite un vertex buffer avec ce tableau, mais quand je l'affiche j'ai plein de points eparpillés autour de 0. J'ai remarqué que quand la taille du tableau est inferieure a 300k tout va bien. Ca doit être une erreur toute bete, je vois pas d'ou ca vient...

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
 
#include <iostream>
 
#include "glew/include/GL/glew.h"
#include "gl/glut.h"
 
using namespace std;
 
#define SIZE 1000000
 
void Display(void);
 
 
float *tab=0;
GLuint buff;
 
 
 
void CreateBuff(void)
{
 
	if(!tab)
	{
		tab=new float[SIZE];
		for(int i=0;i<SIZE;i++)
			tab[i]=0.f;
		glGenBuffers(1,&buff);
		glBindBuffer(GL_ARRAY_BUFFER, buff);
		glBufferData(GL_ARRAY_BUFFER,SIZE*sizeof(float),tab,GL_STREAM_DRAW);
		cout<<"Buff cree"<<endl;
	}		
}
 
void main(void)
{
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);	
	glutInitWindowSize(700,700);
             glutCreateWindow("TestGLew");
 
	GLenum err = glewInit();
	if (GLEW_OK != err)
	{
		cout<<"Glew erreur"<<endl;	
	}
 
	CreateBuff();
 
  	glutDisplayFunc(Display);
 
	glutMainLoop();	
}
 
void Display(void)
{
	if(tab)
	{
		cout<<"Affichage"<<endl;
		glBindBuffer(GL_ARRAY_BUFFER, buff);
 
		glVertexPointer(2,GL_FLOAT,2*sizeof(float),NULL);	
 
		glEnableClientState(GL_VERTEX_ARRAY); 
		glDrawArrays(GL_POINTS,NULL,SIZE/2);
		glDisableClientState(GL_VERTEX_ARRAY);
	}
 
	glutSwapBuffers();
}
Je m'etais trompé dans les tailles des buffers, ca marche :p