Tag Info

Hot answers tagged

6

How are you passing your normals to the vertex shader? It looks like those are the normals for each of the six faces of a cube, but the vertex shader operates on vertices, not faces. Unless you're doing something unusual, you need to specify a normal for each vertex. In addition, if you want a cube to look right, you will need 24 vertices rather than 8, so ...


3

Basically, you'll need some kind of container or collection to hold all entities. Then create some spawn or factory function to actually add them. When drawing (or updating) your game entities, you'll just iterate through this list and modify them accordingly. Here's some pseudo-code example: List<Entity> entities; function spawnEnemy(position pos) ...


3

In my experience with android, it is the garbage collection the kills the performance, not the allocation, although these two are tied hand and hand. As mentioned on the comments, pre-allocation is a way to deal with this issue. This is known as a memory pools. Another similar solution is object pool pattern. An object pool allocates as needed, but does ...


2

You can explicitly get those numbers from id = glGetAttribLocation(program, name); after linking; the name is the string that appears in the vertex shader for the attribute. For example if you passed "vertexPosition" for name then you would get 0. If the layout information is not in the shader then openGL will create a default layout (usually in order as ...



Only top voted, non community-wiki answers of a minimum length are eligible