Computer Graphics CS 385 February 7, 2005. Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining.

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
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.
#4: OpenGL Implementation & Project 2 CSE167: Computer Graphics TAs: Alex Kozlowski & Cameron Chrisman UCSD, Winter 2006.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Computer Science,
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
CENG477 Introduction to Computer Graphics Introduction to OpenGL, GLUT and GLUI.
CSE 494/598 Intro to Applied Computer Graphics Anshuman Razdan DCST AR's Web Page AR's Web Page
Development of Interactive 3D Virtual World Applications
Programming with OpenGL and GLUT
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.
COS 397 Computer Graphics Assoc. Prof. Svetla Boytcheva AUBG 2013 COS 397 Computer Graphics Practical Session №1 Introduction to OpenGL, GLFW and CG.
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
1 GLUT Callback functions Event-driven: Programs that use windows  Input/Output  Wait until an event happens and then execute some pre-defined functions.
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Using OpenGL in Visual C++ Opengl32.dll and glu32.dll should be in the system folder Opengl32.dll and glu32.dll should be in the system folder Opengl32.lib.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter 2 Initial Steps in Drawing Figures Ureerat Suksawatchon Faculty of Informatics.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
 “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.
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);
P RACTICING O PEN GL- P RIMITIVES. O PEN GL O UTPUT P RIMITIVES  Each geometric object is described by a set of vertices and the type of primitive to.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 43 Computer Graphics Programming with OpenGL I.
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: –
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
NoufNaief.net TA: Nouf Al-harbi.
NoufNaief.net 1 TA: Nouf Al-Harbi.
Graphics: Conceptual Model
CSCE 441: Computer Graphics
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
31/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 2: Introduction.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
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.
OpenGL CS418 Computer Graphics John C. Hart. OpenGL: Event-driven How in OpenGL? Programmer registers callback functions Callback function called when.
INTRODUCTION TO OPENGL
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
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.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Basic Program with OpenGL and GLUT
CSC Graphics Programming
The Human Visual System vs The Pinhole camera
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 2: Complete Programs
Materi Anatomi OpenGL Fungsi GLUT Posisi Kamera Proyeksi
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.
OpenGL A Brief Overview.
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Starting to draw dealing with Windows which libraries? clipping
גרפיקה ממוחשבת: מבוא ל-OpenGL
Drawing in the plane 455.
Line and Curve Drawing Algorithms
Computer Graphics Practical Lesson 1-
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 2: Complete Programs
OpenGL A Brief Overview.
Presentation transcript:

Computer Graphics CS 385 February 7, 2005

Fundamentals of OpenGl and Glut Today we will go through the basics of a minimal OpenGl Glut project, explaining the role of each piece of the code.

#include Includes gl.h and glu.h. Contains all the Glut constant definitions Contains all the Glut function declarations Put glut.h in the GL sub-directory of your compilers include directory

main The main function takes two (optional) parameters int argc char* argv[] or char** argv argc is the number of parameters passed to the main function argv[] is an array of strings containing those parameters

glutInit glutInit initializes the GLUT library. It takes two parameters from the main function. The declaration of glutInit is void glutInit(int *argcp, char **argv); In addition to initializing the GLUT library, glutInit will negociate a session with the window system.

glutCreateWindow Creates a top-level window Declaration: int glutCreateWindow(char *name); name is registered with the windowing system and also is used as a lable for the window. The integer returned is an id to identify the window in a multi-window situation.

glutDisplayFunc glutDisplayFunc sets the display callback for the current window. Declaration void glutDisplayFunc(void (*func)(void)); This might look odd to you. Let’s review function pointers.

Function Pointers In C++ you cannot pass a function in as a parameter to another function. Instead, C++ allows you to pass in a pointer to the function. Lets review function pointers. Here is and example:

#include using namespace std; void call(int (*func)(int i), int i) { cout << func(i) << endl; } int square(int i) { return i*i; } int main() { call(square, 3); return 0; }

init() The init() function is not a GLUT or GL function. It is our own customed made function which contains the code to set up the OpenGL environment. Typically, in this function we pu these lines like these glClearColor(1.0,1.0,1.0,1.0); glColor3f(1.0,0.0,0.0);

glutMainLoop() Declaration void glutMainLoop(void); glutMainLoop enters the GLUT event processing loop. This routine should be called at most once in a GLUT program. Once called, this routine will never return. It will call as necessary any callbacks that have been registered

glPointSize Declaration void glPointSize( GLfloat size ) specify the diameter of rasterized points in pixels

Lines A Simple line glBegin(GL_LINES); glVertex2f(-1.0,0.0); glVertex2f( ); glEnd();

Line Width Declaration void glLineWidth( GLfloat width ) Specifies the width of rasterized lines. The width is in pixels The default is one.

Lines GL_LINES works with pairs of consecutive points. If you give it three points, it will ignore the third. To connect three, use GL_LINE_STRIPS This has other properties too.

Line Strips glBegin(GL_LINE_STRIP); glVertex2f(-1.0,0.0); glVertex2f(0.0,-1.0); glVertex2f(1.0,0); glEnd();

Line Strips In general, GL_LINE_STRIP will start at the first point, draw a lines segment to the next point, then to the next all the way to the last point. It will NOT however, connect the last point back to the first point. For this you need GL_LINE_LOOP

Line Loops glBegin(GL_LINE_LOOP); glVertex2f(-.5.0,0.0); glVertex2f(0.0,-.5.0); glVertex2f(.5.0,0.0); glEnd();

Experiment glBegin( PARAMETER GOES HERE ); glVertex2f(-.5.0,0.0); glVertex2f(0.0,-.5.0); glVertex2f(.5.0,0.0); glEnd(); Try the above code with GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP AND GL_POLYGON

QUADS GL_QUADS takes points four at a time and makes quadrilaterals out of them.

TRIANGLES GL_TRIANGLES takes points three at a time and makes triangles out of them out of them.

Other Types Look in the book at GL_TRIANGLE_STRIP GL_QUAD_STRIP GL_TRIANGLE_FAN