UMBC GDC Programming Tutorial

Slides:



Advertisements
Similar presentations
OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Advertisements

OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
OPEN GL. Install GLUT Download package di sini Dari devcpp, buka Tools->PackageManager-
Chapter 2: Graphics Programming
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Part 3: Three Dimensions.
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
What is OpenGL? Low level 2D and 3D Graphics Library Competitor to Direct3D (the rendering part of DirectX) Used in: CAD, virtual reality, scientific.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
OpenGL and Projections
LAB #1: Computer Graphics Framework IGX is a set of programs which allow you to write graphics programs in C/C++ from plain text files. Benefits: 1. You.
Computer Graphics CS 385 February 7, Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.
Reference1. [OpenGL course slides by Rasmus Stenholt]
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
C Programming in Linux Jacob Chan. C/C++ and Java  Portable  Code written in one system and works in another  But in C, there are some libraries that.
Interactive Computer Graphics CS 418 MP1: Dancing I TA: Zhicheng Yan Sushma S Kini Mary Pietrowicz Slides Taken from: “An Interactive Introduction to OpenGL.
Modeling with OpenGL Practice with OpenGL transformations.
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
Computer Graphics I, Fall 2010 Programming with OpenGL Part 3: Three Dimensions.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
Color spaces. Draw Buffers Color models. Mathmatical Protocols for defining colors with numbers  RGB Red, Green, Blue  HSV Hue, Saturation, Value(Brightness)‏
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science,
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
OpenGL and GLUT Review Daniel Ritchie Monday, October 3 rd, 2011.
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Hank Childs, University of Oregon Oct. 28th, 2016 CIS 441/541: Introduction to Computer Graphics Lecture 16: textures.
A bit of C programming Lecture 3 Uli Raich.
Quiz 11/15/16 – C functions, arrays and strings
Programming with OpenGL Part 2: Complete Programs
Week 4 - Monday CS222.
Programming with OpenGL Part 3: Three Dimensions
OpenGL API 2D Graphic Primitives
Programming with OpenGL Part 2: Complete Programs
OpenGL (Open Graphics Library) Mr. B.A.Swamy Assistant Professor Dept of CSE.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Starting to draw dealing with Windows which libraries? clipping
גרפיקה ממוחשבת: מבוא ל-OpenGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 3: Three Dimensions
Introduction to OpenGL
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Starting to draw dealing with Windows which libraries? clipping
Programming with OpenGL Part 3: Three Dimensions
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Programming with OpenGL Part 3: Three Dimensions
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Presentation transcript:

UMBC GDC Programming Tutorial Lesson 1 Understanding the basics of C++ Game Programming using OpenGL (and GLUT) This is geared toward getting your feet wet. Not jumping in.

Overview Why you're here What you'll be using Background of C++ What's different Getting started Get a working demo Add some code Review

Why? Get a grasp on the way of thinking. Understand what makes it different from normal programming. Get experience with a graphics system. Get a sort of hello world working. To ask questions and interrupt me a lot.

Tool Set C++ Most game programming is still done in C++ Basic code is very similar to other high level languages OpenGL Works everywhere (Except XBOX 360) Exposes more of the background GLUT + cppgpgpu Get moving - fast.

C/C++ Background You #include definitions You write functions You call functions from main You exit

Traditional C/C++ Program #include <stdio.h> int AddTwoNumbers( int a, int b ) { return a + b; } int main() printf( “3 + 4 = %d\n”, AddTwoNumbers( a, b ); return 0;

C++ Classes Allow a level of abstraction, enabling: Appearance as objects Classful function members Classful data members

C/C++ Function Pointers Allows you to call a function dynamically Like any other pointer, but dereferences into call

What's Different? #include <stdio.h> int AddTwoNumbers( int a, int b ) { return a + b; } int main() printf( “3 + 4 = %d\n”, AddTwoNumbers( a, b ); return 0;

So... Programming in larger systems requires a leap of faith You are generally not in control of the main loop You must follow certain standards depending on your framework Code no longer remains linear

The Difference Start A B A Some kind of crazy engine sort of thing B

This Thing MyDraw main() GLUT Start Simple, huh?

Getting Started Make sure to open main.c in the main folder. We will be going through the code in the order it appears Stuff in Orange Boxes is pertinent to lesson.

main.cpp overview (1) #include "GLUTCore.h" #include "OGLParts.h" #include <stdio.h> void MyDraw(); Texture T1; Inclusion of Definitions Definition of Texture Object Function Prototype

main.cpp overview (2) int main (int argc, char * const argv[]) { Function Definition int main (int argc, char * const argv[]) { printf("Hello, World!\n"); //This must be set before init. GLUT.SetDrawFunct( MyDraw ); GLUT.Init( argc, (char**)argv, 640, 480, "Hello World" ); //Enable Depth glEnable(GL_DEPTH_TEST); Debugging Set up Variables Initialize System Set Up Environment

(Note: All of this code only gets executed once) main.cpp overview (3) //Load a texture from a file T1.LoadTextureFile( "Basic.ppm" ); GLUT.DrawAndDoMainLoop(); return 0; } Give up control Load an Image (Note: All of this code only gets executed once) Clean exit back to OS

main.cpp overview (4) void MyDraw() { //Clear the screen. glClearColor( .1f, .1f, .2f, 0.0f ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); T1.ActivateTexture( 0 ); DrawSquare(); T1.DeactivateTexture( 0 ); Set up Rendering States Perform Render Action (Clear Screen) Perform Render Action (Draw Quad)

main.cpp overview (5) //Update FPS, print if its time. GLUT.TackFPS(); Tell system to perform function //Update FPS, print if its time. GLUT.TackFPS(); //You need these last two lines. glutSwapBuffers(); glutPostRedisplay(); } Swap front buffer with back buffer (cue to self: talk about double-buffering) Tell system to redraw at its own leisure

Let's add some code Modify the MyDraw() function. Replace call to Enable/Disable Texture and DrawSquare(); with our own code Draw a single triangle in immediate mode

Added code T1.ActivateTexture( 0 ); DrawSquare(); Change Render State T1.ActivateTexture( 0 ); DrawSquare(); glBegin( GL_TRIANGLES ); glColor3f ( 1.0, 0.0, 0.0 ); glVertex3f( 0.0, 1.0, 0.0 ); glColor3f ( 0.0, 1.0, 0.0 ); glVertex3f( 1.0, 0.0, 0.0 ); glColor3f ( 0.0, 0.0, 1.0 ); glVertex3f( 0.0, 0.0, 0.0 ); glEnd(); T1.DeactivateTexture( 0 ); Vertex Attribute (R,G,B) Vertex Location (X,Y,Z)

Review Understand the difference from this and traditional programming Have a basic understanding of this new type of program flow Have a working shape on your screen

Questions (last chance) You know, I feel really bad about putting this image here, since I can't seem to find where it came from. The original source did not credit it.