Hey, I'm relatively new to OpenGL but I have a little experience in C and I was wondering how I would set the pixel coordinates of an OpenGL windows. Its a little hard to explain what I mean but for example if I would like to instead of having (x,y) coordinate (0,0) bang in the center of the windows, have it place to the top left of the screen and instead of having x ranging from say -13.0f to 13.0f (as in the horizontal coordinates of the screen, noting that x=0 would be the center in this case), have it ranging from -100.0f to 100.0f.

If you understand what I mean, please help me out with a function or some links to helpful material. If you don't understand what I mean I can draw a diagram or something to try and explain it better.

Cheers,
Jonathon.

how about you take a stab at it, and when it doesnt work you post what you did here, then we can look and see where the error(s) might be.

How about..
I am not a new member here and I am well aware of the rules and expectations when posting.
When someone posts asking for help, useless replies like the one you have just given are obviously not helpful.

I have already had a good search on around and could not find anything useful, the fact that I am asking for reference to a function that is the solution to my problem means that I cannot just go and have a stab at it. I have no errors because I do not know how to approach this. Hence, why I have posted a question asking for help from someone with more expertise in this area than myself.. Correct me if I am wrong but.. isn't this the point of this forum?

If you don't have anything useful to say then please don't say it..

Any more ideas from anyone?

Cheers.

>Any more ideas from anyone?
With that attitude, probably not. Oh wait, that wasn't useful, was it? I guess I shouldn't have replied. :icon_rolleyes:

What attitude? I'm simply stating that I cannot in this case just "have a stab" at it which is why I posted the question I did.. and a somewhat useless reply is not helpful. I am well aware of the rules around here etc. I apologise if you are offended by the way I wrote my response.

well, sorry if i offended you with my post.

all i meant was that perhaps you can post some code to help us get started with.

its just hard to guess what exactly you want to do and how you're trying to go about it. i dont really feel like creating a GL app from scratch.

Its not a problem. My point is that I cannot start off by just writing code because there is a specific function that I need to do it. I am just asking if there exists a function that would set the coordinates of the screen.

As an example say I wanted to place a line along the centre of the screen from the left side to the right.

glPushMatrix();
  glBegin( GL_LINES );
  glVertex3f( -10.0f , 0.0f , 0.0f );
  glVertex3f(  10.0f , 0.0f , 0.0f );
  glEnd();
glPopMatrix();

However my problem resides in the fact that I would like to use the following code do create the same line purely for convenience.

glPushMatrix();
  glBegin( GL_LINES );
  glVertex3f( 0.0f , 50.0f , 0.0f );
  glVertex3f( 100.0f , 50.0f , 0.0f );
  glEnd();
glPushMatrix();

I am looking for a function that can change the coordinate mapping of the screen from -10.0f --> 10.0f to 0.0f --> 100.0f; on the x axis.

I apologise about before, I think that maybe I was a little out of line.

no worries mate.

i'll look at this later tonight. (US Pacific). I'm not especially familiar with GL to rattle off an answer, and I dont have time to dig into it while at work.

Use one of the glTranslate functions, for example:

glPushMatrix();

[b]glTranslatef(-10.0f, 0.0f, 0.0f)[/b];

glBegin( GL_LINES );
  glVertex3f( 0.0f , 50.0f , 0.0f );
  glVertex3f( 10.0f , 0.0f , 0.0f );
glEnd();
  
glPopMatrix();

Doesn't the translate function simply move an object i.e. in your example so far in a specified direction? I don't think it's what I'm after, thanks anyway. I think it could be something along the lines of glViewPort or something similar, simply setting the coordinate space.

Cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.