OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
glutil.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef UTIL_H
22 #define UTIL_H
23 #include "matrix.h"
24 #include "common.h"
25 #include "shader.h"
26 #include <string>
27 #include <sstream>
28 
29  /*
30 Triangles are either drawn in a clockwise or counterclockwise order. Facets that face away from the viewer
31 can be hidden by setting the rasterizer state to cull such facets.
32 */
33 void cull(bool enabled, GLenum front = GL_CCW, GLenum mode = GL_BACK);
34 
35 /*
36 The incoming pixel depth value can be compared with the depth value present in the depth buffer,
37 to determine whether the pixel shall be drawn or not.
38 */
39 void depth_test(bool enabled, GLenum func = GL_LEQUAL);
40 
41 /*
42 The incoming pixel can write to the depth buffer, combined with the depth_test function.
43 */
44 void depth_write(bool enabled);
45 
46 /*
47 Pixels can be drawn using a function that blends the incoming (source) RGBA values with the RGBA
48 values that are already in the frame buffer (the destination values).
49 */
50 void blend_mode(bool enabled, GLenum src = GL_ONE, GLenum dest = GL_ONE, GLenum func = GL_FUNC_ADD);
51 
52 void use_shader(Shader shader);
53 void attribfv(string name, GLsizei num_components, GLsizei stride, GLsizei offset);
54 void unset_attrib(string name);
55 
56 void uniform(string name, const mat4 &v);
57 void uniform(string name, const vec4 &v);
58 void uniform(string name, const vec3 &v);
59 void uniform(string name, const vec2 &v);
60 void uniform(string name, double v);
61 void uniform(string name, float v);
62 void uniform(string name, int v);
63 void uniform(string name, unsigned int v);
64 
65 bool read_file(const std::string &path, std::string &dest);
66 GLuint gen_buffer(GLenum target, GLsizei size, const void *data);
67 GLuint gen_buffer(GLenum target, GLenum usage, GLsizei size, const void *data);
69 
70 #endif
const GLfloat * v
Definition: gl2ext.h:2231
void uniform(string name, const mat4 &v)
Definition: glutil.cpp:97
void depth_test(bool enabled, GLenum func=GL_LEQUAL)
Definition: glutil.cpp:41
Definition: matrix.h:51
void del_buffer(GLuint buffer)
Definition: glutil.cpp:137
void attribfv(string name, GLsizei num_components, GLsizei stride, GLsizei offset)
Definition: glutil.cpp:87
bool read_file(const std::string &path, std::string &dest)
Definition: glutil.cpp:106
void blend_mode(bool enabled, GLenum src=GL_ONE, GLenum dest=GL_ONE, GLenum func=GL_FUNC_ADD)
Definition: glutil.cpp:67
Definition: matrix.h:28
GLenum GLuint GLintptr offset
Definition: gl2ext.h:629
void cull(bool enabled, GLenum front=GL_CCW, GLenum mode=GL_BACK)
Definition: glutil.cpp:27
void use_shader(Shader shader)
Definition: glutil.cpp:81
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: gl2ext.h:133
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Definition: gl2ext.h:179
Definition: matrix.h:75
GLenum mode
Definition: gl2ext.h:302
void depth_write(bool enabled)
Definition: glutil.cpp:54
GLenum target
Definition: gl2ext.h:720
GLuint gen_buffer(GLenum target, GLsizei size, const void *data)
Definition: glutil.cpp:132
Definition: shader.h:27
GLenum GLuint GLintptr GLsizeiptr size
Definition: gl2ext.h:629
GLuint name
Definition: gl2ext.h:139
Definition: matrix.h:104
GLenum GLuint buffer
Definition: gl2ext.h:628
const void GLsizei GLsizei stride
Definition: gl2ext.h:1335
void unset_attrib(string name)
Definition: glutil.cpp:92
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
GLenum src
Definition: gl2ext.h:304