OpenGL & Delphi. Max Kleiner. http://max.kleiner.com/download/openssl_opengl.pdf 1/22



Similar documents
Graphics Input Primitives. 5. Input Devices Introduction to OpenGL. String Choice/Selection Valuator

Graphics Pipeline in a Nutshell

CMSC 427 Computer Graphics 1

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

An Introduction to. Graphics Programming

Input and Interaction

Input and Interaction. Project Sketchpad. Graphical Input. Physical Devices. Objectives

Chapter 1 Introduction to OpenGL

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Introduzione ad OpenGL

CMSC 427 Computer Graphics 1

Computer Graphics. Anders Hast

Computer Graphics Labs

Input and Interaction. CS 432 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Computer Graphics Labs

Lecture Notes, CEng 477

The mouse callback. Positioning. Working with Callbacks. Obtaining the window size. Objectives

An Introduction to 3D Computer Graphics, Stereoscopic Image, and Animation in OpenGL and C/C++ Fore June

Aston University. School of Engineering & Applied Science

Introduction to Computer Graphics Techniques and Applications. Hong Qin Center for Visual Computing (CVC) Stony Brook University

Methodology for Lecture. Review of Last Demo

Computer Graphics (Basic OpenGL, Input and Interaction)

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

Nicolas P. Rougier PyConFr Conference 2014 Lyon, October 24 25

Einführung Computergraphik (WS 2014/15)

3D Graphics and Cameras

Introduction to Computer Graphics

Computer Graphics. Computer graphics deals with all aspects of creating images with a computer

Equalizer. Parallel OpenGL Application Framework. Stefan Eilemann, Eyescale Software GmbH

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Introduction to GPGPU. Tiziano Diamanti

Computer Graphics on Mobile Devices VL SS ECTS

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

Practical Data Visualization and Virtual Reality. Virtual Reality VR Software and Programming. Karljohan Lundin Palmerius

CS 378: Computer Game Technology

A JAVA-BASED MULTI-PARTICIPANT 3D GRAPHICS APPLICATION INTERFACE USING JAVAGL 1 AND JAVANL 2

MMGD0203 Multimedia Design MMGD0203 MULTIMEDIA DESIGN. Chapter 3 Graphics and Animations

CMSC 425 Game Programming 1

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

QCD as a Video Game?

Programming 3D Applications with HTML5 and WebGL

How To Teach Computer Graphics

Jawaharlal Nehru Engineering College

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

Computer Applications in Textile Engineering. Computer Applications in Textile Engineering

Comp 410/510. Computer Graphics Spring Introduction to Graphics Systems

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

How To Use An Amd Graphics Card In Greece And (Amd) With Greege (Greege) With An Amd Greeper 2.2.

3D graphic acceleration history and architecture

CS 4204 Computer Graphics

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

OpenSSL mit Delphi. Max Kleiner.

Introduction to Graphics Software Development for OMAP 2/3

Finger Paint: Cross-platform Augmented Reality

Computer Graphics Hardware An Overview

OpenGL Shading Language Course. Chapter 5 Appendix. By Jacobo Rodriguez Villar jacobo.rodriguez@typhoonlabs.com

QNX Software Development Platform 6.6. Screen Graphics Subsystem Developer's Guide

Volume Visualization Tools for Geant4 Simulation

Intel Graphics Media Accelerator 900

Beginning Android 4. Games Development. Mario Zechner. Robert Green

Radeon HD 2900 and Geometry Generation. Michael Doggett

The OpenGL R Graphics System: A Specification (Version 3.3 (Core Profile) - March 11, 2010)

Freescale Semiconductor, I

Petascale Visualization: Approaches and Initial Results

A Short Introduction to Computer Graphics

1. INTRODUCTION Graphics 2

Surface and Volumetric Data Rendering and Visualisation

VisIt Visualization Tool

Develop Computer Animation

Vertex and fragment programs

Graphics Cards and Graphics Processing Units. Ben Johnstone Russ Martin November 15, 2011

Game Development in Android Disgruntled Rats LLC. Sean Godinez Brian Morgan Michael Boldischar

Implementação. Interfaces Pessoa Máquina 2010/ Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

Introduction to Computer Graphics

IT 386: 3D Modeling and Animation. Review Sheet. Notes from Professor Nersesian s IT 386: 3D Modeling and Animation course

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

ML2VR Providing MATLAB Users an Easy Transition to Virtual Reality and Immersive Interactivity

OpenGL Programming Guide

CS130 - Intro to computer graphics. Dr. Victor B. Zordan vbz@cs.ucr.edu Objectives

Digital Video-Editing Programs

GPU Architecture. Michael Doggett ATI

VESA BIOS Extension/Accelerator Functions (VBE/AF)

B2.53-R3: COMPUTER GRAPHICS. NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions.

Multiresolution 3D Rendering on Mobile Devices

Solutions for Simulation

OPERATING SYSTEM SERVICES

Introduction GPU Hardware GPU Computing Today GPU Computing Example Outlook Summary. GPU Computing. Numerical Simulation - from Models to Software

Optimizing AAA Games for Mobile Platforms

Transcription:

OpenGL & Delphi Max Kleiner http://max.kleiner.com/download/openssl_opengl.pdf 1/22

OpenGL http://www.opengl.org Evolution of Graphics Assembler (demo pascalspeed.exe) 2D 3D Animation, Simulation (Terrain_delphi.exe) Virtual Reality (CAD, Gothic II, trainsimulator) Computer arbeitet deshalb so schnell, weil er nicht denkt. Sign or design, that s the question Lang ist der Weg durch Lehren, kurz und wirksam durch Beispiele PascalPower 2/22

