![Page 1: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/1.jpg)
OpenGL & GLUT Basics
Window reshaping, Keyboard interaction, Camera, Drawing objects
George Georgiev
http://academy.telerik.com
Technical Trainer
academy.telerik.com
/.../3d-game-developm
ent-opengl
George AtanasovFront-End Developer
![Page 2: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/2.jpg)
Table of Contents Project using OpenGL & FreeGLUT in MSVC++
Window reshaping Keyboard Interaction Camera
Positioning, orientation
Drawing objects Coloring
Positioning, orientation
Basic Lighting2
![Page 3: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/3.jpg)
Project using OpenGL & FreeGLut
A reminder…
![Page 4: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/4.jpg)
OpenGL & FreeGLUT Project
Step 1 – Creating the project Setup OpenGL & FreeGLUT (done
only once)
Open Visual Studio, Choose C++ as a language
Create a Win32 Console application
Tick “Empty project”
Add a new .cpp file #include <gl\glew.h>
#include <gl\freeglut.h>
int main(int argc, char ** argv)
4
![Page 5: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/5.jpg)
OpenGL & FreeGLUT Project (2)
Step 2 - Linking Go to Project > [YourProjectName]
Properties
From the side menu choose Configuration properties > Linker > Input
In the Additional Dependencies type in:glew32.libfreeglut.lib
Do this for both Debug and Release configurations (upper left corner in the window)
Close the properties window, you’re ready to go
5
![Page 6: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/6.jpg)
OpenGL & FreeGLUT Project (2)
Tip – the faster way to link to the libraries Skip the entire Step 2
In the .cpp file write: #pragma comment (lib, “glew32.lib”)
#pragma comment (lib, “freeglut.lib”)
6
![Page 7: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/7.jpg)
Window reshapingThe Reshape function
![Page 8: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/8.jpg)
Window reshaping
Reshape function Specified by glutReshapeFunc
Defines how your window reshapes
Write it once, remember it no more
8
![Page 9: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/9.jpg)
Window reshapingLive Demo
![Page 10: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/10.jpg)
Keyboard interactionThe Keyboard monitoring functions
![Page 11: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/11.jpg)
Keyboard interaction
Keyboard monitoring functions Specified by
glutKeyboardFunc
glutKeyboardUpFunc
Monitor key pressing and key releasing
Doesn’t receive device information Receives translated windows
messages
11
![Page 12: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/12.jpg)
Keyboard interactionLive Demo
![Page 13: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/13.jpg)
Camera controlOrientation and positioning
![Page 14: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/14.jpg)
Camera control
‘Moving the world’ method Using the glTranslate* and
glRotate* functions
You do the things the opposite way around F. e., to move the camera forward,
move the objects backward
Using the gluLookAt function Specifies
camera location
Viewed location
14
![Page 15: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/15.jpg)
Drawing objectsGLUT predefined objects, Coloring,
Positioning
![Page 16: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/16.jpg)
Drawing objects
GLUT predefined functions glutSolid*
glutWireframe*
Coloring glColor* - defines the current
drawing color
Positioning glTranslate* - moves the renderer
by a vector
glRotate* - rotates the renderer by an Euler angle
16
![Page 17: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/17.jpg)
Camera control & Drawing objects
Live Demo
![Page 18: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/18.jpg)
Basic LightingEnabling lighting
![Page 19: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/19.jpg)
Basic lighting
Enabling lighting glEnable
Enabling ‘color material’
19
![Page 20: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/20.jpg)
Basic Lighting
Live Demo
![Page 21: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/21.jpg)
форум програмиране, форум уеб дизайнкурсове и уроци по програмиране, уеб дизайн – безплатно
програмиране за деца – безплатни курсове и уроцибезплатен SEO курс - оптимизация за търсачки
уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop
уроци по програмиране и уеб дизайн за ученициASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC
безплатен курс "Разработка на софтуер в cloud среда"
BG Coder - онлайн състезателна система - online judge
курсове и уроци по програмиране, книги – безплатно от Наков
безплатен курс "Качествен програмен код"
алго академия – състезателно програмиране, състезания
ASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NETкурсове и уроци по програмиране – Телерик академия
курс мобилни приложения с iPhone, Android, WP7, PhoneGap
free C# book, безплатна книга C#, книга Java, книга C#Дончо Минков - сайт за програмиранеНиколай Костов - блог за програмиранеC# курс, програмиране, безплатно
?
? ? ??
?? ?
?
?
?
??
?
?
? ?
Questions?
?
OpenGL Basics
http://academy.telerik.com/
![Page 22: 8. Open GL Basics - 3D Graphics and Game Development](https://reader036.vdocument.in/reader036/viewer/2022081512/555a0438d8b42aa8098b50c9/html5/thumbnails/22.jpg)
Free Trainings @ Telerik Academy
3D Graphics and Game Development academy.telerik.com/.../
3d-game-development-opengl
Telerik Software Academy academy.telerik.com
Telerik Academy @ Facebook facebook.com/TelerikAcademy
Telerik Software Academy Forums forums.academy.telerik.com