Showing posts from April, 2016

[How to ] run OpenGL programs on mac without using Xcode

I recently moved from windows PC to Mac Book Air and as a Computer engineer I had to mess up with CGMT code(Although I hate it).
When I worked with windows PC, I just had to paste some .dll files in system32 and some header files in MinGw folder of code blocks.

But, for MAC, it even more easy.

Mac already comes with all required header files, all you need is an IDE and a good compiler like Xcode but downloading and running 4gb IDE for such a small purpose is not worth it.

The answer is Code:BLocks IDE


Download Code:Blocks from here


Unzip the file and paste the app in your applications folder.


Now open code blocks and New Project -> Glut Project and all done, Build and run all of your programs.

Note: Remember to replace with and remove which is not required on mac.

Thanks you, Hope it helped out.

Mid Point Circle drawing Algorithm In OpenGL C++

#include<GLUT/glut.h>#include<stdio.h>GLint xc,yc,r,sizes=1000;void myInit(void){glClearColor(0.0,1.0,1.0,0.0);glColor3f(1.0f,0.0f,0.0f);glPointSize(3.0);glMatrixMode(GL_PROJECTION);glLoadIdentity();//gluOrtho2D(0.0,640.0,0.0,480.0);glOrtho(-sizes/2,sizes/2,-sizes/2,sizes/2,-1,1);}void readInput(){printf("Enter xc, yc, radius(resp): ");scanf("%i%i%i",&xc,&yc,&r);}void setPixel(GLint xcoordinate,GLint ycoordinate){glBegin(GL_POINTS);glVertex2i(xcoordinate,ycoordinate);glEnd();glFlush();}void draw_axis(){GLint i=(-sizes)/2;for(;i<(sizes/2);i++){         setPixel(i,0);         setPixel(0,i);}}void draw_in_each_oct(GLint xk,GLint yk,GLint xc,GLint yc){     setPixel(xc+xk,yc+yk);     setPixel(xc+yk,yc+xk);     setPixel(xc-yk,yc+xk);     setPixel(xc-xk,yc+yk);     setPixel(xc-xk,yc-yk);     setPixel(xc-yk,yc-xk);     setPixel(xc+yk,yc-xk);     setPixel(xc+xk,yc-yk);}