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
    Senior Member Regular Contributor
    Join Date
    Apr 2012
    Posts
    318
    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
    Senior 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
    Senior 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

Similar Threads

  1. ATI Cards stop refreshing screen at high framerate?
    By imported_JoshKlint in forum OpenGL: Linux
    Replies: 2
    Last Post: 04-09-2014, 05:07 PM
  2. refreshing the same data
    By rafal in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-22-2011, 08:24 AM
  3. refreshing windows
    By coda in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-27-2003, 05:19 AM
  4. urgent: refreshing screen
    By coda in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-20-2003, 05:57 AM
  5. refreshing screen?
    By coda in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-07-2003, 06:40 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
  •  
Proudly hosted by Digital Ocean