0% found this document useful (0 votes)
5 views2 pages

Rosette

This document contains a C++ program that uses OpenGL to create a graphical application displaying a rosette pattern. It defines classes for points and includes functions to initialize the OpenGL context, draw lines, and render the rosette based on a specified number of points and radius. The main function sets up the window and starts the rendering loop.

Uploaded by

Mahnoor shoukat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Rosette

This document contains a C++ program that uses OpenGL to create a graphical application displaying a rosette pattern. It defines classes for points and includes functions to initialize the OpenGL context, draw lines, and render the rosette based on a specified number of points and radius. The main function sets up the window and starts the rendering loop.

Uploaded by

Mahnoor shoukat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// ConsoleApplication18.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"
#include<windows.h>
#include<glut.h>
#include<gl/GLU.h>
#include<math.h>
#include<iostream>

class GLintPoint
{
public:
GLint x,y;
};

class Point2
{
public:
float x,y;
void set (float dx , float dy){x=dx; y=dy;}
void set (Point2& p){x=p.x; y=p.y;}
Point2(float xx , float yy) {x=xx; y=yy;}
Point2() {x=y=0;}
};

Point2 currPos;
Point2 CP;

void moveTo(Point2 p)
{
CP.set(p);
}

void lineTo(Point2 p)
{
glBegin(GL_LINES);
glVertex2f(CP.x , CP.y);
glVertex2f(p.x , p.y);
glEnd();
glFlush();
CP.set(p);
}

void myInit(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0,0.0,0.0,0.0);
glColor3f(0.0,0.0,1.0);
}

void rosette(int N, float radius)


{
Point2*pointlist = new Point2[N];
GLfloat theta= (2.0f * 3.1415926536)/N;
for(int c=0; c<N; c++)
{
pointlist[c].set(radius*sin(theta*c) , radius*cos(theta*c));
}
for( int i=0; i<N; i++)
{
for( int j=0; j<N; j++)
{
moveTo(pointlist[i]);
lineTo(pointlist[j]);
}
}
}

void render()
{
glClear(GL_COLOR_BUFFER_BIT);
glViewport(40,40,640,480);
rosette(5,0.66f);
glFlush();
}

void main(int argc , char** argv)


{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glutInitWindowSize(640, 480);
glutCreateWindow("rosette");
glutInitWindowPosition(100, 150);
myInit();
glutDisplayFunc(render);
glutMainLoop();
}

You might also like