Opengl GL wrong portview position

I’m having some problems with the glViewport, because the point xy 0.0 window is wrong.
if I try to draw a line in the coordinates 1.1 and 32.32, the line does not appear in the window, it seems that the drawing area begins at the edge of the window.

I do not know if I was clear.
but I will post the picture of the problem here

im using this code, to create the viewport


glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f,640,480,0.0f,0.0f,1.0f);

and this code to draw the triangle


glBegin(GL_TRIANGLES);
glVertex2f(mouse_x,mouse_y);
glVertex2f(1.0f,1.0f);
glVertex2f(320.0f,470.0f);
glEnd();

and this is the result

see? the point glVertex2f(1.0f,1.0f); its much behind the window

I wanted to happen was this.

could understand?

The problem is probably with the windowing system framework that you use. Are you sure you don’t get your mouse positions relative to the whole window’s top left corner instead of the window’s client area’s top left corner in case of the OpenGL application?

At least I don’t see anything wrong with the code you’ve copy-pasted here (though I don’t see how you set up your modelview matrix).

[QUOTE=aqnuep;1237851]The problem is probably with the windowing system framework that you use. Are you sure you don’t get your mouse positions relative to the whole window’s top left corner instead of the window’s client area’s top left corner in case of the OpenGL application?

At least I don’t see anything wrong with the code you’ve copy-pasted here (though I don’t see how you set up your modelview matrix).[/QUOTE]

Almost definitely correct - I can see from your screenshot that your window client area is actually about 624x442 which suggests that you’ve created the window at this dimension rather than adjusting the size to account for title bar and borders, and that this has likely carried over into your mouse code too.

Thanks!
the problem was the windows size.