rotate a star in opengl (2D)

Posted by nova a on Stack Overflow See other posts from Stack Overflow or by nova a
Published on 2012-07-09T21:46:16Z Indexed on 2012/09/27 21:37 UTC
Read the original article Hit count: 90

Filed under:
|

I have a 2D star, and I don't know how to rotate it around its center, and I also don't know how to do it with a keyboard key. Also how can I make my object bigger or smaller by a certain percentage (because when I tried to do it by changing pixels, the star goes wrong).

This is my code:

#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/freeglut.h>

void init (void)
{
    glClearColor(0.0,0.0,0.0,00);
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(0.0,200.0,0.0,200.0);

}
void LineSegment(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,1.0,1.0);
    glBegin(GL_LINE_LOOP);
    glVertex2i(20,120);
    glVertex2i(180,120);
    glVertex2i(45,20);
    glVertex2i(100,190);
    glVertex2i(155,20);
    glEnd();
    glFlush();
}
int main(int argc,char** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowPosition(50,100);
    glutCreateWindow("STAR");
    init();
    glutDisplayFunc(LineSegment);
    glutMainLoop();
    return 0;
}

© Stack Overflow or respective owner

Related posts about opengl

Related posts about rotation