OpenGL. 1 OpenGL OpenGL 1.2 3D. (euske) 1. Client-Server Model OpenGL

Similar documents
Lecture 2 2D transformations Introduction to OpenGL

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Lecture 07: Buffers and Textures

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

VR-programming tools (procedural) More VRML later in this course! (declarative)

OpenGL An introduction

Lighting and Texturing

Lecture 4 of 41. Lab 1a: OpenGL Basics

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

MB86290 Series 3D Graphics Library V02 User Manual The core API

Computer graphics MN1

Graphics. Texture Mapping 고려대학교컴퓨터그래픽스연구실.

Image Rendering. Rendering can be divided into three sub-problems. Image Formation The hidden surface problem visibility determination steps

Introduction to OpenGL

A display list is a group of OpenGL commands that have been stored for later execution.

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

Precept 2 Aleksey Boyko February 18, 2011

三維繪圖程式設計 3D Graphics Programming Design 第七章基礎材質張貼技術嘉大資工系盧天麒

Outline. Other Graphics Technology. OpenGL Background and History. Platform Specifics. The Drawing Process

Graphics and Computation Introduction to OpenGL

Computer Graphics. Chapter 10 Three-Dimensional Viewing

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

3D Graphics and API with OpenGL

cs123 Lab 3 OpenGL Part One 1 Introduction 2 OpenGL Basics 2.2 The Rendering Pipeline 2.1 The CPU and the GPU 2.3 Basic Syntax of OpenGL commands

Chapter 7 Display Lists

Computer Graphics Programming

Introduction to OpenGL

Introduction to OpenGL Transformations, Viewing and Lighting. Ali Bigdelou

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

Basic Graphics Programming

Textures. Texture Mapping. Bitmap Textures. Basic Texture Techniques

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

Visualizing Molecular Dynamics

Lectures OpenGL Introduction

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

1 (Practice 1) Introduction to OpenGL

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

An Interactive Introduction to OpenGL Programming

Understand how real-world lighting conditions are approximated by OpenGL

Introduction to OpenGL

Lectures Display List

Lectures Transparency Case Study

Exercise 1 Introduction to OpenGL

Computer Graphics. Bing-Yu Chen National Taiwan University

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Computer Graphics Course 2005

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

Matrix-Rechnung I ' z =... Universität Frankfurt

Computer Graphics. Transformations. CSC 470 Computer Graphics 1

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

OpenGL: A Practical Introduction. (thanks, Mark Livingston!)

Advanced Computer Graphics (CS & SE )

Getting Started. Overview (1): Getting Started (1): Getting Started (2): Getting Started (3): COSC 4431/5331 Computer Graphics.

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

An Interactive Introduction to OpenGL and OpenGL ES Programming. Ed Angel Dave Shreiner

Display Lists in OpenGL

Transformation, Input and Interaction. Hanyang University

Scientific Visualization Basics

12. Selection. - The objects selected are specified by hit records in the selection buffer. E.R. Bachmann & P.L. McDowell MV 4202 Page 1 of 13

Lighting. Chapter 5. Chapter Objectives. After reading this chapter, you'll be able to do the following:

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

/opengl/docs/man_pages/hardcopy/gl/html/gl/

Computer graphics MN1

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

OpenGL: Open Graphics Library. Introduction to OpenGL Part II. How do I render a geometric primitive? What is OpenGL

OpenGL. What it is: Client-server model Network transparent. Computer Graphics

Computer Graphics Lighting

Computer Graphics Lighting. Why Do We Care About Lighting?

Computer Graphics 1 Computer Graphics 1

Introduction to Computer Graphics with OpenGL/GLUT

C OMPUTER G RAPHICS Thursday

Graphics Pipeline & APIs

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

Grafica Computazionale

Introduction to OpenGL and 3D Graphics

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Texture Mapping. Mike Bailey.

2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

三維繪圖程式設計 3D Graphics Programming Design 第三章三維繪圖狀態設定和幾何元件繪製嘉大資工系盧天麒

Graphics Pipeline & APIs

Introduction to OpenGL. CSCI 4229/5229 Computer Graphics Fall 2012

Computer Graphics. Chapter 7 2D Geometric Transformations

Assignment #6 2D Vector Field Visualization Arrow Plot and LIC

Graphics Programming

CONTENTS... 1 OPENGL REFERENCE MANUAL...

9. Display Lists. Display lists optimize performance by caching and saving end results, thus avoiding many intermediate steps for

