18

You seem to be doing a lot on unnecessary binding/unbinding. If you are using a VAO, then you should only bind the VAO when you set it up and when drawing the geometry. You only bind the VBO/IBO again when you need to update them. After drawing or updating a buffer, you don't necessarily have to unbind it, though it might be a good idea to do so to avoid ...


16

The problem with using texture atlases and adjacent texels leaking has to do with the way linear texture filtering works. For any point in the texture that is not sampled exactly at the center of a texel, linear sampling will sample 4 adjacent texels and compute the value at the location you asked as the weighted (based on distance from the sample point) ...


14

A two step check process On the first step, you check the bounding box, and if there is no collision there, then the test is over. If there is collision, you move over to the second pass On the second pass, if you want more precision, and you want a true pixel perfect solution, then you can do just that, a pixel perfect check pass Since your image is a ...


13

The approach you've described, using locks, would be very inefficient and most likely slower than using a single thread. The other approach of keeping copies of data in each thread would probably work well "speed-wise", but with a prohibitive memory cost and code complexity to keep the copies in sync. There are several alternative approaches to this, one ...


12

Circle collider. Good enough for it I would say unless you're doing something fancy with certain parts being affected by physics or the colliding looking unnatural, and even if you need to split it up into several parts I have one thing to say to you: Don't overcomplicate it. You don't need a full quad tree structure for this. Just have several boxes or ...


12

To understand what's going on, you have to understand the rendering pipeline: Your geometry (the quad) is initially defined in world space, think of this as some global coordinate system. Inside of the vertex shader those are transformed to normalised device coordinates (NDC), a virtual coordinate system defined so, that everything from -1 to 1 will get ...


8

Create a scale matrix with a scale of -1 on the axis you want to mirror.


7

As you say, the two formulas don't behave the same way mathematically. So if it makes a difference to the visuals, your first priority should be to pick the one that gives you the better-looking result. Both formulas will be a single instruction on the vast majority of GPUs. x * 0.5 + 0.5 can be done with a mad (multiply-add) instruction, and max is a ...


7

You said highp floats are not supported on your hardware, so I assume you're using mediump. The OpenGL ES shading language spec says that mediump has a minimum relative precision of 2^(-10), or 1/1024. So if a and b are two adjacent mediump values, the ratio (b-a)/a can be as large as 1/1024. Unfortunately, if you look at 65.0 and 64.98, the ratio (65.0 - ...


7

vec3 norm = vec3(uViewMatrix * uModelMatrix * aNormal); The normal cannot be transformed like a point, to transform a normal you use the inverse transpose matrix. If you want the fun details of why this is here is a qoute from the OpenGL Red Book that explains it better then I ever will: Mathematically, it's better to think of normal vectors not as ...


6

Draw calls by themselves are not always the bottleneck, it is what happens between them that is. Generally when you issue a draw call, the command buffer (state changes, data uploads, etc.) is evaluated and the expense of changing many states is actually deferred until this point. For instance, if you issue the same draw call back-to-back the second draw ...


6

From what I read from the shaders the light is in world-space and the light calculation is done on the object in part in untransformed object-space. You need to compute your lighting with both light & model in world-space or both in camera space. Whenever moving the camera messes up the lighting it means some of the data is calculated in a different ...


5

Alpha blending in 3D is tricky, simply due to the fact that you're (usually) still rendering the quad (or polygon) to the depth buffer using the depth buffer, even if your visible texture is just a tiny part of that. To achieve proper rendering you'll have to render everything in the correct order, essentially from back to front. If you don't use the ...


5

If you want to permanently change quads to tris in Blender use Ctrl+T in Edit-Mode


5

Programming in GLESSL is a bit different than programming for a normal CPU. Since you're using OpenGLES 2, I will assume you are using GLESSL 1.0. So I will be pulling quotes from its documentation. In general, GLESSL offers you a variety of types as programming aids, with some guarantees regarding their behavior, but leaves the actual low level ...


5

The general rule of thumb when drawing alpha polys is: 1 - Draw all solid polys first. 2 - Sort back to front if you can. The main reason for this is to ensure that the final colour produced by the blending equation is consistent frame to frame. I often don't bother with this step unless it is something provided by the engine and I can justify the extra ...


5

No need to bring in additional entities, KISS Just render the progress bar out of three parts - left cap, right cap and the body. Schematic: {left cap] [body] [right cap} Left and Right caps are usually always the same - half-circles with transparency. The body texture needs to be stretchable without noticeable effects. Left and Right caps usually get ...


4

You are setting up the depth test correctly. Note that the backface culling is not needed for this case, although it's still good to enable for other reasons. A likely reason why your depth test is not working correctly could be using 0.0 as the near plane when calling gluPerspective. See https://stackoverflow.com/questions/4764057/opengl-depth-test-not-...


4

This is related to the affine transformation matrix. Basically, a 0 means that you are working with a vector (which has no position and is not affected by the affine portion of transformation matrices) and a 1 means that you are working with a point (which is affected by affine transformations). Consider this 3x3 column-major 2D affine translation matrix: ...


4

You can implement the clipping plane functionality using vertex and fragment shaders and using discard fragment. The other option is described in this paper, where it introduces a technique that modifies the projection matrix so the near and far planes are re-positioned to become a general purpose clipping plane. This way you can implement that without ...


4

In brief, you want code like this: glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, this->texture2DObj); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, this->otherTexture2DObj); GLint samplerArrayLoc = glGetUniformLocation(shaderObject, "texture"); const GLint samplers[2] = {0,1}; // we've bound our textures in textures 0 and 1. ...


4

This is non-conforming behaviour by the Nexus 7 (Adreno GPU). You say "uniforms are not meant to be randomly accessed", but according to Appendix A of the spec: Uniforms (excluding samplers) In the vertex shader, support for all forms of array indexing is mandated. In the fragment shader, support for indexing is only mandated for constant-index-...


4

If you have seen a game running at 60fps, then reverting to 30fps will always be noticeably less smooth - it's a perception thing. Get someone who has never played your game before to play it at 30fps and they'll probably think it's just fine. Most games target 60fps these days as games running at 60fps have a much better feel. Most recent (high end?) ...


4

Wow that was fast. It's crazy how sometimes just writing out the question helps you figure out how to approach a solution. Here is my matrixPerspective function: void matrixPerspective(float angle, float near, float far, float aspect, mat4 m) { //float size = near * tanf(angle / 360.0 * M_PI); float size = near * tanf(degreesToRadians(angle) / 2.0)...


4

Well, OpenGL is a state machine, so inorder to plot function dependencies you need to plot a state machine, there is this one that models the most recent versions of OpenGL pipeline including ES2.0 and 4.0. Unfortuantely I couldn't find a diagram the plots function dependencies but I guess that can be mostly deduced from the state machine.


4

What you're doing may not be the most efficient, but it is still quite efficient, simple, flexible and commonly done. A more efficient, but code-wise more complex and less flexible solution would be to use different draw `buckets' into which you put your drawables depending on the required state, e.g. you separate opaque from transparent meshes. With your ...


4

It depends. Using glDrawElements requires an index buffer which is an extra, but does allow for removal of duplicate vertices, concatenation of primitives and reuse of vertices via the hardware vertex cache. Using glDrawArrays is simpler but doesn't have these advantages. Desktop hardware has been optimized around glDrawElements with GL_TRIANGLES for ...


4

See if you can fix this by flipping V coordinate of the UV map: V = 1 - V It is very common that UV gets vertically flipped in different programs/engines. Also note that different image formats (and loaders) could also store/flip images vertically.


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