Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

1248 Excellent

About beans222

  • Rank

Personal Information

  1. The std130 layout will pad out the float to a vec4. The buffer won't be the right size for the uniform struct in the shader and the shader will read zero.
  2. beans222

    OBJ File Problem

    For example, let's make position 6 be 0,1,0. The faces would then be: f (0,1,0)/11 5/12 1/9  then later on f 7/15, (0,1,0)/16 ... Two faces can and do touch after all. They aren't assigned, the data is just used in that order. If any part of the full vertex (position + uv) doesn't match another full vertex they are unique even if part is the same (and get different indices for the GL element buffer). You will end up duplicating data, outputing a position multiple times if it appears with different uvs.   Also, easier to think of those v-lines as positions. Edit: if that's not terribly clear, I apologize. I'm exhausted. I'll post some code tomorrow if necessary.
  3. beans222

    OBJ File Problem

    If you need indices for your engine (or just want to always use indexed renders) Sponji has the right info. What I was getting at with a flat array is that you can build a flat array from the indices after you've read the file: std::vector<int> indices; // pairs: position, uv, position, uv, etc std::vector<vertex> vertices(indices.size()/2); for(int i = 0; i < indices.size()/2; ++i) { vertices[i].x = points[indices[i]].x; // and y, z vertices[i].u = texcoords[indices[i+1]].u // and v } // where points and texcoords are the v and vt from the obj file // and indices is all of the face data. and then 'vertices' is all you need into one vbo with glDrawArrays.
  4. beans222

    OBJ File Problem

    OpenGL only supports 1 index buffer, where an index refers to the "complete" vertex that includes all attributes (uv, normal, etc). The easiest way to go is to copy the position and uv coordinates to a buffer as you read (or after) the indices and just render using glDrawArrays without an element array buffer. Otherwise, you'll need to build a new index buffer based on unique pairs of position+uv.   Also, the binding of GL_ELEMENT_ARRAY_BUFFER is part of the state of a vertex array. Even if you set up glVertexAttribPointers later, you might as well bind the VAO before the element buffer and have that all set (and not messing up the previous VAO's state).
  5. The vertex shader input attributes need to be assigned a location, whether with layout or glBindAttribLocation.     There's a typo highlighted, that should be GL_UNIFORM_BUFFER. Also, I didn't try to get the lighting glsl to work, I just output red from the fragment shader to make sure there was output. It's a cube!
  6.   glBindBufferBase/Range also bind the generic target, so at least for just filling the buffer, those last two calls are the same.         This is where you need to glBindBufferBase to binding point 1 that you've set up for the block. No need to unbind it. And also stop using NULL when you mean zero.
  7. std140 layout pads a vec3 to 4.
  8. Are you just trying to implement a first person view/camera? If so, you either need to simply add the camera's look vector to position (for a floating camera); or need to cross multiply look with up (0,1,0), then the cross result with up, to get forward (for a character that can move and look in somewhat different directions).
  9. beans222

    OpenGL suddenly won't draw buffers?

    My guess would be that the shader compiler is optimizing out the 'inNormal' attribute resulting in glEnableVertexAttribArray raising invalid value (-1 for an attribute index).
  10. Have you set up the depth buffer? Needs to be enabled, cleared each frame, and the most common clear value is 1.0. Here's a wiki page about is: http://www.opengl.org/wiki/Depth_Buffer   edit: also obj indices start at 1, need to adjust to 0 for gl elements if you haven't already.
  11. GL_POLYGON draws a *single* polygon. Try hitting 'triangulate' in blender before exporting to obj and rendering GL_TRIANGLES.
  12.   This. You are sending the 8 vertices of a cube to GL, but drawing triangles that's not going to work (cube has 6 faces that are quads = 12 total triangles). You need to make a GL_ELEMENT_ARRAY buffer out of the faces section of the obj file data.   If you haven't already seen this online book, stop now and read: http://arcsynthesis.org/gltut/
  13. beans222

    Noob question about glDrawArrays

    2904 / 3 = 968. (it is divisible)
  14. It sounds like instancing is extactly what you want. You can create a vertex array with only the instance attribute(s) enabled/setup and avoid using the 6 vertices all together, then in the shader use gl_VertexID? to determine which vertex of the quad it is. Use glDrawArraysInstanced normally [eg for 2 instances of the quad: glDrawArraysInstanced(GL_TRIANGLES, 0, 6, 2) ]
  15. How are you setting up the ModelView matrix to use instancing?
  • 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!