View previous topic :: View next topic |
Author |
Message |
ryutenchi
Joined: 09 Dec 2010 Posts: 8
|
Posted: Tue Feb 01, 2011 9:40 am Post subject: Weird OpenGL buffer issue |
|
|
Now first off, I know this isn't an OpenGL forum, but I think this has something to do with they way I am using D and I have yet to find an OpenGL forum that deals with D. That said... I seem to have an issue in my model loader(renders the same regardless of how I bind to the buffer) where it looks like my normals are getting tacked onto or into my vertex buffer (not interleaving at the moment, trying to get everything working first then with get "fancy"). here is the jist of my load code:
Code: | GLfloat [] verts;
GLfloat [] finalVerts;
GLfloat [] uvs;
GLfloat [] finalUvs;
GLfloat [] norms;
GLfloat [] finalNorms;
//load the list of verts into verts
//load the list of normals into norms
//load the list of uvs into uvs
//read in triangle indices
//for each line of indices
finalVerts ~= verts[i1..(i1+3)];//load first vert in tri
finalVerts ~= verts[i2..(i2+3)];//second
finalVerts ~= verts[i3..(i3+3)];//third
finalUvs ~= uvs[i1..i1+2];//load first vert in tri's uv coords
finalUvs ~= uvs[i2..i2+2];//second
finalUvs ~= uvs[i3..i3+2];//third
finalNorms ~= norms[i1..(i1+3)];//load first vert's normal
finalNorms ~= norms[i2..(i2+3)];//second
finalNorms ~= norms[i3..(i3+3)];//third
glBindBuffer(GL_ARRAY_BUFFER, IDs[ID_types.VBO]);
glBufferData(GL_ARRAY_BUFFER, finalVerts.length * finalVerts[0].sizeof, finalVerts.ptr, GL_STATIC_DRAW);
numFaces = finalVerts.length;
glBindBuffer(GL_ARRAY_BUFFER, 0);//added to make good and sure the buffer bind was reset
glBindBuffer(GL_ARRAY_BUFFER, IDs[ID_types.Normal]);
glBufferData(GL_ARRAY_BUFFER, finalNorms.length * finalNorms[0].sizeof, finalNorms.ptr, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, IDs[ID_types.Texture]);
glBufferData(GL_ARRAY_BUFFER, finalUvs.length * finalUvs[0].sizeof, finalUvs.ptr, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0); |
like I said the render code doesn't seem to make(binding to the vert buffer regardless). ... Any ideas on what I'm doing wrong? Any help (including links to a more appropriate forum for this question) would be greatly appreciated!
Thanks,
-Matt
images for reference:
with smooth normals:
[img]http://twitpic.com/3vhi7m[/img]
[img]http://twitpic.com/3vhig1[/img]
and with "hard" normals:
[img]http://twitpic.com/3vhjbg[/img]
[img]http://twitpic.com/3vhjh6[/img] |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
ryutenchi
Joined: 09 Dec 2010 Posts: 8
|
Posted: Thu Feb 03, 2011 8:38 am Post subject: |
|
|
Little update:
When I go to try and get this working on OSX(have been developing on windows) I had the same issue, but it looked different. That is until I started using shaders with glVertexPointer instead of glVertexAttribPointer for positional data... and then some times it does come up with that junk but if I close the program, suspend the computer, wake it up and try again it fixes it.... no more junk... it's just so weird... |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|