I’m trying to make an application where the user can translate around an image. When the image moves upwards or rightwards, all is well. I simply adjust the raster position. Also, when the user translates leftwards, I adjust GL_UNPACK_SKIP_PIXELS, and it works well (although it redisplays the lefmost part of the image on the righthand side).
My problem is when the user wants to translate downwards. I try to adjust GL_UNPACK_SKIP_ROWS, and it crashes at the glDrawPixels call (I put printf’s before and after).
Any ideas on where to start debugging?
I should mention that the image is contained within its own window, separately from another window displaying a 3d model.
I’m really new to this, and the first way I could think of to scroll downwards on an image was simply not to draw the first few rows. I thought I was being careful by ensuring that rasterpos doesn’t go negative, but does incrementing SKIP_ROWS make pixelDraw(…) go outside the array boundaries?
I’m completely open - what would be the best way to scroll around an image?
Thanks - hadn’t thought of that - it should work well. The only problem with this is that I would have to deal with rescaling the image so that each dimension is a power of 2, whereas it is currently 1280x960. Is there an easy way to do this?
Also - do you know what caused the previous implementation to crash? I’m still a bit clueless there…
You can pass negative values to rasterPos. With non standard opengl (extensions required such as NV_rectangle_whatever, you can supply non power of 2)
It’s not necessary to scale in your case for standard opengl. You can padd the edges with black pixels and send adjusted TexCoords to opengl so that the black areas dont become visible. It’s a bit tricky for this case.
Personally, I would stick to glRasterPos and glDrawPixels.