• Tidak ada hasil yang ditemukan

Session 4: Implement Circle algorithm in OpenGL

N/A
N/A
Protected

Academic year: 2023

Membagikan "Session 4: Implement Circle algorithm in OpenGL"

Copied!
2
0
0

Teks penuh

(1)

Department of Computer Science and Engineering CSE 422: Computer Graphics Lab

Session 4: Implement Circle algorithm in OpenGL Intended Learning Outcome:

a. Students will be able to implement circle algorithm.

b.

Students will be able to draw a circle with center visualization.

Expected Skills:

a. Calculating any point about radius and along axis point (X, Y).

b. Clear idea about drawing a line in first coordinate.

Tools Required:

a. CodeBlocks

b. OpenGL and GLUT using CodeBlocks.

Session Detail:

#include <windows.h>

#include <GL/glut.h>

#include <stdlib.h>

#include <math.h>

void init() {

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

glOrtho(-15,15,-15,15,-15,5);

}void circle(GLfloat rx,GLfloat ry,GLfloat cx,GLfloat cy)//radius_x,radius_y,certre_position_x,centre_position_y {

glBegin(GL_TRIANGLE_FAN);

glVertex2f(cx,cy);

for(int i=0;i<100;i++) {

float angle = 2.0f * 3.1416f * i/100;

float x = rx * cosf(angle);

float y = ry * sinf(angle);

glVertex2f((x+cx),(y+cy));

}

glEnd();

(2)

Department of Computer Science and Engineering CSE 422: Computer Graphics Lab

}

void myDisplay() {

glClear(GL_COLOR_BUFFER_BIT);

glColor3f(1.0f, 0.0f, 0.0f);

circle(3,3,0,0);

glFlush();

}

int main()

{ glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);

glutInitWindowSize(600, 600);

glutInitWindowPosition(200, 200);

glutCreateWindow("Circle Application");

init();

glutDisplayFunc(myDisplay);

glutMainLoop();

return 0;

}

Referensi

Dokumen terkait

Introduction Scope of This Chapter Salient Features of Enzyme Immobilization Advantages of Enzyme Immobilization Disadvantages of Enzyme Immobilization I\fethods of enzy'me

Leading University, Sylhet Department of Computer Science and Engineering Proposed Curriculum for Bachelor of Science in Computer Science &Engineering CSE for BTEB approved diploma