1 #ifndef __TEST_GL_ABSTRACTION_H__
2 #define __TEST_GL_ABSTRACTION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
27 #include <cstring> // for strcmp
30 #include <dali/public-api/dali-core.h>
31 #include <dali/integration-api/core.h>
32 #include <dali/integration-api/gl-abstraction.h>
33 #include <dali/integration-api/gl-defines.h>
34 #include "test-trace-call-stack.h"
39 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
40 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
42 "aPosition", // ATTRIB_POSITION
43 "aNormal", // ATTRIB_NORMAL
44 "aTexCoord", // ATTRIB_TEXCOORD
45 "aColor", // ATTRIB_COLOR
46 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
47 "aBoneIndices" // ATTRIB_BONE_INDICES
50 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
62 inline void ActiveTexture( GLenum textureUnit )
64 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
67 inline GLenum GetActiveTextureUnit() const
69 return mActiveTextureUnit + GL_TEXTURE0;
72 inline void AttachShader( GLuint program, GLuint shader )
74 std::stringstream out;
75 out << program << ", " << shader;
76 mShaderTrace.PushCall("AttachShader", out.str());
79 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
83 inline void BindBuffer( GLenum target, GLuint buffer )
87 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
90 mFramebufferStatus |= 2;
93 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
98 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
99 * @return A vector containing the IDs that were bound.
101 inline const std::vector<GLuint>& GetBoundTextures() const
103 return mBoundTextures;
107 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
108 * @param[in] activeTextureUnit The specific active texture unit.
109 * @return A vector containing the IDs that were bound.
111 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
113 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
117 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
119 inline void ClearBoundTextures()
121 mBoundTextures.clear();
123 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
125 mActiveTextures[ i ].mBoundTextures.clear();
129 inline void BindTexture( GLenum target, GLuint texture )
131 // Record the bound textures for future checks
134 mBoundTextures.push_back( texture );
136 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
138 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
142 std::stringstream out;
143 out << target << ", " << texture;
144 mTextureTrace.PushCall("BindTexture", out.str());
147 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
149 mLastBlendColor.r = red;
150 mLastBlendColor.g = green;
151 mLastBlendColor.b = blue;
152 mLastBlendColor.a = alpha;
155 inline const Vector4& GetLastBlendColor() const
157 return mLastBlendColor;
160 inline void BlendEquation( GLenum mode )
162 mLastBlendEquationRgb = mode;
163 mLastBlendEquationAlpha = mode;
166 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
168 mLastBlendEquationRgb = modeRgb;
169 mLastBlendEquationAlpha = modeAlpha;
172 inline GLenum GetLastBlendEquationRgb() const
174 return mLastBlendEquationRgb;
177 inline GLenum GetLastBlendEquationAlpha() const
179 return mLastBlendEquationAlpha;
182 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
184 mLastBlendFuncSrcRgb = sfactor;
185 mLastBlendFuncDstRgb = dfactor;
186 mLastBlendFuncSrcAlpha = sfactor;
187 mLastBlendFuncDstAlpha = dfactor;
190 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
192 mLastBlendFuncSrcRgb = srcRGB;
193 mLastBlendFuncDstRgb = dstRGB;
194 mLastBlendFuncSrcAlpha = srcAlpha;
195 mLastBlendFuncDstAlpha = dstAlpha;
198 inline GLenum GetLastBlendFuncSrcRgb() const
200 return mLastBlendFuncSrcRgb;
203 inline GLenum GetLastBlendFuncDstRgb() const
205 return mLastBlendFuncDstRgb;
208 inline GLenum GetLastBlendFuncSrcAlpha() const
210 return mLastBlendFuncSrcAlpha;
213 inline GLenum GetLastBlendFuncDstAlpha() const
215 return mLastBlendFuncDstAlpha;
218 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
220 mBufferDataCalls.push_back(size);
223 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
225 mBufferSubDataCalls.push_back(size);
228 inline GLenum CheckFramebufferStatus(GLenum target)
230 //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
231 //Framebuffer texture have been called
232 if( mFramebufferStatus == 7 )
234 return GL_FRAMEBUFFER_COMPLETE;
237 return mCheckFramebufferStatusResult;
240 inline GLenum CheckFramebufferColorAttachment()
242 return mFramebufferColorAttached;
245 inline GLenum CheckFramebufferDepthAttachment()
247 return mFramebufferDepthAttached;
250 inline GLenum CheckFramebufferStencilAttachment()
252 return mFramebufferStencilAttached;
255 inline void Clear(GLbitfield mask)
258 mLastClearBitMask = mask;
261 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
265 inline void ClearDepthf(GLclampf depth)
269 inline void ClearStencil(GLint s)
273 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
277 inline void CompileShader(GLuint shader)
279 std::stringstream out;
281 mShaderTrace.PushCall("CompileShader", out.str());
284 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
288 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
292 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
296 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
300 inline GLuint CreateProgram(void)
302 mShaderTrace.PushCall("CreateProgram", "");
304 ++mLastProgramIdUsed;
305 mUniforms[mLastProgramIdUsed] = UniformIDMap();
306 return mLastProgramIdUsed;
309 inline GLuint CreateShader(GLenum type)
311 std::stringstream out;
313 mShaderTrace.PushCall("CreateShader", out.str());
315 return ++mLastShaderIdUsed;
318 inline void CullFace(GLenum mode)
320 std::stringstream out;
322 mCullFaceTrace.PushCall("CullFace", out.str());
325 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
329 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
333 inline void DeleteProgram(GLuint program)
335 std::stringstream out;
337 mShaderTrace.PushCall("DeleteProgram", out.str());
340 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
344 inline void DeleteShader(GLuint shader)
346 std::stringstream out;
348 mShaderTrace.PushCall("DeleteShader", out.str());
351 inline void DeleteTextures(GLsizei n, const GLuint* textures)
353 std::stringstream out;
354 out << n << ", " << textures << " = [";
356 for(GLsizei i=0; i<n; i++)
358 out << textures[i] << ", ";
359 mDeletedTextureIds.push_back(textures[i]);
362 mTextureTrace.PushCall("DeleteTextures", out.str());
365 inline bool CheckNoTexturesDeleted()
367 return mDeletedTextureIds.size() == 0;
370 inline bool CheckTextureDeleted( GLuint textureId )
374 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
376 if(*iter == textureId)
385 inline void ClearDeletedTextures()
387 mDeletedTextureIds.clear();
390 inline void DepthFunc(GLenum func)
392 std::stringstream out;
394 mDepthFunctionTrace.PushCall("DepthFunc", out.str());
397 inline void DepthMask(GLboolean flag)
401 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
405 inline void DetachShader(GLuint program, GLuint shader)
407 std::stringstream out;
408 out << program << ", " << shader;
409 mShaderTrace.PushCall("DetachShader", out.str());
412 inline void Disable(GLenum cap)
414 std::stringstream out;
416 mEnableDisableTrace.PushCall("Disable", out.str());
419 inline void DisableVertexAttribArray(GLuint index)
421 SetVertexAttribArray( index, false );
424 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
426 std::stringstream out;
427 out << mode << ", " << first << ", " << count;
428 mDrawTrace.PushCall("DrawArrays", out.str());
431 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
433 std::stringstream out;
434 out << mode << ", " << count << ", " << type << ", indices";
435 mDrawTrace.PushCall("DrawElements", out.str());
438 inline void Enable(GLenum cap)
440 std::stringstream out;
442 mEnableDisableTrace.PushCall("Enable", out.str());
445 inline void EnableVertexAttribArray(GLuint index)
447 SetVertexAttribArray( index, true);
450 inline void Finish(void)
454 inline void Flush(void)
458 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
460 if (attachment == GL_DEPTH_ATTACHMENT)
462 mFramebufferDepthAttached = true;
464 else if (attachment == GL_STENCIL_ATTACHMENT)
466 mFramebufferStencilAttached = true;
470 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
473 mFramebufferStatus |= 4;
475 //We check 4 attachment colors
476 if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
478 mFramebufferColorAttached = true;
482 inline void FrontFace(GLenum mode)
486 inline void GenBuffers(GLsizei n, GLuint* buffers)
488 // avoids an assert in GpuBuffers
492 inline void GenerateMipmap(GLenum target)
494 std::stringstream out;
496 mTextureTrace.PushCall("GenerateMipmap", out.str());
499 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
501 for( int i = 0; i < n; i++ )
503 framebuffers[i] = i + 1;
506 //Add 001 bit, this function needs to be called the first one in the chain
507 mFramebufferStatus = 1;
510 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
512 for( int i = 0; i < n; i++ )
514 renderbuffers[i] = i + 1;
519 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
520 * @param[in] ids A vector containing the next IDs to be generated
522 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
524 mNextTextureIds = ids;
527 inline const std::vector<GLuint>& GetNextTextureIds()
529 return mNextTextureIds;
532 inline void GenTextures(GLsizei n, GLuint* textures)
534 for( int i=0; i<n; ++i )
536 if( !mNextTextureIds.empty() )
538 *(textures+i) = mNextTextureIds[0];
539 mNextTextureIds.erase( mNextTextureIds.begin() );
543 *(textures+i) = ++mLastAutoTextureIdUsed;
547 std::stringstream out;
548 for(int i=0; i<n; i++)
556 mTextureTrace.PushCall("GenTextures", out.str());
559 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
563 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
568 *length = snprintf(name, bufsize, "sTexture");
569 *type = GL_SAMPLER_2D;
573 *length = snprintf(name, bufsize, "sEffect");
574 *type = GL_SAMPLER_2D;
582 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
586 inline int GetAttribLocation(GLuint program, const char* name)
588 std::string attribName(name);
590 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
592 if( mStdAttribs[i] == attribName )
598 // 0 is a valid location
602 inline void GetBooleanv(GLenum pname, GLboolean* params)
606 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
610 inline GLenum GetError(void)
612 return mGetErrorResult;
615 inline void GetFloatv(GLenum pname, GLfloat* params)
619 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
623 inline void GetIntegerv(GLenum pname, GLint* params)
627 case GL_MAX_TEXTURE_SIZE:
630 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
633 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
634 *params = mNumBinaryFormats;
636 case GL_PROGRAM_BINARY_FORMATS_OES:
637 *params = mBinaryFormats;
642 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
647 *params = mLinkStatus;
649 case GL_PROGRAM_BINARY_LENGTH_OES:
650 *params = mProgramBinaryLength;
652 case GL_ACTIVE_UNIFORMS:
653 *params = mNumberOfActiveUniforms;
655 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
661 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
665 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
669 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
672 case GL_COMPILE_STATUS:
673 *params = mCompileStatus;
678 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
682 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
686 inline const GLubyte* GetString(GLenum name)
688 return mGetStringResult;
691 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
695 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
699 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
703 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
707 inline GLint GetUniformLocation(GLuint program, const char* name)
709 ProgramUniformMap::iterator it = mUniforms.find(program);
710 if( it == mUniforms.end() )
712 // Not a valid program ID
713 mGetErrorResult = GL_INVALID_OPERATION;
717 UniformIDMap& uniformIDs = it->second;
718 UniformIDMap::iterator it2 = uniformIDs.find( name );
719 if( it2 == uniformIDs.end() )
721 // Uniform not found, so add it...
722 uniformIDs[name] = ++mLastUniformIdUsed;
723 return mLastUniformIdUsed;
729 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
733 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
737 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
741 inline void Hint(GLenum target, GLenum mode)
745 inline GLboolean IsBuffer(GLuint buffer)
747 return mIsBufferResult;
750 inline GLboolean IsEnabled(GLenum cap)
752 return mIsEnabledResult;
755 inline GLboolean IsFramebuffer(GLuint framebuffer)
757 return mIsFramebufferResult;
760 inline GLboolean IsProgram(GLuint program)
762 return mIsProgramResult;
765 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
767 return mIsRenderbufferResult;
770 inline GLboolean IsShader(GLuint shader)
772 return mIsShaderResult;
775 inline GLboolean IsTexture(GLuint texture)
777 return mIsTextureResult;
780 inline void LineWidth(GLfloat width)
784 inline void LinkProgram(GLuint program)
786 std::stringstream out;
788 mShaderTrace.PushCall("LinkProgram", out.str());
790 mNumberOfActiveUniforms=2;
791 GetUniformLocation(program, "sTexture");
792 GetUniformLocation(program, "sEffect");
795 inline void PixelStorei(GLenum pname, GLint param)
799 inline void PolygonOffset(GLfloat factor, GLfloat units)
803 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
807 inline void ReleaseShaderCompiler(void)
811 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
815 inline void SampleCoverage(GLclampf value, GLboolean invert)
819 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
821 mScissorParams.x = x;
822 mScissorParams.y = y;
823 mScissorParams.width = width;
824 mScissorParams.height = height;
827 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
831 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
833 std::string stringBuilder;
834 for(int i = 0; i < count; ++i)
836 stringBuilder += string[i];
838 mShaderSources[shader] = stringBuilder;
839 mLastShaderCompiled = shader;
842 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
844 const std::string shaderSource = mShaderSources[shader];
845 if( static_cast<int>(shaderSource.length()) < bufsize )
847 strcpy(source, shaderSource.c_str());
848 *length = shaderSource.length();
852 *length = bufsize -1;
853 strncpy(source, shaderSource.c_str(), *length);
854 source[*length] = 0x0;
858 inline std::string GetShaderSource(GLuint shader)
860 return mShaderSources[shader];
863 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
867 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
871 inline void StencilMask(GLuint mask)
875 inline void StencilMaskSeparate(GLenum face, GLuint mask)
879 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
883 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
887 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
889 std::stringstream out;
890 out << target<<", "<<level<<", "<<width << ", " << height;
891 mTextureTrace.PushCall("TexImage2D", out.str());
894 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
896 std::stringstream out;
897 out << target << ", " << pname << ", " << param;
898 mTexParamaterTrace.PushCall("TexParameterf", out.str());
901 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
903 std::stringstream out;
904 out << target << ", " << pname << ", " << params[0];
905 mTexParamaterTrace.PushCall("TexParameterfv", out.str());
908 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
910 std::stringstream out;
911 out << target << ", " << pname << ", " << param;
912 mTexParamaterTrace.PushCall("TexParameteri", out.str());
915 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
917 std::stringstream out;
918 out << target << ", " << pname << ", " << params[0];
919 mTexParamaterTrace.PushCall("TexParameteriv", out.str());
922 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
924 std::stringstream out;
925 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
926 mTextureTrace.PushCall("TexSubImage2D", out.str());
929 inline void Uniform1f(GLint location, GLfloat x)
931 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
933 mGetErrorResult = GL_INVALID_OPERATION;
937 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
939 for( int i = 0; i < count; ++i )
941 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
943 mGetErrorResult = GL_INVALID_OPERATION;
949 inline void Uniform1i(GLint location, GLint x)
951 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
953 mGetErrorResult = GL_INVALID_OPERATION;
957 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
959 for( int i = 0; i < count; ++i )
961 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
965 mGetErrorResult = GL_INVALID_OPERATION;
971 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
973 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
977 mGetErrorResult = GL_INVALID_OPERATION;
981 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
983 for( int i = 0; i < count; ++i )
985 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
987 Vector2( v[2*i], v[2*i+1] ) ) )
989 mGetErrorResult = GL_INVALID_OPERATION;
995 inline void Uniform2i(GLint location, GLint x, GLint y)
999 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1003 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1005 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1007 Vector3( x, y, z ) ) )
1009 mGetErrorResult = GL_INVALID_OPERATION;
1013 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1015 for( int i = 0; i < count; ++i )
1017 if( ! mProgramUniforms3f.SetUniformValue(
1020 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1022 mGetErrorResult = GL_INVALID_OPERATION;
1028 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1032 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1036 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1038 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1040 Vector4( x, y, z, w ) ) )
1042 mGetErrorResult = GL_INVALID_OPERATION;
1046 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1048 for( int i = 0; i < count; ++i )
1050 if( ! mProgramUniforms4f.SetUniformValue(
1053 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1055 mGetErrorResult = GL_INVALID_OPERATION;
1061 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1065 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1069 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1073 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1075 for( int i = 0; i < count; ++i )
1077 if( ! mProgramUniformsMat3.SetUniformValue(
1080 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1082 mGetErrorResult = GL_INVALID_OPERATION;
1088 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1090 for( int i = 0; i < count; ++i )
1092 if( ! mProgramUniformsMat4.SetUniformValue(
1097 mGetErrorResult = GL_INVALID_OPERATION;
1103 inline void UseProgram(GLuint program)
1105 mCurrentProgram = program;
1108 inline void ValidateProgram(GLuint program)
1112 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1116 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1120 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1124 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1128 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1132 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1136 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1140 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1144 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1148 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1154 inline void ReadBuffer(GLenum mode)
1158 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1162 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1166 inline void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
1170 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1174 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1178 inline void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
1182 inline void GenQueries(GLsizei n, GLuint* ids)
1186 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1190 inline GLboolean IsQuery(GLuint id)
1195 inline void BeginQuery(GLenum target, GLuint id)
1199 inline void EndQuery(GLenum target)
1203 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1207 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1211 inline GLboolean UnmapBuffer(GLenum target)
1216 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1220 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1224 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1228 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1232 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1236 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1240 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1244 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1248 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1252 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1256 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1260 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1265 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1269 inline void BindVertexArray(GLuint array)
1273 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1277 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1281 inline GLboolean IsVertexArray(GLuint array)
1286 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1290 inline void BeginTransformFeedback(GLenum primitiveMode)
1294 inline void EndTransformFeedback(void)
1298 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1302 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1306 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1310 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1314 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1318 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1322 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1326 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1330 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1334 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1338 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1342 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1346 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1351 inline void Uniform1ui(GLint location, GLuint v0)
1355 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1359 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1363 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1367 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1371 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1375 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1379 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1383 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1387 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1391 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1395 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1399 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1404 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1408 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1412 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1416 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1418 return GL_INVALID_INDEX;
1421 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1425 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1429 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1433 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1437 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1441 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1446 inline GLboolean IsSync(GLsync sync)
1451 inline void DeleteSync(GLsync sync)
1455 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1460 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1464 inline void GetInteger64v(GLenum pname, GLint64* params)
1468 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1472 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1476 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1480 inline void GenSamplers(GLsizei count, GLuint* samplers)
1484 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1488 inline GLboolean IsSampler(GLuint sampler)
1493 inline void BindSampler(GLuint unit, GLuint sampler)
1497 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1501 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1505 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1509 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1513 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1517 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1521 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1525 inline void BindTransformFeedback(GLenum target, GLuint id)
1529 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1533 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1537 inline GLboolean IsTransformFeedback(GLuint id)
1542 inline void PauseTransformFeedback(void)
1546 inline void ResumeTransformFeedback(void)
1550 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1552 mGetProgramBinaryCalled = true;
1555 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1559 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1563 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1567 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1571 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1575 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1579 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1583 public: // TEST FUNCTIONS
1584 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1585 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1586 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1587 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1588 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1589 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1590 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1591 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1592 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1593 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1594 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1595 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1596 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1597 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1598 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1599 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1601 inline bool GetVertexAttribArrayState(GLuint index)
1603 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1608 return mVertexAttribArrayState[ index ];
1610 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1611 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1613 //Methods for CullFace verification
1614 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1615 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1616 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1618 //Methods for Enable/Disable call verification
1619 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1620 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1621 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1623 //Methods for Shader verification
1624 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1625 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1626 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1628 //Methods for Texture verification
1629 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1630 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1631 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1633 //Methods for Texture verification
1634 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1635 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1636 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1638 //Methods for Draw verification
1639 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1640 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1641 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1643 //Methods for Depth function verification
1644 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1645 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1646 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1648 template <typename T>
1649 inline bool GetUniformValue( const char* name, T& value ) const
1651 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1652 program_it != mUniforms.end();
1655 const UniformIDMap &uniformIDs = program_it->second;
1657 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1658 if( uniform_it != uniformIDs.end() )
1660 // found one matching uniform name, lets check the value...
1661 GLuint programId = program_it->first;
1662 GLint uniformId = uniform_it->second;
1664 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1665 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
1672 template <typename T>
1673 inline bool CheckUniformValue( const char* name, const T& value ) const
1675 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1676 program_it != mUniforms.end();
1679 const UniformIDMap &uniformIDs = program_it->second;
1681 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1682 if( uniform_it != uniformIDs.end() )
1684 // found one matching uniform name, lets check the value...
1685 GLuint programId = program_it->first;
1686 GLint uniformId = uniform_it->second;
1688 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1689 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1691 // the value matches
1697 fprintf(stderr, "Not found, printing possible values:\n" );
1698 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1699 program_it != mUniforms.end();
1702 const UniformIDMap &uniformIDs = program_it->second;
1704 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1705 if( uniform_it != uniformIDs.end() )
1707 // found one matching uniform name, lets check the value...
1708 GLuint programId = program_it->first;
1709 GLint uniformId = uniform_it->second;
1711 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1713 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1715 std::stringstream out;
1716 out << uniform_it->first << ": " << origValue;
1717 fprintf(stderr, "%s\n", out.str().c_str() );
1724 template <typename T>
1725 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1727 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1728 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1731 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1733 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1734 program_it != mUniforms.end();
1737 const UniformIDMap &uniformIDs = program_it->second;
1739 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1740 if( uniform_it != uniformIDs.end() )
1742 programId = program_it->first;
1743 uniformId = uniform_it->second;
1750 inline GLuint GetLastShaderCompiled() const
1752 return mLastShaderCompiled;
1755 inline GLuint GetLastProgramCreated() const
1757 return mLastProgramIdUsed;
1760 inline GLbitfield GetLastClearMask() const
1762 return mLastClearBitMask;
1767 ATTRIB_UNKNOWN = -1,
1772 ATTRIB_BONE_WEIGHTS,
1773 ATTRIB_BONE_INDICES,
1777 struct ScissorParams
1784 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
1787 // Methods to check scissor tests
1788 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
1790 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
1792 inline unsigned int GetClearCountCalled() const { return mClearCount; }
1794 typedef std::vector<size_t> BufferDataCalls;
1795 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
1796 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
1798 typedef std::vector<size_t> BufferSubDataCalls;
1799 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
1800 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
1803 GLuint mCurrentProgram;
1804 GLuint mCompileStatus;
1805 BufferDataCalls mBufferDataCalls;
1806 BufferSubDataCalls mBufferSubDataCalls;
1808 GLint mNumberOfActiveUniforms;
1809 GLint mGetAttribLocationResult;
1810 GLenum mGetErrorResult;
1811 GLubyte* mGetStringResult;
1812 GLboolean mIsBufferResult;
1813 GLboolean mIsEnabledResult;
1814 GLboolean mIsFramebufferResult;
1815 GLboolean mIsProgramResult;
1816 GLboolean mIsRenderbufferResult;
1817 GLboolean mIsShaderResult;
1818 GLboolean mIsTextureResult;
1819 GLenum mActiveTextureUnit;
1820 GLenum mCheckFramebufferStatusResult;
1821 GLint mFramebufferStatus;
1822 GLenum mFramebufferColorAttached;
1823 GLenum mFramebufferDepthAttached;
1824 GLenum mFramebufferStencilAttached;
1825 GLint mNumBinaryFormats;
1826 GLint mBinaryFormats;
1827 GLint mProgramBinaryLength;
1828 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1829 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1830 bool mGetProgramBinaryCalled;
1831 typedef std::map< GLuint, std::string> ShaderSourceMap;
1832 ShaderSourceMap mShaderSources;
1833 GLuint mLastShaderCompiled;
1834 GLbitfield mLastClearBitMask;
1835 unsigned int mClearCount;
1837 Vector4 mLastBlendColor;
1838 GLenum mLastBlendEquationRgb;
1839 GLenum mLastBlendEquationAlpha;
1840 GLenum mLastBlendFuncSrcRgb;
1841 GLenum mLastBlendFuncDstRgb;
1842 GLenum mLastBlendFuncSrcAlpha;
1843 GLenum mLastBlendFuncDstAlpha;
1845 // Data for manipulating the IDs returned by GenTextures
1846 GLuint mLastAutoTextureIdUsed;
1847 std::vector<GLuint> mNextTextureIds;
1848 std::vector<GLuint> mDeletedTextureIds;
1849 std::vector<GLuint> mBoundTextures;
1851 struct ActiveTextureType
1853 std::vector<GLuint> mBoundTextures;
1856 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1858 TraceCallStack mCullFaceTrace;
1859 TraceCallStack mEnableDisableTrace;
1860 TraceCallStack mShaderTrace;
1861 TraceCallStack mTextureTrace;
1862 TraceCallStack mTexParamaterTrace;
1863 TraceCallStack mDrawTrace;
1864 TraceCallStack mDepthFunctionTrace;
1866 // Shaders & Uniforms
1867 GLuint mLastShaderIdUsed;
1868 GLuint mLastProgramIdUsed;
1869 GLuint mLastUniformIdUsed;
1870 typedef std::map< std::string, GLint > UniformIDMap;
1871 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1872 ProgramUniformMap mUniforms;
1874 template <typename T>
1875 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1878 typedef std::map< GLint, T > UniformValueMap;
1879 typedef std::map< GLuint, UniformValueMap > Map;
1881 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1888 typename Map::iterator it = Map::find( program );
1889 if( it == Map::end() )
1891 // if its the first uniform for this program add it
1892 std::pair< typename Map::iterator, bool > result =
1893 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1897 UniformValueMap& uniforms = it->second;
1898 uniforms[uniform] = value;
1903 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1906 if ( GetUniformValue( program, uniform, uniformValue ) )
1908 return value == uniformValue;
1914 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1921 typename Map::const_iterator it = Map::find( program );
1922 if( it == Map::end() )
1924 // Uniform values always initialised as 0
1929 const UniformValueMap& uniforms = it->second;
1930 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1931 if( it2 == uniforms.end() )
1933 // Uniform values always initialised as 0
1937 value = it2->second;
1944 ProgramUniformValue<int> mProgramUniforms1i;
1945 ProgramUniformValue<float> mProgramUniforms1f;
1946 ProgramUniformValue<Vector2> mProgramUniforms2f;
1947 ProgramUniformValue<Vector3> mProgramUniforms3f;
1948 ProgramUniformValue<Vector4> mProgramUniforms4f;
1949 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1950 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1952 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1954 return mProgramUniforms1i;
1956 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1958 return mProgramUniforms1f;
1960 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1962 return mProgramUniforms2f;
1964 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1966 return mProgramUniforms3f;
1968 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1970 return mProgramUniforms4f;
1972 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1974 return mProgramUniformsMat4;
1976 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1978 return mProgramUniformsMat3;
1980 inline void SetVertexAttribArray(GLuint index, bool state)
1982 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1987 mVertexAttribArrayState[ index ] = state;
1988 mVertexAttribArrayChanged = true;
1991 ScissorParams mScissorParams;
1995 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2001 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2007 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2009 return Vector2::ZERO;
2013 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2015 return Vector3::ZERO;
2019 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2021 return Vector4::ZERO;
2025 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2031 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2033 return Matrix3( Matrix() );
2038 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2039 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2044 #endif // __TEST_GL_ES_H__