opengl-codes-2d-circle-drawing

opengl-codes-2d-circle-drawing -   1 / 3 OpenGL Codes: 2D...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
OpenGL Codes: 2D Circle (drawing) Written by Rosnita Friday, 06 May 2011 09:03 - Coding: follow the instruction below 1. Add a method for the circle drawing. Type the codes as below:   void drawCircle(float cx, float cy, float r, int num_segments) {   glBegin(GL_LINE_LOOP); for(int ii = 0; ii < num_segments; ii++) { float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle   float x = r * cosf(theta);//calculate the x component float y = r * sinf(theta);//calculate the y component
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview:   1 / 3 OpenGL Codes: 2D Circle (drawing) Written by Rosnita Friday, 06 May 2011 09:03 - glVertex2f(x + cx, y + cy);//output vertex   } glEnd(); glFlush();  }     2.  Call the above method in your display method: myDisplay() or display()  glColor3f(0.0,0.0,0.0); drawCircle(100,100,10,50);    3.  Add #include <math.h> library  2 / 3 OpenGL Codes: 2D Circle (drawing) Written by Rosnita Friday, 06 May 2011 09:03 -   3 / 3...
View Full Document

This note was uploaded on 08/17/2011 for the course CS 102 taught by Professor Halimah during the Summer '11 term at International Islamic University Malaysia.

Page1 / 3

opengl-codes-2d-circle-drawing -   1 / 3 OpenGL Codes: 2D...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online