1 #ifndef TEST_GL_ABSTRACTION_H
2 #define TEST_GL_ABSTRACTION_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
27 #include <cstring> // for strcmp
31 #include <dali/public-api/dali-core.h>
32 #include <dali/integration-api/core.h>
33 #include <dali/integration-api/gl-abstraction.h>
34 #include <dali/integration-api/gl-defines.h>
35 #include <test-trace-call-stack.h>
36 #include <test-compare-types.h>
41 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
42 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
44 "aPosition", // ATTRIB_POSITION
45 "aNormal", // ATTRIB_NORMAL
46 "aTexCoord", // ATTRIB_TEXCOORD
47 "aColor", // ATTRIB_COLOR
48 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
49 "aBoneIndices" // ATTRIB_BONE_INDICES
52 class DALI_CORE_API TestGlAbstraction: public Dali::Integration::GlAbstraction
62 bool IsSurfacelessContextSupported() const;
64 bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const;
68 inline void ActiveTexture( GLenum textureUnit )
70 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
73 inline GLenum GetActiveTextureUnit() const
75 return mActiveTextureUnit + GL_TEXTURE0;
78 inline void AttachShader( GLuint program, GLuint shader )
80 std::stringstream out;
81 out << program << ", " << shader;
83 TraceCallStack::NamedParams namedParams;
84 namedParams["program"] = ToString(program);
85 namedParams["shader"] = ToString(shader);
86 mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
89 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
93 inline void BindBuffer( GLenum target, GLuint buffer )
97 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
100 mFramebufferStatus |= 2;
103 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
108 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
109 * @return A vector containing the IDs that were bound.
111 inline const std::vector<GLuint>& GetBoundTextures() const
113 return mBoundTextures;
117 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
118 * @param[in] activeTextureUnit The specific active texture unit.
119 * @return A vector containing the IDs that were bound.
121 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
123 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
127 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
129 inline void ClearBoundTextures()
131 mBoundTextures.clear();
133 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
135 mActiveTextures[ i ].mBoundTextures.clear();
139 inline void BindTexture( GLenum target, GLuint texture )
141 // Record the bound textures for future checks
144 mBoundTextures.push_back( texture );
146 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
148 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
152 std::stringstream out;
153 out << target << ", " << texture;
155 TraceCallStack::NamedParams namedParams;
156 namedParams["target"] = ToString(target);
157 namedParams["texture"] = ToString(texture);
159 mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
162 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
164 mLastBlendColor.r = red;
165 mLastBlendColor.g = green;
166 mLastBlendColor.b = blue;
167 mLastBlendColor.a = alpha;
170 inline const Vector4& GetLastBlendColor() const
172 return mLastBlendColor;
175 inline void BlendEquation( GLenum mode )
177 mLastBlendEquationRgb = mode;
178 mLastBlendEquationAlpha = mode;
181 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
183 mLastBlendEquationRgb = modeRgb;
184 mLastBlendEquationAlpha = modeAlpha;
187 inline GLenum GetLastBlendEquationRgb() const
189 return mLastBlendEquationRgb;
192 inline GLenum GetLastBlendEquationAlpha() const
194 return mLastBlendEquationAlpha;
197 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
199 mLastBlendFuncSrcRgb = sfactor;
200 mLastBlendFuncDstRgb = dfactor;
201 mLastBlendFuncSrcAlpha = sfactor;
202 mLastBlendFuncDstAlpha = dfactor;
205 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
207 mLastBlendFuncSrcRgb = srcRGB;
208 mLastBlendFuncDstRgb = dstRGB;
209 mLastBlendFuncSrcAlpha = srcAlpha;
210 mLastBlendFuncDstAlpha = dstAlpha;
213 inline GLenum GetLastBlendFuncSrcRgb() const
215 return mLastBlendFuncSrcRgb;
218 inline GLenum GetLastBlendFuncDstRgb() const
220 return mLastBlendFuncDstRgb;
223 inline GLenum GetLastBlendFuncSrcAlpha() const
225 return mLastBlendFuncSrcAlpha;
228 inline GLenum GetLastBlendFuncDstAlpha() const
230 return mLastBlendFuncDstAlpha;
233 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
235 mBufferDataCalls.push_back(size);
238 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
240 mBufferSubDataCalls.push_back(size);
243 inline GLenum CheckFramebufferStatus(GLenum target)
245 //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
246 //Framebuffer texture have been called
247 if( mFramebufferStatus == 7 )
249 return GL_FRAMEBUFFER_COMPLETE;
252 return mCheckFramebufferStatusResult;
255 inline GLenum CheckFramebufferColorAttachment()
257 return mFramebufferColorAttached;
260 inline GLenum CheckFramebufferDepthAttachment()
262 return mFramebufferDepthAttached;
265 inline GLenum CheckFramebufferStencilAttachment()
267 return mFramebufferStencilAttached;
270 inline void Clear(GLbitfield mask)
273 mLastClearBitMask = mask;
276 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
278 mLastClearColor.r = red;
279 mLastClearColor.g = green;
280 mLastClearColor.b = blue;
281 mLastClearColor.a = alpha;
284 inline const Vector4& GetLastClearColor() const
286 return mLastClearColor;
289 inline void ClearDepthf(GLclampf depth)
293 inline void ClearStencil(GLint s)
295 std::stringstream out;
298 TraceCallStack::NamedParams namedParams;
299 namedParams["s"] = ToString( s );
301 mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
304 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
306 mColorMaskParams.red = red;
307 mColorMaskParams.green = green;
308 mColorMaskParams.blue = blue;
309 mColorMaskParams.alpha = alpha;
312 inline void CompileShader(GLuint shader)
314 std::stringstream out;
316 TraceCallStack::NamedParams namedParams;
317 namedParams["shader"] = ToString(shader);
319 mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
322 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
324 std::stringstream out;
325 out << target<<", "<<level<<", "<<width << ", " << height;
327 TraceCallStack::NamedParams namedParams;
328 namedParams["target"] = ToString(target);
329 namedParams["level"] = ToString(level);
330 namedParams["internalformat"] = ToString(internalformat);
331 namedParams["width"] = ToString(width);
332 namedParams["height"] = ToString(height);
333 namedParams["border"] = ToString(border);
334 namedParams["size"] = ToString(imageSize);
336 mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
339 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
341 std::stringstream out;
342 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
344 TraceCallStack::NamedParams namedParams;
345 namedParams["target"] = ToString(target);
346 namedParams["level"] = ToString(level);
347 namedParams["xoffset"] = ToString(xoffset);
348 namedParams["yoffset"] = ToString(yoffset);
349 namedParams["width"] = ToString(width);
350 namedParams["height"] = ToString(height);
351 mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
354 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
358 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
362 inline GLuint CreateProgram(void)
364 mShaderTrace.PushCall("CreateProgram", "");
366 ++mLastProgramIdUsed;
367 mUniforms[mLastProgramIdUsed] = UniformIDMap();
368 return mLastProgramIdUsed;
371 inline GLuint CreateShader(GLenum type)
373 std::stringstream out;
376 TraceCallStack::NamedParams namedParams;
377 namedParams["type"] = ToString(type);
378 mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
380 return ++mLastShaderIdUsed;
383 inline void CullFace(GLenum mode)
385 std::stringstream out;
388 TraceCallStack::NamedParams namedParams;
389 namedParams["program"] = ToString(mode);
391 mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
394 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
398 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
402 inline void DeleteProgram(GLuint program)
404 std::stringstream out;
407 TraceCallStack::NamedParams namedParams;
408 namedParams["program"] = ToString(program);
410 mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
413 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
417 inline void DeleteShader(GLuint shader)
419 std::stringstream out;
422 TraceCallStack::NamedParams namedParams;
423 namedParams["shader"] = ToString(shader);
425 mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
428 inline void DeleteTextures(GLsizei n, const GLuint* textures)
430 std::stringstream out;
431 out << n << ", " << textures << " = [";
433 TraceCallStack::NamedParams namedParams;
435 for(GLsizei i=0; i<n; i++)
437 out << textures[i] << ", ";
438 std::stringstream paramName;
439 paramName<<"texture["<<i<<"]";
440 namedParams[paramName.str()] = ToString(textures[i]);
441 mDeletedTextureIds.push_back(textures[i]);
442 mNumGeneratedTextures--;
446 mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
449 inline bool CheckNoTexturesDeleted()
451 return mDeletedTextureIds.size() == 0;
454 inline bool CheckTextureDeleted( GLuint textureId )
458 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
460 if(*iter == textureId)
469 inline void ClearDeletedTextures()
471 mDeletedTextureIds.clear();
474 inline void DepthFunc(GLenum func)
476 std::stringstream out;
479 TraceCallStack::NamedParams namedParams;
480 namedParams["func"] = ToString(func);
482 mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
485 inline void DepthMask(GLboolean flag)
487 mLastDepthMask = flag;
490 inline bool GetLastDepthMask() const
492 return mLastDepthMask;
495 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
499 inline void DetachShader(GLuint program, GLuint shader)
501 std::stringstream out;
502 out << program << ", " << shader;
503 TraceCallStack::NamedParams namedParams;
504 namedParams["program"] = ToString(program);
505 namedParams["shader"] = ToString(shader);
506 mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
509 inline void Disable(GLenum cap)
511 std::stringstream out;
513 TraceCallStack::NamedParams namedParams;
514 namedParams["cap"] = ToString(cap);
515 mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
518 inline void DisableVertexAttribArray(GLuint index)
520 SetVertexAttribArray( index, false );
523 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
525 std::stringstream out;
526 out << mode << ", " << first << ", " << count;
527 TraceCallStack::NamedParams namedParams;
528 namedParams["mode"] = ToString(mode);
529 namedParams["first"] = ToString(first);
530 namedParams["count"] = ToString(count);
531 mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
534 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
536 std::stringstream out;
537 out << mode << ", " << count << ", " << type << ", indices";
539 TraceCallStack::NamedParams namedParams;
540 namedParams["mode"] = ToString(mode);
541 namedParams["count"] = ToString(count);
542 namedParams["type"] = ToString(type);
543 // Skip void pointers - are they of any use?
544 mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
547 inline void Enable(GLenum cap)
549 std::stringstream out;
551 TraceCallStack::NamedParams namedParams;
552 namedParams["cap"] = ToString(cap);
553 mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
556 inline void EnableVertexAttribArray(GLuint index)
558 SetVertexAttribArray( index, true);
561 inline void Finish(void)
565 inline void Flush(void)
569 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
571 if (attachment == GL_DEPTH_ATTACHMENT)
573 mFramebufferDepthAttached = true;
575 else if (attachment == GL_STENCIL_ATTACHMENT)
577 mFramebufferStencilAttached = true;
581 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
584 mFramebufferStatus |= 4;
586 //We check 4 attachment colors
587 if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
589 mFramebufferColorAttached = true;
593 inline void FrontFace(GLenum mode)
597 inline void GenBuffers(GLsizei n, GLuint* buffers)
599 // avoids an assert in GpuBuffers
603 inline void GenerateMipmap(GLenum target)
605 std::stringstream out;
607 TraceCallStack::NamedParams namedParams;
608 namedParams["target"] = ToString(target);
610 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
613 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
615 for( int i = 0; i < n; i++ )
617 framebuffers[i] = i + 1;
620 //Add 001 bit, this function needs to be called the first one in the chain
621 mFramebufferStatus = 1;
624 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
626 for( int i = 0; i < n; i++ )
628 renderbuffers[i] = i + 1;
633 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
634 * @param[in] ids A vector containing the next IDs to be generated
636 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
638 mNextTextureIds = ids;
641 inline const std::vector<GLuint>& GetNextTextureIds()
643 return mNextTextureIds;
646 inline void GenTextures(GLsizei count, GLuint* textures)
648 for( int i=0; i<count; ++i )
650 if( !mNextTextureIds.empty() )
652 *(textures+i) = mNextTextureIds[0];
653 mNextTextureIds.erase( mNextTextureIds.begin() );
657 *(textures+i) = ++mLastAutoTextureIdUsed;
659 mNumGeneratedTextures++;
662 TraceCallStack::NamedParams namedParams;
663 namedParams["count"] = ToString(count);
665 std::stringstream out;
666 for(int i=0; i<count; i++)
673 std::ostringstream oss;
674 oss<<"indices["<<i<<"]";
675 namedParams[oss.str()] = ToString(textures[i]);
678 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
681 inline GLuint GetLastGenTextureId()
683 return mLastAutoTextureIdUsed;
685 inline GLuint GetNumGeneratedTextures()
687 return mNumGeneratedTextures;
690 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
694 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
699 *length = snprintf(name, bufsize, "sTexture");
700 *type = GL_SAMPLER_2D;
704 *length = snprintf(name, bufsize, "sEffect");
705 *type = GL_SAMPLER_2D;
709 *length = snprintf(name, bufsize, "sGloss");
710 *type = GL_SAMPLER_2D;
718 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
722 inline int GetAttribLocation(GLuint program, const char* name)
724 std::string attribName(name);
726 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
728 if( mStdAttribs[i] == attribName )
734 // 0 is a valid location
738 inline void GetBooleanv(GLenum pname, GLboolean* params)
742 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
746 inline GLenum GetError(void)
748 return mGetErrorResult;
751 inline void GetFloatv(GLenum pname, GLfloat* params)
755 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
759 inline void GetIntegerv(GLenum pname, GLint* params)
763 case GL_MAX_TEXTURE_SIZE:
766 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
769 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
770 *params = mNumBinaryFormats;
772 case GL_PROGRAM_BINARY_FORMATS_OES:
773 *params = mBinaryFormats;
778 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
783 *params = mLinkStatus;
785 case GL_PROGRAM_BINARY_LENGTH_OES:
786 *params = mProgramBinaryLength;
788 case GL_ACTIVE_UNIFORMS:
789 *params = mNumberOfActiveUniforms;
791 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
797 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
801 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
805 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
808 case GL_COMPILE_STATUS:
809 *params = mCompileStatus;
814 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
818 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
822 inline const GLubyte* GetString(GLenum name)
824 return mGetStringResult;
827 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
831 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
835 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
839 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
843 inline GLint GetUniformLocation(GLuint program, const char* name)
845 ProgramUniformMap::iterator it = mUniforms.find(program);
846 if( it == mUniforms.end() )
848 // Not a valid program ID
849 mGetErrorResult = GL_INVALID_OPERATION;
853 UniformIDMap& uniformIDs = it->second;
854 UniformIDMap::iterator it2 = uniformIDs.find( name );
855 if( it2 == uniformIDs.end() )
857 // Uniform not found, so add it...
858 uniformIDs[name] = ++mLastUniformIdUsed;
859 return mLastUniformIdUsed;
865 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
869 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
873 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
877 inline void Hint(GLenum target, GLenum mode)
881 inline GLboolean IsBuffer(GLuint buffer)
883 return mIsBufferResult;
886 inline GLboolean IsEnabled(GLenum cap)
888 return mIsEnabledResult;
891 inline GLboolean IsFramebuffer(GLuint framebuffer)
893 return mIsFramebufferResult;
896 inline GLboolean IsProgram(GLuint program)
898 return mIsProgramResult;
901 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
903 return mIsRenderbufferResult;
906 inline GLboolean IsShader(GLuint shader)
908 return mIsShaderResult;
911 inline GLboolean IsTexture(GLuint texture)
913 return mIsTextureResult;
916 inline void LineWidth(GLfloat width)
920 inline void LinkProgram(GLuint program)
922 std::stringstream out;
925 TraceCallStack::NamedParams namedParams;
926 namedParams["program"] = ToString(program);
927 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
929 mNumberOfActiveUniforms=3;
930 GetUniformLocation(program, "sTexture");
931 GetUniformLocation(program, "sEffect");
932 GetUniformLocation(program, "sGloss");
935 inline void PixelStorei(GLenum pname, GLint param)
939 inline void PolygonOffset(GLfloat factor, GLfloat units)
943 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
947 inline void ReleaseShaderCompiler(void)
951 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
955 inline void SampleCoverage(GLclampf value, GLboolean invert)
959 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
961 mScissorParams.x = x;
962 mScissorParams.y = y;
963 mScissorParams.width = width;
964 mScissorParams.height = height;
966 std::stringstream out;
967 out << x << ", " << y << ", " << width << ", " << height;
968 TraceCallStack::NamedParams namedParams;
969 namedParams["x"] = ToString( x );
970 namedParams["y"] = ToString( y );
971 namedParams["width"] = ToString( width );
972 namedParams["height"] = ToString( height );
973 mScissorTrace.PushCall( "Scissor", out.str(), namedParams );
976 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
980 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
982 std::string stringBuilder;
983 for(int i = 0; i < count; ++i)
985 stringBuilder += string[i];
987 mShaderSources[shader] = stringBuilder;
988 mLastShaderCompiled = shader;
991 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
993 const std::string shaderSource = mShaderSources[shader];
994 const int shaderSourceLength = static_cast<int>(shaderSource.length());
995 if( shaderSourceLength < bufsize )
997 strncpy( source, shaderSource.c_str(), shaderSourceLength );
998 *length = shaderSourceLength;
1002 *length = bufsize -1;
1003 strncpy(source, shaderSource.c_str(), *length);
1004 source[*length] = 0x0;
1008 inline std::string GetShaderSource(GLuint shader)
1010 return mShaderSources[shader];
1013 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
1015 std::stringstream out;
1016 out << func << ", " << ref << ", " << mask;
1018 TraceCallStack::NamedParams namedParams;
1019 namedParams["func"] = ToString( func );
1020 namedParams["ref"] = ToString( ref );
1021 namedParams["mask"] = ToString( mask );
1023 mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
1026 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
1028 std::stringstream out;
1029 out << face << ", " << func << ", " << ref << ", " << mask;
1031 TraceCallStack::NamedParams namedParams;
1032 namedParams["face"] = ToString( face );
1033 namedParams["func"] = ToString( func );
1034 namedParams["ref"] = ToString( ref );
1035 namedParams["mask"] = ToString( mask );
1037 mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1040 inline void StencilMask(GLuint mask)
1042 std::stringstream out;
1045 TraceCallStack::NamedParams namedParams;
1046 namedParams["mask"] = ToString( mask );
1048 mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1051 inline void StencilMaskSeparate(GLenum face, GLuint mask)
1053 std::stringstream out;
1054 out << face << ", " << mask;
1056 TraceCallStack::NamedParams namedParams;
1057 namedParams["face"] = ToString( face );
1058 namedParams["mask"] = ToString( mask );
1060 mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1063 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1065 std::stringstream out;
1066 out << fail << ", " << zfail << ", " << zpass;
1068 TraceCallStack::NamedParams namedParams;
1069 namedParams["fail"] = ToString( fail );
1070 namedParams["zfail"] = ToString( zfail );
1071 namedParams["zpass"] = ToString( zpass );
1073 mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1076 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1078 std::stringstream out;
1079 out << face << ", " << fail << ", " << zfail << "," << zpass;
1081 TraceCallStack::NamedParams namedParams;
1082 namedParams["face"] = ToString( face );
1083 namedParams["fail"] = ToString( fail );
1084 namedParams["zfail"] = ToString( zfail );
1085 namedParams["zpass"] = ToString( zpass );
1087 mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1090 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1092 std::stringstream out;
1093 out << target<<", "<<level<<", "<<width << ", " << height;
1095 TraceCallStack::NamedParams namedParams;
1096 namedParams["target"] = ToString(target);
1097 namedParams["level"] = ToString(level);
1098 namedParams["internalformat"] = ToString(internalformat);
1099 namedParams["width"] = ToString(width);
1100 namedParams["height"] = ToString(height);
1101 namedParams["border"] = ToString(border);
1102 namedParams["format"] = ToString(format);
1103 namedParams["type"] = ToString(type);
1105 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1108 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1110 std::stringstream out;
1111 out << target << ", " << pname << ", " << param;
1113 TraceCallStack::NamedParams namedParams;
1114 namedParams["target"] = ToString(target);
1115 namedParams["pname"] = ToString(pname);
1116 namedParams["param"] = ToString(param);
1118 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1121 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1123 std::stringstream out;
1124 out << target << ", " << pname << ", " << params[0];
1126 TraceCallStack::NamedParams namedParams;
1127 namedParams["target"] = ToString(target);
1128 namedParams["pname"] = ToString(pname);
1129 namedParams["params[0]"] = ToString(params[0]);
1131 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1134 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1136 std::stringstream out;
1137 out << target << ", " << pname << ", " << param;
1138 TraceCallStack::NamedParams namedParams;
1139 namedParams["target"] = ToString(target);
1140 namedParams["pname"] = ToString(pname);
1141 namedParams["param"] = ToString(param);
1142 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1145 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1147 std::stringstream out;
1148 out << target << ", " << pname << ", " << params[0];
1149 TraceCallStack::NamedParams namedParams;
1150 namedParams["target"] = ToString(target);
1151 namedParams["pname"] = ToString(pname);
1152 namedParams["params[0]"] = ToString(params[0]);
1153 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1156 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1158 std::stringstream out;
1159 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1161 TraceCallStack::NamedParams namedParams;
1162 namedParams["target"] = ToString(target);
1163 namedParams["level"] = ToString(level);
1164 namedParams["xoffset"] = ToString(xoffset);
1165 namedParams["yoffset"] = ToString(yoffset);
1166 namedParams["width"] = ToString(width);
1167 namedParams["height"] = ToString(height);
1168 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1171 inline void Uniform1f(GLint location, GLfloat value )
1173 std::string params = ToString( value );
1174 AddUniformCallToTraceStack( location, params );
1176 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, value ) )
1178 mGetErrorResult = GL_INVALID_OPERATION;
1182 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1185 for( int i = 0; i < count; ++i )
1187 params = params + ToString( v[i] ) + ",";
1190 AddUniformCallToTraceStack( location, params );
1192 for( int i = 0; i < count; ++i )
1194 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1196 mGetErrorResult = GL_INVALID_OPERATION;
1202 inline void Uniform1i(GLint location, GLint x)
1204 std::string params = ToString( x );
1206 AddUniformCallToTraceStack( location, params );
1208 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1210 mGetErrorResult = GL_INVALID_OPERATION;
1214 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1216 std::string params = ToString( v );
1217 AddUniformCallToTraceStack( location, params );
1219 for( int i = 0; i < count; ++i )
1221 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1225 mGetErrorResult = GL_INVALID_OPERATION;
1231 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1233 std::string params = ToString( x ) + "," + ToString( y );
1234 AddUniformCallToTraceStack( location, params );
1236 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1240 mGetErrorResult = GL_INVALID_OPERATION;
1244 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1246 std::string params = ToString( v );
1247 AddUniformCallToTraceStack( location, params );
1249 for( int i = 0; i < count; ++i )
1251 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1253 Vector2( v[2*i], v[2*i+1] ) ) )
1255 mGetErrorResult = GL_INVALID_OPERATION;
1261 inline void Uniform2i(GLint location, GLint x, GLint y)
1263 std::string params = ToString( x ) + "," + ToString( y );
1264 AddUniformCallToTraceStack( location, params );
1267 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1269 std::string params = ToString( v );
1270 AddUniformCallToTraceStack( location, params );
1273 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1275 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1276 AddUniformCallToTraceStack( location, params );
1278 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1280 Vector3( x, y, z ) ) )
1282 mGetErrorResult = GL_INVALID_OPERATION;
1286 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1288 std::string params = ToString( v );
1289 AddUniformCallToTraceStack( location, params );
1291 for( int i = 0; i < count; ++i )
1293 if( ! mProgramUniforms3f.SetUniformValue(
1296 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1298 mGetErrorResult = GL_INVALID_OPERATION;
1304 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1306 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1307 AddUniformCallToTraceStack( location, params );
1310 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1312 std::string params = ToString( v );
1313 AddUniformCallToTraceStack( location, params );
1316 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1318 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1319 AddUniformCallToTraceStack( location, params );
1321 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1323 Vector4( x, y, z, w ) ) )
1325 mGetErrorResult = GL_INVALID_OPERATION;
1329 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1331 std::string params = ToString( v );
1332 AddUniformCallToTraceStack( location, params );
1334 for( int i = 0; i < count; ++i )
1336 if( ! mProgramUniforms4f.SetUniformValue(
1339 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1341 mGetErrorResult = GL_INVALID_OPERATION;
1347 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1349 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1350 AddUniformCallToTraceStack( location, params );
1353 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1355 std::string params = ToString( v );
1356 AddUniformCallToTraceStack( location, params );
1359 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1361 std::string params = ToString( value );
1362 AddUniformCallToTraceStack( location, params );
1365 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1367 std::string params = ToString( value );
1368 AddUniformCallToTraceStack( location, params );
1370 for( int i = 0; i < count; ++i )
1372 if( ! mProgramUniformsMat3.SetUniformValue(
1375 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1377 mGetErrorResult = GL_INVALID_OPERATION;
1383 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1385 std::string params = ToString( value );
1386 AddUniformCallToTraceStack( location, params );
1388 for( int i = 0; i < count; ++i )
1390 if( ! mProgramUniformsMat4.SetUniformValue(
1395 mGetErrorResult = GL_INVALID_OPERATION;
1401 inline void UseProgram(GLuint program)
1403 mCurrentProgram = program;
1406 inline void ValidateProgram(GLuint program)
1410 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1414 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1418 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1422 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1426 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1430 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1434 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1438 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1442 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1446 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1448 std::string commaString(", ");
1449 std::string params( std::to_string(x) + commaString + std::to_string(y) + commaString + std::to_string(width) + commaString + std::to_string(height) );
1451 mViewportTrace.PushCall("Viewport", params);
1456 inline void ReadBuffer(GLenum mode)
1460 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1464 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1468 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)
1472 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1476 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1480 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)
1484 inline void GenQueries(GLsizei n, GLuint* ids)
1488 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1492 inline GLboolean IsQuery(GLuint id)
1497 inline void BeginQuery(GLenum target, GLuint id)
1501 inline void EndQuery(GLenum target)
1505 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1509 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1513 inline GLboolean UnmapBuffer(GLenum target)
1518 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1522 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1526 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1530 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1534 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1538 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1542 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1546 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1550 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1554 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1558 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1562 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1567 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1571 inline void BindVertexArray(GLuint array)
1575 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1579 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1583 inline GLboolean IsVertexArray(GLuint array)
1588 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1592 inline void BeginTransformFeedback(GLenum primitiveMode)
1596 inline void EndTransformFeedback(void)
1600 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1604 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1608 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1612 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1616 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1620 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1624 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1628 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1632 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1636 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1640 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1644 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1648 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1653 inline void Uniform1ui(GLint location, GLuint v0)
1657 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1661 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1665 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1669 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1673 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1677 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1681 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1685 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1689 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1693 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1697 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1701 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1706 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1710 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1714 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1718 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1720 return GL_INVALID_INDEX;
1723 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1727 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1731 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1735 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1739 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1743 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1748 inline GLboolean IsSync(GLsync sync)
1753 inline void DeleteSync(GLsync sync)
1757 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1762 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1766 inline void GetInteger64v(GLenum pname, GLint64* params)
1770 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1774 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1778 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1782 inline void GenSamplers(GLsizei count, GLuint* samplers)
1786 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1790 inline GLboolean IsSampler(GLuint sampler)
1795 inline void BindSampler(GLuint unit, GLuint sampler)
1799 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1803 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1807 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1811 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1815 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1819 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1823 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1827 inline void BindTransformFeedback(GLenum target, GLuint id)
1831 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1835 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1839 inline GLboolean IsTransformFeedback(GLuint id)
1844 inline void PauseTransformFeedback(void)
1848 inline void ResumeTransformFeedback(void)
1852 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1854 mGetProgramBinaryCalled = true;
1857 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1861 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1865 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1869 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1873 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1877 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1881 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1887 inline void AddUniformCallToTraceStack( GLint location, std::string& value )
1889 std::string name = "<not found>";
1890 bool matched = false;
1892 UniformIDMap& map = mUniforms[mCurrentProgram];
1893 for (UniformIDMap::iterator it=map.begin(); it!=map.end(); ++it)
1895 if( it->second == location )
1905 mSetUniformTrace.PushCall( name, value );
1910 public: // TEST FUNCTIONS
1911 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1912 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1913 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1914 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1915 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1916 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1917 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1918 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1919 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1920 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1921 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1922 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1923 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1924 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1925 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1926 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1928 inline bool GetVertexAttribArrayState(GLuint index)
1930 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1935 return mVertexAttribArrayState[ index ];
1937 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1938 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1940 //Methods for CullFace verification
1941 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1942 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1943 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1945 //Methods for Enable/Disable call verification
1946 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1947 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1948 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1950 //Methods for Shader verification
1951 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1952 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1953 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1955 //Methods for Texture verification
1956 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1957 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1958 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1960 //Methods for Texture verification
1961 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1962 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1963 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1965 //Methods for Draw verification
1966 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1967 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1968 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1970 //Methods for Depth function verification
1971 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1972 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1973 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1975 //Methods for Stencil function verification
1976 inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1977 inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1978 inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1980 //Methods for Scissor verification
1981 inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); }
1982 inline void ResetScissorCallStack() { mScissorTrace.Reset(); }
1983 inline TraceCallStack& GetScissorTrace() { return mScissorTrace; }
1985 //Methods for Uniform function verification
1986 inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); }
1987 inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); }
1988 inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; }
1990 //Methods for Viewport verification
1991 inline void EnableViewportCallTrace(bool enable) { mViewportTrace.Enable(enable); }
1992 inline void ResetViewportCallStack() { mViewportTrace.Reset(); }
1993 inline TraceCallStack& GetViewportTrace() { return mViewportTrace; }
1995 template <typename T>
1996 inline bool GetUniformValue( const char* name, T& value ) const
1998 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1999 program_it != mUniforms.end();
2002 const UniformIDMap &uniformIDs = program_it->second;
2004 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2005 if( uniform_it != uniformIDs.end() )
2007 // found one matching uniform name, lets check the value...
2008 GLuint programId = program_it->first;
2009 GLint uniformId = uniform_it->second;
2011 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2012 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
2019 template <typename T>
2020 inline bool CheckUniformValue( const char* name, const T& value ) const
2022 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2023 program_it != mUniforms.end();
2026 const UniformIDMap &uniformIDs = program_it->second;
2028 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2029 if( uniform_it != uniformIDs.end() )
2031 // found one matching uniform name, lets check the value...
2032 GLuint programId = program_it->first;
2033 GLint uniformId = uniform_it->second;
2035 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2036 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
2038 // the value matches
2044 fprintf(stderr, "Not found, printing possible values:\n" );
2045 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2046 program_it != mUniforms.end();
2049 const UniformIDMap &uniformIDs = program_it->second;
2051 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2052 if( uniform_it != uniformIDs.end() )
2054 // found one matching uniform name, lets check the value...
2055 GLuint programId = program_it->first;
2056 GLint uniformId = uniform_it->second;
2058 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2060 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
2062 std::stringstream out;
2063 out << uniform_it->first << ": " << origValue;
2064 fprintf(stderr, "%s\n", out.str().c_str() );
2071 template <typename T>
2072 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
2074 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
2075 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
2078 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
2080 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2081 program_it != mUniforms.end();
2084 const UniformIDMap &uniformIDs = program_it->second;
2086 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2087 if( uniform_it != uniformIDs.end() )
2089 programId = program_it->first;
2090 uniformId = uniform_it->second;
2097 inline GLuint GetLastShaderCompiled() const
2099 return mLastShaderCompiled;
2102 inline GLuint GetLastProgramCreated() const
2104 return mLastProgramIdUsed;
2107 inline GLbitfield GetLastClearMask() const
2109 return mLastClearBitMask;
2114 ATTRIB_UNKNOWN = -1,
2119 ATTRIB_BONE_WEIGHTS,
2120 ATTRIB_BONE_INDICES,
2124 struct ScissorParams
2131 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
2134 // Methods to check scissor tests
2135 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2137 struct ColorMaskParams
2144 ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2147 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2149 inline unsigned int GetClearCountCalled() const { return mClearCount; }
2151 inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2153 typedef std::vector<size_t> BufferDataCalls;
2154 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2155 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2157 typedef std::vector<size_t> BufferSubDataCalls;
2158 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2159 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2162 GLuint mCurrentProgram;
2163 GLuint mCompileStatus;
2164 BufferDataCalls mBufferDataCalls;
2165 BufferSubDataCalls mBufferSubDataCalls;
2167 GLint mNumberOfActiveUniforms;
2168 GLint mGetAttribLocationResult;
2169 GLenum mGetErrorResult;
2170 GLubyte* mGetStringResult;
2171 GLboolean mIsBufferResult;
2172 GLboolean mIsEnabledResult;
2173 GLboolean mIsFramebufferResult;
2174 GLboolean mIsProgramResult;
2175 GLboolean mIsRenderbufferResult;
2176 GLboolean mIsShaderResult;
2177 GLboolean mIsTextureResult;
2178 GLenum mActiveTextureUnit;
2179 GLenum mCheckFramebufferStatusResult;
2180 GLint mFramebufferStatus;
2181 GLenum mFramebufferColorAttached;
2182 GLenum mFramebufferDepthAttached;
2183 GLenum mFramebufferStencilAttached;
2184 GLint mNumBinaryFormats;
2185 GLint mBinaryFormats;
2186 GLint mProgramBinaryLength;
2187 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2188 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
2189 bool mGetProgramBinaryCalled;
2190 typedef std::map< GLuint, std::string> ShaderSourceMap;
2191 ShaderSourceMap mShaderSources;
2192 GLuint mLastShaderCompiled;
2193 GLbitfield mLastClearBitMask;
2194 Vector4 mLastClearColor;
2195 unsigned int mClearCount;
2197 Vector4 mLastBlendColor;
2198 GLenum mLastBlendEquationRgb;
2199 GLenum mLastBlendEquationAlpha;
2200 GLenum mLastBlendFuncSrcRgb;
2201 GLenum mLastBlendFuncDstRgb;
2202 GLenum mLastBlendFuncSrcAlpha;
2203 GLenum mLastBlendFuncDstAlpha;
2205 GLboolean mLastDepthMask;
2207 // Data for manipulating the IDs returned by GenTextures
2208 GLuint mLastAutoTextureIdUsed;
2209 GLuint mNumGeneratedTextures;
2210 std::vector<GLuint> mNextTextureIds;
2211 std::vector<GLuint> mDeletedTextureIds;
2212 std::vector<GLuint> mBoundTextures;
2214 struct ActiveTextureType
2216 std::vector<GLuint> mBoundTextures;
2219 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2221 TraceCallStack mCullFaceTrace;
2222 TraceCallStack mEnableDisableTrace;
2223 TraceCallStack mShaderTrace;
2224 TraceCallStack mTextureTrace;
2225 TraceCallStack mTexParamaterTrace;
2226 TraceCallStack mDrawTrace;
2227 TraceCallStack mDepthFunctionTrace;
2228 TraceCallStack mStencilFunctionTrace;
2229 TraceCallStack mScissorTrace;
2230 TraceCallStack mSetUniformTrace;
2231 TraceCallStack mViewportTrace;
2233 // Shaders & Uniforms
2234 GLuint mLastShaderIdUsed;
2235 GLuint mLastProgramIdUsed;
2236 GLuint mLastUniformIdUsed;
2237 typedef std::map< std::string, GLint > UniformIDMap;
2238 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2239 ProgramUniformMap mUniforms;
2241 template <typename T>
2242 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2245 typedef std::map< GLint, T > UniformValueMap;
2246 typedef std::map< GLuint, UniformValueMap > Map;
2248 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2255 typename Map::iterator it = Map::find( program );
2256 if( it == Map::end() )
2258 // if its the first uniform for this program add it
2259 std::pair< typename Map::iterator, bool > result =
2260 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2264 UniformValueMap& uniforms = it->second;
2265 uniforms[uniform] = value;
2270 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2273 if ( GetUniformValue( program, uniform, uniformValue ) )
2275 return CompareType<T>(value, uniformValue, Math::MACHINE_EPSILON_10);
2281 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2288 typename Map::const_iterator it = Map::find( program );
2289 if( it == Map::end() )
2291 // Uniform values always initialised as 0
2296 const UniformValueMap& uniforms = it->second;
2297 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2298 if( it2 == uniforms.end() )
2300 // Uniform values always initialised as 0
2304 value = it2->second;
2311 ProgramUniformValue<int> mProgramUniforms1i;
2312 ProgramUniformValue<float> mProgramUniforms1f;
2313 ProgramUniformValue<Vector2> mProgramUniforms2f;
2314 ProgramUniformValue<Vector3> mProgramUniforms3f;
2315 ProgramUniformValue<Vector4> mProgramUniforms4f;
2316 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2317 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2319 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2321 return mProgramUniforms1i;
2323 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2325 return mProgramUniforms1f;
2327 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2329 return mProgramUniforms2f;
2331 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2333 return mProgramUniforms3f;
2335 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2337 return mProgramUniforms4f;
2339 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2341 return mProgramUniformsMat4;
2343 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2345 return mProgramUniformsMat3;
2347 inline void SetVertexAttribArray(GLuint index, bool state)
2349 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2354 mVertexAttribArrayState[ index ] = state;
2355 mVertexAttribArrayChanged = true;
2358 ScissorParams mScissorParams;
2359 ColorMaskParams mColorMaskParams;
2363 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2369 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2375 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2377 return Vector2::ZERO;
2381 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2383 return Vector3::ZERO;
2387 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2389 return Vector4::ZERO;
2393 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2399 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2401 return Matrix3( Matrix() );
2406 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2407 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2410 #endif // TEST_GL_ABSTRACTION_H