OpenGL Overview General OpenGL Introduction Rendering Primitives (points, lines, polygons and images) Rendering Modes Lighting Texture Mapping Imaging PaccalPower 3/22

Simple Code Schema drawscene() begin //set background color glclearcolor() glclear(gl_color_buffer_bit) //color of a polygon primitive glcolor3f() //set the polygon glbegin(gl_polygon) glvertex2f() glvertex2f()... glend() //draw the GL commands glflush() end 4/22

What s OpenGL? Graphics rendering API high-quality color images composed of geometric and image primitives with just 150 commands window system independent (context) operating system independent www.opengl.org /www.sgi.com/opengl www.softwareschule.ch/download/opengldelphidemo.zip Open port from freepascal http://www.delphi3000.com/articles/article_5166 PascalPower 5/22

OpenGL Architecture Polynomial Evaluator Per Vertex Operations & Primitive Assembly CPU Display List Rasterization Texturing Per Fragment Operations Frame Buffer Texture Memory Pixel Operations 6/22

OpenGL as a Renderer Geometric primitives points, lines and polygons Image Primitives images and bitmaps separate pipeline for images and geometry linked through texture mapping Rendering depends on state colors, materials, light sources, etc. Generally, there are two operations that you do with OpenGL: 1. draw something 2. change the state of how OpenGL draws 7/22

Related APIs AGL (mac), GLX, WGL (windows) glue between OpenGL and windowing systems GLU (OpenGL Utility Library) part of OpenGL NURBS, tessellators, quadric shapes, etc. GLUT (OpenGL Utility Toolkit) portable windowing API not officially part of OpenGL for making simple OpenGL applications 8/22

OpenGL and Related APIs application program OpenGL Motif widget or similar GLUT GLX, AGL or WGL X, Win32, Mac O/S GLU GL software and/or hardware 9/22

Preliminaries Headers Files Libraries uses Buttons, StdCtrls, GL, OpenGLContext_d; version from Mike Lischke OpenGL12.pas GL Converted to Delphi by Tom Nuydens : http://www.delphi3d.net glut.h includes gl.h and glu.h. opengl32 = 'OpenGL32.dll'; libgl.so on Linux glu32 = 'GLU32.dll'; Enumerated Types OpenGL defines numerous types for compatibility GLfloat, GLint, GLenum, etc. 10/22

GLUT Basics Application Structure Process 1. Configure and open window 2. Initialize OpenGL state (background color, light positions and texture maps). 3. Register input callback functions 1. render, resize 2. input: keyboard, mouse, etc. 4. Enter event processing loop (e.g. onidle() 11/22

Sa(i)mple Program void main( int argc, char** argv ) { int mode = GLUT_RGB GLUT_DOUBLE; glutinitdisplaymode( mode ); glutcreatewindow( argv[0] ); init(); glutdisplayfunc( display ); glutreshapefunc( resize ); glutkeyboardfunc( key ); glutidlefunc( idle ); } glutmainloop(); 12/22

OpenGL Initialization Set up whatever state you re going to use void init( void ) { glclearcolor( 0.0, 0.0, 0.0, 1.0 ); glcleardepth( 1.0 ); glenable( GL_LIGHT0 ); glenable( GL_LIGHTING ); glenable( GL_DEPTH_TEST ); } 13/22

GLUT Callback Functions Routine to call when something happens window resize or redraw user input Animation (mostly with onidle) OnPaint:= OpenGLControl1Paint; OnResize:= OpenGLControl1Resize; PascalPower 14/22

Idle Callbacks Use for animation and continuous update of motion variables Application.OnIdle:= IdleFunc; (DEMO) procedure TGLform.IdleFunc(Sender: TObject; var Done: Boolean); begin openglcontrol1.updateframetimediff; OpenGLControl1Paint(Self); Done:= false; if openglcontrol1.framedifftimeinmsecs > 2 then glform.hintlabel1.caption:= 'FPS: ' end; + inttostr((1000 div openglcontrol1.framedifftimeinmsecs)); 15/22

OpenGL Geometric Primitives All geometric primitives are specified by vertices GL_POINTS GL_LINES GL_LINE_STRIP GL_LINE_LOOP GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP 16/22

Simple Example void drawrhombus( GLfloat color[] ) { } glbegin( GL_QUADS ); glcolor3fv( color ); glvertex2f( 0.0, 0.0 ); glvertex2f( 1.0, 0.0 ); glvertex2f( 1.5, 1.118 ); glvertex2f( 0.5, 1.118 ); glend(); 17/22

OpenGL Command Formats glvertex3fv( v ) Number of components 2 - (x,y) 3 - (x,y,z) 4 - (x,y,z,w) PascalPower Data Type b - byte ub - unsigned byte s - short us - unsigned short i - int ui - unsigned int f - float d - double Vector (coords( coords) omit v for scalar form glvertex2f( x, y ) 18/22

Controlling Rendering Appearance From Wireframe to Texture Mapped 19/22

Transformations in OpenGL Camera Analogy 3D is just like taking a photograph (lots of photographs!) viewing volume camera tripod model 20/22

Camera Analogy and Transformations Projection transformations adjust the lens of the camera Viewing transformations tripod define position and orientation of the viewing volume in the world Modeling transformations moving the model Viewport transformations enlarge or reduce the physical photograph 21/22

That s all Folks ;) if you can t see it you can t manage IT PascalPower 22/22