Programming Concepts. Derive a new class from Activity of the framework Prepare the data beforehand, e.g., vertices, colours, normal vectors, texture.

Slides:



Advertisements
Similar presentations
Stupid OpenGL Shader Tricks
Advertisements

POST-PROCESSING SET09115 Intro Graphics Programming.
Android basics. About Android Linux based operating system Open source Designed for handheld devices Developed by Android Inc. Google (2005) Open Handset.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit
CS378 - Mobile Computing 3D Graphics.
 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.
Cosc 5/4730 OpenGL ES An introduction. OpenGL ES GL was first developed by SGI as a priority graphics language – OpenGL was developed initially by SGI.
Lecture Series on Android Programming Lecturer: Prof.Luqun Li Teaching Assistants: Fengyou Sun, Haijun Yang, Ting.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
How Inflation Works!. Examine the following code public class MainActivity extends Activity public void onCreate(Bundle savedInstanceState)
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
Geometric Objects and Transformations. Coordinate systems rial.html.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
CS 418: Interactive Computer Graphics Introduction to WebGL: HelloTriangle.html Eric Shaffer.
OpenGL Shading Language (Advanced Computer Graphics) Ernest Tatum.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
Real-Time High Quality Rendering CSE 291 [Winter 2015], Lecture 4 Brief Intro to Programmable Shaders
1 Graphics CSCI 343, Fall 2015 Lecture 4 More on WebGL.
CS 480/680 Intro Dr. Frederick C Harris, Jr. Fall 2014.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
1 3D API OPENGL ES v1.0 Owned by Silicon Graphics (SGL) Control was then transferred to Khronos Group Introduction.
Image Synthesis Rabie A. Ramadan, PhD 4. 2 Review Questions Q1: What are the two principal tasks required to create an image of a three-dimensional scene?
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
OpenGL-ES 3.0 And Beyond Boston Photo credit :Johnson Cameraface OpenGL Basics.
2009 GRAPHICS : PROJECT 1 BASED ON DX9 BASICS. Documented by Dongjoon Kim SNU CS Ph.D Course Student Contact : NOTE.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Programming with OpenGL Part 2: Complete Programs Ed Angel Professor.
CS378 - Mobile Computing 3D Graphics.
A UGMENTED F UTURE OF M OBILE R EALITY Oleg Novosad Mobile / Web / Game Engineer.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
Mobile & Casual Gaming OpenGL ES Intro. /red/chapter03.html.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Google VR (gvr) CardBoard and DayDream With OpenGL
GUI Programming Fundamentals
Real-Time Rendering Buffers in OpenGL 3.3
The Basics: HTML5, Drawing, and Source Code Organization
Graphics Processing Unit
Introduction to OpenGL
The Graphics Rendering Pipeline
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming 3D Graphics
Chapter VI OpenGL ES and Shader
Graphics Processing Unit
Introduction to Shaders
Programming with OpenGL Part 2: Complete Programs
Programming with OpenGL Part 3: Shaders
Programming with OpenGL Part 2: Complete Programs
Computer Graphics Introduction to Shaders
03 | Creating, Texturing and Moving Objects
Introduction to OpenGL
Language Definitions Chap. 3 of Orange Book.
Frame Buffers Fall 2018 CS480/680.
OpenGL-Rendering Pipeline
Opengl implementation
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

Programming Concepts

Derive a new class from Activity of the framework Prepare the data beforehand, e.g., vertices, colours, normal vectors, texture coordinates, etc. Create your Renderer Check GPU version Prepare vertex shader program(s) Prepare fragment shader program(s) Compile and link your GPU program(s) Implement methods: onSurfaceCreated, onSurfaceChanged, onDrawFrame, etc.

Create a class derived from Activity public class MainActivity extends Activity { \\body }

Define OnCreate Method (Pseudo code) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); create GLSurfaceView supportsEs2 = Check if the system supports OpenGL ES 2.0. if (supportsEs2) { Set GLSurfaceView.setEGLContextClientVersion for OpenGL ES 2.0. Set GLSurfaceView.setRenderer for rendering } else { // This is where you could create an OpenGL ES 1.x compatible // renderer if you wanted to support both ES 1 and ES 2. return; } setContentView(mGLSurfaceView); }

Define onCreateOptionsMenu // Inflate the menu resource (defined in XML) into the Menu provided in the public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; }

Renderer public class MyRenderer implements GLSurfaceView.Renderer { // three matrices: projection, view, model // vertices // handles for passing information: // matrix, position, color }

Initialization of Data final float[] myVerticesData = { X0, Y0, Z0, // position in 3Dimensional Space R0, G0, B0, A0//red,green,blue,alpha X1, Y1, Z1, R1, G1, B1, A1 X2, Y2, Z2, R2, G2, B2, A2 //more if more vertices };

Initialization of a Buffer mMyVerticesBuffer = ByteBuffer.allocateDirect( myVerticesData.length*mBytesPerFloat ).order( ByteOrder.nativeOrder() ).asFloatBuffer(); mMyVerticesBuffer.put( myVerticesData ).position(0);

onSurfaceCreated method // called at the start of rendering // or the OpenGL ES drawing context has to be recreated public void onSurfaceCreated(GL10 glUnused, EGLConfig config) { 1.set the LookAtMatrix of the Camera 2.prepare a vertexShaderProgram 3.prepare a fragmentShaderProgram 4.Check vertexShader( vertexShaderProgram ) 5.Check fragmentShader( fragmentShaderProgram ) 6.Create a GPU program for the vertex and fragment programs 7.Link GPU program(s) 8.Get the GPU program handles of the parameters 9.Use the GPU program }

onSurfaceChanged method The onSurfaceChanged() method is called when the surface changes size. Possible functions: – set the OpenGL viewport – set the camera

onDrawFrame method The onDrawFrame() method is called every frame. It is responsible for drawing the scene. Usually clear the framebuffer and then call functions to draw the current scene.