Saturday, April 28, 2012

GLFW Tutorial 4: Texture mapping sample code in OpenGL Framework

If you are new to the GLFW(OpenGL framework) you can follow beginning tutorial here.
On Contrary with GLUT texture mapping is very easy in GLFW . We want to use pre-generated 2D images for surface textures, light maps, transparency maps etc.These images are stored with a standard image format in a file, which requires the program to decode and load the      image(s) from file(s), which can require much work from the programmer.To make programming easier for OpenGL developers, GLFW has built-in support for loading images from files.
In this tutorial I give example for surface textures only. Surface textures are important because it helps to make object realistic.
To load a texture from a file, you can use the function glfwLoadTexture2D:
int glfwLoadTexture2D( const char *name, int flags )
This function reads a 2D image from a Truevision Targa format file (.TGA) with the name given by name, and uploads it to texture memory. It is similar to the OpenGL function glTexImage2D, except that the image data is read from a file instead of from main memory, and all the pixel format and data storage flags are handled automatically. The flags argument can be used to control how the texture is loaded. If flags is GLFW_ORIGIN_UL_BIT, the origin of the texture will be the upper left corner (otherwise it is the lower left corner). If flags is GLFW_BUILD_MIPMAPS_BIT, all mipmap levels will be generated and uploaded to texture memory (otherwise only one mipmap level is loaded). If flags is GLFW_ALPHA_MAP_BIT, then any gray scale images will be loaded as alpha maps rather than luminance maps. To make combinations of the flags, or them together (e.g. like this: GLFW_ORIGIN_UL_BIT |GLFW_BUILD_MIPMAPS_BIT).
Here is the sample program to illustrate the texture mapping with complete source code written in c++ with gcc compile and code::blocks IDE. You can also download the project file.

Tuesday, April 17, 2012

GLFW(OpenGL FrameWork) tutorial 3:Transformation:Translation,Scaling and Rotation.

If you are beginner to OpenGL FrameWork (GLFW) visit my previous tutorial lesson Here so that you can understand in details.Translation ,Scaling and Rotation of object is so easy because OpenGL provide these command to us we don’t have to write our own  Transformation matrix.

Translation command:

Translation is movement along any of the three axis in a 3D scene, for example, moving something the left is a translation on the X axis if you are looking straight on.
Command:
glTranslatef( xValue, yValue, zValue );
e.g:
glTranslate(5.0, 0.0, 0.0);
This translate the scene five unit along positive x-axis. One things you must remember ,all the scene drawn below this command will be translated.
So,if you want to translate only one object then you have to restore the transformation. Restore can be done by putting drawing scene and translation command between glPushMatrix() and glPopMatrix() .

Monday, April 16, 2012

GLFW (OpenGL Framework) tutorial 2: Drawing Basic Shapes

Lets first discuss how OpenGL does. Describing co-ordinates system of OpenGL, center of co-ordinate is middle of widow, positive x-axis is pointed towards right and negative x-axis toward left ,positive y-axis is pointed towards up and negative y-axis towards bottom , positive z-axis is pointed towards outside of screen and negative z-axis towards inside the screen.
  • coord_system
OpenGL draw object similar to our eye . By default eye is in origin and we are looking toward negative z-axis.

GLFW tutorial 1:Introduction to OpenGL Framework

Welcome to codeincodeblock.blogspot.com I have created this tutorial for 3D programming in OpenGL for beginners. OpenGL has wide range of use some of them is Gamming ,simulation, virtual prototyping. This tutorial provide only basic knowledge of OpenGL in brief with full source code and complete explanation so, that you can move quickly to advanced OpenGL programming. All tutorials is written in c++ so that you must know the basic c++ to understand this tutorial.
We use OpenGL for 3d programming. You may wondering what is OpenGL. OpenGL is software interface for graphics hardware in other word we can say it is language translator so that we can use only one language for different graphics hardware. OpenGL is hardware independent. We can draw both 3D and 2D stuff. For 2D their are better libraries like SDL ,Allegro. We use OpenGL basically for 3D stuff.
I use GLFW library and code::blocks IDE. You may confused reading OpenGL and using GLFW library, what does GLFW means? The creation of a window to render stuff in is not covered in the OpenGL specification. This is handled by platform-specific APIs. GLFW is one of this  APIs. It is a crossplatform windowing and keyboard/mouse/joystick handler. Contrary to GLUT, this is more aimed for creating games. Supports Windows, Mac OS X and Unix-like systems such as Linux and FreeBSD.
You don’t have code::blocks IDE then download it form Here .There are two options of download so, choose codeblocks-10.05mingw-setup.exe file in which MinGW compiler is already install. Then you need to setup the GLFW library in code::blocks. Follow my previous article Setup GLFW Project for setup.
Now you are ready for OpenGL 3d programming..
Goto tutorial 2 Drawing Basic Shape

Saturday, April 14, 2012

List of Top Ten College Mini Projects in c/c++ with full source code

If you are looking to learn techniques to develop mini-projects in C/C++ programming language through examples, then you are on the right page. On this page, I have listed the Top 10 Mini Projects written in C and C++ programming. You can choose any one of them based on your needs. The source code for all projects is also available; you can download them from GitHub, and the download link is provided inside each project page.

You will also find project videos on YouTube where I have explained the project algorithm, problem solving techniques, and source code in details. Video links are available inside project page. Please do not forget to subscribe my channel to get new videos update.

All the projects are compiled using the GCC compiler with the Code::Blocks IDE on a Windows machine. Most of the projects do not work on machines other than Windows.

All the projects are created for educational purposes. You can freely use a project or reuse parts of the source code for your college or personal projects. However, you are not allowed to distribute them for commercial purposes. If you have any queries or suggestions, you can email me at smokindinesh@gmail.com.

Projects in c
  1. Quiz Game : 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. Videos are also available to understand project source code in detail.
  2. Contacts Management: You will learn CRUD (Create, Read, Update, and Delete) operation in C files, and various modes of opening files. Also, you can watch video to understand source code in detail.
  3. Personal Dairy Management System: This project is very similar to Contacts Mangement. Sorce code of Contacts Management is reused. You will learn to write reusable source code and implement in another project. Project video is also available inside project page.
  4. Library management: It is larger and more complex than my other projects, such as the Quiz game, Contact Management, and Personal Diary Management. In this project, I have implemented a variety of techniques and features, including Admin and Student modes, user security, reading and writing CSV files, and many others. This project will provide you with numerous insights. If you’re aiming for the highest grade in your project/lab assignment, I recommend following this project. Project video is also available to understand source code in detail.
  5. Snake Game: This game is created without graphics library. Game window, snake, and food is created by printing * and 0 characters. It is very good project to learn game development techniques and algorithms. You can also watch video to understand project in detail. 
  6. Tic-tac-toe game: This is another game project created without graphics library. Although, looks simply, it is technically more complex than snake game. Computer player is also implemented which will play game with user. In this project you will understand techniques of implementing multiplayer, and algorithms of implementing computer player. Project videos are also available.
  7. Tetris Game: This is perfect game to understand real world game development techniques. Although it is created without using graphics, I have implemented linear algebra to rotate and translate shapes which is widely used in 2D and 3D graphics game. I suggest you follow this project to understand real world game development techniques.
  8. Department store system
  9. Telecom Billing Management System
  10. Bank Management System
  11. Medical Store Management System