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 <dali/dali.h>
29 #include <dali/integration-api/core.h>
30 #include <dali/integration-api/gl-abstraction.h>
31 #include <dali/integration-api/gl-defines.h>
32 #include "test-trace-call-stack.h"
37 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
38 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
40 "aPosition", // ATTRIB_POSITION
41 "aNormal", // ATTRIB_NORMAL
42 "aTexCoord", // ATTRIB_TEXCOORD
43 "aColor", // ATTRIB_COLOR
44 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
45 "aBoneIndices" // ATTRIB_BONE_INDICES
48 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
56 void PostRender(unsigned int timeDelta);
60 inline void ActiveTexture( GLenum textureUnit )
62 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
65 inline GLenum GetActiveTextureUnit() const
67 return mActiveTextureUnit + GL_TEXTURE0;
70 inline void AttachShader( GLuint program, GLuint shader )
72 std::stringstream out;
73 out << program << ", " << shader;
74 mShaderTrace.PushCall("AttachShader", out.str());
77 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
81 inline void BindBuffer( GLenum target, GLuint buffer )
85 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
89 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
94 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
95 * @return A vector containing the IDs that were bound.
97 inline const std::vector<GLuint>& GetBoundTextures() const
99 return mBoundTextures;
103 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
104 * @param[in] activeTextureUnit The specific active texture unit.
105 * @return A vector containing the IDs that were bound.
107 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
109 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
113 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
115 inline void ClearBoundTextures()
117 mBoundTextures.clear();
119 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
121 mActiveTextures[ i ].mBoundTextures.clear();
125 inline void BindTexture( GLenum target, GLuint texture )
127 // Record the bound textures for future checks
130 mBoundTextures.push_back( texture );
132 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
134 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
138 std::stringstream out;
139 out << target << ", " << texture;
140 mTextureTrace.PushCall("BindTexture", out.str());
143 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
145 mLastBlendColor.r = red;
146 mLastBlendColor.g = green;
147 mLastBlendColor.b = blue;
148 mLastBlendColor.a = alpha;
151 inline const Vector4& GetLastBlendColor() const
153 return mLastBlendColor;
156 inline void BlendEquation( GLenum mode )
158 mLastBlendEquationRgb = mode;
159 mLastBlendEquationAlpha = mode;
162 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
164 mLastBlendEquationRgb = modeRgb;
165 mLastBlendEquationAlpha = modeAlpha;
168 inline GLenum GetLastBlendEquationRgb() const
170 return mLastBlendEquationRgb;
173 inline GLenum GetLastBlendEquationAlpha() const
175 return mLastBlendEquationAlpha;
178 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
180 mLastBlendFuncSrcRgb = sfactor;
181 mLastBlendFuncDstRgb = dfactor;
182 mLastBlendFuncSrcAlpha = sfactor;
183 mLastBlendFuncDstAlpha = dfactor;
186 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
188 mLastBlendFuncSrcRgb = srcRGB;
189 mLastBlendFuncDstRgb = dstRGB;
190 mLastBlendFuncSrcAlpha = srcAlpha;
191 mLastBlendFuncDstAlpha = dstAlpha;
194 inline GLenum GetLastBlendFuncSrcRgb() const
196 return mLastBlendFuncSrcRgb;
199 inline GLenum GetLastBlendFuncDstRgb() const
201 return mLastBlendFuncDstRgb;
204 inline GLenum GetLastBlendFuncSrcAlpha() const
206 return mLastBlendFuncSrcAlpha;
209 inline GLenum GetLastBlendFuncDstAlpha() const
211 return mLastBlendFuncDstAlpha;
214 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
218 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
222 inline GLenum CheckFramebufferStatus(GLenum target)
224 return mCheckFramebufferStatusResult;
227 inline void Clear(GLbitfield mask)
231 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
235 inline void ClearDepthf(GLclampf depth)
239 inline void ClearStencil(GLint s)
243 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
247 inline void CompileShader(GLuint shader)
249 std::stringstream out;
251 mShaderTrace.PushCall("CompileShader", out.str());
254 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
258 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
262 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
266 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
270 inline GLuint CreateProgram(void)
272 mShaderTrace.PushCall("CreateProgram", "");
274 ++mLastProgramIdUsed;
275 mUniforms[mLastProgramIdUsed] = UniformIDMap();
276 return mLastProgramIdUsed;
279 inline GLuint CreateShader(GLenum type)
281 std::stringstream out;
283 mShaderTrace.PushCall("CreateShader", out.str());
285 return ++mLastShaderIdUsed;
288 inline void CullFace(GLenum mode)
290 std::stringstream out;
292 mCullFaceTrace.PushCall("CullFace", out.str());
295 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
299 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
303 inline void DeleteProgram(GLuint program)
305 std::stringstream out;
307 mShaderTrace.PushCall("DeleteProgram", out.str());
310 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
314 inline void DeleteShader(GLuint shader)
316 std::stringstream out;
318 mShaderTrace.PushCall("DeleteShader", out.str());
321 inline void DeleteTextures(GLsizei n, const GLuint* textures)
323 std::stringstream out;
324 out << n << ", " << textures << " = [" ;
326 for(GLsizei i=0; i<n; i++)
328 out << textures[i] << ", " ;
329 mDeletedTextureIds.push_back(textures[i]);
332 mTextureTrace.PushCall("DeleteTextures", out.str());
335 inline bool CheckNoTexturesDeleted()
337 return mDeletedTextureIds.size() == 0;
340 inline bool CheckTextureDeleted( GLuint textureId )
344 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
346 if(*iter == textureId)
355 inline void ClearDeletedTextures()
357 mDeletedTextureIds.clear();
360 inline void DepthFunc(GLenum func)
364 inline void DepthMask(GLboolean flag)
368 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
372 inline void DetachShader(GLuint program, GLuint shader)
374 std::stringstream out;
375 out << program << ", " << shader;
376 mShaderTrace.PushCall("DetachShader", out.str());
379 inline void Disable(GLenum cap)
381 std::stringstream out;
383 mCullFaceTrace.PushCall("Disable", out.str());
386 inline void DisableVertexAttribArray(GLuint index)
388 SetVertexAttribArray( index, false );
391 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
393 std::stringstream out;
394 out << mode << ", " << first << ", " << count;
395 mDrawTrace.PushCall("DrawArrays", out.str());
398 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
400 std::stringstream out;
401 out << mode << ", " << count << ", " << type << ", indices";
402 mDrawTrace.PushCall("DrawElements", out.str());
405 inline void Enable(GLenum cap)
407 std::stringstream out;
409 mCullFaceTrace.PushCall("Enable", out.str());
412 inline void EnableVertexAttribArray(GLuint index)
414 SetVertexAttribArray( index, true);
417 inline void Finish(void)
421 inline void Flush(void)
425 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
429 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
433 inline void FrontFace(GLenum mode)
437 inline void GenBuffers(GLsizei n, GLuint* buffers)
439 // avoids an assert in GpuBuffers
443 inline void GenerateMipmap(GLenum target)
447 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
451 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
456 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
457 * @param[in] ids A vector containing the next IDs to be generated
459 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
461 mNextTextureIds = ids;
464 inline const std::vector<GLuint>& GetNextTextureIds()
466 return mNextTextureIds;
469 inline void GenTextures(GLsizei n, GLuint* textures)
471 for( int i=0; i<n; ++i )
473 if( !mNextTextureIds.empty() )
475 *(textures+i) = mNextTextureIds[0];
476 mNextTextureIds.erase( mNextTextureIds.begin() );
480 *(textures+i) = ++mLastAutoTextureIdUsed;
484 std::stringstream out;
485 for(int i=0; i<n; i++)
493 mTextureTrace.PushCall("GenTexture", out.str());
496 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
500 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
504 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
508 inline int GetAttribLocation(GLuint program, const char* name)
510 std::string attribName(name);
512 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
514 if( mStdAttribs[i] == attribName )
520 // 0 is a valid location
524 inline void GetBooleanv(GLenum pname, GLboolean* params)
528 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
532 inline GLenum GetError(void)
534 return mGetErrorResult;
537 inline void GetFloatv(GLenum pname, GLfloat* params)
541 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
545 inline void GetIntegerv(GLenum pname, GLint* params)
549 case GL_MAX_TEXTURE_SIZE:
552 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
555 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
556 *params = mNumBinaryFormats;
558 case GL_PROGRAM_BINARY_FORMATS_OES:
559 *params = mBinaryFormats;
564 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
568 *params = mLinkStatus;
570 case GL_PROGRAM_BINARY_LENGTH_OES:
571 *params = mProgramBinaryLength;
576 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
581 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
585 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
588 case GL_COMPILE_STATUS:
589 *params = mCompileStatus;
594 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
598 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
602 inline const GLubyte* GetString(GLenum name)
604 return mGetStringResult;
607 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
611 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
615 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
619 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
623 inline GLint GetUniformLocation(GLuint program, const char* name)
625 ProgramUniformMap::iterator it = mUniforms.find(program);
626 if( it == mUniforms.end() )
628 // Not a valid program ID
629 mGetErrorResult = GL_INVALID_OPERATION;
633 UniformIDMap& uniformIDs = it->second;
634 UniformIDMap::iterator it2 = uniformIDs.find( name );
635 if( it2 == uniformIDs.end() )
637 // Uniform not found, so add it...
638 uniformIDs[name] = ++mLastUniformIdUsed;
639 return mLastUniformIdUsed;
645 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
649 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
653 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
657 inline void Hint(GLenum target, GLenum mode)
661 inline GLboolean IsBuffer(GLuint buffer)
663 return mIsBufferResult;
666 inline GLboolean IsEnabled(GLenum cap)
668 return mIsEnabledResult;
671 inline GLboolean IsFramebuffer(GLuint framebuffer)
673 return mIsFramebufferResult;
676 inline GLboolean IsProgram(GLuint program)
678 return mIsProgramResult;
681 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
683 return mIsRenderbufferResult;
686 inline GLboolean IsShader(GLuint shader)
688 return mIsShaderResult;
691 inline GLboolean IsTexture(GLuint texture)
693 return mIsTextureResult;
696 inline void LineWidth(GLfloat width)
700 inline void LinkProgram(GLuint program)
702 std::stringstream out;
704 mShaderTrace.PushCall("LinkProgram", out.str());
707 inline void PixelStorei(GLenum pname, GLint param)
711 inline void PolygonOffset(GLfloat factor, GLfloat units)
715 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
719 inline void ReleaseShaderCompiler(void)
723 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
727 inline void SampleCoverage(GLclampf value, GLboolean invert)
731 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
735 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
739 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
741 std::string stringBuilder;
742 for(int i = 0; i < count; ++i)
744 stringBuilder += string[i];
746 mShaderSources[shader] = stringBuilder;
747 mLastShaderCompiled = shader;
750 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
752 const std::string shaderSource = mShaderSources[shader];
753 if( static_cast<int>(shaderSource.length()) < bufsize )
755 strcpy(source, shaderSource.c_str());
756 *length = shaderSource.length();
760 *length = bufsize -1;
761 strncpy(source, shaderSource.c_str(), *length);
762 source[*length] = 0x0;
766 inline std::string GetShaderSource(GLuint shader)
768 return mShaderSources[shader];
771 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
775 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
779 inline void StencilMask(GLuint mask)
783 inline void StencilMaskSeparate(GLenum face, GLuint mask)
787 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
791 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
795 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
797 std::stringstream out;
798 out << width << ", " << height;
799 mTextureTrace.PushCall("TexImage2D", out.str());
802 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
804 std::stringstream out;
805 out << target << ", " << pname << ", " << param;
806 mTexParamaterTrace.PushCall("TexParameterf", out.str());
809 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
811 std::stringstream out;
812 out << target << ", " << pname << ", " << params[0];
813 mTexParamaterTrace.PushCall("TexParameterfv", out.str());
816 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
818 std::stringstream out;
819 out << target << ", " << pname << ", " << param;
820 mTexParamaterTrace.PushCall("TexParameteri", out.str());
823 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
825 std::stringstream out;
826 out << target << ", " << pname << ", " << params[0];
827 mTexParamaterTrace.PushCall("TexParameteriv", out.str());
830 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
832 std::stringstream out;
833 out << xoffset << ", " << yoffset << ", " << width << ", " << height;
834 mTextureTrace.PushCall("TexSubImage2D", out.str());
837 inline void Uniform1f(GLint location, GLfloat x)
839 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
841 mGetErrorResult = GL_INVALID_OPERATION;
845 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
847 for( int i = 0; i < count; ++i )
849 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
851 mGetErrorResult = GL_INVALID_OPERATION;
857 inline void Uniform1i(GLint location, GLint x)
859 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
861 mGetErrorResult = GL_INVALID_OPERATION;
865 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
867 for( int i = 0; i < count; ++i )
869 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
873 mGetErrorResult = GL_INVALID_OPERATION;
879 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
881 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
885 mGetErrorResult = GL_INVALID_OPERATION;
889 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
891 for( int i = 0; i < count; ++i )
893 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
895 Vector2( v[2*i], v[2*i+1] ) ) )
897 mGetErrorResult = GL_INVALID_OPERATION;
903 inline void Uniform2i(GLint location, GLint x, GLint y)
907 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
911 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
913 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
915 Vector3( x, y, z ) ) )
917 mGetErrorResult = GL_INVALID_OPERATION;
921 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
923 for( int i = 0; i < count; ++i )
925 if( ! mProgramUniforms3f.SetUniformValue(
928 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
930 mGetErrorResult = GL_INVALID_OPERATION;
936 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
940 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
944 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
946 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
948 Vector4( x, y, z, w ) ) )
950 mGetErrorResult = GL_INVALID_OPERATION;
954 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
956 for( int i = 0; i < count; ++i )
958 if( ! mProgramUniforms4f.SetUniformValue(
961 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
963 mGetErrorResult = GL_INVALID_OPERATION;
969 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
973 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
977 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
981 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
983 for( int i = 0; i < count; ++i )
985 if( ! mProgramUniformsMat3.SetUniformValue(
988 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
990 mGetErrorResult = GL_INVALID_OPERATION;
996 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
998 for( int i = 0; i < count; ++i )
1000 if( ! mProgramUniformsMat4.SetUniformValue(
1005 mGetErrorResult = GL_INVALID_OPERATION;
1011 inline void UseProgram(GLuint program)
1013 mCurrentProgram = program;
1016 inline void ValidateProgram(GLuint program)
1020 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1024 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1028 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1032 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1036 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1040 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1044 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1048 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1052 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1056 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1062 inline void ReadBuffer(GLenum mode)
1066 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1070 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1074 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)
1078 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1082 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1086 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)
1090 inline void GenQueries(GLsizei n, GLuint* ids)
1094 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1098 inline GLboolean IsQuery(GLuint id)
1103 inline void BeginQuery(GLenum target, GLuint id)
1107 inline void EndQuery(GLenum target)
1111 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1115 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1119 inline GLboolean UnmapBuffer(GLenum target)
1124 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1128 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1132 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1136 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1140 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1144 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1148 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1152 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1156 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1160 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1164 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1168 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1173 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1177 inline void BindVertexArray(GLuint array)
1181 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1185 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1189 inline GLboolean IsVertexArray(GLuint array)
1194 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1198 inline void BeginTransformFeedback(GLenum primitiveMode)
1202 inline void EndTransformFeedback(void)
1206 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1210 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1214 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1218 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1222 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1226 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1230 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1234 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1238 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1242 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1246 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1250 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1254 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1259 inline void Uniform1ui(GLint location, GLuint v0)
1263 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1267 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1271 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1275 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1279 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1283 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1287 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1291 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1295 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1299 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1303 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1307 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1312 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1316 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1320 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1324 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1326 return GL_INVALID_INDEX;
1329 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1333 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1337 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1341 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1345 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1349 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1354 inline GLboolean IsSync(GLsync sync)
1359 inline void DeleteSync(GLsync sync)
1363 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1368 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1372 inline void GetInteger64v(GLenum pname, GLint64* params)
1376 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1380 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1384 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1388 inline void GenSamplers(GLsizei count, GLuint* samplers)
1392 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1396 inline GLboolean IsSampler(GLuint sampler)
1401 inline void BindSampler(GLuint unit, GLuint sampler)
1405 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1409 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1413 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1417 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1421 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1425 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1429 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1433 inline void BindTransformFeedback(GLenum target, GLuint id)
1437 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1441 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1445 inline GLboolean IsTransformFeedback(GLuint id)
1450 inline void PauseTransformFeedback(void)
1454 inline void ResumeTransformFeedback(void)
1458 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1462 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1466 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1470 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1474 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1478 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1482 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1486 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1490 public: // TEST FUNCTIONS
1491 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1492 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1493 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1494 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1495 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1496 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1497 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1498 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1499 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1500 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1501 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1502 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1503 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1504 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1505 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1506 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1508 inline bool GetVertexAttribArrayState(GLuint index)
1510 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1515 return mVertexAttribArrayState[ index ];
1517 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1518 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1520 //Methods for CullFace verification
1521 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1522 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1523 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1525 //Methods for Shader verification
1526 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1527 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1528 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1530 //Methods for Texture verification
1531 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1532 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1533 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1535 //Methods for Texture verification
1536 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1537 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1538 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1540 //Methods for Draw verification
1541 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1542 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1543 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1545 template <typename T>
1546 inline bool CheckUniformValue( const char* name, const T& value ) const
1548 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1549 program_it != mUniforms.end();
1552 const UniformIDMap &uniformIDs = program_it->second;
1554 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1555 if( uniform_it != uniformIDs.end() )
1557 // found one matching uniform name, lets check the value...
1558 GLuint programId = program_it->first;
1559 GLint uniformId = uniform_it->second;
1561 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1562 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1564 // the value matches
1570 fprintf(stderr, "Not found, printing possible values:" );
1571 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1572 program_it != mUniforms.end();
1575 const UniformIDMap &uniformIDs = program_it->second;
1577 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1578 if( uniform_it != uniformIDs.end() )
1580 // found one matching uniform name, lets check the value...
1581 GLuint programId = program_it->first;
1582 GLint uniformId = uniform_it->second;
1584 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1586 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1588 std::stringstream out;
1589 out << uniform_it->first << ": " << origValue;
1590 fprintf(stderr, "%s", out.str().c_str() );
1597 template <typename T>
1598 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1600 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1601 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1604 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1606 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1607 program_it != mUniforms.end();
1610 const UniformIDMap &uniformIDs = program_it->second;
1612 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1613 if( uniform_it != uniformIDs.end() )
1615 programId = program_it->first;
1616 uniformId = uniform_it->second;
1625 inline GLuint GetLastShaderCompiled() const
1627 return mLastShaderCompiled;
1630 inline GLuint GetLastProgramCreated() const
1632 return mLastProgramIdUsed;
1637 ATTRIB_UNKNOWN = -1,
1642 ATTRIB_BONE_WEIGHTS,
1643 ATTRIB_BONE_INDICES,
1649 GLuint mCurrentProgram;
1650 GLuint mCompileStatus;
1652 GLint mGetAttribLocationResult;
1653 GLenum mGetErrorResult;
1654 GLubyte* mGetStringResult;
1655 GLboolean mIsBufferResult;
1656 GLboolean mIsEnabledResult;
1657 GLboolean mIsFramebufferResult;
1658 GLboolean mIsProgramResult;
1659 GLboolean mIsRenderbufferResult;
1660 GLboolean mIsShaderResult;
1661 GLboolean mIsTextureResult;
1662 GLenum mActiveTextureUnit;
1663 GLenum mCheckFramebufferStatusResult;
1664 GLint mNumBinaryFormats;
1665 GLint mBinaryFormats;
1666 GLint mProgramBinaryLength;
1667 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1668 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1669 typedef std::map< GLuint, std::string> ShaderSourceMap;
1670 ShaderSourceMap mShaderSources;
1671 GLuint mLastShaderCompiled;
1673 Vector4 mLastBlendColor;
1674 GLenum mLastBlendEquationRgb;
1675 GLenum mLastBlendEquationAlpha;
1676 GLenum mLastBlendFuncSrcRgb;
1677 GLenum mLastBlendFuncDstRgb;
1678 GLenum mLastBlendFuncSrcAlpha;
1679 GLenum mLastBlendFuncDstAlpha;
1681 // Data for manipulating the IDs returned by GenTextures
1682 GLuint mLastAutoTextureIdUsed;
1683 std::vector<GLuint> mNextTextureIds;
1684 std::vector<GLuint> mDeletedTextureIds;
1685 std::vector<GLuint> mBoundTextures;
1687 struct ActiveTextureType
1689 std::vector<GLuint> mBoundTextures;
1692 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1694 TraceCallStack mCullFaceTrace;
1695 TraceCallStack mShaderTrace;
1696 TraceCallStack mTextureTrace;
1697 TraceCallStack mTexParamaterTrace;
1698 TraceCallStack mDrawTrace;
1700 // Shaders & Uniforms
1701 GLuint mLastShaderIdUsed;
1702 GLuint mLastProgramIdUsed;
1703 GLuint mLastUniformIdUsed;
1704 typedef std::map< std::string, GLint > UniformIDMap;
1705 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1706 ProgramUniformMap mUniforms;
1708 template <typename T>
1709 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1712 typedef std::map< GLint, T > UniformValueMap;
1713 typedef std::map< GLuint, UniformValueMap > Map;
1715 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1722 typename Map::iterator it = Map::find( program );
1723 if( it == Map::end() )
1725 // if its the first uniform for this program add it
1726 std::pair< typename Map::iterator, bool > result =
1727 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1731 UniformValueMap& uniforms = it->second;
1732 uniforms[uniform] = value;
1737 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1740 if ( GetUniformValue( program, uniform, uniformValue ) )
1742 return value == uniformValue;
1748 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1755 typename Map::const_iterator it = Map::find( program );
1756 if( it == Map::end() )
1758 // Uniform values always initialised as 0
1763 const UniformValueMap& uniforms = it->second;
1764 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1765 if( it2 == uniforms.end() )
1767 // Uniform values always initialised as 0
1771 value = it2->second;
1778 ProgramUniformValue<int> mProgramUniforms1i;
1779 ProgramUniformValue<float> mProgramUniforms1f;
1780 ProgramUniformValue<Vector2> mProgramUniforms2f;
1781 ProgramUniformValue<Vector3> mProgramUniforms3f;
1782 ProgramUniformValue<Vector4> mProgramUniforms4f;
1783 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1784 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1786 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1788 return mProgramUniforms1i;
1790 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1792 return mProgramUniforms1f;
1794 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1796 return mProgramUniforms2f;
1798 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1800 return mProgramUniforms3f;
1802 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1804 return mProgramUniforms4f;
1806 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1808 return mProgramUniformsMat4;
1810 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1812 return mProgramUniformsMat3;
1814 inline void SetVertexAttribArray(GLuint index, bool state)
1816 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1821 mVertexAttribArrayState[ index ] = state;
1822 mVertexAttribArrayChanged = true;
1827 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
1833 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
1839 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
1841 return Vector2::ZERO;
1845 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
1847 return Vector3::ZERO;
1851 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
1853 return Vector4::ZERO;
1857 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
1863 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
1865 return Matrix3( Matrix() );
1870 bool BlendEnabled(const Dali::TraceCallStack& callStack);
1871 bool BlendDisabled(const Dali::TraceCallStack& callStack);
1876 #endif // __TEST_GL_ES_H__