1 #ifndef __TEST_GL_ABSTRACTION_H__
2 #define __TEST_GL_ABSTRACTION_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
26 #include <dali/dali.h>
28 #include <dali/integration-api/core.h>
29 #include <dali/integration-api/gl-abstraction.h>
30 #include "test-trace-call-stack.h"
35 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
36 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
38 "aPosition", // ATTRIB_POSITION
39 "aNormal", // ATTRIB_NORMAL
40 "aTexCoord", // ATTRIB_TEXCOORD
41 "aColor", // ATTRIB_COLOR
42 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
43 "aBoneIndices" // ATTRIB_BONE_INDICES
46 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
55 inline void ActiveTexture( GLenum textureUnit )
57 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
60 inline GLenum GetActiveTextureUnit() const
62 return mActiveTextureUnit + GL_TEXTURE0;
65 inline void AttachShader( GLuint program, GLuint shader )
67 std::stringstream out;
68 out << program << ", " << shader;
69 mShaderTrace.PushCall("AttachShader", out.str());
72 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
76 inline void BindBuffer( GLenum target, GLuint buffer )
80 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
84 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
89 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
90 * @return A vector containing the IDs that were bound.
92 inline const std::vector<GLuint>& GetBoundTextures() const
94 return mBoundTextures;
98 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
99 * @param[in] activeTextureUnit The specific active texture unit.
100 * @return A vector containing the IDs that were bound.
102 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
104 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
108 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
110 inline void ClearBoundTextures()
112 mBoundTextures.clear();
114 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
116 mActiveTextures[ i ].mBoundTextures.clear();
120 inline void BindTexture( GLenum target, GLuint texture )
122 // Record the bound textures for future checks
125 mBoundTextures.push_back( texture );
127 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
129 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
134 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
136 mLastBlendColor.r = red;
137 mLastBlendColor.g = green;
138 mLastBlendColor.b = blue;
139 mLastBlendColor.a = alpha;
142 inline const Vector4& GetLastBlendColor() const
144 return mLastBlendColor;
147 inline void BlendEquation( GLenum mode )
149 mLastBlendEquationRgb = mode;
150 mLastBlendEquationAlpha = mode;
153 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
155 mLastBlendEquationRgb = modeRgb;
156 mLastBlendEquationAlpha = modeAlpha;
159 inline GLenum GetLastBlendEquationRgb() const
161 return mLastBlendEquationRgb;
164 inline GLenum GetLastBlendEquationAlpha() const
166 return mLastBlendEquationAlpha;
169 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
171 mLastBlendFuncSrcRgb = sfactor;
172 mLastBlendFuncDstRgb = dfactor;
173 mLastBlendFuncSrcAlpha = sfactor;
174 mLastBlendFuncDstAlpha = dfactor;
177 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
179 mLastBlendFuncSrcRgb = srcRGB;
180 mLastBlendFuncDstRgb = dstRGB;
181 mLastBlendFuncSrcAlpha = srcAlpha;
182 mLastBlendFuncDstAlpha = dstAlpha;
185 inline GLenum GetLastBlendFuncSrcRgb() const
187 return mLastBlendFuncSrcRgb;
190 inline GLenum GetLastBlendFuncDstRgb() const
192 return mLastBlendFuncDstRgb;
195 inline GLenum GetLastBlendFuncSrcAlpha() const
197 return mLastBlendFuncSrcAlpha;
200 inline GLenum GetLastBlendFuncDstAlpha() const
202 return mLastBlendFuncDstAlpha;
205 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
209 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
213 inline GLenum CheckFramebufferStatus(GLenum target)
215 return mCheckFramebufferStatusResult;
218 inline void Clear(GLbitfield mask)
222 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
226 inline void ClearDepthf(GLclampf depth)
230 inline void ClearStencil(GLint s)
234 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
238 inline void CompileShader(GLuint shader)
240 std::stringstream out;
242 mShaderTrace.PushCall("CompileShader", out.str());
245 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
249 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
253 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
257 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
261 inline GLuint CreateProgram(void)
263 mShaderTrace.PushCall("CreateProgram", "");
265 ++mLastProgramIdUsed;
266 mUniforms[mLastProgramIdUsed] = UniformIDMap();
267 return mLastProgramIdUsed;
270 inline GLuint CreateShader(GLenum type)
272 std::stringstream out;
274 mShaderTrace.PushCall("CreateShader", out.str());
276 return ++mLastShaderIdUsed;
279 inline void CullFace(GLenum mode)
281 std::stringstream out;
283 mCullFaceTrace.PushCall("CullFace", out.str());
286 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
290 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
294 inline void DeleteProgram(GLuint program)
296 std::stringstream out;
298 mShaderTrace.PushCall("DeleteProgram", out.str());
301 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
305 inline void DeleteShader(GLuint shader)
307 std::stringstream out;
309 mShaderTrace.PushCall("DeleteShader", out.str());
312 inline void DeleteTextures(GLsizei n, const GLuint* textures)
314 std::stringstream out;
315 out << n << ", " << textures << " = [" ;
317 for(GLsizei i=0; i<n; i++)
319 out << textures[i] << ", " ;
320 mDeletedTextureIds.push_back(textures[i]);
323 mTextureTrace.PushCall("DeleteTextures", out.str());
326 inline bool CheckNoTexturesDeleted()
328 return mDeletedTextureIds.size() == 0;
331 inline bool CheckTextureDeleted( GLuint textureId )
335 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
337 if(*iter == textureId)
346 inline void ClearDeletedTextures()
348 mDeletedTextureIds.clear();
351 inline void DepthFunc(GLenum func)
355 inline void DepthMask(GLboolean flag)
359 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
363 inline void DetachShader(GLuint program, GLuint shader)
365 std::stringstream out;
366 out << program << ", " << shader;
367 mShaderTrace.PushCall("DetachShader", out.str());
370 inline void Disable(GLenum cap)
372 std::stringstream out;
374 mCullFaceTrace.PushCall("Disable", out.str());
377 inline void DisableVertexAttribArray(GLuint index)
379 SetVertexAttribArray( index, false );
382 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
384 std::stringstream out;
385 out << mode << ", " << first << ", " << count;
386 mDrawTrace.PushCall("DrawArrays", out.str());
389 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
391 std::stringstream out;
392 out << mode << ", " << count << ", " << type << ", indices";
393 mDrawTrace.PushCall("DrawElements", out.str());
396 inline void Enable(GLenum cap)
398 std::stringstream out;
400 mCullFaceTrace.PushCall("Enable", out.str());
403 inline void EnableVertexAttribArray(GLuint index)
405 SetVertexAttribArray( index, true);
408 inline void Finish(void)
412 inline void Flush(void)
416 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
420 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
424 inline void FrontFace(GLenum mode)
428 inline void GenBuffers(GLsizei n, GLuint* buffers)
430 // avoids an assert in GpuBuffers
434 inline void GenerateMipmap(GLenum target)
438 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
442 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
447 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
448 * @param[in] ids A vector containing the next IDs to be generated
450 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
452 mNextTextureIds = ids;
455 inline const std::vector<GLuint>& GetNextTextureIds()
457 return mNextTextureIds;
460 inline void GenTextures(GLsizei n, GLuint* textures)
462 for( int i=0; i<n; ++i )
464 if( !mNextTextureIds.empty() )
466 *(textures+i) = mNextTextureIds[0];
467 mNextTextureIds.erase( mNextTextureIds.begin() );
471 *(textures+i) = ++mLastAutoTextureIdUsed;
476 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
480 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
484 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
488 inline int GetAttribLocation(GLuint program, const char* name)
490 std::string attribName(name);
492 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
494 if( mStdAttribs[i] == attribName )
500 // 0 is a valid location
504 inline void GetBooleanv(GLenum pname, GLboolean* params)
508 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
512 inline GLenum GetError(void)
514 return mGetErrorResult;
517 inline void GetFloatv(GLenum pname, GLfloat* params)
521 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
525 inline void GetIntegerv(GLenum pname, GLint* params)
529 case GL_MAX_TEXTURE_SIZE:
532 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
535 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
536 *params = mNumBinaryFormats;
538 case GL_PROGRAM_BINARY_FORMATS_OES:
539 *params = mBinaryFormats;
544 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
548 *params = mLinkStatus;
550 case GL_PROGRAM_BINARY_LENGTH_OES:
551 *params = mProgramBinaryLength;
556 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
561 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
565 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
568 case GL_COMPILE_STATUS:
569 *params = mCompileStatus;
574 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
578 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
582 inline const GLubyte* GetString(GLenum name)
584 return mGetStringResult;
587 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
591 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
595 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
599 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
603 inline GLint GetUniformLocation(GLuint program, const char* name)
605 ProgramUniformMap::iterator it = mUniforms.find(program);
606 if( it == mUniforms.end() )
608 // Not a valid program ID
609 mGetErrorResult = GL_INVALID_OPERATION;
613 UniformIDMap& uniformIDs = it->second;
614 UniformIDMap::iterator it2 = uniformIDs.find( name );
615 if( it2 == uniformIDs.end() )
617 // Uniform not found, so add it...
618 uniformIDs[name] = ++mLastUniformIdUsed;
619 return mLastUniformIdUsed;
625 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
629 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
633 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
637 inline void Hint(GLenum target, GLenum mode)
641 inline GLboolean IsBuffer(GLuint buffer)
643 return mIsBufferResult;
646 inline GLboolean IsEnabled(GLenum cap)
648 return mIsEnabledResult;
651 inline GLboolean IsFramebuffer(GLuint framebuffer)
653 return mIsFramebufferResult;
656 inline GLboolean IsProgram(GLuint program)
658 return mIsProgramResult;
661 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
663 return mIsRenderbufferResult;
666 inline GLboolean IsShader(GLuint shader)
668 return mIsShaderResult;
671 inline GLboolean IsTexture(GLuint texture)
673 return mIsTextureResult;
676 inline void LineWidth(GLfloat width)
680 inline void LinkProgram(GLuint program)
682 std::stringstream out;
684 mShaderTrace.PushCall("LinkProgram", out.str());
687 inline void PixelStorei(GLenum pname, GLint param)
691 inline void PolygonOffset(GLfloat factor, GLfloat units)
695 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
699 inline void ReleaseShaderCompiler(void)
703 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
707 inline void SampleCoverage(GLclampf value, GLboolean invert)
711 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
715 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
719 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
721 std::string stringBuilder;
722 for(int i = 0; i < count; ++i)
724 stringBuilder += string[i];
726 mShaderSources[shader] = stringBuilder;
727 mLastShaderCompiled = shader;
730 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
732 const std::string shaderSource = mShaderSources[shader];
733 if( static_cast<int>(shaderSource.length()) < bufsize )
735 strcpy(source, shaderSource.c_str());
736 *length = shaderSource.length();
740 *length = bufsize -1;
741 strncpy(source, shaderSource.c_str(), *length);
742 source[*length] = 0x0;
746 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
750 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
754 inline void StencilMask(GLuint mask)
758 inline void StencilMaskSeparate(GLenum face, GLuint mask)
762 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
766 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
770 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
772 std::stringstream out;
773 out << width << ", " << height;
774 mTextureTrace.PushCall("TexImage2D", out.str());
777 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
781 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
785 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
789 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
793 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
795 std::stringstream out;
796 out << xoffset << ", " << yoffset << ", " << width << ", " << height;
797 mTextureTrace.PushCall("TexSubImage2D", out.str());
800 inline void Uniform1f(GLint location, GLfloat x)
802 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
804 mGetErrorResult = GL_INVALID_OPERATION;
808 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
810 for( int i = 0; i < count; ++i )
812 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
814 mGetErrorResult = GL_INVALID_OPERATION;
820 inline void Uniform1i(GLint location, GLint x)
822 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
824 mGetErrorResult = GL_INVALID_OPERATION;
828 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
830 for( int i = 0; i < count; ++i )
832 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
836 mGetErrorResult = GL_INVALID_OPERATION;
842 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
844 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
848 mGetErrorResult = GL_INVALID_OPERATION;
852 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
854 for( int i = 0; i < count; ++i )
856 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
858 Vector2( v[2*i], v[2*i+1] ) ) )
860 mGetErrorResult = GL_INVALID_OPERATION;
866 inline void Uniform2i(GLint location, GLint x, GLint y)
870 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
874 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
876 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
878 Vector3( x, y, z ) ) )
880 mGetErrorResult = GL_INVALID_OPERATION;
884 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
886 for( int i = 0; i < count; ++i )
888 if( ! mProgramUniforms3f.SetUniformValue(
891 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
893 mGetErrorResult = GL_INVALID_OPERATION;
899 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
903 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
907 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
909 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
911 Vector4( x, y, z, w ) ) )
913 mGetErrorResult = GL_INVALID_OPERATION;
917 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
919 for( int i = 0; i < count; ++i )
921 if( ! mProgramUniforms4f.SetUniformValue(
924 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
926 mGetErrorResult = GL_INVALID_OPERATION;
932 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
936 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
940 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
944 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
946 for( int i = 0; i < count; ++i )
948 if( ! mProgramUniformsMat3.SetUniformValue(
951 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
953 mGetErrorResult = GL_INVALID_OPERATION;
959 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
961 for( int i = 0; i < count; ++i )
963 if( ! mProgramUniformsMat4.SetUniformValue(
968 mGetErrorResult = GL_INVALID_OPERATION;
974 inline void UseProgram(GLuint program)
976 mCurrentProgram = program;
979 inline void ValidateProgram(GLuint program)
983 inline void VertexAttrib1f(GLuint indx, GLfloat x)
987 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
991 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
995 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
999 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1003 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1007 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1011 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1015 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1019 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1025 inline void ReadBuffer(GLenum mode)
1029 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1033 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1037 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)
1041 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1045 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1049 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)
1053 inline void GenQueries(GLsizei n, GLuint* ids)
1057 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1061 inline GLboolean IsQuery(GLuint id)
1066 inline void BeginQuery(GLenum target, GLuint id)
1070 inline void EndQuery(GLenum target)
1074 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1078 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1082 inline GLboolean UnmapBuffer(GLenum target)
1087 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1091 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1095 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1099 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1103 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1107 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1111 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1115 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1119 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1123 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1127 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1131 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1136 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1140 inline void BindVertexArray(GLuint array)
1144 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1148 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1152 inline GLboolean IsVertexArray(GLuint array)
1157 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1161 inline void BeginTransformFeedback(GLenum primitiveMode)
1165 inline void EndTransformFeedback(void)
1169 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1173 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1177 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1181 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1185 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1189 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1193 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1197 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1201 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1205 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1209 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1213 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1217 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1222 inline void Uniform1ui(GLint location, GLuint v0)
1226 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1230 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1234 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1238 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1242 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1246 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1250 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1254 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1258 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1262 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1266 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1270 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1275 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1279 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1283 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1287 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1289 return GL_INVALID_INDEX;
1292 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1296 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1300 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1304 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1308 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1312 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1317 inline GLboolean IsSync(GLsync sync)
1322 inline void DeleteSync(GLsync sync)
1326 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1331 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1335 inline void GetInteger64v(GLenum pname, GLint64* params)
1339 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1343 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1347 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1351 inline void GenSamplers(GLsizei count, GLuint* samplers)
1355 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1359 inline GLboolean IsSampler(GLuint sampler)
1364 inline void BindSampler(GLuint unit, GLuint sampler)
1368 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1372 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1376 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1380 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1384 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1388 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1392 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1396 inline void BindTransformFeedback(GLenum target, GLuint id)
1400 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1404 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1408 inline GLboolean IsTransformFeedback(GLuint id)
1413 inline void PauseTransformFeedback(void)
1417 inline void ResumeTransformFeedback(void)
1421 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1425 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1429 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1433 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1437 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1441 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1445 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1449 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1453 public: // TEST FUNCTIONS
1454 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1455 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1456 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1457 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1458 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1459 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1460 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1461 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1462 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1463 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1464 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1465 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1466 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1467 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1468 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1469 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1471 inline bool GetVertexAttribArrayState(GLuint index)
1473 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1478 return mVertexAttribArrayState[ index ];
1480 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1481 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1483 //Methods for CullFace verification
1484 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1485 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1486 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1488 //Methods for Shader verification
1489 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1490 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1491 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1493 //Methods for Texture verification
1494 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1495 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1496 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1498 //Methods for Draw verification
1499 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1500 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1501 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1503 template <typename T>
1504 inline bool CheckUniformValue( const char* name, const T& value ) const
1506 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1507 program_it != mUniforms.end();
1510 const UniformIDMap &uniformIDs = program_it->second;
1512 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1513 if( uniform_it != uniformIDs.end() )
1515 // found one matching uniform name, lets check the value...
1516 GLuint programId = program_it->first;
1517 GLint uniformId = uniform_it->second;
1519 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1520 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1522 // the value matches
1528 fprintf(stderr, "Not found, printing possible values:" );
1529 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1530 program_it != mUniforms.end();
1533 const UniformIDMap &uniformIDs = program_it->second;
1535 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1536 if( uniform_it != uniformIDs.end() )
1538 // found one matching uniform name, lets check the value...
1539 GLuint programId = program_it->first;
1540 GLint uniformId = uniform_it->second;
1542 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1544 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1546 std::stringstream out;
1547 out << uniform_it->first << ": " << origValue;
1548 fprintf(stderr, "%s", out.str().c_str() );
1555 template <typename T>
1556 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1558 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1559 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1562 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1564 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1565 program_it != mUniforms.end();
1568 const UniformIDMap &uniformIDs = program_it->second;
1570 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1571 if( uniform_it != uniformIDs.end() )
1573 programId = program_it->first;
1574 uniformId = uniform_it->second;
1583 inline GLuint GetLastShaderCompiled() const
1585 return mLastShaderCompiled;
1588 inline GLuint GetLastProgramCreated() const
1590 return mLastProgramIdUsed;
1595 ATTRIB_UNKNOWN = -1,
1600 ATTRIB_BONE_WEIGHTS,
1601 ATTRIB_BONE_INDICES,
1607 GLuint mCurrentProgram;
1608 GLuint mCompileStatus;
1610 GLint mGetAttribLocationResult;
1611 GLenum mGetErrorResult;
1612 GLubyte* mGetStringResult;
1613 GLboolean mIsBufferResult;
1614 GLboolean mIsEnabledResult;
1615 GLboolean mIsFramebufferResult;
1616 GLboolean mIsProgramResult;
1617 GLboolean mIsRenderbufferResult;
1618 GLboolean mIsShaderResult;
1619 GLboolean mIsTextureResult;
1620 GLenum mActiveTextureUnit;
1621 GLenum mCheckFramebufferStatusResult;
1622 GLint mNumBinaryFormats;
1623 GLint mBinaryFormats;
1624 GLint mProgramBinaryLength;
1625 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1626 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1627 typedef std::map< GLuint, std::string> ShaderSourceMap;
1628 ShaderSourceMap mShaderSources;
1629 GLuint mLastShaderCompiled;
1631 Vector4 mLastBlendColor;
1632 GLenum mLastBlendEquationRgb;
1633 GLenum mLastBlendEquationAlpha;
1634 GLenum mLastBlendFuncSrcRgb;
1635 GLenum mLastBlendFuncDstRgb;
1636 GLenum mLastBlendFuncSrcAlpha;
1637 GLenum mLastBlendFuncDstAlpha;
1639 // Data for manipulating the IDs returned by GenTextures
1640 GLuint mLastAutoTextureIdUsed;
1641 std::vector<GLuint> mNextTextureIds;
1642 std::vector<GLuint> mDeletedTextureIds;
1643 std::vector<GLuint> mBoundTextures;
1645 struct ActiveTextureType
1647 std::vector<GLuint> mBoundTextures;
1650 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1652 TraceCallStack mCullFaceTrace;
1653 TraceCallStack mShaderTrace;
1654 TraceCallStack mTextureTrace;
1655 TraceCallStack mDrawTrace;
1657 // Shaders & Uniforms
1658 GLuint mLastShaderIdUsed;
1659 GLuint mLastProgramIdUsed;
1660 GLuint mLastUniformIdUsed;
1661 typedef std::map< std::string, GLint > UniformIDMap;
1662 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1663 ProgramUniformMap mUniforms;
1665 template <typename T>
1666 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1669 typedef std::map< GLint, T > UniformValueMap;
1670 typedef std::map< GLuint, UniformValueMap > Map;
1672 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1679 typename Map::iterator it = Map::find( program );
1680 if( it == Map::end() )
1682 // if its the first uniform for this program add it
1683 std::pair< typename Map::iterator, bool > result =
1684 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1688 UniformValueMap& uniforms = it->second;
1689 uniforms[uniform] = value;
1694 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1697 if ( GetUniformValue( program, uniform, uniformValue ) )
1699 return value == uniformValue;
1705 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1712 typename Map::const_iterator it = Map::find( program );
1713 if( it == Map::end() )
1715 // Uniform values always initialised as 0
1720 const UniformValueMap& uniforms = it->second;
1721 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1722 if( it2 == uniforms.end() )
1724 // Uniform values always initialised as 0
1728 value = it2->second;
1735 ProgramUniformValue<int> mProgramUniforms1i;
1736 ProgramUniformValue<float> mProgramUniforms1f;
1737 ProgramUniformValue<Vector2> mProgramUniforms2f;
1738 ProgramUniformValue<Vector3> mProgramUniforms3f;
1739 ProgramUniformValue<Vector4> mProgramUniforms4f;
1740 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1741 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1743 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1745 return mProgramUniforms1i;
1747 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1749 return mProgramUniforms1f;
1751 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1753 return mProgramUniforms2f;
1755 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1757 return mProgramUniforms3f;
1759 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1761 return mProgramUniforms4f;
1763 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1765 return mProgramUniformsMat4;
1767 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1769 return mProgramUniformsMat3;
1771 inline void SetVertexAttribArray(GLuint index, bool state)
1773 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1778 mVertexAttribArrayState[ index ] = state;
1779 mVertexAttribArrayChanged = true;
1784 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
1790 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
1796 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
1798 return Vector2::ZERO;
1802 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
1804 return Vector3::ZERO;
1808 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
1810 return Vector4::ZERO;
1814 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
1820 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
1822 return Matrix3( Matrix() );
1827 bool BlendEnabled(const Dali::TraceCallStack& callStack);
1828 bool BlendDisabled(const Dali::TraceCallStack& callStack);
1833 #endif // __TEST_GL_ES_H__