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/public-api/dali-core.h>
28 #include <dali/integration-api/core.h>
29 #include <dali/integration-api/gl-abstraction.h>
30 #include <dali/integration-api/gl-defines.h>
31 #include "test-trace-call-stack.h"
36 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
37 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
39 "aPosition", // ATTRIB_POSITION
40 "aNormal", // ATTRIB_NORMAL
41 "aTexCoord", // ATTRIB_TEXCOORD
42 "aColor", // ATTRIB_COLOR
43 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
44 "aBoneIndices" // ATTRIB_BONE_INDICES
47 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
55 void PostRender(unsigned int timeDelta);
59 inline void ActiveTexture( GLenum textureUnit )
61 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
64 inline GLenum GetActiveTextureUnit() const
66 return mActiveTextureUnit + GL_TEXTURE0;
69 inline void AttachShader( GLuint program, GLuint shader )
71 std::stringstream out;
72 out << program << ", " << shader;
73 mShaderTrace.PushCall("AttachShader", out.str());
76 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
80 inline void BindBuffer( GLenum target, GLuint buffer )
84 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
88 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
93 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
94 * @return A vector containing the IDs that were bound.
96 inline const std::vector<GLuint>& GetBoundTextures() const
98 return mBoundTextures;
102 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
103 * @param[in] activeTextureUnit The specific active texture unit.
104 * @return A vector containing the IDs that were bound.
106 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
108 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
112 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
114 inline void ClearBoundTextures()
116 mBoundTextures.clear();
118 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
120 mActiveTextures[ i ].mBoundTextures.clear();
124 inline void BindTexture( GLenum target, GLuint texture )
126 // Record the bound textures for future checks
129 mBoundTextures.push_back( texture );
131 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
133 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
137 std::stringstream out;
138 out << target << ", " << texture;
139 mTextureTrace.PushCall("BindTexture", out.str());
142 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
144 mLastBlendColor.r = red;
145 mLastBlendColor.g = green;
146 mLastBlendColor.b = blue;
147 mLastBlendColor.a = alpha;
150 inline const Vector4& GetLastBlendColor() const
152 return mLastBlendColor;
155 inline void BlendEquation( GLenum mode )
157 mLastBlendEquationRgb = mode;
158 mLastBlendEquationAlpha = mode;
161 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
163 mLastBlendEquationRgb = modeRgb;
164 mLastBlendEquationAlpha = modeAlpha;
167 inline GLenum GetLastBlendEquationRgb() const
169 return mLastBlendEquationRgb;
172 inline GLenum GetLastBlendEquationAlpha() const
174 return mLastBlendEquationAlpha;
177 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
179 mLastBlendFuncSrcRgb = sfactor;
180 mLastBlendFuncDstRgb = dfactor;
181 mLastBlendFuncSrcAlpha = sfactor;
182 mLastBlendFuncDstAlpha = dfactor;
185 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
187 mLastBlendFuncSrcRgb = srcRGB;
188 mLastBlendFuncDstRgb = dstRGB;
189 mLastBlendFuncSrcAlpha = srcAlpha;
190 mLastBlendFuncDstAlpha = dstAlpha;
193 inline GLenum GetLastBlendFuncSrcRgb() const
195 return mLastBlendFuncSrcRgb;
198 inline GLenum GetLastBlendFuncDstRgb() const
200 return mLastBlendFuncDstRgb;
203 inline GLenum GetLastBlendFuncSrcAlpha() const
205 return mLastBlendFuncSrcAlpha;
208 inline GLenum GetLastBlendFuncDstAlpha() const
210 return mLastBlendFuncDstAlpha;
213 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
217 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
221 inline GLenum CheckFramebufferStatus(GLenum target)
223 return mCheckFramebufferStatusResult;
226 inline void Clear(GLbitfield mask)
230 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
234 inline void ClearDepthf(GLclampf depth)
238 inline void ClearStencil(GLint s)
242 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
246 inline void CompileShader(GLuint shader)
248 std::stringstream out;
250 mShaderTrace.PushCall("CompileShader", out.str());
253 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
257 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
261 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
265 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
269 inline GLuint CreateProgram(void)
271 mShaderTrace.PushCall("CreateProgram", "");
273 ++mLastProgramIdUsed;
274 mUniforms[mLastProgramIdUsed] = UniformIDMap();
275 return mLastProgramIdUsed;
278 inline GLuint CreateShader(GLenum type)
280 std::stringstream out;
282 mShaderTrace.PushCall("CreateShader", out.str());
284 return ++mLastShaderIdUsed;
287 inline void CullFace(GLenum mode)
289 std::stringstream out;
291 mCullFaceTrace.PushCall("CullFace", out.str());
294 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
298 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
302 inline void DeleteProgram(GLuint program)
304 std::stringstream out;
306 mShaderTrace.PushCall("DeleteProgram", out.str());
309 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
313 inline void DeleteShader(GLuint shader)
315 std::stringstream out;
317 mShaderTrace.PushCall("DeleteShader", out.str());
320 inline void DeleteTextures(GLsizei n, const GLuint* textures)
322 std::stringstream out;
323 out << n << ", " << textures << " = [" ;
325 for(GLsizei i=0; i<n; i++)
327 out << textures[i] << ", " ;
328 mDeletedTextureIds.push_back(textures[i]);
331 mTextureTrace.PushCall("DeleteTextures", out.str());
334 inline bool CheckNoTexturesDeleted()
336 return mDeletedTextureIds.size() == 0;
339 inline bool CheckTextureDeleted( GLuint textureId )
343 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
345 if(*iter == textureId)
354 inline void ClearDeletedTextures()
356 mDeletedTextureIds.clear();
359 inline void DepthFunc(GLenum func)
363 inline void DepthMask(GLboolean flag)
367 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
371 inline void DetachShader(GLuint program, GLuint shader)
373 std::stringstream out;
374 out << program << ", " << shader;
375 mShaderTrace.PushCall("DetachShader", out.str());
378 inline void Disable(GLenum cap)
380 std::stringstream out;
382 mCullFaceTrace.PushCall("Disable", out.str());
385 inline void DisableVertexAttribArray(GLuint index)
387 SetVertexAttribArray( index, false );
390 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
392 std::stringstream out;
393 out << mode << ", " << first << ", " << count;
394 mDrawTrace.PushCall("DrawArrays", out.str());
397 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
399 std::stringstream out;
400 out << mode << ", " << count << ", " << type << ", indices";
401 mDrawTrace.PushCall("DrawElements", out.str());
404 inline void Enable(GLenum cap)
406 std::stringstream out;
408 mCullFaceTrace.PushCall("Enable", out.str());
411 inline void EnableVertexAttribArray(GLuint index)
413 SetVertexAttribArray( index, true);
416 inline void Finish(void)
420 inline void Flush(void)
424 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
428 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
432 inline void FrontFace(GLenum mode)
436 inline void GenBuffers(GLsizei n, GLuint* buffers)
438 // avoids an assert in GpuBuffers
442 inline void GenerateMipmap(GLenum target)
446 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
450 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
455 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
456 * @param[in] ids A vector containing the next IDs to be generated
458 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
460 mNextTextureIds = ids;
463 inline const std::vector<GLuint>& GetNextTextureIds()
465 return mNextTextureIds;
468 inline void GenTextures(GLsizei n, GLuint* textures)
470 for( int i=0; i<n; ++i )
472 if( !mNextTextureIds.empty() )
474 *(textures+i) = mNextTextureIds[0];
475 mNextTextureIds.erase( mNextTextureIds.begin() );
479 *(textures+i) = ++mLastAutoTextureIdUsed;
483 std::stringstream out;
484 for(int i=0; i<n; i++)
492 mTextureTrace.PushCall("GenTexture", out.str());
495 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
499 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
503 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
507 inline int GetAttribLocation(GLuint program, const char* name)
509 std::string attribName(name);
511 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
513 if( mStdAttribs[i] == attribName )
519 // 0 is a valid location
523 inline void GetBooleanv(GLenum pname, GLboolean* params)
527 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
531 inline GLenum GetError(void)
533 return mGetErrorResult;
536 inline void GetFloatv(GLenum pname, GLfloat* params)
540 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
544 inline void GetIntegerv(GLenum pname, GLint* params)
548 case GL_MAX_TEXTURE_SIZE:
551 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
554 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
555 *params = mNumBinaryFormats;
557 case GL_PROGRAM_BINARY_FORMATS_OES:
558 *params = mBinaryFormats;
563 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
567 *params = mLinkStatus;
569 case GL_PROGRAM_BINARY_LENGTH_OES:
570 *params = mProgramBinaryLength;
575 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
580 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
584 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
587 case GL_COMPILE_STATUS:
588 *params = mCompileStatus;
593 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
597 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
601 inline const GLubyte* GetString(GLenum name)
603 return mGetStringResult;
606 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
610 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
614 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
618 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
622 inline GLint GetUniformLocation(GLuint program, const char* name)
624 ProgramUniformMap::iterator it = mUniforms.find(program);
625 if( it == mUniforms.end() )
627 // Not a valid program ID
628 mGetErrorResult = GL_INVALID_OPERATION;
632 UniformIDMap& uniformIDs = it->second;
633 UniformIDMap::iterator it2 = uniformIDs.find( name );
634 if( it2 == uniformIDs.end() )
636 // Uniform not found, so add it...
637 uniformIDs[name] = ++mLastUniformIdUsed;
638 return mLastUniformIdUsed;
644 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
648 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
652 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
656 inline void Hint(GLenum target, GLenum mode)
660 inline GLboolean IsBuffer(GLuint buffer)
662 return mIsBufferResult;
665 inline GLboolean IsEnabled(GLenum cap)
667 return mIsEnabledResult;
670 inline GLboolean IsFramebuffer(GLuint framebuffer)
672 return mIsFramebufferResult;
675 inline GLboolean IsProgram(GLuint program)
677 return mIsProgramResult;
680 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
682 return mIsRenderbufferResult;
685 inline GLboolean IsShader(GLuint shader)
687 return mIsShaderResult;
690 inline GLboolean IsTexture(GLuint texture)
692 return mIsTextureResult;
695 inline void LineWidth(GLfloat width)
699 inline void LinkProgram(GLuint program)
701 std::stringstream out;
703 mShaderTrace.PushCall("LinkProgram", out.str());
706 inline void PixelStorei(GLenum pname, GLint param)
710 inline void PolygonOffset(GLfloat factor, GLfloat units)
714 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
718 inline void ReleaseShaderCompiler(void)
722 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
726 inline void SampleCoverage(GLclampf value, GLboolean invert)
730 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
734 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
738 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
740 std::string stringBuilder;
741 for(int i = 0; i < count; ++i)
743 stringBuilder += string[i];
745 mShaderSources[shader] = stringBuilder;
746 mLastShaderCompiled = shader;
749 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
751 const std::string shaderSource = mShaderSources[shader];
752 if( static_cast<int>(shaderSource.length()) < bufsize )
754 strcpy(source, shaderSource.c_str());
755 *length = shaderSource.length();
759 *length = bufsize -1;
760 strncpy(source, shaderSource.c_str(), *length);
761 source[*length] = 0x0;
765 inline std::string GetShaderSource(GLuint shader)
767 return mShaderSources[shader];
770 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
774 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
778 inline void StencilMask(GLuint mask)
782 inline void StencilMaskSeparate(GLenum face, GLuint mask)
786 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
790 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
794 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
796 std::stringstream out;
797 out << width << ", " << height;
798 mTextureTrace.PushCall("TexImage2D", out.str());
801 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
803 std::stringstream out;
804 out << target << ", " << pname << ", " << param;
805 mTexParamaterTrace.PushCall("TexParameterf", out.str());
808 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
810 std::stringstream out;
811 out << target << ", " << pname << ", " << params[0];
812 mTexParamaterTrace.PushCall("TexParameterfv", out.str());
815 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
817 std::stringstream out;
818 out << target << ", " << pname << ", " << param;
819 mTexParamaterTrace.PushCall("TexParameteri", out.str());
822 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
824 std::stringstream out;
825 out << target << ", " << pname << ", " << params[0];
826 mTexParamaterTrace.PushCall("TexParameteriv", out.str());
829 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
831 std::stringstream out;
832 out << xoffset << ", " << yoffset << ", " << width << ", " << height;
833 mTextureTrace.PushCall("TexSubImage2D", out.str());
836 inline void Uniform1f(GLint location, GLfloat x)
838 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
840 mGetErrorResult = GL_INVALID_OPERATION;
844 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
846 for( int i = 0; i < count; ++i )
848 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
850 mGetErrorResult = GL_INVALID_OPERATION;
856 inline void Uniform1i(GLint location, GLint x)
858 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
860 mGetErrorResult = GL_INVALID_OPERATION;
864 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
866 for( int i = 0; i < count; ++i )
868 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
872 mGetErrorResult = GL_INVALID_OPERATION;
878 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
880 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
884 mGetErrorResult = GL_INVALID_OPERATION;
888 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
890 for( int i = 0; i < count; ++i )
892 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
894 Vector2( v[2*i], v[2*i+1] ) ) )
896 mGetErrorResult = GL_INVALID_OPERATION;
902 inline void Uniform2i(GLint location, GLint x, GLint y)
906 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
910 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
912 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
914 Vector3( x, y, z ) ) )
916 mGetErrorResult = GL_INVALID_OPERATION;
920 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
922 for( int i = 0; i < count; ++i )
924 if( ! mProgramUniforms3f.SetUniformValue(
927 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
929 mGetErrorResult = GL_INVALID_OPERATION;
935 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
939 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
943 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
945 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
947 Vector4( x, y, z, w ) ) )
949 mGetErrorResult = GL_INVALID_OPERATION;
953 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
955 for( int i = 0; i < count; ++i )
957 if( ! mProgramUniforms4f.SetUniformValue(
960 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
962 mGetErrorResult = GL_INVALID_OPERATION;
968 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
972 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
976 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
980 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
982 for( int i = 0; i < count; ++i )
984 if( ! mProgramUniformsMat3.SetUniformValue(
987 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
989 mGetErrorResult = GL_INVALID_OPERATION;
995 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
997 for( int i = 0; i < count; ++i )
999 if( ! mProgramUniformsMat4.SetUniformValue(
1004 mGetErrorResult = GL_INVALID_OPERATION;
1010 inline void UseProgram(GLuint program)
1012 mCurrentProgram = program;
1015 inline void ValidateProgram(GLuint program)
1019 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1023 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1027 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1031 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1035 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1039 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1043 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1047 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1051 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1055 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1061 inline void ReadBuffer(GLenum mode)
1065 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1069 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1073 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)
1077 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1081 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1085 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)
1089 inline void GenQueries(GLsizei n, GLuint* ids)
1093 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1097 inline GLboolean IsQuery(GLuint id)
1102 inline void BeginQuery(GLenum target, GLuint id)
1106 inline void EndQuery(GLenum target)
1110 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1114 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1118 inline GLboolean UnmapBuffer(GLenum target)
1123 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1127 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1131 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1135 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1139 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1143 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1147 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1151 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1155 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1159 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1163 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1167 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1172 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1176 inline void BindVertexArray(GLuint array)
1180 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1184 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1188 inline GLboolean IsVertexArray(GLuint array)
1193 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1197 inline void BeginTransformFeedback(GLenum primitiveMode)
1201 inline void EndTransformFeedback(void)
1205 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1209 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1213 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1217 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1221 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1225 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1229 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1233 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1237 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1241 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1245 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1249 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1253 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1258 inline void Uniform1ui(GLint location, GLuint v0)
1262 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1266 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1270 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1274 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1278 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1282 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1286 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1290 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1294 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1298 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1302 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1306 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1311 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1315 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1319 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1323 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1325 return GL_INVALID_INDEX;
1328 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1332 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1336 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1340 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1344 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1348 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1353 inline GLboolean IsSync(GLsync sync)
1358 inline void DeleteSync(GLsync sync)
1362 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1367 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1371 inline void GetInteger64v(GLenum pname, GLint64* params)
1375 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1379 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1383 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1387 inline void GenSamplers(GLsizei count, GLuint* samplers)
1391 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1395 inline GLboolean IsSampler(GLuint sampler)
1400 inline void BindSampler(GLuint unit, GLuint sampler)
1404 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1408 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1412 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1416 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1420 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1424 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1428 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1432 inline void BindTransformFeedback(GLenum target, GLuint id)
1436 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1440 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1444 inline GLboolean IsTransformFeedback(GLuint id)
1449 inline void PauseTransformFeedback(void)
1453 inline void ResumeTransformFeedback(void)
1457 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1461 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1465 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1469 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1473 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1477 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1481 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1485 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1489 public: // TEST FUNCTIONS
1490 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1491 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1492 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1493 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1494 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1495 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1496 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1497 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1498 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1499 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1500 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1501 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1502 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1503 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1504 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1505 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1507 inline bool GetVertexAttribArrayState(GLuint index)
1509 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1514 return mVertexAttribArrayState[ index ];
1516 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1517 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1519 //Methods for CullFace verification
1520 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1521 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1522 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1524 //Methods for Shader verification
1525 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1526 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1527 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1529 //Methods for Texture verification
1530 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1531 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1532 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1534 //Methods for Texture verification
1535 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1536 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1537 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1539 //Methods for Draw verification
1540 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1541 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1542 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1544 template <typename T>
1545 inline bool CheckUniformValue( const char* name, const T& value ) const
1547 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1548 program_it != mUniforms.end();
1551 const UniformIDMap &uniformIDs = program_it->second;
1553 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1554 if( uniform_it != uniformIDs.end() )
1556 // found one matching uniform name, lets check the value...
1557 GLuint programId = program_it->first;
1558 GLint uniformId = uniform_it->second;
1560 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1561 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1563 // the value matches
1569 fprintf(stderr, "Not found, printing possible values:" );
1570 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1571 program_it != mUniforms.end();
1574 const UniformIDMap &uniformIDs = program_it->second;
1576 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1577 if( uniform_it != uniformIDs.end() )
1579 // found one matching uniform name, lets check the value...
1580 GLuint programId = program_it->first;
1581 GLint uniformId = uniform_it->second;
1583 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1585 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1587 std::stringstream out;
1588 out << uniform_it->first << ": " << origValue;
1589 fprintf(stderr, "%s", out.str().c_str() );
1596 template <typename T>
1597 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1599 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1600 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1603 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1605 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1606 program_it != mUniforms.end();
1609 const UniformIDMap &uniformIDs = program_it->second;
1611 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1612 if( uniform_it != uniformIDs.end() )
1614 programId = program_it->first;
1615 uniformId = uniform_it->second;
1624 inline GLuint GetLastShaderCompiled() const
1626 return mLastShaderCompiled;
1629 inline GLuint GetLastProgramCreated() const
1631 return mLastProgramIdUsed;
1636 ATTRIB_UNKNOWN = -1,
1641 ATTRIB_BONE_WEIGHTS,
1642 ATTRIB_BONE_INDICES,
1648 GLuint mCurrentProgram;
1649 GLuint mCompileStatus;
1651 GLint mGetAttribLocationResult;
1652 GLenum mGetErrorResult;
1653 GLubyte* mGetStringResult;
1654 GLboolean mIsBufferResult;
1655 GLboolean mIsEnabledResult;
1656 GLboolean mIsFramebufferResult;
1657 GLboolean mIsProgramResult;
1658 GLboolean mIsRenderbufferResult;
1659 GLboolean mIsShaderResult;
1660 GLboolean mIsTextureResult;
1661 GLenum mActiveTextureUnit;
1662 GLenum mCheckFramebufferStatusResult;
1663 GLint mNumBinaryFormats;
1664 GLint mBinaryFormats;
1665 GLint mProgramBinaryLength;
1666 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1667 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1668 typedef std::map< GLuint, std::string> ShaderSourceMap;
1669 ShaderSourceMap mShaderSources;
1670 GLuint mLastShaderCompiled;
1672 Vector4 mLastBlendColor;
1673 GLenum mLastBlendEquationRgb;
1674 GLenum mLastBlendEquationAlpha;
1675 GLenum mLastBlendFuncSrcRgb;
1676 GLenum mLastBlendFuncDstRgb;
1677 GLenum mLastBlendFuncSrcAlpha;
1678 GLenum mLastBlendFuncDstAlpha;
1680 // Data for manipulating the IDs returned by GenTextures
1681 GLuint mLastAutoTextureIdUsed;
1682 std::vector<GLuint> mNextTextureIds;
1683 std::vector<GLuint> mDeletedTextureIds;
1684 std::vector<GLuint> mBoundTextures;
1686 struct ActiveTextureType
1688 std::vector<GLuint> mBoundTextures;
1691 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1693 TraceCallStack mCullFaceTrace;
1694 TraceCallStack mShaderTrace;
1695 TraceCallStack mTextureTrace;
1696 TraceCallStack mTexParamaterTrace;
1697 TraceCallStack mDrawTrace;
1699 // Shaders & Uniforms
1700 GLuint mLastShaderIdUsed;
1701 GLuint mLastProgramIdUsed;
1702 GLuint mLastUniformIdUsed;
1703 typedef std::map< std::string, GLint > UniformIDMap;
1704 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
1705 ProgramUniformMap mUniforms;
1707 template <typename T>
1708 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
1711 typedef std::map< GLint, T > UniformValueMap;
1712 typedef std::map< GLuint, UniformValueMap > Map;
1714 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
1721 typename Map::iterator it = Map::find( program );
1722 if( it == Map::end() )
1724 // if its the first uniform for this program add it
1725 std::pair< typename Map::iterator, bool > result =
1726 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
1730 UniformValueMap& uniforms = it->second;
1731 uniforms[uniform] = value;
1736 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
1739 if ( GetUniformValue( program, uniform, uniformValue ) )
1741 return value == uniformValue;
1747 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
1754 typename Map::const_iterator it = Map::find( program );
1755 if( it == Map::end() )
1757 // Uniform values always initialised as 0
1762 const UniformValueMap& uniforms = it->second;
1763 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
1764 if( it2 == uniforms.end() )
1766 // Uniform values always initialised as 0
1770 value = it2->second;
1777 ProgramUniformValue<int> mProgramUniforms1i;
1778 ProgramUniformValue<float> mProgramUniforms1f;
1779 ProgramUniformValue<Vector2> mProgramUniforms2f;
1780 ProgramUniformValue<Vector3> mProgramUniforms3f;
1781 ProgramUniformValue<Vector4> mProgramUniforms4f;
1782 ProgramUniformValue<Matrix> mProgramUniformsMat4;
1783 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
1785 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
1787 return mProgramUniforms1i;
1789 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
1791 return mProgramUniforms1f;
1793 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
1795 return mProgramUniforms2f;
1797 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
1799 return mProgramUniforms3f;
1801 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
1803 return mProgramUniforms4f;
1805 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
1807 return mProgramUniformsMat4;
1809 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
1811 return mProgramUniformsMat3;
1813 inline void SetVertexAttribArray(GLuint index, bool state)
1815 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1820 mVertexAttribArrayState[ index ] = state;
1821 mVertexAttribArrayChanged = true;
1826 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
1832 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
1838 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
1840 return Vector2::ZERO;
1844 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
1846 return Vector3::ZERO;
1850 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
1852 return Vector4::ZERO;
1856 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
1862 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
1864 return Matrix3( Matrix() );
1869 bool BlendEnabled(const Dali::TraceCallStack& callStack);
1870 bool BlendDisabled(const Dali::TraceCallStack& callStack);
1875 #endif // __TEST_GL_ES_H__