how to draw 3d building in opengl
,
Introduction
We have already practical textures to objects in the following article.
- 3D Planetary System In OpenGL
Here, we will just draw some scene using QUADS. Start, configure Visual Studio for glut. Read the following article to configure Visual Studio for glut and to get started with OpenGL.
- Getting Started with OpenGL In Visual C++
For applying textures, nosotros need textures image (256*256) 24 bit bitmap files.
Hither's the scene graph image that I have drawn.
Coding
I accept created the post-obit files in the project.
- 3D_GameScene_OpenGL.cpp
- DisplayScene.h
- DisplayScene.cpp
- LoadImageFile.h
- LoadImageFile.cpp
- DrawScene.h
- DrawScene.cpp
3D_GameScene_OpenGL.cpp
This is the main source file where I have divers a main() function.
DisplayScene.cpp
In this file, I have used a switch case statement to draw scenes past providing different texture image files equally arguments to it. I accept declared form and data in DisplayScene.h header file.
LoadImageFile.cpp
This file contains a function that applies the texture to the drawn objects.
DrawScene.cpp
In this file, I have drawn a scene or defined the function which are declared in DrawScene.h header file.
Run across the code defined in the above files.
DisplayScene.h
- #ifndef _DISPLAYSCENE_H
- #ascertain _DISPLAYSCENE_H
- enum MyTextures
- {
- DEFAULT = 0x01,
- Animation=0x02,
- BUILDINGS=0x03,
- HORROR=0x04,
- GREENY=0x05,
- Woods=0x06,
- ROCKS=0x07,
- Circuit=0x08
- };
- form DisplayGameScene
- {
- public :
- static void DisplayTexturedGameScene( int , int , BOOL );
- };
Postar um comentário for "how to draw 3d building in opengl"