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.

Slides:



Advertisements
Similar presentations
Programming with OpenGL - Getting started - Hanyang University Han Jae-Hyek.
Advertisements

Computer Graphics - Graphics Programming -
Chapter 2: Graphics Programming
Pemrograman OpenGL Dasar
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,
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
OpenGL and Projections
30/1/2006Based on: Angel (4th Edition) & Akeine-Möller & Haines (2nd Edition)1 CSC345: Advanced Graphics & Virtual Environments Lecture 1: Introduction.
Programming with OpenGL Part 0: 3D API March 1, 2007.
Programming with OpenGL Part 1: Background Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics 1.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
Computer Graphics Bing-Yu Chen National Taiwan University.
ISC/GAM 4322 ISC 6310 Multimedia Development and Programming Unit 1 Graphics Systems and Models.
Graphics Systems and Models Chapter 1. CS 480/680 2Chapter 1 -- Graphics Systems and Models Introduction: Introduction: Computer Graphics Computer Graphics.
Demetriou/Loizidou – ACSC330 – Chapter 2 Graphics Programming Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science Frederick Institute.
CSC 461: Lecture 41 CSC461: Lecture 4 Introduction to OpenGL Objectives: Development of the OpenGL API OpenGL Architecture -- OpenGL as a state machine.
Graphics Architectures & OpenGL API Introduction Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Programming with OpenGL Part 1: Background
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Graphics Systems and OpenGL. Business of Generating Images Images are made up of pixels.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
1 Figures are extracted from Angel's book (ISBN x) The Human Visual System vs The Pinhole camera Human Visual System Visible Spectrum Pinhole.
Introduction to GL Geb Thomas. Example Code int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
Introduction to OpenGL Week 1 David Breen Department of Computer Science Drexel University Based on material from Ed Angel, University of New Mexico CS.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Programming with OpenGL Review.
1 Chapter 2: Graphics Programming Bryson Payne CSCI 3600 NGCSU.
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.
Chun-Yuan Lin Introduction to OpenGL 2015/12/19 1 CG.
Pemrograman OpenGL Dasar Pertemuan 5 Hand out Komputer Grafik.
NoufNaief.net TA: Nouf Al-harbi.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
Computer Graphics Lab 1 OpenGL.
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Chapter 1 Graphics Systems and Models Models and Architectures.
Introduction to Graphics Programming. Graphics API.
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.
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.
Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran
Programming with OpenGL Part 1: Background
Graphics Systems and Models
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
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
גרפיקה ממוחשבת: מבוא ל-OpenGL
Programming with OpenGL Part 1: Background
Introduction to OpenGL
Models and Architectures
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 1: Background
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

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 and glu32.lib should be in the lib folder for VC++ Opengl32.lib and glu32.lib should be in the lib folder for VC++ gl.h and glu.h should be in a folder called GL under the include folder for VC++ gl.h and glu.h should be in a folder called GL under the include folder for VC++ Get glut32.lib, glut32.dll and glut.h from the course homepage and put them in the same places as the other files Get glut32.lib, glut32.dll and glut.h from the course homepage and put them in the same places as the other files

Using OpenGL in Visual C++ Fire up visual studio Fire up visual studio Create a new project as the following: File  New  Project (input your project name, then a directory (workspace) with the same name will be built)  Win32 Console Application  An Empty Application Create a new project as the following: File  New  Project (input your project name, then a directory (workspace) with the same name will be built)  Win32 Console Application  An Empty Application

Using OpenGL in Visual C++ In the workspace click on “File View” to access (expand) the source code tree In the workspace click on “File View” to access (expand) the source code tree In “Source Files”, add in the source code (*.c files) In “Source Files”, add in the source code (*.c files) Select Project  Settings  Link and in “Object/library modules” add “Opengl32.lib glu32.lib glut32.lib” Select Project  Settings  Link and in “Object/library modules” add “Opengl32.lib glu32.lib glut32.lib” Press “F7” to build “your_project.exe” Press “F7” to build “your_project.exe”

Objects are usually defined by a set of vertices Objects are usually defined by a set of vertices The following code fragment defines a triangular polygon in OpenGL The following code fragment defines a triangular polygon in OpenGL glBegin(GL_POLYGON); glBegin(GL_POLYGON); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,1.0,0.0); glVertex3f(0.0,1.0,0.0); glVertex3f(0.0,0.0,1.0); glVertex3f(0.0,0.0,1.0); glEND(); glEND();

Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 A Simple Program Generate a square on a solid background

Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 simple.c #include void mydisplay(){ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } int main(int argc, char** argv){ glutCreateWindow("simple"); glutDisplayFunc(mydisplay); glutMainLoop(); }

7 Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 simple.c revisited In this version, we shall see the same output but we have defined all the relevant state values through function calls using the default values In this version, we shall see the same output but we have defined all the relevant state values through function calls using the default values In particular, we set In particular, we set Colors Colors Viewing conditions Viewing conditions Window properties Window properties

8 Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 main.c #include #include int main(int argc, char** argv) {glutInit(&argc,argv);glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);glutInitWindowSize(500,500);glutInitWindowPosition(0,0);glutCreateWindow("simple");glutDisplayFunc(mydisplay); init(); glutMainLoop();} includes gl.h define window properties set OpenGL state enter event loop display callback

