Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Screen isn't refreshing?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    5

    Screen isn't refreshing?

    Hello. I try to make a rotatable triangle. But i have a problem
    Code :
    #include <GL/glut.h>
    #include <stdlib.h>
    GLfloat rquad=0.0;
     
    GLfloat aci;
    void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
    void gluPerspective(GLdouble fov, GLdouble aspect, GLdouble near, GLdouble far);
    void ayarlar(void)
    {
    glClearColor(0.0,0.0,0.0,0.0);
    glShadeModel(GL_SMOOTH);
    gluPerspective(0.0,0.0, 1.5, 20.0);
    }
    void gosterim(void)
    {
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glMatrixMode (GL_MODELVIEW);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 0.0, 0.0);
    glRotatef(aci,45.0f,45.0f,0.0f);
    glBegin(GL_TRIANGLES);
    glColor3f(1.0, 0.0, 0.0);
    glVertex3f(0.75f,0.5f,0.0f);
    glVertex3f(0.25f,0.5f,0.0f);
    glVertex3f(0.5f,1.0f,0.2f);
     
    glColor3f(0.0, 1.0, 0.0);
    glVertex3f(0.75f,0.5f,-0.2f);
    glVertex3f(0.25f,0.5f,-0.2f);
    glVertex3f(0.5f,1.0f,-0.2f);
    glEnd();
    aci+=0.5f;
    glFlush();
    }
    int main(int argc,char ** argv)
    {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
    glutInitWindowPosition(0,0);
    glutInitWindowSize(200,200);
    glutCreateWindow("OpenGL");
    ayarlar();
    glutDisplayFunc(gosterim);
    glutMainLoop();
    return 0;
    }

    But triangles isn't rotating. If i maximize the windows, the screen refreshing by 1 frame. Hope understand. Sorry for bad English..

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    204
    did you try by adding glLoadIdentity (); after glMatrixMode (GL_MODELVIEW).?

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    5
    Yes i tried. But same problem :/

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    I believe you need a glutIdleFunc which gets called whenever GLUT has nothing to do, in this you want to trigger a redisplay to redraw the scene, that will call your display function.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    5
    Thanks for reply. But I don't know how to use it. Can you change my code?

  6. #6
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    325
    Quote Originally Posted by ByDreaM View Post
    But I don't know how to use it. Can you change my code?
    You find the documentation here: http://www.opengl.org/resources/libr...c3/node63.html . If I would start fixing your code, I would also switch from the out-dated immediate mode to modern GL and I don't have the time for that ;-)

  7. #7
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    5
    I made it. Thank you
    Last edited by ByDreaM; 09-09-2013 at 07:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •