Computer Graphics Vertex Array Object

Slides:



Advertisements
Similar presentations
Chapter 11. Faster Geometry Throughput Presented by Garrett Yeh.
Advertisements

Modeling 靜宜大學資工系 蔡奇偉副教授. 大綱  何謂多邊形?  多邊形的種類  多邊形的正面與反面  填滿多邊形  OpenGL 多邊形相關函式  範例.
Colorings of graphs and Ramsey’s theorem
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
As well as colors, normals, and other vertex data PUSHIN’ GEO TO THE GPU JEFF CHASTINE 1.
1 Finding a shortest vector in a two-dimensional lattice modulo m Theoretical Computer Science, Vol 172, 1997 Gunter Rote 田錦燕95/06/01.
Meshes Dr. Scott Schaefer. 3D Surfaces Vertex Table.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
Drawing Geometric Objects
10215: The Largest/Smallest Box... ★ 題組: Problem Set Archive with Online Judge 題號: 10215: The Largest/Smallest Box... 解題者:張維珊 解題日期: 2006 年 4 月 17 日 題意:
桁架分析.
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Introduction to OpenGL Joseph Kider University of Pennsylvania CIS 565 – Fall 2011 (Source: Patrick Cozzi)
3-3 使用幾何繪圖工具 Flash 的幾何繪圖工具包括線段工具 (Line Tool) 、橢圓形工具 (Oval Tool) 、多邊星形 工具 (Rectangle Tool) 3 種。這些工具畫出 來的幾何圖形包括了筆畫線條和填色區域, 將它們適當地組合加上有技巧地變形與配 色, 不但比鉛筆工具簡單,
: IIUC HexWorld ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11092: IIUC HexWorld 解題者:江秀桂 解題日期: 2007 年 3 月 6 日.
2005/7 Linear system-1 The Linear Equation System and Eliminations.
OpenGL and WebGL Drawing Functions CSCI 440 Day Five.
:Count the Trees ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 10007:Count the Trees 解題者:楊家豪 解題日期: 2006 年 3 月 題意: 給 n 個點, 每一個點有自己的 Label,
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.
1 柱體與錐體 1. 找出柱體與錐體的規則 2. 柱體的命名與特性 3. 柱體的展開圖 4. 錐體的命名與特性 5. 錐體的展開圖
Basic OpenGL Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, September 10, 2003.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Triangulation Introduction to Computer Graphics and Animation (Principle of Computer Graphics) Rattapoom Waranusast.
Speeding Up Rendering After Deciding What to Draw.
2 COEN Computer Graphics I Introductions n Brad Grantham lecturer lab dude n Dave Shreiner lecturer slave driver.
Computer Graphics CS 385 January 31, Fractals Some definitions Object which is self-similar at all scales. Regardless of scale the same level of.
Interactive Computer Graphics CS 418 – Spring 2015 Mesh Rendering, Transformation, Camera Viewing and Projection in OpenGL TA: Zhicheng Yan Sushma S Kini.
State Management and Drawing Geometry Objects
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.
OPENGL INTRODUCTION 林宏祥 2014/10/06. 此投影片已被稍微簡化過,跟今日課堂上的內容不太一樣。 如果想要看更詳細說明的人,請參考每頁投影片下面的『備忘稿』
Computer Graphics Bing-Yu Chen National Taiwan University.
OpenGL Shader Language Vertex and Fragment Shading Programs.
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
What are Computer Graphics Basically anything that is on you Monitor – This includes the text that you will see Text isn’t Advanced Graphics But…. Understanding.
OpenGL Vertex Arrays OpenGL vertex arrays store vertex properties such as coordinates, normal vectors, color values and texture coordinates. These properties.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
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,
CIS 681 Review: OpenGL. CIS 681 Command Syntax OpenGL commands start with a gl. This is followed by the base command such as Color. Followed by the number.
OpenGL Objects Finalised. Debugging Tip For Debugging your applications remember: glGetError(); gluErrorString(); Don’t use these in release code (the.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Computer Graphics Lecture 34. OpenGL Programming II Taqdees A. Siddiqi
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Pushin’ Geo to the GPU As well as colors, normals, and other vertex data Made by Jeff Chastine, Modified by Chao Mei Jeff Chastine.
CSC Graphics Programming
The Human Visual System vs The Pinhole camera
Real-Time Rendering Buffers in OpenGL 3.3
Real-Time Rendering Geometry and Buffers
Introduction to OpenGL
Programming with OpenGL Part 2: Complete Programs
Objectives Simple Shaders Programming shaders with GLSL
OpenGL ARB Superbuffers
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Screen Space & World Space
Programming with OpenGL Part 4: Color and Attributes
Chapter VI OpenGL ES and Shader
Building Models Ed Angel Professor Emeritus of Computer Science
Isaac Gang University of Mary Hardin-Baylor
Vertex Array Objects & Buffer Objects
Computer Graphics Practical Lesson 8
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 4: Color and Attributes
Programming with OpenGL Part 2: Complete Programs
Mickaël Sereno Shaders Mickaël Sereno 25/04/2019 Mickaël Sereno -
Introduction to OpenGL
Computer Graphics Transformations
Mickaël Sereno Graphics Memory Mickaël Sereno 11/07/2019 Mickaël Sereno -
Opengl implementation
Presentation transcript:

Computer Graphics Vertex Array Object Ming-Te Chi Department of Computer Science,  National Chengchi University 2016

Bottleneck in rendering Application Client side GPU Server side

OpenGL Geometric Primitives All geometric primitives are specified by vertices GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_POLYGON GL_POINTS GL_QUADS GL_TRIANGLES GL_QUAD_STRIP GL_TRIANGLE_STRIP OpenGL中,3D幾何物體均以頂點做為基礎 一維的物體 點: 以一個頂點標示其位置 二維的物體 線,以兩個以上的頂點表示出線段 三維的表面,可以三個頂點決定出一個三角面,或四個頂點表示個四角面,或多邊形 另外,也可串接多個同樣幾何物體的strip表示法 GL_TRIANGLE_FAN

Immediate mode glBegin(GLenum mode); … glVertex3f(…); glEnd(); Application Client side GPU Server side glBegin(); … glEnd();

Display lists Preprocess Gluint mylist; glNewList(mylist, GL_COMPILE); some glcode glEndList(); Display glCallList(mylist); deprecated in opengl 3.1

Vertex Arrays void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); define an array of vertex data void glDrawArrays(GLenum mode, GLint first, GLsizei count); render primitives from array data deprecated in opengl 3.1

