Saturday, April 28, 2012

Texture mapping in SharpGL (OpenGL in C#) sample program for windows form

At first you have to setup the SharpGL in Visual Studio for that you can follow my previous articles create SharpGL project in c# .
OpenGL bind the texture form the texture memory which do not store arbitrary images but a texture has specific constraints on the images. So,OpenGL function for texture is same whatever be the library we used for e.g GLUT,SharpGL,GLFW only the difference is how we load the images on the texture memory. These images are store in different file format , which required the program to decode and load the images form file into texture memory and this is painful effort for the programmer to write there own decoding and loading code.
In GLUT  texture  mapping example is shown in this article Texture mapping in GLUT where you can see BMP image is loaded at first in the memory and that texture memory data is used by OpenGL function for texture mapping but in GLFW we don’t have to write code for loading image from file it provide the built in function for loading image from a Truevision Targa format file (.TGA) and here is the sample project Texture in GLFW.
Now in SharpGL texture is not so difficult. We can create the Bitmap object by loading BMP image file and all the information of image can be used with this Bitmap object.

This is the snapshot of my project.
You can download the project file with complete source code from here download
Download TextureMappin_SharpGL.rar

No comments:

Post a Comment