• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 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 #ifndef _GL2_ENCODER_H_
17 #define _GL2_ENCODER_H_
18 
19 #include "gl2_enc.h"
20 #include "IOStream.h"
21 #include "GLClientState.h"
22 #include "GLSharedGroup.h"
23 #include "FixedBuffer.h"
24 
25 
26 class GL2Encoder : public gl2_encoder_context_t {
27 public:
28     GL2Encoder(IOStream *stream);
29     virtual ~GL2Encoder();
setClientState(GLClientState * state)30     void setClientState(GLClientState *state) {
31         m_state = state;
32     }
setSharedGroup(GLSharedGroupPtr shared)33     void setSharedGroup(GLSharedGroupPtr shared){ m_shared = shared; }
state()34     const GLClientState *state() { return m_state; }
shared()35     const GLSharedGroupPtr shared() { return m_shared; }
flush()36     void flush() {
37         gl2_encoder_context_t::m_stream->flush();
38     }
39 
setInitialized()40     void setInitialized(){ m_initialized = true; };
isInitialized()41     bool isInitialized(){ return m_initialized; };
42 
setError(GLenum error)43     virtual void setError(GLenum error){ m_error = error; };
getError()44     virtual GLenum getError() { return m_error; };
45 
46 private:
47 
48     bool    m_initialized;
49     GLClientState *m_state;
50     GLSharedGroupPtr m_shared;
51     GLenum  m_error;
52 
53     GLint *m_compressedTextureFormats;
54     GLint m_num_compressedTextureFormats;
55     GLint *getCompressedTextureFormats();
56 
57     FixedBuffer m_fixedBuffer;
58 
59     void sendVertexAttributes(GLint first, GLsizei count);
60 
61     glGetError_client_proc_t    m_glGetError_enc;
62     static GLenum s_glGetError(void * self);
63 
64     glFlush_client_proc_t m_glFlush_enc;
65     static void s_glFlush(void * self);
66 
67     glPixelStorei_client_proc_t m_glPixelStorei_enc;
68     static void s_glPixelStorei(void *self, GLenum param, GLint value);
69 
70     glGetString_client_proc_t m_glGetString_enc;
71     static const GLubyte * s_glGetString(void *self, GLenum name);
72 
73     glBindBuffer_client_proc_t m_glBindBuffer_enc;
74     static void s_glBindBuffer(void *self, GLenum target, GLuint id);
75 
76 
77     glBufferData_client_proc_t m_glBufferData_enc;
78     static void s_glBufferData(void *self, GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
79     glBufferSubData_client_proc_t m_glBufferSubData_enc;
80     static void s_glBufferSubData(void *self, GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
81     glDeleteBuffers_client_proc_t m_glDeleteBuffers_enc;
82     static void s_glDeleteBuffers(void *self, GLsizei n, const GLuint * buffers);
83 
84     glDrawArrays_client_proc_t m_glDrawArrays_enc;
85     static void s_glDrawArrays(void *self, GLenum mode, GLint first, GLsizei count);
86 
87     glDrawElements_client_proc_t m_glDrawElements_enc;
88     static void s_glDrawElements(void *self, GLenum mode, GLsizei count, GLenum type, const void *indices);
89 
90 
91     glGetIntegerv_client_proc_t m_glGetIntegerv_enc;
92     static void s_glGetIntegerv(void *self, GLenum pname, GLint *ptr);
93 
94     glGetFloatv_client_proc_t m_glGetFloatv_enc;
95     static void s_glGetFloatv(void *self, GLenum pname, GLfloat *ptr);
96 
97     glGetBooleanv_client_proc_t m_glGetBooleanv_enc;
98     static void s_glGetBooleanv(void *self, GLenum pname, GLboolean *ptr);
99 
100     glVertexAttribPointer_client_proc_t m_glVertexAttribPointer_enc;
101     static void s_glVertexAtrribPointer(void *self, GLuint indx, GLint size, GLenum type,
102                                         GLboolean normalized, GLsizei stride, const GLvoid * ptr);
103 
104     glEnableVertexAttribArray_client_proc_t m_glEnableVertexAttribArray_enc;
105     static void s_glEnableVertexAttribArray(void *self, GLuint index);
106 
107     glDisableVertexAttribArray_client_proc_t m_glDisableVertexAttribArray_enc;
108     static void s_glDisableVertexAttribArray(void *self, GLuint index);
109 
110     glGetVertexAttribiv_client_proc_t m_glGetVertexAttribiv_enc;
111     static void s_glGetVertexAttribiv(void *self, GLuint index, GLenum pname, GLint *params);
112 
113     glGetVertexAttribfv_client_proc_t m_glGetVertexAttribfv_enc;
114     static void s_glGetVertexAttribfv(void *self, GLuint index, GLenum pname, GLfloat *params);
115 
116     glGetVertexAttribPointerv_client_proc_t m_glGetVertexAttribPointerv;
117     static void s_glGetVertexAttribPointerv(void *self, GLuint index, GLenum pname, GLvoid **pointer);
118 
119     static void s_glShaderSource(void *self, GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
120 
121     static void s_glFinish(void *self);
122 
123     glLinkProgram_client_proc_t m_glLinkProgram_enc;
124     static void s_glLinkProgram(void *self, GLuint program);
125 
126     glDeleteProgram_client_proc_t m_glDeleteProgram_enc;
127     static void s_glDeleteProgram(void * self, GLuint program);
128 
129     glGetUniformiv_client_proc_t m_glGetUniformiv_enc;
130     static void s_glGetUniformiv(void *self, GLuint program, GLint location , GLint *params);
131 
132     glGetUniformfv_client_proc_t m_glGetUniformfv_enc;
133     static void s_glGetUniformfv(void *self, GLuint program, GLint location , GLfloat *params);
134 
135     glCreateProgram_client_proc_t m_glCreateProgram_enc;
136     static GLuint s_glCreateProgram(void *self);
137 
138     glCreateShader_client_proc_t m_glCreateShader_enc;
139     static GLuint s_glCreateShader(void *self, GLenum shaderType);
140 
141     glDeleteShader_client_proc_t m_glDeleteShader_enc;
142     static void s_glDeleteShader(void *self, GLuint shader);
143 
144     glGetUniformLocation_client_proc_t m_glGetUniformLocation_enc;
145     static int s_glGetUniformLocation(void *self, GLuint program, const GLchar *name);
146     glUseProgram_client_proc_t m_glUseProgram_enc;
147 
148     glUniform1f_client_proc_t m_glUniform1f_enc;
149     glUniform1fv_client_proc_t m_glUniform1fv_enc;
150     glUniform1i_client_proc_t m_glUniform1i_enc;
151     glUniform1iv_client_proc_t m_glUniform1iv_enc;
152     glUniform2f_client_proc_t m_glUniform2f_enc;
153     glUniform2fv_client_proc_t m_glUniform2fv_enc;
154     glUniform2i_client_proc_t m_glUniform2i_enc;
155     glUniform2iv_client_proc_t m_glUniform2iv_enc;
156     glUniform3f_client_proc_t m_glUniform3f_enc;
157     glUniform3fv_client_proc_t m_glUniform3fv_enc;
158     glUniform3i_client_proc_t m_glUniform3i_enc;
159     glUniform3iv_client_proc_t m_glUniform3iv_enc;
160     glUniform4f_client_proc_t m_glUniform4f_enc;
161     glUniform4fv_client_proc_t m_glUniform4fv_enc;
162     glUniform4i_client_proc_t m_glUniform4i_enc;
163     glUniform4iv_client_proc_t m_glUniform4iv_enc;
164     glUniformMatrix2fv_client_proc_t m_glUniformMatrix2fv_enc;
165     glUniformMatrix3fv_client_proc_t m_glUniformMatrix3fv_enc;
166     glUniformMatrix4fv_client_proc_t m_glUniformMatrix4fv_enc;
167 
168     static void s_glUseProgram(void *self, GLuint program);
169 	static void s_glUniform1f(void *self , GLint location, GLfloat x);
170 	static void s_glUniform1fv(void *self , GLint location, GLsizei count, const GLfloat* v);
171 	static void s_glUniform1i(void *self , GLint location, GLint x);
172 	static void s_glUniform1iv(void *self , GLint location, GLsizei count, const GLint* v);
173 	static void s_glUniform2f(void *self , GLint location, GLfloat x, GLfloat y);
174 	static void s_glUniform2fv(void *self , GLint location, GLsizei count, const GLfloat* v);
175 	static void s_glUniform2i(void *self , GLint location, GLint x, GLint y);
176 	static void s_glUniform2iv(void *self , GLint location, GLsizei count, const GLint* v);
177 	static void s_glUniform3f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z);
178 	static void s_glUniform3fv(void *self , GLint location, GLsizei count, const GLfloat* v);
179 	static void s_glUniform3i(void *self , GLint location, GLint x, GLint y, GLint z);
180 	static void s_glUniform3iv(void *self , GLint location, GLsizei count, const GLint* v);
181 	static void s_glUniform4f(void *self , GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
182 	static void s_glUniform4fv(void *self , GLint location, GLsizei count, const GLfloat* v);
183 	static void s_glUniform4i(void *self , GLint location, GLint x, GLint y, GLint z, GLint w);
184 	static void s_glUniform4iv(void *self , GLint location, GLsizei count, const GLint* v);
185 	static void s_glUniformMatrix2fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
186 	static void s_glUniformMatrix3fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
187 	static void s_glUniformMatrix4fv(void *self , GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
188 };
189 #endif
190