Click here to load reader
View
107
Download
2
Embed Size (px)
Citation preview
OpenGL ProgrammingSession I
OpenGL
● Cross Language, Cross platform application programming interface
● 2D & 3D Graphics rendering
● Interacts with Graphics Processing Unit
● Hardware accelerated rendering
Linux opengl architecture
glClearColor
● Specify clear values of the color buffers
● void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
glClear
● Clears the buffer to preset values
● void glClear(GLbitfield mask)
● Mask values are as follows,– GL_COLOR_BUFFER_BIT
– GL_DEPTH_BUFFER_BIT
– GL_STENCIL_BUFFER_BIT
glGenBuffers
● Generates buffer object names
● void glGenBuffers(GLsizei n, GLuint *buffers);
– Specifies number of buffer object names to be generated
– Specifies an array in which the generated buffer objects names are stored.
● glIsBuffer
– GLboolean glIsBuffer(GLuint buffer);
– determines if a name corresponds to the buffer object
● glDeleteBuffers
– Cleans up buffer object names
–
glBindBuffer
● Binds a named buffer object
● void glBindBuffer(GLenum target, GLuint buffer);
● Target– Target to which the buffer object is bound
● Buffer– Specifies the name of the object
Buffer Target & Purpose
Buffer Binding Target Purpose
GL_ARRAY_BUFFER Vertex Attributes
GL_ATOMIC_COUNTER_BUFFER Atomic Counter Storage
GL_COPY_READ_BUFFER Buffer Copy Source
GL_COPY_WRITE_BUFFER Buffer Copy Destination
GL_DISPATCH_INDIRECT_BUFFER Indirect compute dispatch commands
GL_DRAW_INDIRECT_BUFFER Indirect Command arguments
GL_ELEMENT_ARRAY_BUFFER Vertex Array Indices
GL_PIXEL_PACK_BUFFER Pixel Read Target
GL_PIXEL_UNPACK_BUFFER Texture Data Source
GL_QUERY_BUFFER Query Result Buffer
GL_SHADER_STORAGE_BUFFER Read-write storage for shaders
GL_TEXTURE_BUFFER Texture Data buffer
GL_TRANSFORM_FEEDBACK_BUFFER Transform Feedback Buffer
GL_UNIFORM_BUFFER Uniform Block Storage
glBufferData
● Creates & Initializes a buffer object's data store
● void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage).
● Target – To which buffer object is bound
● Buffer – name of the buffer object
● Size – in bytes of buffer object's data store
● Data – Pointer to data that will be copied into data store.
● Usage – Pattern of data store
Data store pattern
Pattern Description
STREAM Modified once and used at most a few times
STATIC Modified once and used many times
DYNAMIC Modified repeatedly and used many times
DRAW Modified by application and used as source for GL drawing
READ Modified by reading data from GL, used to return that data queried by application
COPY Reading data from GL, used as a source for GL drawing
glUseProgram
● Installs a program objects as part of current rendering state
● void glUseProgram(GLuint program);
● Program– Specifies the handle of program object whose executables are to be used as part of current rendering state.
● GlDeleteProgram– Deletes a program object
glEnableVertexAttribArray
● Enable / Disable a generic vertex attribute array
● void glEnableVertexAttribArray(GLuint index);
● void glDisableVertexAttribArray(GLuint index);
● index– Specifies the index of the generic vertex attributes
●
glVertexAttribPointer
● Define an array of generic vertex attribute data
● void glVertexAttribPointer( GLuint index,GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer);
glDrawArrays
● Render primitives from array data
● void glDrawArrays(GLenum mode, GLint first, GLsizei count);
● mode
– Specifies what kind of primitives to render
● First
– Specifies the starting index in the enables arrays
● Count
– Specifies the number of indices to be rendered.