Vertex Arrays- example const int SMALL_STAR=100; Glfloat vSmallStars[SMALL_STAR*2]; //assign position into vSmallStars … glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, vSmallStars); glDrawArrays(GL_POINTS, 0, SMALL_STAR); 接下來還有vertex buffer object

After OpenGL 3.3

Vertex Array Object (VAO) In modern OpenGL, VAO with VBO is the main way to render primitive. A VAO is an OpenGL Object that encapsulates all of the state needed to specify vertex data. Note that VAOs do not contain the arrays themselves; the arrays are stored in Buffer Objects http://www.opengl.org/wiki/Vertex_Array_Objects#Vertex_Array_Object A Vertex Array Object (VAO) is an OpenGL Object that encapsulates all of the state needed to specify vertex data (with one minor exception noted below). They define the format of the vertex data as well as the sources for the vertex arrays. Note that VAOs do not contain the arrays themselves; the arrays are stored in Buffer Objects (see below). The VAOs simply reference already existing buffer objects. Vertex buffer object (VBO) creates "buffer objects" for vertex attributes in high-performance memory on the server side and provides same access functions to reference the arrays, which are used in vertex arrays, such as glVertexPointer(), glNormalPointer(), glTexCoordPointer(), etc.

VAO – triangle example // An array of 3 vectors which represents 3 vertices static const GLfloat g_vertex_buffer_data[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; ShaderInfo shaders[] = { { GL_VERTEX_SHADER, "triangles.vert" }, { GL_FRAGMENT_SHADER, "triangles.frag" }, { GL_NONE, NULL } }; GLuint program = LoadShaders(shaders); glUseProgram(program);

// Generate and Bind VAO GLuint VertexArrayID; glGenVertexArrays(1, &VertexArrayID); glBindVertexArray(VertexArrayID); // This will identify our vertex buffer GLuint vertexbuffer; // Generate 1 buffer, put the resulting identifier in vertexbuffer glGenBuffers(1, &vertexbuffer); // The following commands will talk about our 'vertexbuffer' buffer glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); // Give our vertices to OpenGL. glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW); Application Client side GPU Server side Glfloat [] VAO VBO

VAO in display() GPU - Server side VAO program VBO Vertex shader glUseProgram(program); // 1st attribute buffer : vertices glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer(    0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.    3, // size    GL_FLOAT,  // type    GL_FALSE,  // normalized?    0,  // stride    (void*)0 // array buffer offset ); glEnableVertexAttribArray(0);   // Draw the triangle ! Starting from vertex 0; 3 vertices total -> 1 triangle glDrawArrays(GL_TRIANGLES, 0, 3); glDisableVertexAttribArray(0); VBO 001010101010101010… Vertex shader in vec3 position in vec3 color Omit some detail about program and shader