Shifting pixels in a drawn display

Started by
1 comment, last by Schwartz86 12 years, 10 months ago
Hello,

I am relatively new to using OpenGL and am needing a bit of guidance.

I am working on a project that draws a 'display' using opengl. However, the coordinate system all the drawing routines use is setup such that instead of going from (0,0) to (x,y) it goes from (-x/2, -y/2) to (x/2, y/2). Another (proprietary) library I am using allows be to use openGL to draw "overlays", however, its coordinate system uses 0,0 to x,y.

So essentially, I am wanting to draw everything to the screen and then "shift" it to the coordinate system that other library expects. I hope this makes sense...

All I really need is a routine that would allow me to shift all the pixels that have just been drawn by an x and y offset. Otherwise, I will have to change all the old drawing routines which will be messy and daunting.

Thanks
Advertisement
Not real sure this is what you're looking for but try translating by -x/2, -y/2 right before drawing anything from the proprietary library. So something like:

glLoadIdentity();
glTranslatef(-x/2, -y/2, 0);
//Now draw stuff from proprietary library


This essentially makes the upper left hand corner (0,0) for the drawing that is to come

Not real sure this is what you're looking for but try translating by -x/2, -y/2 right before drawing anything from the proprietary library. So something like:

glLoadIdentity();
glTranslatef(-x/2, -y/2, 0);
//Now draw stuff from proprietary library


This essentially makes the upper left hand corner (0,0) for the drawing that is to come


Awesome thanks. That worked almost perfectly, just had to leave off the negative signs. At the time I wrote it I realized that it was an embarrassingly simple problem that could be fixed with one line of code. However, never touching OpenGL before today, I wasn't sure what that line was!

Thanks again!

+1 rep

This topic is closed to new replies.

Advertisement