Hello!
I,ve problem with large coordinates! I’m writting simple 2D Cad in Borland C++ Builder, and I have something like this:
double startx,starty;
void __fastcall TForm2::FormCreate(TObject *Sender)
{
HDC dc = GetDC(Handle);
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL/* | PFD_DOUBLEBUFFER*/,
PFD_TYPE_RGBA,
24,
0,0,0,0,0,0,
0,0,
0,0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,
};
PixelFormat = ChoosePixelFormat(dc, &pfd);
SetPixelFormat(dc, PixelFormat, &pfd);
HGLRC ogl = wglCreateContext(dc);
wglMakeCurrent(dc, ogl);
glMatrixMode(GL_PROJECTION);
startx = 5000000.0;starty = 5000000.0;
//startx = 0000000.0;starty = 0000000.0;
gluOrtho2D( startx, startx + 1.0, starty, starty + 1.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, ClientWidth, ClientHeight);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
//------------------------------------------------
void __fastcall DrawScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0.8f, 0.8f, 0.8f);
for( double l = 0.0; l < 1.0; l = l+.02 )
{
glBegin(GL_LINES);
glVertex2d(startx,starty + l);
glVertex2d(startx + 1.0,starty + l);
glEnd();
glBegin(GL_LINES);
glVertex2d(startx + l,starty);
glVertex2d(startx + l,starty + 1.0);
glEnd();
}
glFlush();
}
When startx = 5000000.0;starty = 5000000.0; DrawScene display
only 1 vertical and 1 horis. line.
When startx = 0.0;starty = 0.0; DrawScene display > 1 vert. lines and 1 > horis. lines and this is what I want.
What is wrong, when I set startx and starty to (5000000,5000000) ?
Thanks for reply, and sorry for my english