Texture mapping is the process of applying colors from an image to an object created in OpenGL. A simple example would be, applying a brick image onto a square which makes the square look like an original wall.
OpenGL supports four basic texture map types. 1D, 2D, 3D and cube map textures. The following code is an example of a 2D texture mapping, which provides a basic usage of textures.
Note: To run this code on your machine, make a bitmap image (64 x 64) and name it floor.bmp . Keep this image in the same folder where your exe file is located. If you are Code::Blocks user, then compiling from IDE results in Error, it says that it couldn’t found the Image. So just compile it and run the exe file which is inside debug or release folder. Visual Studio user can directly run this program without even including <windows.h> but Code::Blocks user must include <windows.h>.
تعليقات: 0
إرسال تعليق