9 Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 GLUT functions glutInit allows application to get command line arguments and initializes system glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window (the rendering context) gluInitDisplayMode requests properties for the window (the rendering context) RGB color RGB color Single buffering Single buffering Properties logically ORed together Properties logically ORed together glutWindowSize in pixels glutWindowSize in pixels glutWindowPosition from top-left corner of display glutWindowPosition from top-left corner of display glutCreateWindow create window with title “simple” glutCreateWindow create window with title “simple” glutDisplayFunc display callback glutDisplayFunc display callback glutMainLoop enter infinite event loop glutMainLoop enter infinite event loop

10 Angel: Interactive Computer Graphics 4E © Addison- Wesley 2005 init.c void init() { glClearColor (0.0, 0.0, 0.0, 1.0); glColor3f(1.0, 1.0, 1.0); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); } black clear color opaque window fill/draw with white viewing volume

We can define a viewer or camera in a variety of ways We can define a viewer or camera in a variety of ways We can identify four types of necessary specifications: We can identify four types of necessary specifications: Position Position Orientation Orientation Focal length Focal length Film plane Film plane

Light sources can be defined by their location, strength, color, and directionality. Light sources can be defined by their location, strength, color, and directionality. API’s provide a set of functions to specify these parameters for each source. API’s provide a set of functions to specify these parameters for each source. Material properties are characteristics, or attributes, of the objects Material properties are characteristics, or attributes, of the objects such properties are usually defined through a series of function calls at the time that each object is defined. such properties are usually defined through a series of function calls at the time that each object is defined.

8. Graphics Architectures On one side of the API is the application program. On the other is some combination of hardware and software that implements the functionality of the API On one side of the API is the application program. On the other is some combination of hardware and software that implements the functionality of the API Researchers have taken various approaches to developing architectures to support graphics APIs Researchers have taken various approaches to developing architectures to support graphics APIs

Early systems used general purpose computers Early systems used general purpose computers single processing unit single processing unit In the early days of computer graphics, computers were so slow that refreshing even simple images, containing a few hundred line segments, would burden an expensive computer In the early days of computer graphics, computers were so slow that refreshing even simple images, containing a few hundred line segments, would burden an expensive computer

8.1 Display Processors 8.1 Display Processors The earliest attempts to build a special purpose graphics system were concerned primarily with relieving the task of refreshing the display The earliest attempts to build a special purpose graphics system were concerned primarily with relieving the task of refreshing the display

8.2 Pipeline Architectures 8.2 Pipeline Architectures The major advances in graphics architectures parallel closely the advances in workstations. The major advances in graphics architectures parallel closely the advances in workstations. For computer graphics applications, the most important use of custom VLSI circuits has been in creating pipeline architectures For computer graphics applications, the most important use of custom VLSI circuits has been in creating pipeline architectures A simple arithmetic pipeline is shown here: A simple arithmetic pipeline is shown here:

If we think in terms of processing the geometry of our objects to obtain an image, we can use the following block diagram: If we think in terms of processing the geometry of our objects to obtain an image, we can use the following block diagram:

8.3 Transformations 8.3 Transformations Many of the steps in the imaging process can be viewed as transformations between representations of objects in different coordinate systems Many of the steps in the imaging process can be viewed as transformations between representations of objects in different coordinate systems for example: from the system in which the object was defined to the system of the camera for example: from the system in which the object was defined to the system of the camera We can represent each change of coordinate systems by a matrix We can represent each change of coordinate systems by a matrix We can represent successive changes by multiplying (or concatenating) the individual matrices into a single matrix. We can represent successive changes by multiplying (or concatenating) the individual matrices into a single matrix.

8.4 Clipping 8.4 Clipping Why do we Clip? Why do we Clip?

8.5. Projection 8.5. Projection In general three-dimensional objects are kept in three dimensions as long as possible, as they pass through the pipeline. In general three-dimensional objects are kept in three dimensions as long as possible, as they pass through the pipeline. Eventually though, they must be projected into two-dimensional objects. Eventually though, they must be projected into two-dimensional objects. There are various projections that we can implement. There are various projections that we can implement. we can implement this step using 4 x 4 matrices, and, thus, also fit it into the pipeline. we can implement this step using 4 x 4 matrices, and, thus, also fit it into the pipeline.

8.6 Rasterization 8.6 Rasterization Finally, our projected objects must be represented as pixels in the frame buffer. Finally, our projected objects must be represented as pixels in the frame buffer.

8.7 Performance Characteristics 8.7 Performance Characteristics There are two fundamentally different types of processing There are two fundamentally different types of processing Front end -- geometric processing, based on the processing of vertices Front end -- geometric processing, based on the processing of vertices ideally suited for pipelining, and usually involves floating- point calculations. ideally suited for pipelining, and usually involves floating- point calculations. The geometry engine developed by SGI was a VLSI implementation for many of these operations in a special purpose chip. These became the basis for a series of graphics workstations. The geometry engine developed by SGI was a VLSI implementation for many of these operations in a special purpose chip. These became the basis for a series of graphics workstations. Back end -- involves direct manipulation of bits in the frame buffer. Back end -- involves direct manipulation of bits in the frame buffer. Ideally suited for parallel bit processors. Ideally suited for parallel bit processors.

9. Summary In this chapter we have set the stage for our top- down development of computer graphics. In this chapter we have set the stage for our top- down development of computer graphics. Computer graphics is a method of image formation that should be related to classical methods -- in particular to cameras Computer graphics is a method of image formation that should be related to classical methods -- in particular to cameras Our next step is to explore the application side of Computer Graphics programming Our next step is to explore the application side of Computer Graphics programming We will use the OpenGL API We will use the OpenGL API