Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Jul 2012
Offline Last Active Private

#5252745 Only the last instance is rendered

Posted by on 17 September 2015 - 02:38 PM

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.

#5195823 OBJ File Problem

Posted by on 01 December 2014 - 10:46 PM

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.

#5185443 Access vertex array in compute shader

Posted by on 06 October 2014 - 10:08 PM

std140 layout pads a vec3 to 4.

#5183209 [FIXED]Open simple obj file -> nothing

Posted by on 26 September 2014 - 03:36 PM

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.

#5183155 [FIXED]Open simple obj file -> nothing

Posted by on 26 September 2014 - 10:33 AM

GL_POLYGON draws a *single* polygon. Try hitting 'triangulate' in blender before exporting to obj and rendering GL_TRIANGLES.

#5182560 [FIXED]Open simple obj file -> nothing

Posted by on 23 September 2014 - 08:56 PM

Can you share the code where you create the array? How are you using the faces data from the file?


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/

#5181962 Noob question about glDrawArrays

Posted by on 21 September 2014 - 04:29 PM

2904 / 3 = 968. (it is divisible)

#5181960 Can you use the same vertex data more than once per draw call?

Posted by on 21 September 2014 - 04:14 PM

It sounds like instancing is extactly what you want.

I don't think so... I have instancing working with a different ModelView matrix for every instance of drawing a set of 2 triangles that make up a quad for a sprite. My "problem" with that way of doing things was that I was sending 6 identical vertices for every single quad, and then just altering their position later in the shader using a different ModelView matrix for each instance. Meaning I had a lot of essentially redundant data that I felt I should be able to reduce. My question is probably as relevant to the behaviour of glDrawArrays as it is to glDrawArraysInstanced.

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) ]

#5166237 (Super) Smart Pointer

Posted by on 11 July 2014 - 10:15 AM

Read Buckeye's original post again. If the AI has a pointer *to the pointer* to the enemy, they can all see whether the enemy object exists/NULL or not with a single if-statement. No looping. The AI just sees a lack of enemy next time they get updated.

#5166107 Terrain - map editor

Posted by on 10 July 2014 - 08:00 PM

I would go height map for a terrain editor. Bullet's height map object allows for the map array to be dynamically modified. Creating a new btBvhTriangleMeshShape every time the terrain is modified may or may not be too slow, but using the height map wouldn't require quite as much Bullet-related code.


On the other hand, do you really need physics *while* the terrain is being altered/extruded/etc? You could stop physics, allow the user to extrude (terminology?) a hill, and then start simulating again after building a new btBvhTriangleMeshShape. If your editor includes placing other objects (like debris), you might need to use an invisible sphere to push away other objects before creating a new btBvhTriangleMeshShape. Or even try to detect which non-static objects would need to be moved and just warp them above the new highest point in the area and let them fall back down (the user will have to re-place them, but hey, they rose a hill there).


Disclaimer: I've never written such an editor; I use Blender (poorly).

#5165637 some assembly unknowns

Posted by on 08 July 2014 - 02:29 PM

If you use NASM to output a raw binary it will assume 16-bit code for a DOS .com executable.



#5151960 OpenGL doesn't draw triangle

Posted by on 06 May 2014 - 08:17 PM

Lack of a vertex array bound before setting up attributes? (glGenVertexArrays / glBindVertexArray)

#5130134 Drawing multiple objects

Posted by on 09 February 2014 - 01:43 PM

Sorry for the long delay between replies.


It's very strange that you would only get the error the second time through.

One thing to try would be to explicitly enable that extension using:

#extension GL_ARB_explicit_attrib_location : enable

after the version line.


Might be worthwhile to attempt to update your drivers.

#5129455 Drawing multiple objects

Posted by on 06 February 2014 - 07:02 PM

What version of GL context are you getting?

Could you post your vertex shader code?


There are functions that separate vertex format from the buffers being used, but for GL ~3.3 a vertex array per unique model is the norm. It's also perfectly normal for a great many objects to use the same shader program and to sort by shader. That error sounds like a GLSL compile error, but if you were successfully rendering one object with the same shader before your attempt to render more, I'm at a loss to solve the problem with just the information provided.


It's probably not relevant, but the second parameter to glVertexAttribPointer is the number of elements (floats here), not sizeof(float), if that helps. I don't know what your vertex format is so no idea if there's really 8 floats per vertex.

#5128758 assimp subsets problem

Posted by on 04 February 2014 - 10:45 AM

Both of those assumptions are wrong. The material ID could be i rather often, but it's possible for two subsets to use the same material (less materials than meshes). The offset cannot always be zero. If you have DX starting from the beginning of the vertex buffer everytime, each subset's indices

will always use the first X vertices and not the right ones. A subset's indices are always 0 - num_vertices for that subset.

You could add the starting vertex to all the indices for each subset, but it would be easier to just set offset.


After looking through the .net code on the linked site, he is adding vertex start to all the indices. I have to assume then that the model format

used in the book has the indices like that already.