0

I'm attempting per pixel collision detection for 2D sprites drawn as textured quads on a Samsung Galaxy S6 Edge+. Using C# and OpenTK.

glGenQueries always returns no query names (array 'queries' is unchanged) and the test to see if a query was made always fails and my exception hits.

The OpenGL error returned is 1282 (INVALID_OPERATION). The spec says that this occurs between glBegin and glEnd which I'm not even using (ES doesnt support them).

I dont think I'm doing anything wrong in this code, but the problem is either in device capabilities or the setup of the framebuffer/graphics mode.

uint error = 0;
int[] queries = new int[1];
ES30.GL.GenQueries(1, queries);

if (!ES30.GL.IsQuery(queries[0]))
{
    error = (uint)GL.GetError();
    throw new Exception("ES30.GL.GenQueries returned no query name");
}

My framebuffer is setup like this (8 stencil bits, I've tried 1. no depth (2d game))

ColorFormat f = new ColorFormat(32);
GraphicsMode = new AndroidGraphicsMode(f, 0, 8, 4, 0, false);

Any help appreciated, I've brickwalled in google for ages.

Regards

Matt

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • 1
    "*The spec says that this occurs between glBegin and glEnd which I'm not even using*" No, it does not. `GL_INVALID_OPERATION` can occur due to a great many operations. Just read the ES 3.0 specification. However, `glGenQueries` is not allowed to raise `GL_INVALID_OPERATION`. So odds are that something else caused it or your driver is broken. – Nicol Bolas Apr 02 '16 at 23:39
  • Thanks for the clarification. I've managed to get the app running in an emulator and genQueries behaves as expected there. On the device it does indeed raise INVALID_OPERATION. Not sure where to go from here on the device. – Matthew Barnett Apr 04 '16 at 01:25
  • To back Nicol up on that, the most authoritative ES 3 man page is at https://www.khronos.org/opengles/sdk/docs/man3/html/glGenQueries.xhtml — you probably accidentally read the documentation for desktop OpenGL prior to the core profile (e.g. https://www.opengl.org/sdk/docs/man2/xhtml/glGenQueries.xml ). ES doesn't provide `glBegin` or `glEnd`. – Tommy Apr 05 '16 at 03:04
  • Whatever the case. The driver on the device doesn't behave correctly. – Matthew Barnett Apr 06 '16 at 17:02

0 Answers0