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 GLuint CheckFramebufferColorAttachmentCount()
257 return mFramebufferColorAttachmentCount;
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_ATTACHMENT0 + Dali::FrameBuffer::MAX_COLOR_ATTACHMENTS))
589 uint8_t mask = 1 << (attachment - GL_COLOR_ATTACHMENT0);
590 if ((mFrameBufferColorStatus & mask) == 0)
592 mFrameBufferColorStatus |= mask;
593 ++mFramebufferColorAttachmentCount;
598 inline void FrontFace(GLenum mode)
602 inline void GenBuffers(GLsizei n, GLuint* buffers)
604 // avoids an assert in GpuBuffers
608 inline void GenerateMipmap(GLenum target)
610 std::stringstream out;
612 TraceCallStack::NamedParams namedParams;
613 namedParams["target"] = ToString(target);
615 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
618 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
620 for( int i = 0; i < n; i++ )
622 framebuffers[i] = i + 1;
625 //Add 001 bit, this function needs to be called the first one in the chain
626 mFramebufferStatus = 1;
629 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
631 for( int i = 0; i < n; i++ )
633 renderbuffers[i] = i + 1;
638 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
639 * @param[in] ids A vector containing the next IDs to be generated
641 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
643 mNextTextureIds = ids;
646 inline const std::vector<GLuint>& GetNextTextureIds()
648 return mNextTextureIds;
651 inline void GenTextures(GLsizei count, GLuint* textures)
653 for( int i=0; i<count; ++i )
655 if( !mNextTextureIds.empty() )
657 *(textures+i) = mNextTextureIds[0];
658 mNextTextureIds.erase( mNextTextureIds.begin() );
662 *(textures+i) = ++mLastAutoTextureIdUsed;
664 mNumGeneratedTextures++;
667 TraceCallStack::NamedParams namedParams;
668 namedParams["count"] = ToString(count);
670 std::stringstream out;
671 for(int i=0; i<count; i++)
678 std::ostringstream oss;
679 oss<<"indices["<<i<<"]";
680 namedParams[oss.str()] = ToString(textures[i]);
683 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
686 inline GLuint GetLastGenTextureId()
688 return mLastAutoTextureIdUsed;
690 inline GLuint GetNumGeneratedTextures()
692 return mNumGeneratedTextures;
695 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
699 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
704 *length = snprintf(name, bufsize, "sTexture");
705 *type = GL_SAMPLER_2D;
709 *length = snprintf(name, bufsize, "sEffect");
710 *type = GL_SAMPLER_2D;
714 *length = snprintf(name, bufsize, "sGloss");
715 *type = GL_SAMPLER_2D;
723 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
727 inline int GetAttribLocation(GLuint program, const char* name)
729 std::string attribName(name);
731 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
733 if( mStdAttribs[i] == attribName )
739 // 0 is a valid location
743 inline void GetBooleanv(GLenum pname, GLboolean* params)
747 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
751 inline GLenum GetError(void)
753 return mGetErrorResult;
756 inline void GetFloatv(GLenum pname, GLfloat* params)
760 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
764 inline void GetIntegerv(GLenum pname, GLint* params)
768 case GL_MAX_TEXTURE_SIZE:
771 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
774 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
775 *params = mNumBinaryFormats;
777 case GL_PROGRAM_BINARY_FORMATS_OES:
778 *params = mBinaryFormats;
783 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
788 *params = mLinkStatus;
790 case GL_PROGRAM_BINARY_LENGTH_OES:
791 *params = mProgramBinaryLength;
793 case GL_ACTIVE_UNIFORMS:
794 *params = mNumberOfActiveUniforms;
796 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
802 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
806 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
810 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
813 case GL_COMPILE_STATUS:
814 *params = mCompileStatus;
819 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
823 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
827 inline const GLubyte* GetString(GLenum name)
829 return mGetStringResult;
832 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
836 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
840 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
844 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
848 inline GLint GetUniformLocation(GLuint program, const char* name)
850 ProgramUniformMap::iterator it = mUniforms.find(program);
851 if( it == mUniforms.end() )
853 // Not a valid program ID
854 mGetErrorResult = GL_INVALID_OPERATION;
858 UniformIDMap& uniformIDs = it->second;
859 UniformIDMap::iterator it2 = uniformIDs.find( name );
860 if( it2 == uniformIDs.end() )
862 // Uniform not found, so add it...
863 uniformIDs[name] = ++mLastUniformIdUsed;
864 return mLastUniformIdUsed;
870 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
874 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
878 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
882 inline void Hint(GLenum target, GLenum mode)
886 inline GLboolean IsBuffer(GLuint buffer)
888 return mIsBufferResult;
891 inline GLboolean IsEnabled(GLenum cap)
893 return mIsEnabledResult;
896 inline GLboolean IsFramebuffer(GLuint framebuffer)
898 return mIsFramebufferResult;
901 inline GLboolean IsProgram(GLuint program)
903 return mIsProgramResult;
906 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
908 return mIsRenderbufferResult;
911 inline GLboolean IsShader(GLuint shader)
913 return mIsShaderResult;
916 inline GLboolean IsTexture(GLuint texture)
918 return mIsTextureResult;
921 inline void LineWidth(GLfloat width)
925 inline void LinkProgram(GLuint program)
927 std::stringstream out;
930 TraceCallStack::NamedParams namedParams;
931 namedParams["program"] = ToString(program);
932 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
934 mNumberOfActiveUniforms=3;
935 GetUniformLocation(program, "sTexture");
936 GetUniformLocation(program, "sEffect");
937 GetUniformLocation(program, "sGloss");
940 inline void PixelStorei(GLenum pname, GLint param)
944 inline void PolygonOffset(GLfloat factor, GLfloat units)
948 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
952 inline void ReleaseShaderCompiler(void)
956 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
960 inline void SampleCoverage(GLclampf value, GLboolean invert)
964 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
966 mScissorParams.x = x;
967 mScissorParams.y = y;
968 mScissorParams.width = width;
969 mScissorParams.height = height;
971 std::stringstream out;
972 out << x << ", " << y << ", " << width << ", " << height;
973 TraceCallStack::NamedParams namedParams;
974 namedParams["x"] = ToString( x );
975 namedParams["y"] = ToString( y );
976 namedParams["width"] = ToString( width );
977 namedParams["height"] = ToString( height );
978 mScissorTrace.PushCall( "Scissor", out.str(), namedParams );
981 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
985 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
987 std::string stringBuilder;
988 for(int i = 0; i < count; ++i)
990 stringBuilder += string[i];
992 mShaderSources[shader] = stringBuilder;
993 mLastShaderCompiled = shader;
996 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
998 const std::string shaderSource = mShaderSources[shader];
999 const int shaderSourceLength = static_cast<int>(shaderSource.length());
1000 if( shaderSourceLength < bufsize )
1002 strncpy( source, shaderSource.c_str(), shaderSourceLength );
1003 *length = shaderSourceLength;
1007 *length = bufsize -1;
1008 strncpy(source, shaderSource.c_str(), *length);
1009 source[*length] = 0x0;
1013 inline std::string GetShaderSource(GLuint shader)
1015 return mShaderSources[shader];
1018 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
1020 std::stringstream out;
1021 out << func << ", " << ref << ", " << mask;
1023 TraceCallStack::NamedParams namedParams;
1024 namedParams["func"] = ToString( func );
1025 namedParams["ref"] = ToString( ref );
1026 namedParams["mask"] = ToString( mask );
1028 mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
1031 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
1033 std::stringstream out;
1034 out << face << ", " << func << ", " << ref << ", " << mask;
1036 TraceCallStack::NamedParams namedParams;
1037 namedParams["face"] = ToString( face );
1038 namedParams["func"] = ToString( func );
1039 namedParams["ref"] = ToString( ref );
1040 namedParams["mask"] = ToString( mask );
1042 mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1045 inline void StencilMask(GLuint mask)
1047 std::stringstream out;
1050 TraceCallStack::NamedParams namedParams;
1051 namedParams["mask"] = ToString( mask );
1053 mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1056 inline void StencilMaskSeparate(GLenum face, GLuint mask)
1058 std::stringstream out;
1059 out << face << ", " << mask;
1061 TraceCallStack::NamedParams namedParams;
1062 namedParams["face"] = ToString( face );
1063 namedParams["mask"] = ToString( mask );
1065 mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1068 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1070 std::stringstream out;
1071 out << fail << ", " << zfail << ", " << zpass;
1073 TraceCallStack::NamedParams namedParams;
1074 namedParams["fail"] = ToString( fail );
1075 namedParams["zfail"] = ToString( zfail );
1076 namedParams["zpass"] = ToString( zpass );
1078 mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1081 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1083 std::stringstream out;
1084 out << face << ", " << fail << ", " << zfail << "," << zpass;
1086 TraceCallStack::NamedParams namedParams;
1087 namedParams["face"] = ToString( face );
1088 namedParams["fail"] = ToString( fail );
1089 namedParams["zfail"] = ToString( zfail );
1090 namedParams["zpass"] = ToString( zpass );
1092 mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1095 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1097 std::stringstream out;
1098 out << target<<", "<<level<<", "<<width << ", " << height;
1100 TraceCallStack::NamedParams namedParams;
1101 namedParams["target"] = ToString(target);
1102 namedParams["level"] = ToString(level);
1103 namedParams["internalformat"] = ToString(internalformat);
1104 namedParams["width"] = ToString(width);
1105 namedParams["height"] = ToString(height);
1106 namedParams["border"] = ToString(border);
1107 namedParams["format"] = ToString(format);
1108 namedParams["type"] = ToString(type);
1110 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1113 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1115 std::stringstream out;
1116 out << target << ", " << pname << ", " << param;
1118 TraceCallStack::NamedParams namedParams;
1119 namedParams["target"] = ToString(target);
1120 namedParams["pname"] = ToString(pname);
1121 namedParams["param"] = ToString(param);
1123 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1126 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1128 std::stringstream out;
1129 out << target << ", " << pname << ", " << params[0];
1131 TraceCallStack::NamedParams namedParams;
1132 namedParams["target"] = ToString(target);
1133 namedParams["pname"] = ToString(pname);
1134 namedParams["params[0]"] = ToString(params[0]);
1136 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1139 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1141 std::stringstream out;
1142 out << target << ", " << pname << ", " << param;
1143 TraceCallStack::NamedParams namedParams;
1144 namedParams["target"] = ToString(target);
1145 namedParams["pname"] = ToString(pname);
1146 namedParams["param"] = ToString(param);
1147 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1150 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1152 std::stringstream out;
1153 out << target << ", " << pname << ", " << params[0];
1154 TraceCallStack::NamedParams namedParams;
1155 namedParams["target"] = ToString(target);
1156 namedParams["pname"] = ToString(pname);
1157 namedParams["params[0]"] = ToString(params[0]);
1158 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1161 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1163 std::stringstream out;
1164 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1166 TraceCallStack::NamedParams namedParams;
1167 namedParams["target"] = ToString(target);
1168 namedParams["level"] = ToString(level);
1169 namedParams["xoffset"] = ToString(xoffset);
1170 namedParams["yoffset"] = ToString(yoffset);
1171 namedParams["width"] = ToString(width);
1172 namedParams["height"] = ToString(height);
1173 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1176 inline void Uniform1f(GLint location, GLfloat value )
1178 std::string params = ToString( value );
1179 AddUniformCallToTraceStack( location, params );
1181 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, value ) )
1183 mGetErrorResult = GL_INVALID_OPERATION;
1187 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1190 for( int i = 0; i < count; ++i )
1192 params = params + ToString( v[i] ) + ",";
1195 AddUniformCallToTraceStack( location, params );
1197 for( int i = 0; i < count; ++i )
1199 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1201 mGetErrorResult = GL_INVALID_OPERATION;
1207 inline void Uniform1i(GLint location, GLint x)
1209 std::string params = ToString( x );
1211 AddUniformCallToTraceStack( location, params );
1213 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1215 mGetErrorResult = GL_INVALID_OPERATION;
1219 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1221 std::string params = ToString( v );
1222 AddUniformCallToTraceStack( location, params );
1224 for( int i = 0; i < count; ++i )
1226 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1230 mGetErrorResult = GL_INVALID_OPERATION;
1236 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1238 std::string params = ToString( x ) + "," + ToString( y );
1239 AddUniformCallToTraceStack( location, params );
1241 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1245 mGetErrorResult = GL_INVALID_OPERATION;
1249 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1251 std::string params = ToString( v );
1252 AddUniformCallToTraceStack( location, params );
1254 for( int i = 0; i < count; ++i )
1256 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1258 Vector2( v[2*i], v[2*i+1] ) ) )
1260 mGetErrorResult = GL_INVALID_OPERATION;
1266 inline void Uniform2i(GLint location, GLint x, GLint y)
1268 std::string params = ToString( x ) + "," + ToString( y );
1269 AddUniformCallToTraceStack( location, params );
1272 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1274 std::string params = ToString( v );
1275 AddUniformCallToTraceStack( location, params );
1278 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1280 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1281 AddUniformCallToTraceStack( location, params );
1283 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1285 Vector3( x, y, z ) ) )
1287 mGetErrorResult = GL_INVALID_OPERATION;
1291 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1293 std::string params = ToString( v );
1294 AddUniformCallToTraceStack( location, params );
1296 for( int i = 0; i < count; ++i )
1298 if( ! mProgramUniforms3f.SetUniformValue(
1301 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1303 mGetErrorResult = GL_INVALID_OPERATION;
1309 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1311 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1312 AddUniformCallToTraceStack( location, params );
1315 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1317 std::string params = ToString( v );
1318 AddUniformCallToTraceStack( location, params );
1321 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1323 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1324 AddUniformCallToTraceStack( location, params );
1326 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1328 Vector4( x, y, z, w ) ) )
1330 mGetErrorResult = GL_INVALID_OPERATION;
1334 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1336 std::string params = ToString( v );
1337 AddUniformCallToTraceStack( location, params );
1339 for( int i = 0; i < count; ++i )
1341 if( ! mProgramUniforms4f.SetUniformValue(
1344 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1346 mGetErrorResult = GL_INVALID_OPERATION;
1352 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1354 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1355 AddUniformCallToTraceStack( location, params );
1358 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1360 std::string params = ToString( v );
1361 AddUniformCallToTraceStack( location, params );
1364 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1366 std::string params = ToString( value );
1367 AddUniformCallToTraceStack( location, params );
1370 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1372 std::string params = ToString( value );
1373 AddUniformCallToTraceStack( location, params );
1375 for( int i = 0; i < count; ++i )
1377 if( ! mProgramUniformsMat3.SetUniformValue(
1380 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1382 mGetErrorResult = GL_INVALID_OPERATION;
1388 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1390 std::string params = ToString( value );
1391 AddUniformCallToTraceStack( location, params );
1393 for( int i = 0; i < count; ++i )
1395 if( ! mProgramUniformsMat4.SetUniformValue(
1400 mGetErrorResult = GL_INVALID_OPERATION;
1406 inline void UseProgram(GLuint program)
1408 mCurrentProgram = program;
1411 inline void ValidateProgram(GLuint program)
1415 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1419 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1423 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1427 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1431 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1435 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1439 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1443 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1447 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1451 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1453 std::string commaString(", ");
1454 std::string params( std::to_string(x) + commaString + std::to_string(y) + commaString + std::to_string(width) + commaString + std::to_string(height) );
1456 mViewportTrace.PushCall("Viewport", params);
1461 inline void ReadBuffer(GLenum mode)
1465 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1469 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1473 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)
1477 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1481 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1485 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)
1489 inline void GenQueries(GLsizei n, GLuint* ids)
1493 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1497 inline GLboolean IsQuery(GLuint id)
1502 inline void BeginQuery(GLenum target, GLuint id)
1506 inline void EndQuery(GLenum target)
1510 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1514 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1518 inline GLboolean UnmapBuffer(GLenum target)
1523 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1527 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1531 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1535 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1539 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1543 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1547 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1551 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1555 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1559 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1563 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1567 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1572 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1576 inline void BindVertexArray(GLuint array)
1580 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1584 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1588 inline GLboolean IsVertexArray(GLuint array)
1593 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1597 inline void BeginTransformFeedback(GLenum primitiveMode)
1601 inline void EndTransformFeedback(void)
1605 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1609 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1613 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1617 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1621 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1625 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1629 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1633 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1637 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1641 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1645 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1649 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1653 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1658 inline void Uniform1ui(GLint location, GLuint v0)
1662 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1666 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1670 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1674 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1678 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1682 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1686 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1690 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1694 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1698 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1702 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1706 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1711 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1715 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1719 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1723 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1725 return GL_INVALID_INDEX;
1728 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1732 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1736 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1740 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1744 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1748 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1753 inline GLboolean IsSync(GLsync sync)
1758 inline void DeleteSync(GLsync sync)
1762 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1767 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1771 inline void GetInteger64v(GLenum pname, GLint64* params)
1775 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1779 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1783 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1787 inline void GenSamplers(GLsizei count, GLuint* samplers)
1791 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1795 inline GLboolean IsSampler(GLuint sampler)
1800 inline void BindSampler(GLuint unit, GLuint sampler)
1804 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1808 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1812 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1816 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1820 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1824 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1828 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1832 inline void BindTransformFeedback(GLenum target, GLuint id)
1836 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1840 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1844 inline GLboolean IsTransformFeedback(GLuint id)
1849 inline void PauseTransformFeedback(void)
1853 inline void ResumeTransformFeedback(void)
1857 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1859 mGetProgramBinaryCalled = true;
1862 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1866 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1870 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1874 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1878 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1882 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1886 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1892 inline void AddUniformCallToTraceStack( GLint location, std::string& value )
1894 std::string name = "<not found>";
1895 bool matched = false;
1897 UniformIDMap& map = mUniforms[mCurrentProgram];
1898 for (UniformIDMap::iterator it=map.begin(); it!=map.end(); ++it)
1900 if( it->second == location )
1910 mSetUniformTrace.PushCall( name, value );
1915 public: // TEST FUNCTIONS
1916 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1917 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1918 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1919 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1920 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1921 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1922 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1923 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1924 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1925 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1926 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1927 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1928 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1929 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1930 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1931 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1933 inline bool GetVertexAttribArrayState(GLuint index)
1935 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1940 return mVertexAttribArrayState[ index ];
1942 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1943 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1945 //Methods for CullFace verification
1946 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1947 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1948 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1950 //Methods for Enable/Disable call verification
1951 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1952 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1953 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1955 //Methods for Shader verification
1956 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1957 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1958 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1960 //Methods for Texture verification
1961 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1962 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1963 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1965 //Methods for Texture verification
1966 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1967 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1968 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1970 //Methods for Draw verification
1971 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1972 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1973 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1975 //Methods for Depth function verification
1976 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1977 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1978 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1980 //Methods for Stencil function verification
1981 inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1982 inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1983 inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1985 //Methods for Scissor verification
1986 inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); }
1987 inline void ResetScissorCallStack() { mScissorTrace.Reset(); }
1988 inline TraceCallStack& GetScissorTrace() { return mScissorTrace; }
1990 //Methods for Uniform function verification
1991 inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); }
1992 inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); }
1993 inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; }
1995 //Methods for Viewport verification
1996 inline void EnableViewportCallTrace(bool enable) { mViewportTrace.Enable(enable); }
1997 inline void ResetViewportCallStack() { mViewportTrace.Reset(); }
1998 inline TraceCallStack& GetViewportTrace() { return mViewportTrace; }
2000 template <typename T>
2001 inline bool GetUniformValue( const char* name, T& value ) const
2003 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2004 program_it != mUniforms.end();
2007 const UniformIDMap &uniformIDs = program_it->second;
2009 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2010 if( uniform_it != uniformIDs.end() )
2012 // found one matching uniform name, lets check the value...
2013 GLuint programId = program_it->first;
2014 GLint uniformId = uniform_it->second;
2016 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2017 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
2024 template <typename T>
2025 inline bool CheckUniformValue( const char* name, const T& value ) const
2027 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2028 program_it != mUniforms.end();
2031 const UniformIDMap &uniformIDs = program_it->second;
2033 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2034 if( uniform_it != uniformIDs.end() )
2036 // found one matching uniform name, lets check the value...
2037 GLuint programId = program_it->first;
2038 GLint uniformId = uniform_it->second;
2040 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2041 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
2043 // the value matches
2049 fprintf(stderr, "Not found, printing possible values:\n" );
2050 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2051 program_it != mUniforms.end();
2054 const UniformIDMap &uniformIDs = program_it->second;
2056 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2057 if( uniform_it != uniformIDs.end() )
2059 // found one matching uniform name, lets check the value...
2060 GLuint programId = program_it->first;
2061 GLint uniformId = uniform_it->second;
2063 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2065 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
2067 std::stringstream out;
2068 out << uniform_it->first << ": " << origValue;
2069 fprintf(stderr, "%s\n", out.str().c_str() );
2076 template <typename T>
2077 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
2079 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
2080 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
2083 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
2085 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2086 program_it != mUniforms.end();
2089 const UniformIDMap &uniformIDs = program_it->second;
2091 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2092 if( uniform_it != uniformIDs.end() )
2094 programId = program_it->first;
2095 uniformId = uniform_it->second;
2102 inline GLuint GetLastShaderCompiled() const
2104 return mLastShaderCompiled;
2107 inline GLuint GetLastProgramCreated() const
2109 return mLastProgramIdUsed;
2112 inline GLbitfield GetLastClearMask() const
2114 return mLastClearBitMask;
2119 ATTRIB_UNKNOWN = -1,
2124 ATTRIB_BONE_WEIGHTS,
2125 ATTRIB_BONE_INDICES,
2129 struct ScissorParams
2136 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
2139 // Methods to check scissor tests
2140 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2142 struct ColorMaskParams
2149 ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2152 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2154 inline unsigned int GetClearCountCalled() const { return mClearCount; }
2156 inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2158 typedef std::vector<size_t> BufferDataCalls;
2159 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2160 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2162 typedef std::vector<size_t> BufferSubDataCalls;
2163 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2164 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2167 GLuint mCurrentProgram;
2168 GLuint mCompileStatus;
2169 BufferDataCalls mBufferDataCalls;
2170 BufferSubDataCalls mBufferSubDataCalls;
2172 GLint mNumberOfActiveUniforms;
2173 GLint mGetAttribLocationResult;
2174 GLenum mGetErrorResult;
2175 GLubyte* mGetStringResult;
2176 GLboolean mIsBufferResult;
2177 GLboolean mIsEnabledResult;
2178 GLboolean mIsFramebufferResult;
2179 GLboolean mIsProgramResult;
2180 GLboolean mIsRenderbufferResult;
2181 GLboolean mIsShaderResult;
2182 GLboolean mIsTextureResult;
2183 GLenum mActiveTextureUnit;
2184 GLenum mCheckFramebufferStatusResult;
2185 GLint mFramebufferStatus;
2186 GLenum mFramebufferDepthAttached;
2187 GLenum mFramebufferStencilAttached;
2188 GLuint mFramebufferColorAttachmentCount;
2189 GLuint mFrameBufferColorStatus;
2190 GLint mNumBinaryFormats;
2191 GLint mBinaryFormats;
2192 GLint mProgramBinaryLength;
2193 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2194 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
2195 bool mGetProgramBinaryCalled;
2196 typedef std::map< GLuint, std::string> ShaderSourceMap;
2197 ShaderSourceMap mShaderSources;
2198 GLuint mLastShaderCompiled;
2199 GLbitfield mLastClearBitMask;
2200 Vector4 mLastClearColor;
2201 unsigned int mClearCount;
2203 Vector4 mLastBlendColor;
2204 GLenum mLastBlendEquationRgb;
2205 GLenum mLastBlendEquationAlpha;
2206 GLenum mLastBlendFuncSrcRgb;
2207 GLenum mLastBlendFuncDstRgb;
2208 GLenum mLastBlendFuncSrcAlpha;
2209 GLenum mLastBlendFuncDstAlpha;
2211 GLboolean mLastDepthMask;
2213 // Data for manipulating the IDs returned by GenTextures
2214 GLuint mLastAutoTextureIdUsed;
2215 GLuint mNumGeneratedTextures;
2216 std::vector<GLuint> mNextTextureIds;
2217 std::vector<GLuint> mDeletedTextureIds;
2218 std::vector<GLuint> mBoundTextures;
2220 struct ActiveTextureType
2222 std::vector<GLuint> mBoundTextures;
2225 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2227 TraceCallStack mCullFaceTrace;
2228 TraceCallStack mEnableDisableTrace;
2229 TraceCallStack mShaderTrace;
2230 TraceCallStack mTextureTrace;
2231 TraceCallStack mTexParamaterTrace;
2232 TraceCallStack mDrawTrace;
2233 TraceCallStack mDepthFunctionTrace;
2234 TraceCallStack mStencilFunctionTrace;
2235 TraceCallStack mScissorTrace;
2236 TraceCallStack mSetUniformTrace;
2237 TraceCallStack mViewportTrace;
2239 // Shaders & Uniforms
2240 GLuint mLastShaderIdUsed;
2241 GLuint mLastProgramIdUsed;
2242 GLuint mLastUniformIdUsed;
2243 typedef std::map< std::string, GLint > UniformIDMap;
2244 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2245 ProgramUniformMap mUniforms;
2247 template <typename T>
2248 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2251 typedef std::map< GLint, T > UniformValueMap;
2252 typedef std::map< GLuint, UniformValueMap > Map;
2254 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2261 typename Map::iterator it = Map::find( program );
2262 if( it == Map::end() )
2264 // if its the first uniform for this program add it
2265 std::pair< typename Map::iterator, bool > result =
2266 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2270 UniformValueMap& uniforms = it->second;
2271 uniforms[uniform] = value;
2276 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2279 if ( GetUniformValue( program, uniform, uniformValue ) )
2281 return CompareType<T>(value, uniformValue, Math::MACHINE_EPSILON_10);
2287 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2294 typename Map::const_iterator it = Map::find( program );
2295 if( it == Map::end() )
2297 // Uniform values always initialised as 0
2302 const UniformValueMap& uniforms = it->second;
2303 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2304 if( it2 == uniforms.end() )
2306 // Uniform values always initialised as 0
2310 value = it2->second;
2317 ProgramUniformValue<int> mProgramUniforms1i;
2318 ProgramUniformValue<float> mProgramUniforms1f;
2319 ProgramUniformValue<Vector2> mProgramUniforms2f;
2320 ProgramUniformValue<Vector3> mProgramUniforms3f;
2321 ProgramUniformValue<Vector4> mProgramUniforms4f;
2322 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2323 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2325 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2327 return mProgramUniforms1i;
2329 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2331 return mProgramUniforms1f;
2333 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2335 return mProgramUniforms2f;
2337 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2339 return mProgramUniforms3f;
2341 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2343 return mProgramUniforms4f;
2345 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2347 return mProgramUniformsMat4;
2349 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2351 return mProgramUniformsMat3;
2353 inline void SetVertexAttribArray(GLuint index, bool state)
2355 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2360 mVertexAttribArrayState[ index ] = state;
2361 mVertexAttribArrayChanged = true;
2364 ScissorParams mScissorParams;
2365 ColorMaskParams mColorMaskParams;
2369 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2375 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2381 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2383 return Vector2::ZERO;
2387 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2389 return Vector3::ZERO;
2393 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2395 return Vector4::ZERO;
2399 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2405 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2407 return Matrix3( Matrix() );
2412 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2413 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2416 #endif // TEST_GL_ABSTRACTION_H