Monday, November 21, 2011

Draw a 3D Chess Board using OpenGL utility toolkits (GLUT), a graphics project with source code

This program  may help you in graphics project of your college.I simply  tries to draw the 3D Chess Board.  For this our main goal is to draw white and black rectangular box alternately along both x and y-axis.Drawing rectangular box is simple ,it is drawn by providing all side co-ordinates with the help of glVertex3f function and only top face is assign with black or white color and other face with brown color with the help of glColor3f function. I have made two function void draw_BlackArea() and void draw_whiteArea() to draw black and white square box respectively .Inside two for loop I have call these function by creating displaylist and with the help of glTranslatef(GLfloat x,GLfloat y,GLfloat z) function I draw  alternatively by translating their position.

Tuesday, November 15, 2011

Draw Reflection of Object on the floor using OpenGL Utility Toolkit (GLUT)

Drawing reflection capture the extra realism of the Object in 3D programming.For example Bouncing ball having its reflection on the floor can make the bouncing scenario more beautiful and realistic. So,OpenGL has all the features needed to render fast high-quality reflections on planar surfaces.
        Reflection technique is not so hard its pretty simple.If you want to draw reflection on floor then suppose your floor is in x-z plane and your object along positive y-axis above the plane then for reflection of object draw the copy of object along the negative y-axis vertically below the plane or floor.Your floor must look like the reflecting surface to see the object which is below the floor for this we use alpha blending which make the floor transparent by certain percent say 40% then it is specified to be 40% the color of the floor and 60% the color of the reflection or object.But only alpha blending doesn’t make the reflection real because the reflected copy of the object may leak outside or bottom of the floor so to fixed this problem we actually going to use the stencil buffer concept.With OpenGL stenciling, we can "pre-draw" the floor into the stencil buffer without updating the color or depth buffers. Then when we go to draw the reflection,  just only allow the reflection to update pixels marked as belonging to the floor's stencil value. The floor can then be any complex (but coplanar) polygon and the reflection only shows up in the floor.

Drawing a Bitmapped Character or string in OpenGL sample example

A bitmap is a rectangular array of 0s and 1s that serves as a drawing mask for a corresponding rectangular portion of the window. Suppose you're drawing a bitmap and that the current raster color is red. Wherever there's a 1 in the bitmap, the corresponding pixel is replaced by a red pixel and If there's a 0 in the bitmap, the contents of thepixel are unaffected. The most common use of bitmaps is for drawing characters on the screen.
            In the simple example we use two main function glBitmap and glRasterPos2i function.
The glBitmap function draws a bitmap.

Saturday, November 12, 2011

Rotate an Object in OpenGL(GLUT) sample example with source

In GLUT we rotate the object by glRotate3f(angle_rotation,GLfloat x, GLfloat y ,GLfloat z) function angle_rotation parameter is value of angle to rotate and x,y,z co-ordinate are axis of rotation.But it does not rotate object continuously for that we have to change angle of rotation by small amount of increment. We do this by using timer thread with the help of glutTimerFunc function.Here is the sample source code copy and compile it.

Friday, November 11, 2011

How to change the color of object in OpenGL(GLUT) using keyboard function

If you have problem in changing color of object in OpenGL using keyboard while running program then this article may help you.Simply we can’t change the color of object while running for this we have to create a timer thread by using
Void  glutTimerFunc(unsigned int msecs,void (*func(int value),value)  function or other techinque can also be use.
Parameter:
msecs

Number of milliseconds to pass before calling the callback.

func

The timer callback function.

value

Integer value to pass to the timer callback.

Saturday, November 5, 2011

TCP Client and Server sample example with source code for Beginners in C#.

Welcome to this page who want to start writing  their own program communication through socket API using C# .Net framework.
The .NET framework provides two classes specifically for TCP: TcpClient and TcpListener.These classes provide a higher level abstraction of the Socket class, but as we will see there are instances when advanced functionality is available only through direct use of the Socket class.

In this article I have shared the simple client server program before but many visitor comment me about bad indentation of code.That's why I removed previous code completely and  started to write the series of article related TCP/IP Socket in C#.
The list of chapter:
1. Basic TCP Socket program
2. Basic UDP Socket program
3. Basic .Net Socket progarm

Note: Chapters in advanced topic will be updated soon.

How to display IPAddress of hosts using c#

This sample program demonstrates the use of the Dns, IPAddress, and IPHostEntry classes. The program takes a list of names or IP addresses as command-line parameters and prints the name and an IP address of the local host, followed by the names and IP addresses of the hosts specified on the command line.
The Dns class has several methods for resolving IP addresses. The GetHostName() method takes no arguments and returns a string containing the local host name. The GetHostByName() and Resolve() methods are basically identical; they take a string argument containing the host name to be looked up and returns the IP address and host name information for the supplied input in the form of an IPHostEntry class instance. The GetHostByAddress() method takes a string argument containing the dotted-quad string representation of an IP address and also returns host information in an IPHostEntry instance.