21
OpenGL & GLUT Basics Window reshaping, Keyboard interaction, Camera, Drawing objects George Georgiev Telerik Corporation www.telerik. com

OpenGL & GLUT Basics

  • Upload
    baris

  • View
    108

  • Download
    1

Embed Size (px)

DESCRIPTION

OpenGL & GLUT Basics. Window reshaping, Keyboard interaction, Camera, Drawing objects. George Georgiev. Telerik Corporation. www.telerik.com. Table of Contents. Project using OpenGL & FreeGLUT in MSVC++ Window reshaping Keyboard Interaction Camera Positioning, orientation - PowerPoint PPT Presentation

Citation preview

Page 1: OpenGL & GLUT Basics

OpenGL & GLUT Basics

Window reshaping, Keyboard interaction, Camera, Drawing objects

George GeorgievTelerik Corporationwww.telerik.

com

Page 2: OpenGL & GLUT Basics

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: OpenGL & GLUT Basics

Project using OpenGL & FreeGLut

A reminder…

Page 4: OpenGL & GLUT Basics

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: OpenGL & GLUT Basics

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: OpenGL & GLUT Basics

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: OpenGL & GLUT Basics

Window reshapingThe Reshape function

Page 8: OpenGL & GLUT Basics

Window reshaping Reshape function

Specified by glutReshapeFunc Defines how your window reshapes Write it once, remember it no more

8

Page 9: OpenGL & GLUT Basics

Window reshapingLive Demo

Page 10: OpenGL & GLUT Basics

Keyboard interactionThe Keyboard monitoring functions

Page 11: OpenGL & GLUT Basics

Keyboard interaction Keyboard monitoring functions

Specified by glutKeyboardFunc glutKeyboardUpFunc

Monitor key pressing and key releasing

Doesn’t receive device information Receives translated windows

messages11

Page 12: OpenGL & GLUT Basics

Keyboard interactionLive Demo

Page 13: OpenGL & GLUT Basics

Camera controlOrientation and positioning

Page 14: OpenGL & GLUT Basics

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: OpenGL & GLUT Basics

Drawing objectsGLUT predefined objects, Coloring,

Positioning

Page 16: OpenGL & GLUT Basics

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: OpenGL & GLUT Basics

Camera control & Drawing objects

Live Demo

Page 18: OpenGL & GLUT Basics

Basic LightingEnabling lighting

Page 19: OpenGL & GLUT Basics

Basic lighting Enabling lighting

glEnable Enabling ‘color material’

19

Page 20: OpenGL & GLUT Basics

Basic LightingLive Demo

Page 21: OpenGL & GLUT Basics

OpenGL Basics

Questions? ?

?? ? ??

?? ?

?