Posts

Showing posts with the label OpenGl

GL_PATTERNS

CHECKS: GLubyte checks[] = { 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0xC3, 0xC3, 0xC3, 0xC3,/* 11….11 11….11 11….11 11….11*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0x3C, 0x3C, 0x3C, 0x3C,/* ..1111.. ..1111.. ..1111.. ..1111..*/ 0xC3, 0...

Objects using Line-Attribute, Fill-Area Attribute, Color functions of OpenGL

1. Load the libraries #include<GL/glut.h> #include<windows.h> 2. Create a display function where you will be drawing your shape and objects void display() { } 3. Give Screen color using ClearColor     glClearColor(0.0,0.1,0.0,0.0);     glClear(GL_COLOR_BUFFER_BIT); 4. Use factor and pattern to give some styles to your line. for more pattern click:  GL_Pattern     GLint factor=1;     GLushort pattern=0x0c0f; 5. Enable the Stipple     glEnable(GL_LINE_STIPPLE); // enabling the line pattern function     glLineStipple(factor,pattern); 6.Draw the shape     glColor3f(1.0,0.0,0.0);     glBegin(GL_LINES);     glVertex2f(0.0,0.0);     glVertex2f(1.0,0.0);     glEnd(); 7.disable the stipple then flush it.     glDisable(GL_LINE_STIPPLE);     glFlush(); 8. Main Function int main(int argc,char** argv) 9.  Ii...

Draw Circle in OpenGL

glColor3f(0.92,0.93,0.38); // (R,G,B) glBegin(GL_TRIANGLE_FAN); for(int ii = 0; ii < 300; ii++) { float cx = 35; //X coordinate float cy = 250; //y coordinate float r = 30.0; //radius float theta = 2.0f * 3.1415926f * float(ii) / float(300);//get the current angle float x = (r-45) * cosf(theta);//calculate the x component float y = r * sinf(theta);//calculate the y component glVertex2f(x + cx, y + cy);//output vertex } glEnd();