Jump to content
  • Advertisement
Sign in to follow this  
taytay

Where is my mistake?

This topic is 2642 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am getting weird artifacts while using VBO and IBO but sometimes it works well. It generates a mess. Here is my code that generates it



for(a=0; a<mw; a++){

int k=0, m=0;
int t=0;
for(i=1; i<1024; i++){
for(j=1; j<1024; j++){
if(temp[j] == a){
t++;

buf[k+0].pos = vec3(i-512, j-512, 100);
buf[k+1].pos = vec3(i+1-512, j-512, 100);
buf[k+2].pos = vec3(i+1-512, j+1-512, 100);
buf[k+3].pos = vec3(i-512, j+1-512, 100);
buf[k+4].pos = vec3(i+0.5-512, j+0.5-512, 100);

buf[k+0].nor = buf[k+1].nor = buf[k+2].nor = buf[k+3].nor = buf[k+4].nor = vec3(0, 0, 1);

ind[m+0]=k+0;
ind[m+1]=k+1;
ind[m+2]=k+4;

ind[m+3]=k+3;
ind[m+4]=k+0;
ind[m+5]=k+4;

ind[m+6]=k+1;
ind[m+7]=k+2;
ind[m+8]=k+4;

ind[m+9]=k+2;
ind[m+10]=k+3;
ind[m+11]=k+4;
k+=5;
m+=12;
}
}
}
if(t != water[a]) MessageBox (HWND_DESKTOP, "Error water", "Error", MB_OK | MB_ICONEXCLAMATION);

glGenBuffersARB(1, &wvb[a]);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, wvb[a]);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(Vertex)*k, buf, GL_STATIC_DRAW_ARB);


glGenBuffersARB(1, &wib[a]);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, wib[a]);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(unsigned int)*m, ind, GL_STATIC_DRAW_ARB);
}


and rendering code
glBindBufferARB(GL_ARRAY_BUFFER_ARB, wvb);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(0));
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(Vertex), BUFFER_OFFSET(12));


glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, wib);

glDrawElements(GL_TRIANGLES, water*4*3, GL_UNSIGNED_INT, BUFFER_OFFSET(0));


any help please :(?

Share this post


Link to post
Share on other sites
Advertisement

I tried to lay my hand on the screen, but I'm still unable to see the artifacts. :rolleyes:
Maybe some screenshots could help ?


I don't know why but it does not do it anymore :D

Is it possible that problem is I am using Dev-c++ and it uses an older unsupported version of OpenGL?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!