• Advertisement

Archived

This topic is now archived and is closed to further replies.

tiles getting clipped..

This topic is 5271 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Using a basic opengl in a window app, I have the following so far: First I do a: *hRC = wglCreateContext( *hDC ); then for the renderer:
            glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glOrtho(-1000, 1000, -1000, 1000, -0, 1000);

            glLoadIdentity();

            glRotatef(-45, 1.0f, 1.0f, 0.0f);
            for (e=-0.8; e<=0.8; e = e + 0.2)  // add scalefactor to make equidistant pieces, eg tiles

              for (f=-0.8; f<=0.8; f = f + 0.2) {
                DrawObjectEx(&triangle, e,f,g, objrot);
            }
            g=g+0.001;
            SwapBuffers (hDC);
//            objrot.theta += 1.0f;

            Sleep (1);
        }

and this is the DrawObject...
   int DrawObjectEx(OBJECT *obj, float x, float y, float z, OBJrot r) { //so far, x,y,z, and rotation

    glPushMatrix();
    glRotatef (r.theta, r.x, r.y, r.z);
    glTranslatef(x,y,z);
    glBegin (obj->objStyle);
      glColor3f (obj->cv[0].c1, obj->cv[0].c2, obj->cv[0].c3);  glVertex3f(obj->cv[0].v1, obj->cv[0].v2, obj->cv[0].v3);
      glColor3f (obj->cv[1].c1, obj->cv[1].c2, obj->cv[1].c3);  glVertex3f(obj->cv[1].v1, obj->cv[1].v2, obj->cv[1].v3);
      glColor3f (obj->cv[2].c1, obj->cv[2].c2, obj->cv[2].c3);  glVertex3f(obj->cv[2].v1, obj->cv[2].v2, obj->cv[2].v3);
    glEnd ();
    glPopMatrix();
}
After a certain point, the tiles get clipped by some invisible boundary.. what am I doing wrong.. I fseek, therefore I fam. [edited by - drarem on August 17, 2003 4:34:28 PM]

Share this post


Link to post
Share on other sites
Advertisement
Don''t think I set one up, it''s the basic opengl window template that comes with dev-cpp. I thought that was what glOrtho() was for, I''ve tried gluLookAt with no change whatsoever (before the LoadIdentity()), haven''t set a GL_MATRIXMODE either..





I fseek, therefore I fam.

Share this post


Link to post
Share on other sites
Try changing your last value in glOrtho to 2000. Also, why is your znear -0?

Share this post


Link to post
Share on other sites
made it look a little nicer but still doing something weird. the -0 is a typo, it's at 0. I tried all values at 2000/-2000 as well.

Below is the source, all it does is set up the opengl to render to a window on the desktop.. maybe I should try to go fullscreen.


void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int iFormat;

/* get the device context (DC) */
*hDC = GetDC (hWnd);

/* set the pixel format for the DC */
ZeroMemory (&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat (*hDC, &pfd);
SetPixelFormat (*hDC, iFormat, &pfd);

/* create and enable the render context (RC) */
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );
}


I fseek, therefore I fam.

[edited by - drarem on August 17, 2003 5:26:34 PM]

Share this post


Link to post
Share on other sites
still don''t work. It''s like a triangular wipe, as the tiles move up and off into the distance..I tried using glTranslatef() to move it back into the distance a little, no luck.

Doing a DrawObject(&obj, e,f+g,0, objrot); it ''clips'' on the upper left side of the screen, diagonally. I am moving it vertically obviously.


glViewport(0,0,800,600);
glOrtho(-2000, 2000, 2000, -2000, 0, -20000);
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(-45, 1.0f, 1.0f, 0.0f);
for (e=-1; e<0.8; e = e + 0.2) // add scalefactor to make equidistant pieces, like tiles

for (f=-1; f<0.8; f = f + 0.2) {

DrawObjectEx(&triangle, e,f,g, objrot);
}
g=g+0.005;
SwapBuffers (hDC);


I fseek, therefore I fam.

Share this post


Link to post
Share on other sites

  • Advertisement