Viewing Transformation

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

Computer Graphics. Basic 3D Programming. Contents

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Letterkenny Institute of Technology

OpenGL Transformations

Transcription:

OpenGL (euske) 1 OpenGL - 1.1 OpenGL 1. Client-Server Model 2. 3. 1.2 3D OpenGL (Depth-Buffer Algorithm Z-Buffer Algorithm) (polygon ) ( rendering) Client-Server Model X Window System ( GL ) GL (Indy O 2 ) X (GLX) X GL X X GL X (drawable : ) OpenGL ( ) ( (texture mapping) (antialiasing) ) 1. GL 2. GL (primitive) ( ) ( ) 3. ( ) 4. 3D 2D (clip) ( ) 5. 6. (flat shading) (smooth shading) OpenGL (glow shading) OpenGL 3D 1

(diffuse) (specular) (ambient) 2 ( ) ( ) OpenGL 2D 3D 2.1 OpenGL 3 1. OpenGL gl prefix 2. OpenGL Utility (GLU) bitmap glu prefix 3. OpenGL X (GLX) X Window System glx prefix GL void gl < FUNCTION > {#}{s i f d}{v} (...); ( ) < F UNCT ION > #( ) s, i, f, d glvertex3f void glvertex3f (GLfloat x, GLfloat y, GLfloat z); v ( ) void glvertex3fv (GLfloat v[3]); GLfloat GL float < gl.h > s GLshort short (16bit) i GLint int (32bit) f GLfloat float(32bit) d GLdouble double(64bit) GLenum 2

2.2 (primitive ) (glbegin) (glvertex) void glbegin (GLenum mode 1 ); void glend (void); void glfrontface (GLenum mode 2 ); void glvertex3{s i f d} (GL?? x, GL?? y, GL?? z); void glvertex3{s i f d}v (GL?? v[3]); void glnormal3{s i f d} (GL?? x, GL?? y, GL?? z); void glnormal3{s i f d}v (GL?? v[3]); glvertex2 glvertex4 glnormal3* glvertex3* glvertex3* gltexcoord2* ( ) glvertex3* 1 1 glnormal3* glvertex3* glnormal3* 1. glbegin(type); GL POLYGON 4 (convex) 2. glnormal3*(..); ( ) 3. (a) gltexcoord2*(..); (b) glvertex3*(..); 4. glend(); glfrontface GL CW GL CCW ( ) 1 mode: GL POLYGON, GL QUADS, GL TRIANGLES.. 2 mode: GL CW, GL CCW 3

2.3 OpenGL 3D 2 void glmatrixmode (GLenum mode 3 ); void glloadidentify (void); void gltranslate{f d} (GL?? x, GL?? y, GL?? z); void glrotate{f d} (GL?? degree, GL?? x, GL?? y, GL?? z); void glscale{f d} (GL?? x, GL?? y, GL?? z); void glulookat (GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz); void glfrustum (GLdouble left, GLdouble righgt, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); void glviewport (GLint x, GLint y, GLsizei width, GLsizei height); void glpushmatrix (void); void glpopmatrix (void); glmatrixmode gltranslate*, glrotate*, glscale* glulookat ( ) glfrustum glviewport glpushmatrix, glpopmatrix 2.4 OpenGL 8 GL LIGHT0 GL LIGHT7 void gllight{i f} (GLenum light 4, GLenum pname, GL?? param..); void gllight{i f}v (GLenum light, GLenum pname, GL?? v[ ]); void glmaterial{i f} (GLenum face 5, GLenum pname, GL?? param..); void glmaterial{i f}v (GLenum face, GLenum pname, GL?? v[ ]); void glenable (GLenum light); gllight* ( ) 3 mode: GL MODELVIEW, GL PROJECTION, GL TEXTURE 4 light: GL LIGHT0, GL LIGHT1,..., GL LIGHT7 5 face: GL FRONT, GL BACK, GL FRONT AND BACK 4

(pname) GL AMBIENT 4 (R, G, B, A) GL DIFFUSE 4 (R, G, B, A) GL SPECULAR 4 (R, G, B, A) GL POSITION 4 (x, y, z, w) GL SPOT DIRECTION 3 (vx, vy, vz) GL SPOT CUTOFF 1 (degree) GL POSITION w w = 0 ( ) w 0 180 RGBA A glenable 6 glmaterial* ( ) (pname) GL AMBIENT 4 (R, G, B, A) GL DIFFUSE 4 (R, G, B, A) GL AMBIENT AND DIFFUSE 4 (R, G, B, A) GL SPECULAR 4 (R, G, B, A) GL SHININESS 1 (shininess) GL EMISSION 4 (degree) ( hilite) ( ) 2.5 void glteximage2d (GL TEXTURE 2D, GLint level, GLint components, GLsizei width, GLsizei height, GLint border, GL RGB, GL UNSIGNED BYTE, const GLvoid* pixels); void gltexparameter{i f} (GL TEXTURE 2D, GLenum pname 7, GL?? param 8 ); void gltexcoord2{s i f d} (GL?? s, GL?? t); void gltexcoord2{s i f d}v (GL?? v[2]); OpenGL GLubyte teximagename[imagewidth][imageheight][3]; 6 glenable OpenGL 7 pname: GL TEXTURE WRAP S, GL TEXTURE WRAP T, GL TEXTURE MAG FILTER, GL TEXTURE MIN FILTER 8 param: GL CLAMP, GL REPEAT, GL NEAREST, GL LINER 5

glteximage2d GL RGB width, height 3 [x][y][0],[x][y][1], [x][y][2] Red, Green, Blue (0, 0)-(1, 1) (s, t) glvertex3* gltexcoord2* gltexparameter* GL TEXTURE MAG FILTER, GL TEXTURE MIN FILTER GL NEAREST GL LINER gltexparameter* GL TEXTURE WRAP S, GL TEXTURE WRAP T GL REPEAT gltexcoord2* 2.6 OpenGL (glbegin, glend, glvertex3*, gllight* ) 2 ( ) void glnewlist (GLuint list, GLenum mode 9 ); void glendlist (void); void glcalllist (GLuint list); 1. glnewlist ( ) 2. GL COMPILE GL COMPILE AND EXECUTE 3. glendlist 4. glcalllist glnewlist glendlist 2.7 void glclear (GLbitfield mask 10 ); void glclearcolor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void glcleardepth (GLclampd depth); void glshademodel (GLenum model 11 ); 9 mode: GL COMPILE, GL COMPILE AND EXECUTE 10 mask: GL COLOR BUFFER BIT, GL DEPTH BUFFER BIT 11 model: GL FLAT, GL SMOOTH 6

void glflush (void); void glenable (GLenum enable); void gldisable (GLenum enable); glclear glclearcolor, glcleardepth glshademodel glflush GL glenable, gldisable OpenGL / OpenGL : glenable(gl_lighting); glenable(gl_normalize); glenable(gl_texture_2d); glenable(gl_depth_test); // // // // Depth-Buffer gltexenv(gl_texture_env, GL_TEXTURE_ENV_MODE, GL_MODULATE); // gllightmodelf(gl_light_model_two_side, GL_TRUE); // glshademodel(gl_flat); glclearcolor(0.0, 0.0, 0.0, 1.0); glcleardepth(0.0); glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); // // // 0 3 - GLX OpenGL X XVisualInfo* glxchoosevisual (Display* dpy, int screen, int* attriblist); int glxgetconfig (Display* dpy, XVisualInfo* vis, int attrib, int* value); GLXContext glxcreatecomtext (Display* dpy, XVisualInfo* vis, GLXContext sharelist, Bool direct); Bool glxmakecurrent (Display* dpy, GLXDrawable draw, GLXContext ctx); GLXPixmap glxcreateglxpixmap (Display* dpy, XVisualInfo* vis, Pixmap pixmap); void glxswapbuffers (Display* dpy, Window window); GLX 1. glxchoosevisual Visual 2. glxcreatecontext 3. 4. X 5. Expose OpenGL 7

glxchoosevisual GL glxcreatecontext glxmakecurrent OK glxswapbuffers GLX DOUBLEBUFFER GLX : int list[] = {GLX_RGBA, // RGB GLX_RED_SIZE, 1, // Red, Green, Blue GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1, // GLX_DOUBLEBUFFER, // None}; // XVisualInfo* myvisual; GLXContext mycontext; Display* dpy; Window win; Colormap colmap; mycontext = glxcreatecontext(dpy, myvisual, None, GL_FALSE); // X glxmakecurrent(dpy, win, mycontext); // dpy = XOpenDisplay(NULL); // X myvisual = glxchoosevisual(dpy, 0, list); // colmap = XCreateColormap(...); // win = XCreateSimpleWindow(...); // XSetWMProperties(...); // XMapWindow(...); // /* */... 8