Opengl & Pointers
BlitzMax Forums/OpenGL Module/Opengl & Pointers
| ||
Hi and thanks in advance I want to use picking in opengl and am happy to use the colour picking method abd I have a function as follows: However this crashes! I think it is due to the use of pointers but am not sure. Am I using pointers correctly here?? |
| ||
http://www.opengl.org/sdk/docs/man/xhtml/glPixelStore.xml I always set GL_PACK_ROW_LENGTH and GL_UNPACK_ROW_LENGTH any time I get or set pixels in OpenGL, just to be safe. If you don't call whichever is needed before a read/set call you will cause random errors that are extremely hard to track down, so I just always call them both in case I make a mistake. You can also just do this: glReadPixels Mx, My, 600, 500, GL_RGB, GL_UNSIGNED_BYTE, pixel Last edited 2011 |
| ||
glReadPixels Mx, My, 600, 500, GL_RGB, GL_UNSIGNED_BYTE, Pixel_ptr vs glReadPixels(X, GraphicsHeight() - Y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixbytes) You want to flip your y-coordinate because OpenGL handles buffers "upside down". If you want to pick only a single pixel then surely the area should be 1x1. Apparently we don't need a separate pointer for this. |