Results 1 to 2 of 2

Thread: Not showing result

  1. #1
    Junior Member Newbie
    Join Date
    May 2015
    Posts
    7

    Not showing result

    hi, i have this code....
    Code :
    #include<gl\glut.h>
    void init()
    {
        glClearColor(0.0,0.0,0.0,1.0);
        glViewport(0,0,500,500);
        gluOrtho2D(-5.0,495.0,-5.0,495.0);
        glMatrixMode(GL_MODELVIEW);
    }
    int hapa=0;
    void Display()
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glLoadIdentity();
        glTranslatef(20.0*hapa,0,0);
        glRectf(-5,-5,5,5);
        glFlush();
    }
    void update(int);
    int main(int a,char** b)
    {
        glutInit(&a,b);
        glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
        glutInitWindowSize(500,500);
        glutCreateWindow("Dritare");
        init();
        glutDisplayFunc(Display);
        glutMainLoop();
    }
    void update(int value)
    {
        hapa++;
        glutPostRedisplay();
        glutTimerFunc(1000,update,0);
    }
    and it just shows me a white window when i try to compile....
    ps. when i remove update function does not shows nothing too but if i replace translatef(...) with rotate function it works :/
    thank you in advance

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,100
    Your init() function needs to call glMatrixMode(GL_PROJECTION) before calling gluOrtho2D(). Otherwise, it will be part of the model-view matrix, and will be cleared by the glLoadIdentity() call.

Similar Threads

  1. Expected result?
    By 3rdgenta in forum OpenCL
    Replies: 1
    Last Post: 05-15-2017, 04:22 AM
  2. Texture not showing
    By shawn619 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-25-2012, 11:54 AM
  3. Best result when using a vertexcachesize of 8?
    By Toaster in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 08-26-2003, 12:13 AM
  4. vp program and "result"
    By V-man in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 06-25-2003, 12:13 PM
  5. is this a speedy result?
    By SebastianB in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-26-2003, 12:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean