Monday, April 13, 2015

Mini Solar System Computer Graphics Programs



Presenting your C/C++ Mini Solar System Computer Graphics Programs which is executed in Visual Studio. This C++ mini project demo graphically the mini solar system.

What is mini Solar System?

As we all know there are 8 planets (Pluto being exclude to be a planet) in Solar system comprising Sun as it's center point. All planet revolve around Sun in solar system. There are planets in this start system, who owns satellite.

Update Coming Soon......................
Read more...

Friday, April 10, 2015

Flag Hosting Graphics Programs in C/C++

There are many Graphics Program available for C/C++. In our website we have posted so many Graphics Programs in C/C++ which used the OpenGL graphics library. While there few program available for turbo C which used the graphics.h library, but they are outdated. The new time is to adopt opengl, one point to support this is that OpenGL is opensource. The API provided by CGI has so many that we can render to make some good game or other animated programs. You can became a game developer by mastering the graphics programs.Visit OpenGL.org for more. Don't forget to visit the forum.

This blog is dedicated to OpenGL programming and we are focusing on that only, but sometime off topics are good to have. Before getting stated with opengl, we aspect that you all have some knowledge of C/C++. All the programs posted here are written in C/C++ or otherwise mentioned.

Today we are going to see the Flag Hosting Program in C/C++. This program is submitted by +Srikanth Kini.

Flag Hosting Graphics Programs in C C++


Aim of the Project : The projects objective to show graphically hosting of a Flag.

Description of the Project : In this project we have 3 people, a flag pole and sun. All these objects are drawn using the basic primitive functions provided in OpenGL. At the beginning flag is down, which is hosted by a person (first among the three) who walk toward the pole. There is little complication in here as the person don't seems to walk rather moving toward pole. Since this is 2D project it not look realistic.

The person approaches the falgpost and host the flag, which is shown with a good animation. Flag go up and waves out. This is unlike the previous waving flag graphics program in C/C++. There is "Vande Matrama" written in right side as  flag waves. The salutes can also made with animation, which look awesome.

User Interaction : This program has no much user interaction but few. In the beginning as program start there is no motion, so there is s/S key which initiate the  program animation. As s/S is pressed the person in front start moving to host the flag. To exit, just press esc key.

Future enhancements :

  • Convert the Whole Program into 3D version.
  • There are only three people there, more can be added with a proper stadium.
  •  Make the motion more realistic.
  • Flagpost and other can be improve with better quality of graphics design.
  • Sound can be added with National anthem getting sung as flag get hosted.
  • Flowers should fall as flag get hosted.
Download the free source code for this Graphics Programs. Put your comment and let us know your views.










Read more...

Wednesday, April 8, 2015

Wind Mill C++ Projects Download

OpenGL c++ projects with source code
Are you looking for C++ Projects with source code?

Your search for C/C++ projects ends here! This post will give your the C/C++ mini projects which used the core library of OpenGL graphics. You can have this C/C++ Projects Download free from the download link given  at the end of the post.

Everybody know the importance of C/C++ in the computer science filed. Almost every engineer study the language, but only few master it.  For Computer science students learning the C/C++ language is much important, this shape their Carrier. They must master it and able to write programs which includes C/C++  features like functions, arrays and pointers, file handling and data structure, etc.

After mastering the basics of C/C++, you must be able to implement it in some kind of C/C++ projects or mini projects. But, the C/C++ projects or mini projects that features the above mentioned concepts is a difficult task. To solve these difficulty we provides C++ Projects Download. These projects can be use for college work or for final year projects or even as a reference for you research or learning process.

OpenGL is a open source graphics library which allow us to render real world objects in to computer graphics with C/C++ (can be use with other languages as well). Here our project will focus more on graphics than normal C/C++ programs. In this post we are going to talk about the Wind Mill C++ Projects with free source code download.

Wind Mill C++ Projects Download

Objective of Wind Mill C++ Projects


Every Project aim toward something, they have come core idea which need to be implemented. This Wind Mill C++ Projects is aimed to show generation of electricity via wind (renewable energy source). Basically it used the concept of wind energy in computer graphics with C++.

As you can see in the image, there is wind farm with a power house and few wind turbines. Cloud Can be seen in the sky as well. As the wind flow the speed of cloud increase (this used to show wind is flowing, air is invisible to us). Wind can flow in either direction, so the turbines blade will also move in the same direction as of the wind.

User Interaction Wind Mill C++ Projects

This C++ Projects used the mouse interaction to communicate between the computer and the user.  Right click the mouse button to see the options. Detail is shown in the table below.


MenuUses
No WindThere is no wind Flowing
Wind CWWindow Flowing in the Clockwise direction
Wind ACWWindow Flowing in the Anti-Clockwise direction
Fast Wind CWWindow Flowing Faster in the Clockwise direction
Fast Wind ACWWindow Flowing in the Anti-Clockwise direction
QuitLeave the Program

Now turn to have source code - C++ Projects Download free source code
Read more...

Monday, April 6, 2015

OpenGL Geometric Primitives and Menus

In OpenGL programming we have so many function, methods included in the open source libraries. Most basic thing we need to learn in OpenGL are the Geometric Primitives. In the OpenGL points, lines, polygons, images, and bitmaps are considered to be primitives.

Another major use in OpenGL are the colors, they are used in so many ways and are also very important in OpenGL Programming. We render the object with color using glcolor2f or glcolor3f  etc as required in the program.

Use of the Points in the OpenGL Porgram is very important and it's base for all heavy programming. After the points we have Lines, this OpenGL Geometric Primitive use to draw many 2d and 3d shapes like triangle, rectangles, squares and other polygons with the use of proper vertices coordinates.  We have many Polygon functions also defined in OpenGL graphics API. Only the circle which we need to draw. In today's Program we talk about of  these OpenGL Geometric Primitive.

Learn How to Draw a Circle in OpenGL Programming.

The following program will demonstrate the use of OpenGL Geometric Primitives and Menus. This program is submitted by +venkatesh bandaru. It good to see he share his knowledge with us.  I hope you like the program which will do the following -
  • Allow user to choose different sets of color
  • Let Choose the Primitive like pixels, lines, circle and eclipse.
  • With the combined selection of Color and Primitive objects, it get drawn on the screen.
  • The program used the Concept of Menu and Sub menu for selection, which is done with right click of mouse.
Following the source code -

#include <iostream>

#include <glut.h>
#include <math.h>

struct Point {
GLint x;
GLint y;
};

struct GLColor {
GLfloat red;
GLfloat green;
GLfloat blue;
};

GLColor colors[6] = {
{ 0.0f, 0.0f, 0.0f }, // Black
{ 1.0f, 0.0f, 0.0f }, // Red
{ 0.0f, 1.0f, 0.0f }, // Green
{ 0.0f, 0.0f, 1.0f }, // Blue
{ 1.0f, 1.0f, 0.0f }, // Yellow
{ 1.0f, 0.0f, 1.0f } // Purple
};

GLColor color = colors[0]; // Default: Black

void init() {
glClearColor(1.0f, 1.0f, 1.0f, 0);
glColor3f(color.red, color.green, color.blue);
glPointSize(1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
}

void display(void) {

}

void draw_pixel(Point p) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(color.red, color.green, color.blue);
glBegin(GL_POINTS);
glVertex2i(p.x, p.y);
glEnd();
glFlush();
}

void draw_dda(Point p1, Point p2) {
GLfloat dx = p2.x - p1.x;
GLfloat dy = p2.y - p1.y;

GLfloat x1 = p1.x;
GLfloat y1 = p1.y;

GLfloat step = 0;

if (abs(dx) > abs(dy)) {
step = abs(dx);
}
else {
step = abs(dy);
}

GLfloat xInc = dx / step;
GLfloat yInc = dy / step;

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(color.red, color.green, color.blue);
glBegin(GL_POINTS);

for (float i = 1; i <= step; i++) {
glVertex2i(x1, y1);
x1 += xInc;
y1 += yInc;
}
glEnd();
glFlush();

}

void draw_circle(Point pC, GLfloat radius) {
GLfloat step = 1 / radius;
GLfloat x, y;

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(color.red, color.green, color.blue);
glBegin(GL_POINTS);

for (GLfloat theta = 0; theta <= 360; theta += step) {
x = pC.x + (radius * cos(theta));
y = pC.y + (radius * sin(theta));
glVertex2i(x, y);
}
glEnd();
glFlush();
}

void draw_ellipse(Point pC, GLfloat radiusY, GLfloat radiusX) {
GLfloat step = 1 / radiusX;
GLfloat x, y;

glClear(GL_COLOR_BUFFER_BIT);
glColor3f(color.red, color.green, color.blue);
glBegin(GL_POINTS);
for (GLfloat theta = 0; theta <= 360; theta += step) {
x = pC.x + (radiusX * cos(theta));
y = pC.y + (radiusY * sin(theta));
glVertex2i(x, y);
}
glEnd();
glFlush();
}

void mainMenuHandler(int choice) {
Point p = { 320, 240 }; // draw_pixel
Point p1 = { 10, 100 }; // draw_line
Point p2 = { 200, 100 }; // --

Point pC = { 320, 240 }; // Circle center point
GLfloat radius = 200; // Circle radius

switch (choice) {
case 1: // Pixel
draw_pixel(p);
break;

case 2: // Line
draw_dda(p1, p2);
break;

case 3: // Circle
draw_circle(pC, radius);
break;

case 4: // Ellipse
draw_ellipse(pC, 60.0f, 200.0f);
break;

case 5: // Exit
exit(0);
break;
}
}

void subMenuHandler(int choice) {
color = colors[choice];
}

int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(200, 200);
glutInitWindowSize(640, 480);
glutCreateWindow("OpenGL Circle and Menus");
glutDisplayFunc(display);
init();

int subMenu = glutCreateMenu(subMenuHandler);
glutAddMenuEntry("Default", 0);
glutAddMenuEntry("Red", 1);
glutAddMenuEntry("Green", 2);
glutAddMenuEntry("Blue", 3);
glutAddMenuEntry("Yellow", 4);
glutAddMenuEntry("Purple", 5);

glutCreateMenu(mainMenuHandler);
glutAddSubMenu("Change Color", subMenu);
glutAddMenuEntry("Pixel", 1);
glutAddMenuEntry("Line", 2);
glutAddMenuEntry("Circle", 3);
glutAddMenuEntry("Ellipse", 4);
glutAddMenuEntry("Exit", 5);

glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMainLoop();

return 0;
}

I hope you liked this simple OpenGL Programming Concept. Do share your view with comments.
Read more...

Wednesday, April 1, 2015

Singly Linked List Computer Graphics Program

C is a general-purpose, imperative computer programming language. C Programming is vast with so many concept behind it (operators, loops, functions, single and double dimensional arrays, performing operations on strings, files, pointers etc.). One of the key concept which we learn is about Linked List.

Linked list in c the concept which not many of us grab properly. It is very important programming concept in C. There are many Operation in the Linked list, before going to learn about them, I want to tell you we are not giving concept of Linked list in c, but Computer Graphics Program.  Yes we are using the C langiuage as the primary language to write the programm but here we deal with graphics programming and not c programming. You must know about the Linked List in C which is pre-assumed here.  The programm uses the OpenGL API to render graphics. Hence it is basically a C or C++ Computer Graphics Program using OpenGL.

Various operations on Singly Linked list in C

Singly Linked list is a linear data structre with many operations can be done on the nodes unlike the array in C. Various operations that can be done are listed below -
  1. Creation
  2. Insert at starting
  3. Insert at position(user's choice)
  4. Insert at end
  5. Delete 1st node
  6. Delete last node
  7. Delete at position(user's choice)
  8. Display 
 
The source code of the C program to illustrate the operations of singly linked list. Try to learn it firt in C then go for graphics program.


This Computer Graphics Program is operated via two windows as seen in the image. With one we insert the data while graphics is shown in other window. There is some problem in the programm so we need to keep patience in input the data to program. Everything is working perfect if done calmly, while in some PC with less graphics, it may stop working.

Read more...