Intro to OpenGL (Version 2) Geb Thomas. Setting Up GLUT You will need GLUT for opening windows We can use the version made by Nate Robins: –http://www.xmission.com/~nate/glut.htmlhttp://www.xmission.com/~nate/glut.html.

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-
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
OPENGL.
#include int line_width = 1; void Display( void ) { glEnable( GL_LINE_STIPPLE ); glClearColor (0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT);
© 2004, Tom Duff and George Ledin Jr1 Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma.
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 Basics Donghui Han. Assignment Grading Visual Studio Glut Files of four types needed: – Source code:.cpp,.h – Executable file:.exe (build in release.
OpenGL Basics.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
Draw a Simple Object. Example 1/4 #include “ glut.h ” void display(); void reshape(GLsizei w, GLsizei h); void main(int argc, char** argv){ glutInit(&argc,
OpenGL (I). What is OpenGL (OGL)? OGL is a 3D graphics & modeling library Can also use it to draw 2D objects.
CSC 461: Lecture 51 CSC461 Lecture 5: Simple OpenGL Program Objectives: Discuss a simple program Discuss a simple program Introduce the OpenGL program.
Hidden Surfaces and Shading CS BSP Tree T1T1 T2T2 E if (f 1 (E) < 0) then draw T 1 draw T 2 else draw T 2 draw T 1 f 1 (p) = 0 is the.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
CSE 494/598 Intro to Applied Computer Graphics Anshuman Razdan DCST AR's Web Page AR's Web Page
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.
Development of Interactive 3D Virtual World Applications
Write a Simple Program with OpenGL & GLUT. Books and Web Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible.
Reference1. [OpenGL course slides by Rasmus Stenholt]
CS380 LAB I OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
CAP 4703 Computer Graphic Methods Prof. Roy Levow Lecture 2.
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Graphics Programming and OpenGL.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Lecture 3 OpenGL.
Write a Simple Program with OpenGL & GLUT. Books OpenGL Programming Guide (Red-book) OpenGL Reference Manual (Blue-book) OpenGL Super Bible
 “OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D and.
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Managing Multiple Windows with OpenGL and GLUT
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
DREAM PLAN IDEA IMPLEMENTATION Introduction to Computer Graphics Dr. Kourosh Kiani
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.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
NoufNaief.net 1 TA: Nouf Al-Harbi.
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.
Doç. Dr. Cemil Öz SAÜ Bilgisayar Mühendisliği Dr. Cemil Öz.
Graphics: Conceptual Model
Introduction to OpenGL Programming
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
Chap 2 Write a Simple OpenGL Program. Preparing 1/2 environment : Microsoft Visual C 、 Microsoft Visual C++.Net Also need : GLUT
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS559: Computer Graphics Lecture 12: OpenGL: ModelView Li Zhang Spring 2010.
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
Introduction to Graphics Programming. Graphics API.
Introduction to Graphics Programming. Graphics: Conceptual Model Real Object Human Eye Display Device Graphics System Synthetic Model Synthetic Camera.
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
CS380 LAB II OpenGL Donghyuk Kim Reference1. [OpenGL course slides by Rasmus Stenholt] Reference2. [
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
OpenGL and GLUT Review Daniel Ritchie Monday, October 3 rd, 2011.
Basic Program with OpenGL and GLUT
Computer Graphics Lecture 33
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.
גרפיקה ממוחשבת: מבוא ל-OpenGL
Introduction to OpenGL
OpenGL program.
Programming with OpenGL Part 2: Complete Programs
Managing Multiple Windows with OpenGL and GLUT
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Presentation transcript:

Intro to OpenGL (Version 2) Geb Thomas

Setting Up GLUT You will need GLUT for opening windows We can use the version made by Nate Robins: – Download the.zip file, unzip it and store it in a convenient directory on your drive I stored everything in h:/documents/glut

Setting up the Compiler You need to tell the compiler where the header file is. One way is instead of using #include, which assumes that the glut header file is in a standard location, you can use #include “h:/documents/glut/glut.h”. Then the compiler will look at this location. An easy way to handle the.dll file is to copy it to the location of your executable file, perhaps: H:\testProgram\debug

Setting up a Window with GLUT Learn about glut here: tion/glut/spec3/spec3.html glutInit(argc, argv); /* initialize glut */ glutInitWindowSize(int width, int height); –/* set the window size. 300x300 by default */ glutInitWindowPosition(x, y); –/* set the window position, default –1, -1, which means let the operating system decide */

glutInitDisplayMode Use glutInitDisplayMode( GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH ) Provides RGB color rather than indexed color A single frame buffer, rather than double buffering A depth buffer

Opening a Window int glutCreateWindow(char *name); Returns an integer identifier for the window No drawing is effective until glutMainLoop Several windows or subwindows may be opened. Windows may be resized or repositioned Window and display modes are system states that may be set and queried

The Main Loop Glut allows you to define callbacks: –void glutDisplayFunc(void (*func)(void)); –void glutReshapeFunc(void (*func)(int width, int height)); –void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y)); –void glutMouseFunc(void (*func)(int button, int state, int x, int y)); void glutMainLoop(void);

Working with OpenGL Get information from here (as well as other sources) – dweb/dynaweb/SGI_Developer/OpenGL_PG/ dweb/dynaweb/SGI_Developer/OpenGL_PG/

Clearing the Window To clear the color to black (in RGBA mode) –glClearColor(0.0, 0.0, 0.0, 0.0); –glClear(GL_COLOR_BUFFER_BIT); To also clear the depth buffer you might use: –glClearColor(0.0, 0.0, 0.0, 0.0); –glClearDepth(1.0); –glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

Drawing Colors The current drawing color is a state. Change the state with glColor3f commands such as: –glColor3f(0.0, 0.0, 0.0); // black –glColor3f(1.0, 0.0, 0.0); //red –glColor3f(0.0, 1.0, 0.0); //green –glColor3f(1.0, 1.0, 0.0); //yellow –glColor3f(0.0, 0.0, 1.0); //blue –glColor3f(1.0, 0.0, 1.0); //magenta –glColor3f(0.0, 1.0, 1.0); //cyan –glColor3f(1.0, 1.0, 1.0); //white

Flushing the Buffers void glFlush(void); Sends a command to flush out the pipeline and finish the drawing void glFinish(void); Waits until drawing is completed, then returns

Setting up a Coordinate Frame void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h); }