Jump to content

  • Log In with Google      Sign In   
  • Create Account

Shifting pixels in a drawn display


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Schwartz86   Members   -  Reputation: 102

Like
0Likes
Like

Posted 09 June 2011 - 11:20 AM

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

Sponsor:

#2 TheCrow33   Members   -  Reputation: 120

Like
1Likes
Like

Posted 09 June 2011 - 11:37 AM

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

#3 Schwartz86   Members   -  Reputation: 102

Like
0Likes
Like

Posted 09 June 2011 - 05:19 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS