Thursday, June 30, 2011

BItmap maping and texture map in OpenGL

This the sample code for texture map in teapot and bit map is used to draw chess board.Code is compiled in codeblocks you can copy and paste this code for your study or project.Please use your own image for texture map.Image must be in bmp formate.


#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
GLuint texture[2];
GLint slices=16;
GLint stacks=16;
struct Image {
    unsigned long sizeX;
    unsigned long sizeY;
    char *data;
};
typedef struct Image Image;

Thursday, June 23, 2011

Mini project tic-tac-toe game source code in C

Hi this is a tic-tac-toe game you can copy sourcecode here or Download from GitHub.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include <windows.h>

Tuesday, June 21, 2011

Mini project Quiz in C

Welcome to the Mini Project Quiz in C! This article is about creating a simple quiz game in the C programming language. The target readers of this article are students and absolute beginner C programmers. If you are an experienced C programmer then it is not for you.

You will learn to break down an application into modules (functions), switch between screens based on user input, multi-dimensional array techniques, loops and so much more.

Like in other sample mini-projects, I have not used a file handling system to store information to make it simple and easy to understand basic techniques.
After finishing this article, you will:

  • Truly understand how to break down the application and create a flow chart.
  • Be able to convert the flow chart processes into C functions.
  • Learn techniques to switch between processes based on user input. 
  • Have mastered the usages of multi-dimensional C arrays and loops.


You can download the final version of the application from GitHub Download from Github.

I have divided this article into 3 parts:
Part 1: Flow Chart and Main Menu: In this lesson, you will learn to create an application flow chart and create a welcome menu screen of the game.
Part 2: Multi-dimensional C array: In this lesson, you will understand techniques to create a function and switching between multiple functions as per user choice. You will master how to use one-dimensional, two-dimensional, and three-dimensional C arrays to store questions, question options, and answers. 
Part 3: Gameplay and the final score: You will learn to use a loop to display questions one by one, check the user's correct answer, and calculate the final score.

You can also watch a video about this project on YouTube.



mini project Department store source code


This mini project is about department store all features required for department store are added in this programe.You can copy the source code and compile it in a code block.This project is perfect for your college mini project in C. Download Project from Github


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<windows.h>

#define ANS 15
#define ACS 4
 COORD coord={0,0}; // this is global variable
                                    //center of axis is set to the top left cornor of the screen
void gotoxy(int x,int y)
{
    coord.X=x;
    coord.Y=y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
/*declaration of checking functions*/
void c_code(char[]);
int check(char[]);

/*structure declaration*/
typedef struct{
char name[ANS],code[ACS];
float rate;
int quantity;
}rec;
rec item;

/*declaration of display functions*/
void curser(int);
void dbill();
void d_mainmenu();
void display(rec *,int,int);
void window(int,int,int,int);
void dis_con();
void d_search();
void highlight(int,int);

/*declaration of main menu functions*/
void bill() ;
void edit();
void add();
void del();
void exit();

/*declaration of display submenu functions*/
void d_code();
void d_rate();
void d_quan();
void d_all();

/*start of main*/
int main()
{
d_mainmenu();
return 0;
}

Sunday, June 19, 2011

Mini project snake game in c

Mini project in C many Student do management project like library management ,Hotel management etc.But Snake Game is mini project of first semester build by my friend which is very different.It is console application without graphic library that's why it is more interesting.This game is perfect without any error and better user interface.It is complied in code::block using c language.Here goes a source code you can copy and compiled it in code::block.I hope it can help and become a reference for your project. Download Project from Github.

Friday, June 17, 2011

Mini project "3D Bounce " in OpenGL

This project is my second-year mini-project. I have use the GLUT(OpenGL) library in c++.3D Bounce is a game in which we have to bounce the ball to collect the floating star,after collecting all star then a door opens for the next room. Due to lack of time, I can't complete this project but all image drawing part is completed and I hope you will complete it for your collage project.You can download it source code from this link http://www.4shared.com/file/J-cjGaN-/bounce.html .This program is written in complete object oriented environment ,I have made different class in different file and It's code is very lengthy so  I can't give source code here.

Wednesday, June 15, 2011

Drawing a snowman using OpenGL source code


This source code is written in c using the OpenGL library. This program is just a demo to draw a different shape object and I draw a man like an object in this program. I have also added a keyboard event in this program.

#include <math.h>
#include <GL/glut.h>
#include <stdio.h>
#include <string.h>
//#include <cstdlib>
//if you got error in exit() by compiler then does not incluede stdlib.h because //exit() is also defined in glut.h file.

float angle=0.0,deltaAngle = 0.0,ratio;
float x=0.0f,y=1.75f,z=5.0f;
float lx=0.0f,ly=0.0f,lz=-1.0f;
int deltaMove = 0,h,w;
int font=(int)GLUT_BITMAP_8_BY_13;
static GLint snowman_display_list;
int bitmapHeight=13;

int frame,time,timebase=0;
char s[30];

void initWindow();

void changeSize(int w1, int h1)
{

// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h1 == 0)
h1 = 1;

w = w1;
h = h1;
ratio = 1.0f * w / h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Set the viewport to be the entire window
    glViewport(0, 0, w, h);

// Set the clipping volume
gluPerspective(45,ratio,0.1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(x, y, z,
     x + lx,y + ly,z + lz,
 0.0f,1.0f,0.0f);


}


Sunday, June 12, 2011

Mouse event handling source code in OpenGL



This source code is written in C++ with OpenGL.It is just a demo for mouse event handling you can use this code for your project. In this example void motionPassive(int x, int y) to find out the cursor position in the window. By finding the difference between the previous and initial position the direction of the camera is changed.

Texture map in solid sphere using GLUT(OpenGL)


This source code is written in C used to draw a solid sphere using OpenGL and you can map texture in it. Create a project for OpenGL and copy and paste this code and use your desire image file for texture mapping.

//main.c

#include <GL/gl.h>
#include <GL/glut.h>
#include <windows.h>
#include <stdio.h>
#include <math.h>
GLuint texture;
double angle = 0;
typedef struct
{
    int X;
    int Y;
    int Z;
    double U;
    double V;
}VERTICES;

const double PI = 3.1415926535897;
const int space = 10;
const int VertexCount = (90 / space) * (360 / space) * 4;
VERTICES VERTEX[VertexCount];
GLuint LoadTextureRAW( const char * filename );