GAM666 – Introduction To Game Programming ● As of DirectX 8, DirectDraw (2D) and Direct3D (3D) have been combined into DirectX Graphics (still often called.

Slides:



Advertisements
Similar presentations
Real-Time Rendering 靜宜大學資工研究所 蔡奇偉副教授 2010©.
Advertisements

COMPUTER GRAPHICS CS 482 – FALL 2014 NOVEMBER 10, 2014 GRAPHICS HARDWARE GRAPHICS PROCESSING UNITS PARALLELISM.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
The Graphics Pipeline CS2150 Anthony Jones. Introduction What is this lecture about? – The graphics pipeline as a whole – With examples from the video.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Realtime 3D Computer Graphics Computer Graphics Computer Graphics Software & Hardware Rendering Software & Hardware Rendering 3D APIs 3D APIs Pixel & Vertex.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
INTRO TO COMPUTER GRAPHICS TEXT EDWARD ANGEL: EDITION 5 CS770/870
CSE 381 – Advanced Game Programming Basic 3D Graphics
Geometric Objects and Transformations. Coordinate systems rial.html.
Tennis for Two, 1958, by William Higinbotham, Brookhaven National Lab CSE 380 – Computer Game Programming Graphics Device Management.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Week 2 - Wednesday CS361.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
The Graphics Rendering Pipeline 3D SCENE Collection of 3D primitives IMAGE Array of pixels Primitives: Basic geometric structures (points, lines, triangles,
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
NVTune Kenneth Hurley. NVIDIA CONFIDENTIAL NVTune Overview What issues are we trying to solve? Games and applications need to have high frame rates Answer.
Computing & Information Sciences Kansas State University Lecture 19 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 19 of 42 William H. Hsu.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Maths & Technologies for Games DirectX 11 – New Features Tessellation & Displacement Mapping CO3303 Week 19.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
3D Programming and DirectX API. Content Mathematics Mathematics Prepare to Write a 3D program Prepare to Write a 3D program Program Structure Program.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Mark Nelson 3d projections Fall 2013
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
GAM666 – Introduction To Game Programming ● Programmer's perspective of Game Industry ● Introduction to Windows Programming ● 2D animation using DirectX.
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
Computer Graphics Matrices
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
GAM666 – Introduction To Game Programming ● DirectDraw, the 2D component of DirectX, uses the term “surface” to mean an area of memory in which pixel data.
GAM666 – Introduction To Game Programming ● Textures are simply 2D images which are spread over the triangles of a 3D shape ● Each vertex has texture coordinates.
Mobile & Casual Gaming OpenGL ES Intro. /red/chapter03.html.
Chapter 1 Graphics Systems and Models Models and Architectures.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
Image Fusion In Real-time, on a PC. Goals Interactive display of volume data in 3D –Allow more than one data set –Allow fusion of different modalities.
- Introduction - Graphics Pipeline
Introduction to OpenGL
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
Models and Architectures
Computer Graphics Introduction to Shaders
03 | Creating, Texturing and Moving Objects
Introduction to OpenGL
OpenGL-Rendering Pipeline
Presentation transcript:

GAM666 – Introduction To Game Programming ● As of DirectX 8, DirectDraw (2D) and Direct3D (3D) have been combined into DirectX Graphics (still often called Direct3D, however) ● DirectX Graphics includes a library of 3D math helper functions, d3dx9math.h, the use of which is entirely optional but has gained wide acceptance Basic 3D Using DirectX 9

GAM666 – Introduction To Game Programming DirectX 9 COM Object Pointers: ● LPDIRECT3D9 – main Direct3D control object used to create others ● LPDIRECT3DDEVICE9 – device onto which 3D is rendered ● LPDIRECT3DVERTEXBUFFER9 – list of vertices describing a shape to be rendered ● LP3DXFONT – font for rendering text onto a 3D scene Basic 3D Using DirectX 9

GAM666 – Introduction To Game Programming Basic frame rendering logic: ● Clear the display target's backbuffer using Direct3DDevice Clear() ● Call Direct3DDevice BeginScene() ● Render primitives [shapes] using Direct3DDevice DrawPrimitive() and text using Direct3DXFont DrawText() ● Call Direct3DDevice EndScene() ● Flip backbuffer to screen with Direct3DDevice Present() Basic 3D Using DirectX 9

GAM666 – Introduction To Game Programming ● Direct3DCreate9() to create Direct3D object ● Enumeration in DirectX Graphics is easier than in DirectDraw7 (no enumeration callback function needs to be supplied, rather call a query function in your own loop) ● Direct3D CreateDevice() to create Direct3DDevice ● Direct3DDevice CreateVertexBuffer() to allocate vertex buffers ● D3DXCreateFont() to make 3D font 3D Setup

GAM666 – Introduction To Game Programming ● D3DXVECTOR3 – x, y and z coordinates for a 3D point or vector (context determines which) ● D3DXMATRIX – 4x4 3D transformation matrix ● There are many D3DX* functions to create or manipulate these ● Visit to review basics of 3D vectors and matrix arithmetic Critical d3dx9math.h data types

GAM666 – Introduction To Game Programming Direct3D has us specify 3 transformation matrices (each vertex is transformed by all three, in turn, before it is rendered): ● World matrix – moves a vertex from its specified coordinates to somewhere else ● View matrix – moves a vertex so it will be as if we were looking from a particular viewpoint (with increasing Z coordinates in front of us) ● Projection matrix – moves a vertex so that if we ignore the Z coordinate (2D projection), reasonable perspective will be apparent Fixed Function Transformation Pipeline

GAM666 – Introduction To Game Programming Use Direct3DDevice SetTransform() to change one of the transformation matrices: ● The world matrix is changed whenever we have a primitive to render that should not be moved to where the current world matrix would move it (typically, just before rendering each relocatable primitive) ● The view matrix is changed whenever we want the “camera” or viewpoint to change, typically with each frame as the user moves around ● The projection matrix is changed whenever we want to change the perspective or clipping, typically only once at the beginning Fixed Function Transformation Pipeline

GAM666 – Introduction To Game Programming ● When a vertex buffer is created, there is some flexibility in specifying exactly what data will be supplied for each vertex of a primitive (e.g. with a texture you need to supply texture coordinates for each vertex, but with no texture you might want to specify a colour for each vertex) ● The D3DFVF_ flags identify which pieces of data you'll be using, e.g. ● D3DFVF_XYZ means you want XYZ coordinates (almost always want this) ● D3DFVF_DIFFUSE means you want to specify a [diffuse] colour (sometimes want) Flexible Vertex Formats (FVF)

GAM666 – Introduction To Game Programming ● Although FVF flags are combined with bitwise or (|) - so the order they are specified in doesn't matter - there IS an order in which the matching data will appear in the vertex buffer ● Use “Vertex Formats” in Visual Studio help to see the order the data will appear in the vertex buffer when specific vertex flags are used ● Use Direct3DDevice SetFVF() to specify what vertex format you are about to use Flexible Vertex Formats (FVF)

GAM666 – Introduction To Game Programming ● D3DPT_POINTLIST – list of separate points ● D3DPT_LINELIST – list of line segments, 2 vertices per segment ● D3DPT_LINESTRIP – list of joined line segments, 2 vertices for first, 1 for each thereafter ● D3DPT_TRIANGLELIST – list of triangles, 3 vertices per triangle ● D3DPT_TRIANGLEFAN – list of triangles sharing a common starting point, 3 vertices for the first, 1 for each thereafter ● D3DPT_TRIANGLESTRIP – list of triangles, each sharing two points with the next, 3 vertices for the first, 1 for each thereafter Vertex Buffer Primitive Types

GAM666 – Introduction To Game Programming ● Since vertex buffers may live on the video card or elsewhere where shared access may be a problem, you must lock a vertex buffer area before you update it, and unlock it when you are done ● Don't update vertex buffers needlessly, as it is potentially slow ● Use Direct3DDevice SetStreamSource() to identify which vertex buffer to use ● Use Direct3DDevice DrawPrimitive() to render a primitive from the current vertex buffer, specifying the type of primitive and number of primitives. Using Vertex Buffers

GAM666 – Introduction To Game Programming ● The Direct3DDevice will probably need to be Reset() if you regain focus after losing it, and the vertex buffers (and anything else that might have resided in video memory) may have to be refilled or reallocated ● Use Direct3DDevice SetRenderState() to turn features (such as lighting and alpha blending) on or off, or otherwise control them ● Note that most of the characteristics of the fixed function transformation pipeline are obsoleted by newer, but not universally available, shader technology – double coverage is required for the near future Other Considerations