Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
18 votes
Accepted

Should unbind buffers?

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 ...
user avatar
  • 3,017
14 votes

2D collision detection

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 ...
user avatar
13 votes
Accepted

Taking advantage of multithreading between game loop and openGL

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 ...
user avatar
  • 3,017
12 votes
Accepted

Confusion over GLViewport

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 ...
user avatar
  • 271
12 votes
Accepted

2D collision detection

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 ...
user avatar
  • 411
7 votes
Accepted

Calculated normals for mesh not working

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 ...
user avatar
  • 601
6 votes
Accepted

OpenGL light appears to move with camera and changes with object rotation

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 &...
user avatar
5 votes
Accepted

How can I use an unsigned int as a GLSL attribute for OpenGL ES 2

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. ...
user avatar
  • 13.2k
4 votes
Accepted

How to obtain the currently bound texture ID in an openGL ES 2.0 project

You should reconsider whether you really need to do this. Most of the time, querying the GL for such information should be avoided because it has an important performance cost. Since you are the one ...
user avatar
  • 23.4k
4 votes
Accepted

How can I reliably implement GPU skinning in Android?

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) ...
user avatar
  • 821
4 votes

How can I read from multiple textures in an OpenGL ES 2 shader?

In brief, you want code like this: ...
user avatar
4 votes

How to change from 60FPS to 30FPS while keeping things smooth?

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 ...
user avatar
4 votes

Offset a camera/render without changing perspective

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: ...
user avatar
  • 1,891
4 votes

OpenGL (ES 2.0) Function Dependencies

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 ...
user avatar
  • 12.5k
4 votes
Accepted

How do OpenGL ES 2 engines typically handle automatic geometry sorting and batching?

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 ...
user avatar
  • 462
4 votes

Indexed draw vs draw array

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 ...
user avatar
4 votes
Accepted

Why is my texture wrong?

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 ...
user avatar
  • 10k
3 votes

How can I use an unsigned int as a GLSL attribute for OpenGL ES 2

I'm answering based on my OpenGL non-ES knowledge, which I hope works on ES as well. It sounds like you want to use GLushort in your C code, referred to as ...
user avatar
  • 323
3 votes

2D collision detection

I would use a circle for the body and a single rectangle for the beak, but that's just my opinion. Overcomplicating your collision geometry can slow down your app though, you're practically doubling (...
user avatar
  • 617
3 votes
Accepted

Reducing APK File Size by using JPG instead of PNG for game background images

If you use an alpha-channel for your assets (which is most likely), then you're out of luck with vanilla JPEG anyway. PNG provides a pretty good compression while also being lossless and a format ...
user avatar
  • 22.5k
3 votes

Replace each white spot of image to radial gradient

If the source image is bi-level (1-bit black/white), a direct mapping of greyscale to gradient will not suffice. A possible solution to the problem is to compute a distance field (preferably as an ...
user avatar
  • 4,064
3 votes

How to avoid subpixel values in a resolution independent 2D game with orthographic projection?

I think I would store two sets of coordinates. One used for drawing your objects DISPLAY POSITION and a second used for keeping a ...
user avatar
  • 548
3 votes
Accepted

Desaturate texture using mask in OpenGL 2

I'd go for a second shader that accepts two textures and does the desaturation. Performance loss will be minimal. ...
user avatar
  • 10k
3 votes
Accepted

How to specify colour in a single 32 bit value

Fragment shaders operate with floats. This is an abstraction over the actual underlying hardware format (GLSL is a high-level language after all), so you shouldn't expect that to indicate that you've ...
user avatar
3 votes

Avoiding memory allocation in Android game development

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 ...
user avatar
  • 1,196
3 votes

model view projection multiplication order

It depends on the implementation of the multiply operation. The internals will suppose an ordering within your matrices, row major or column major. If the ordering of your matrices is arranged the way ...
user avatar
  • 2,343
3 votes
Accepted

Do shader compilers typically know not to look up unused texture channels?

You are not going to see any difference from fetching one channel over many. There is no optimization to make. Longer explanation: Texure is stored, you can guess without any doubt, by pixel in ...
user avatar
  • 2,343
3 votes

What's the best practice for a progress bar in OpenGL ES 2.0?

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: ...
user avatar
  • 10k
3 votes
Accepted

How to know when Android OpenGL Context has been preserved?

If you require specific behavior, your best option is to use a plain SurfaceView rather than a GLSurfaceView. GLSurfaceView is just a SurfaceView subclass that handles threading and EGL context ...
user avatar
  • 361

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