Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/External/Android/ndk_helper/include/shader.h Source File

Diligent Engine API Reference

shader.h
1 /*
2 * Copyright 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef SHADER_H_
18 #define SHADER_H_
19
20 #include <jni.h>
21
22 #include <vector>
23 #include <map>
24 #include <string>
25
26 #include <EGL/egl.h>
27 #include <GLES/gl.h>
28
29 #include <android/log.h>
30
31 #include "JNIHelper.h"
32
33 namespace ndk_helper {
34
35 namespace shader {
36
37 /******************************************************************
38 * Shader compiler helper
39 * namespace: ndkHelper::shader
40 *
41 */
42
43 /******************************************************************
44 * CompileShader() with vector
45 *
46 * arguments:
47 * out: shader, shader variable
48 * in: type, shader type (i.e. GL_VERTEX_SHADER/GL_FRAGMENT_SHADER)
49 * in: data, source vector
50 * return: true if a shader compilation succeeded, false if it failed
51 *
52 */
53 bool CompileShader(GLuint *shader, const GLenum type,
54 std::vector<uint8_t> &data);
55
56 /******************************************************************
57 * CompileShader() with buffer
58 *
59 * arguments:
60 * out: shader, shader variable
61 * in: type, shader type (i.e. GL_VERTEX_SHADER/GL_FRAGMENT_SHADER)
62 * in: source, source buffer
63 * in: iSize, buffer size
64 * return: true if a shader compilation succeeded, false if it failed
65 *
66 */
67 bool CompileShader(GLuint *shader, const GLenum type, const GLchar *source,
68 const int32_t iSize);
69
70 /******************************************************************
71 * CompileShader() with filename
72 *
73 * arguments:
74 * out: shader, shader variable
75 * in: type, shader type (i.e. GL_VERTEX_SHADER/GL_FRAGMENT_SHADER)
76 * in: strFilename, filename
77 * return: true if a shader compilation succeeded, false if it failed
78 *
79 */
80 bool CompileShader(GLuint *shader, const GLenum type, const char *strFileName);
81
82 /******************************************************************
83 * CompileShader() with std::map helps patching on a shader on the fly.
84 *
85 * arguments:
86 * out: shader, shader variable
87 * in: type, shader type (i.e. GL_VERTEX_SHADER/GL_FRAGMENT_SHADER)
88 * in: mapParameters
89 * For a example,
90 * map : %KEY% -> %VALUE% replaces all %KEY% entries in the given shader
91 *code to %VALUE"
92 * return: true if a shader compilation succeeded, false if it failed
93 *
94 */
95 bool CompileShader(GLuint *shader, const GLenum type, const char *str_file_name,
96 const std::map<std::string, std::string> &map_parameters);
97
98 /******************************************************************
99 * LinkProgram()
100 *
101 * arguments:
102 * in: program, program
103 * return: true if a shader linkage succeeded, false if it failed
104 *
105 */
106 bool LinkProgram(const GLuint prog);
107
108 /******************************************************************
109 * validateProgram()
110 *
111 * arguments:
112 * in: program, program
113 * return: true if a shader validation succeeded, false if it failed
114 *
115 */
116 bool ValidateProgram(const GLuint prog);
117 } // namespace shader
118
119 } // namespace ndkHelper
120 #endif /* SHADER_H_ */
ndk_helper
Definition: gestureDetector.h:32