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)
280 inline void ClearDepthf(GLclampf depth)
284 inline void ClearStencil(GLint s)
286 std::stringstream out;
289 TraceCallStack::NamedParams namedParams;
290 namedParams["s"] = ToString( s );
292 mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
295 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
297 mColorMaskParams.red = red;
298 mColorMaskParams.green = green;
299 mColorMaskParams.blue = blue;
300 mColorMaskParams.alpha = alpha;
303 inline void CompileShader(GLuint shader)
305 std::stringstream out;
307 TraceCallStack::NamedParams namedParams;
308 namedParams["shader"] = ToString(shader);
310 mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
313 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
315 std::stringstream out;
316 out << target<<", "<<level<<", "<<width << ", " << height;
318 TraceCallStack::NamedParams namedParams;
319 namedParams["target"] = ToString(target);
320 namedParams["level"] = ToString(level);
321 namedParams["internalformat"] = ToString(internalformat);
322 namedParams["width"] = ToString(width);
323 namedParams["height"] = ToString(height);
324 namedParams["border"] = ToString(border);
325 namedParams["size"] = ToString(imageSize);
327 mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
330 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
332 std::stringstream out;
333 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
335 TraceCallStack::NamedParams namedParams;
336 namedParams["target"] = ToString(target);
337 namedParams["level"] = ToString(level);
338 namedParams["xoffset"] = ToString(xoffset);
339 namedParams["yoffset"] = ToString(yoffset);
340 namedParams["width"] = ToString(width);
341 namedParams["height"] = ToString(height);
342 mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
345 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
349 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
353 inline GLuint CreateProgram(void)
355 mShaderTrace.PushCall("CreateProgram", "");
357 ++mLastProgramIdUsed;
358 mUniforms[mLastProgramIdUsed] = UniformIDMap();
359 return mLastProgramIdUsed;
362 inline GLuint CreateShader(GLenum type)
364 std::stringstream out;
367 TraceCallStack::NamedParams namedParams;
368 namedParams["type"] = ToString(type);
369 mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
371 return ++mLastShaderIdUsed;
374 inline void CullFace(GLenum mode)
376 std::stringstream out;
379 TraceCallStack::NamedParams namedParams;
380 namedParams["program"] = ToString(mode);
382 mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
385 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
389 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
393 inline void DeleteProgram(GLuint program)
395 std::stringstream out;
398 TraceCallStack::NamedParams namedParams;
399 namedParams["program"] = ToString(program);
401 mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
404 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
408 inline void DeleteShader(GLuint shader)
410 std::stringstream out;
413 TraceCallStack::NamedParams namedParams;
414 namedParams["shader"] = ToString(shader);
416 mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
419 inline void DeleteTextures(GLsizei n, const GLuint* textures)
421 std::stringstream out;
422 out << n << ", " << textures << " = [";
424 TraceCallStack::NamedParams namedParams;
426 for(GLsizei i=0; i<n; i++)
428 out << textures[i] << ", ";
429 std::stringstream paramName;
430 paramName<<"texture["<<i<<"]";
431 namedParams[paramName.str()] = ToString(textures[i]);
432 mDeletedTextureIds.push_back(textures[i]);
433 mNumGeneratedTextures--;
437 mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
440 inline bool CheckNoTexturesDeleted()
442 return mDeletedTextureIds.size() == 0;
445 inline bool CheckTextureDeleted( GLuint textureId )
449 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
451 if(*iter == textureId)
460 inline void ClearDeletedTextures()
462 mDeletedTextureIds.clear();
465 inline void DepthFunc(GLenum func)
467 std::stringstream out;
470 TraceCallStack::NamedParams namedParams;
471 namedParams["func"] = ToString(func);
473 mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
476 inline void DepthMask(GLboolean flag)
478 mLastDepthMask = flag;
481 inline bool GetLastDepthMask() const
483 return mLastDepthMask;
486 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
490 inline void DetachShader(GLuint program, GLuint shader)
492 std::stringstream out;
493 out << program << ", " << shader;
494 TraceCallStack::NamedParams namedParams;
495 namedParams["program"] = ToString(program);
496 namedParams["shader"] = ToString(shader);
497 mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
500 inline void Disable(GLenum cap)
502 std::stringstream out;
504 TraceCallStack::NamedParams namedParams;
505 namedParams["cap"] = ToString(cap);
506 mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
509 inline void DisableVertexAttribArray(GLuint index)
511 SetVertexAttribArray( index, false );
514 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
516 std::stringstream out;
517 out << mode << ", " << first << ", " << count;
518 TraceCallStack::NamedParams namedParams;
519 namedParams["mode"] = ToString(mode);
520 namedParams["first"] = ToString(first);
521 namedParams["count"] = ToString(count);
522 mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
525 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
527 std::stringstream out;
528 out << mode << ", " << count << ", " << type << ", indices";
530 TraceCallStack::NamedParams namedParams;
531 namedParams["mode"] = ToString(mode);
532 namedParams["count"] = ToString(count);
533 namedParams["type"] = ToString(type);
534 // Skip void pointers - are they of any use?
535 mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
538 inline void Enable(GLenum cap)
540 std::stringstream out;
542 TraceCallStack::NamedParams namedParams;
543 namedParams["cap"] = ToString(cap);
544 mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
547 inline void EnableVertexAttribArray(GLuint index)
549 SetVertexAttribArray( index, true);
552 inline void Finish(void)
556 inline void Flush(void)
560 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
562 if (attachment == GL_DEPTH_ATTACHMENT)
564 mFramebufferDepthAttached = true;
566 else if (attachment == GL_STENCIL_ATTACHMENT)
568 mFramebufferStencilAttached = true;
572 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
575 mFramebufferStatus |= 4;
577 //We check 4 attachment colors
578 if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
580 mFramebufferColorAttached = true;
584 inline void FrontFace(GLenum mode)
588 inline void GenBuffers(GLsizei n, GLuint* buffers)
590 // avoids an assert in GpuBuffers
594 inline void GenerateMipmap(GLenum target)
596 std::stringstream out;
598 TraceCallStack::NamedParams namedParams;
599 namedParams["target"] = ToString(target);
601 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
604 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
606 for( int i = 0; i < n; i++ )
608 framebuffers[i] = i + 1;
611 //Add 001 bit, this function needs to be called the first one in the chain
612 mFramebufferStatus = 1;
615 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
617 for( int i = 0; i < n; i++ )
619 renderbuffers[i] = i + 1;
624 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
625 * @param[in] ids A vector containing the next IDs to be generated
627 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
629 mNextTextureIds = ids;
632 inline const std::vector<GLuint>& GetNextTextureIds()
634 return mNextTextureIds;
637 inline void GenTextures(GLsizei count, GLuint* textures)
639 for( int i=0; i<count; ++i )
641 if( !mNextTextureIds.empty() )
643 *(textures+i) = mNextTextureIds[0];
644 mNextTextureIds.erase( mNextTextureIds.begin() );
648 *(textures+i) = ++mLastAutoTextureIdUsed;
650 mNumGeneratedTextures++;
653 TraceCallStack::NamedParams namedParams;
654 namedParams["count"] = ToString(count);
656 std::stringstream out;
657 for(int i=0; i<count; i++)
664 std::ostringstream oss;
665 oss<<"indices["<<i<<"]";
666 namedParams[oss.str()] = ToString(textures[i]);
669 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
672 inline GLuint GetLastGenTextureId()
674 return mLastAutoTextureIdUsed;
676 inline GLuint GetNumGeneratedTextures()
678 return mNumGeneratedTextures;
681 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
685 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
690 *length = snprintf(name, bufsize, "sTexture");
691 *type = GL_SAMPLER_2D;
695 *length = snprintf(name, bufsize, "sEffect");
696 *type = GL_SAMPLER_2D;
700 *length = snprintf(name, bufsize, "sGloss");
701 *type = GL_SAMPLER_2D;
709 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
713 inline int GetAttribLocation(GLuint program, const char* name)
715 std::string attribName(name);
717 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
719 if( mStdAttribs[i] == attribName )
725 // 0 is a valid location
729 inline void GetBooleanv(GLenum pname, GLboolean* params)
733 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
737 inline GLenum GetError(void)
739 return mGetErrorResult;
742 inline void GetFloatv(GLenum pname, GLfloat* params)
746 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
750 inline void GetIntegerv(GLenum pname, GLint* params)
754 case GL_MAX_TEXTURE_SIZE:
757 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
760 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
761 *params = mNumBinaryFormats;
763 case GL_PROGRAM_BINARY_FORMATS_OES:
764 *params = mBinaryFormats;
769 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
774 *params = mLinkStatus;
776 case GL_PROGRAM_BINARY_LENGTH_OES:
777 *params = mProgramBinaryLength;
779 case GL_ACTIVE_UNIFORMS:
780 *params = mNumberOfActiveUniforms;
782 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
788 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
792 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
796 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
799 case GL_COMPILE_STATUS:
800 *params = mCompileStatus;
805 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
809 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
813 inline const GLubyte* GetString(GLenum name)
815 return mGetStringResult;
818 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
822 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
826 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
830 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
834 inline GLint GetUniformLocation(GLuint program, const char* name)
836 ProgramUniformMap::iterator it = mUniforms.find(program);
837 if( it == mUniforms.end() )
839 // Not a valid program ID
840 mGetErrorResult = GL_INVALID_OPERATION;
844 UniformIDMap& uniformIDs = it->second;
845 UniformIDMap::iterator it2 = uniformIDs.find( name );
846 if( it2 == uniformIDs.end() )
848 // Uniform not found, so add it...
849 uniformIDs[name] = ++mLastUniformIdUsed;
850 return mLastUniformIdUsed;
856 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
860 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
864 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
868 inline void Hint(GLenum target, GLenum mode)
872 inline GLboolean IsBuffer(GLuint buffer)
874 return mIsBufferResult;
877 inline GLboolean IsEnabled(GLenum cap)
879 return mIsEnabledResult;
882 inline GLboolean IsFramebuffer(GLuint framebuffer)
884 return mIsFramebufferResult;
887 inline GLboolean IsProgram(GLuint program)
889 return mIsProgramResult;
892 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
894 return mIsRenderbufferResult;
897 inline GLboolean IsShader(GLuint shader)
899 return mIsShaderResult;
902 inline GLboolean IsTexture(GLuint texture)
904 return mIsTextureResult;
907 inline void LineWidth(GLfloat width)
911 inline void LinkProgram(GLuint program)
913 std::stringstream out;
916 TraceCallStack::NamedParams namedParams;
917 namedParams["program"] = ToString(program);
918 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
920 mNumberOfActiveUniforms=3;
921 GetUniformLocation(program, "sTexture");
922 GetUniformLocation(program, "sEffect");
923 GetUniformLocation(program, "sGloss");
926 inline void PixelStorei(GLenum pname, GLint param)
930 inline void PolygonOffset(GLfloat factor, GLfloat units)
934 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
938 inline void ReleaseShaderCompiler(void)
942 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
946 inline void SampleCoverage(GLclampf value, GLboolean invert)
950 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
952 mScissorParams.x = x;
953 mScissorParams.y = y;
954 mScissorParams.width = width;
955 mScissorParams.height = height;
957 std::stringstream out;
958 out << x << ", " << y << ", " << width << ", " << height;
959 TraceCallStack::NamedParams namedParams;
960 namedParams["x"] = ToString( x );
961 namedParams["y"] = ToString( y );
962 namedParams["width"] = ToString( width );
963 namedParams["height"] = ToString( height );
964 mScissorTrace.PushCall( "Scissor", out.str(), namedParams );
967 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
971 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
973 std::string stringBuilder;
974 for(int i = 0; i < count; ++i)
976 stringBuilder += string[i];
978 mShaderSources[shader] = stringBuilder;
979 mLastShaderCompiled = shader;
982 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
984 const std::string shaderSource = mShaderSources[shader];
985 const int shaderSourceLength = static_cast<int>(shaderSource.length());
986 if( shaderSourceLength < bufsize )
988 strncpy( source, shaderSource.c_str(), shaderSourceLength );
989 *length = shaderSourceLength;
993 *length = bufsize -1;
994 strncpy(source, shaderSource.c_str(), *length);
995 source[*length] = 0x0;
999 inline std::string GetShaderSource(GLuint shader)
1001 return mShaderSources[shader];
1004 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
1006 std::stringstream out;
1007 out << func << ", " << ref << ", " << mask;
1009 TraceCallStack::NamedParams namedParams;
1010 namedParams["func"] = ToString( func );
1011 namedParams["ref"] = ToString( ref );
1012 namedParams["mask"] = ToString( mask );
1014 mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
1017 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
1019 std::stringstream out;
1020 out << face << ", " << func << ", " << ref << ", " << mask;
1022 TraceCallStack::NamedParams namedParams;
1023 namedParams["face"] = ToString( face );
1024 namedParams["func"] = ToString( func );
1025 namedParams["ref"] = ToString( ref );
1026 namedParams["mask"] = ToString( mask );
1028 mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1031 inline void StencilMask(GLuint mask)
1033 std::stringstream out;
1036 TraceCallStack::NamedParams namedParams;
1037 namedParams["mask"] = ToString( mask );
1039 mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1042 inline void StencilMaskSeparate(GLenum face, GLuint mask)
1044 std::stringstream out;
1045 out << face << ", " << mask;
1047 TraceCallStack::NamedParams namedParams;
1048 namedParams["face"] = ToString( face );
1049 namedParams["mask"] = ToString( mask );
1051 mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1054 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1056 std::stringstream out;
1057 out << fail << ", " << zfail << ", " << zpass;
1059 TraceCallStack::NamedParams namedParams;
1060 namedParams["fail"] = ToString( fail );
1061 namedParams["zfail"] = ToString( zfail );
1062 namedParams["zpass"] = ToString( zpass );
1064 mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1067 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1069 std::stringstream out;
1070 out << face << ", " << fail << ", " << zfail << "," << zpass;
1072 TraceCallStack::NamedParams namedParams;
1073 namedParams["face"] = ToString( face );
1074 namedParams["fail"] = ToString( fail );
1075 namedParams["zfail"] = ToString( zfail );
1076 namedParams["zpass"] = ToString( zpass );
1078 mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1081 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1083 std::stringstream out;
1084 out << target<<", "<<level<<", "<<width << ", " << height;
1086 TraceCallStack::NamedParams namedParams;
1087 namedParams["target"] = ToString(target);
1088 namedParams["level"] = ToString(level);
1089 namedParams["internalformat"] = ToString(internalformat);
1090 namedParams["width"] = ToString(width);
1091 namedParams["height"] = ToString(height);
1092 namedParams["border"] = ToString(border);
1093 namedParams["format"] = ToString(format);
1094 namedParams["type"] = ToString(type);
1096 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1099 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1101 std::stringstream out;
1102 out << target << ", " << pname << ", " << param;
1104 TraceCallStack::NamedParams namedParams;
1105 namedParams["target"] = ToString(target);
1106 namedParams["pname"] = ToString(pname);
1107 namedParams["param"] = ToString(param);
1109 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1112 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1114 std::stringstream out;
1115 out << target << ", " << pname << ", " << params[0];
1117 TraceCallStack::NamedParams namedParams;
1118 namedParams["target"] = ToString(target);
1119 namedParams["pname"] = ToString(pname);
1120 namedParams["params[0]"] = ToString(params[0]);
1122 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1125 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1127 std::stringstream out;
1128 out << target << ", " << pname << ", " << param;
1129 TraceCallStack::NamedParams namedParams;
1130 namedParams["target"] = ToString(target);
1131 namedParams["pname"] = ToString(pname);
1132 namedParams["param"] = ToString(param);
1133 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1136 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1138 std::stringstream out;
1139 out << target << ", " << pname << ", " << params[0];
1140 TraceCallStack::NamedParams namedParams;
1141 namedParams["target"] = ToString(target);
1142 namedParams["pname"] = ToString(pname);
1143 namedParams["params[0]"] = ToString(params[0]);
1144 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1147 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1149 std::stringstream out;
1150 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1152 TraceCallStack::NamedParams namedParams;
1153 namedParams["target"] = ToString(target);
1154 namedParams["level"] = ToString(level);
1155 namedParams["xoffset"] = ToString(xoffset);
1156 namedParams["yoffset"] = ToString(yoffset);
1157 namedParams["width"] = ToString(width);
1158 namedParams["height"] = ToString(height);
1159 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1162 inline void Uniform1f(GLint location, GLfloat value )
1164 std::string params = ToString( value );
1165 AddUniformCallToTraceStack( location, params );
1167 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, value ) )
1169 mGetErrorResult = GL_INVALID_OPERATION;
1173 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1176 for( int i = 0; i < count; ++i )
1178 params = params + ToString( v[i] ) + ",";
1181 AddUniformCallToTraceStack( location, params );
1183 for( int i = 0; i < count; ++i )
1185 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1187 mGetErrorResult = GL_INVALID_OPERATION;
1193 inline void Uniform1i(GLint location, GLint x)
1195 std::string params = ToString( x );
1197 AddUniformCallToTraceStack( location, params );
1199 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1201 mGetErrorResult = GL_INVALID_OPERATION;
1205 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1207 std::string params = ToString( v );
1208 AddUniformCallToTraceStack( location, params );
1210 for( int i = 0; i < count; ++i )
1212 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1216 mGetErrorResult = GL_INVALID_OPERATION;
1222 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1224 std::string params = ToString( x ) + "," + ToString( y );
1225 AddUniformCallToTraceStack( location, params );
1227 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1231 mGetErrorResult = GL_INVALID_OPERATION;
1235 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1237 std::string params = ToString( v );
1238 AddUniformCallToTraceStack( location, params );
1240 for( int i = 0; i < count; ++i )
1242 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1244 Vector2( v[2*i], v[2*i+1] ) ) )
1246 mGetErrorResult = GL_INVALID_OPERATION;
1252 inline void Uniform2i(GLint location, GLint x, GLint y)
1254 std::string params = ToString( x ) + "," + ToString( y );
1255 AddUniformCallToTraceStack( location, params );
1258 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1260 std::string params = ToString( v );
1261 AddUniformCallToTraceStack( location, params );
1264 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1266 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1267 AddUniformCallToTraceStack( location, params );
1269 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1271 Vector3( x, y, z ) ) )
1273 mGetErrorResult = GL_INVALID_OPERATION;
1277 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1279 std::string params = ToString( v );
1280 AddUniformCallToTraceStack( location, params );
1282 for( int i = 0; i < count; ++i )
1284 if( ! mProgramUniforms3f.SetUniformValue(
1287 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1289 mGetErrorResult = GL_INVALID_OPERATION;
1295 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1297 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1298 AddUniformCallToTraceStack( location, params );
1301 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1303 std::string params = ToString( v );
1304 AddUniformCallToTraceStack( location, params );
1307 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1309 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1310 AddUniformCallToTraceStack( location, params );
1312 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1314 Vector4( x, y, z, w ) ) )
1316 mGetErrorResult = GL_INVALID_OPERATION;
1320 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1322 std::string params = ToString( v );
1323 AddUniformCallToTraceStack( location, params );
1325 for( int i = 0; i < count; ++i )
1327 if( ! mProgramUniforms4f.SetUniformValue(
1330 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1332 mGetErrorResult = GL_INVALID_OPERATION;
1338 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1340 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1341 AddUniformCallToTraceStack( location, params );
1344 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1346 std::string params = ToString( v );
1347 AddUniformCallToTraceStack( location, params );
1350 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1352 std::string params = ToString( value );
1353 AddUniformCallToTraceStack( location, params );
1356 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1358 std::string params = ToString( value );
1359 AddUniformCallToTraceStack( location, params );
1361 for( int i = 0; i < count; ++i )
1363 if( ! mProgramUniformsMat3.SetUniformValue(
1366 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1368 mGetErrorResult = GL_INVALID_OPERATION;
1374 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1376 std::string params = ToString( value );
1377 AddUniformCallToTraceStack( location, params );
1379 for( int i = 0; i < count; ++i )
1381 if( ! mProgramUniformsMat4.SetUniformValue(
1386 mGetErrorResult = GL_INVALID_OPERATION;
1392 inline void UseProgram(GLuint program)
1394 mCurrentProgram = program;
1397 inline void ValidateProgram(GLuint program)
1401 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1405 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1409 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1413 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1417 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1421 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1425 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1429 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1433 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1437 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1443 inline void ReadBuffer(GLenum mode)
1447 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1451 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1455 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)
1459 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1463 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1467 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)
1471 inline void GenQueries(GLsizei n, GLuint* ids)
1475 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1479 inline GLboolean IsQuery(GLuint id)
1484 inline void BeginQuery(GLenum target, GLuint id)
1488 inline void EndQuery(GLenum target)
1492 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1496 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1500 inline GLboolean UnmapBuffer(GLenum target)
1505 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1509 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1513 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1517 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1521 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1525 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1529 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1533 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1537 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1541 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1545 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1549 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1554 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1558 inline void BindVertexArray(GLuint array)
1562 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1566 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1570 inline GLboolean IsVertexArray(GLuint array)
1575 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1579 inline void BeginTransformFeedback(GLenum primitiveMode)
1583 inline void EndTransformFeedback(void)
1587 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1591 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1595 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1599 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1603 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1607 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1611 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1615 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1619 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1623 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1627 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1631 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1635 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1640 inline void Uniform1ui(GLint location, GLuint v0)
1644 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1648 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1652 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1656 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1660 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1664 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1668 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1672 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1676 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1680 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1684 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1688 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1693 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1697 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1701 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1705 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1707 return GL_INVALID_INDEX;
1710 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1714 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1718 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1722 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1726 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1730 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1735 inline GLboolean IsSync(GLsync sync)
1740 inline void DeleteSync(GLsync sync)
1744 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1749 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1753 inline void GetInteger64v(GLenum pname, GLint64* params)
1757 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1761 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1765 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1769 inline void GenSamplers(GLsizei count, GLuint* samplers)
1773 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1777 inline GLboolean IsSampler(GLuint sampler)
1782 inline void BindSampler(GLuint unit, GLuint sampler)
1786 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1790 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1794 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1798 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1802 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1806 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1810 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1814 inline void BindTransformFeedback(GLenum target, GLuint id)
1818 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1822 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1826 inline GLboolean IsTransformFeedback(GLuint id)
1831 inline void PauseTransformFeedback(void)
1835 inline void ResumeTransformFeedback(void)
1839 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1841 mGetProgramBinaryCalled = true;
1844 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1848 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1852 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1856 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1860 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1864 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1868 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1874 inline void AddUniformCallToTraceStack( GLint location, std::string& value )
1876 std::string name = "<not found>";
1877 bool matched = false;
1879 UniformIDMap& map = mUniforms[mCurrentProgram];
1880 for (UniformIDMap::iterator it=map.begin(); it!=map.end(); ++it)
1882 if( it->second == location )
1892 mSetUniformTrace.PushCall( name, value );
1897 public: // TEST FUNCTIONS
1898 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1899 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1900 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1901 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1902 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1903 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1904 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1905 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1906 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1907 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1908 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1909 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1910 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1911 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1912 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1913 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1915 inline bool GetVertexAttribArrayState(GLuint index)
1917 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1922 return mVertexAttribArrayState[ index ];
1924 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1925 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1927 //Methods for CullFace verification
1928 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1929 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1930 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1932 //Methods for Enable/Disable call verification
1933 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1934 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1935 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1937 //Methods for Shader verification
1938 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1939 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1940 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1942 //Methods for Texture verification
1943 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1944 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1945 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1947 //Methods for Texture verification
1948 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1949 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1950 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1952 //Methods for Draw verification
1953 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1954 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1955 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1957 //Methods for Depth function verification
1958 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1959 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1960 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1962 //Methods for Stencil function verification
1963 inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1964 inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1965 inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1967 //Methods for Scissor verification
1968 inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); }
1969 inline void ResetScissorCallStack() { mScissorTrace.Reset(); }
1970 inline TraceCallStack& GetScissorTrace() { return mScissorTrace; }
1972 //Methods for Uniform function verification
1973 inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); }
1974 inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); }
1975 inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; }
1977 template <typename T>
1978 inline bool GetUniformValue( const char* name, T& value ) const
1980 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1981 program_it != mUniforms.end();
1984 const UniformIDMap &uniformIDs = program_it->second;
1986 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1987 if( uniform_it != uniformIDs.end() )
1989 // found one matching uniform name, lets check the value...
1990 GLuint programId = program_it->first;
1991 GLint uniformId = uniform_it->second;
1993 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1994 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
2001 template <typename T>
2002 inline bool CheckUniformValue( const char* name, const T& value ) const
2004 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2005 program_it != mUniforms.end();
2008 const UniformIDMap &uniformIDs = program_it->second;
2010 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2011 if( uniform_it != uniformIDs.end() )
2013 // found one matching uniform name, lets check the value...
2014 GLuint programId = program_it->first;
2015 GLint uniformId = uniform_it->second;
2017 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2018 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
2020 // the value matches
2026 fprintf(stderr, "Not found, printing possible values:\n" );
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 );
2042 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
2044 std::stringstream out;
2045 out << uniform_it->first << ": " << origValue;
2046 fprintf(stderr, "%s\n", out.str().c_str() );
2053 template <typename T>
2054 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
2056 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
2057 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
2060 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
2062 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2063 program_it != mUniforms.end();
2066 const UniformIDMap &uniformIDs = program_it->second;
2068 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2069 if( uniform_it != uniformIDs.end() )
2071 programId = program_it->first;
2072 uniformId = uniform_it->second;
2079 inline GLuint GetLastShaderCompiled() const
2081 return mLastShaderCompiled;
2084 inline GLuint GetLastProgramCreated() const
2086 return mLastProgramIdUsed;
2089 inline GLbitfield GetLastClearMask() const
2091 return mLastClearBitMask;
2096 ATTRIB_UNKNOWN = -1,
2101 ATTRIB_BONE_WEIGHTS,
2102 ATTRIB_BONE_INDICES,
2106 struct ScissorParams
2113 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
2116 // Methods to check scissor tests
2117 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2119 struct ColorMaskParams
2126 ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2129 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2131 inline unsigned int GetClearCountCalled() const { return mClearCount; }
2133 inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2135 typedef std::vector<size_t> BufferDataCalls;
2136 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2137 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2139 typedef std::vector<size_t> BufferSubDataCalls;
2140 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2141 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2144 GLuint mCurrentProgram;
2145 GLuint mCompileStatus;
2146 BufferDataCalls mBufferDataCalls;
2147 BufferSubDataCalls mBufferSubDataCalls;
2149 GLint mNumberOfActiveUniforms;
2150 GLint mGetAttribLocationResult;
2151 GLenum mGetErrorResult;
2152 GLubyte* mGetStringResult;
2153 GLboolean mIsBufferResult;
2154 GLboolean mIsEnabledResult;
2155 GLboolean mIsFramebufferResult;
2156 GLboolean mIsProgramResult;
2157 GLboolean mIsRenderbufferResult;
2158 GLboolean mIsShaderResult;
2159 GLboolean mIsTextureResult;
2160 GLenum mActiveTextureUnit;
2161 GLenum mCheckFramebufferStatusResult;
2162 GLint mFramebufferStatus;
2163 GLenum mFramebufferColorAttached;
2164 GLenum mFramebufferDepthAttached;
2165 GLenum mFramebufferStencilAttached;
2166 GLint mNumBinaryFormats;
2167 GLint mBinaryFormats;
2168 GLint mProgramBinaryLength;
2169 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2170 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
2171 bool mGetProgramBinaryCalled;
2172 typedef std::map< GLuint, std::string> ShaderSourceMap;
2173 ShaderSourceMap mShaderSources;
2174 GLuint mLastShaderCompiled;
2175 GLbitfield mLastClearBitMask;
2176 unsigned int mClearCount;
2178 Vector4 mLastBlendColor;
2179 GLenum mLastBlendEquationRgb;
2180 GLenum mLastBlendEquationAlpha;
2181 GLenum mLastBlendFuncSrcRgb;
2182 GLenum mLastBlendFuncDstRgb;
2183 GLenum mLastBlendFuncSrcAlpha;
2184 GLenum mLastBlendFuncDstAlpha;
2186 GLboolean mLastDepthMask;
2188 // Data for manipulating the IDs returned by GenTextures
2189 GLuint mLastAutoTextureIdUsed;
2190 GLuint mNumGeneratedTextures;
2191 std::vector<GLuint> mNextTextureIds;
2192 std::vector<GLuint> mDeletedTextureIds;
2193 std::vector<GLuint> mBoundTextures;
2195 struct ActiveTextureType
2197 std::vector<GLuint> mBoundTextures;
2200 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2202 TraceCallStack mCullFaceTrace;
2203 TraceCallStack mEnableDisableTrace;
2204 TraceCallStack mShaderTrace;
2205 TraceCallStack mTextureTrace;
2206 TraceCallStack mTexParamaterTrace;
2207 TraceCallStack mDrawTrace;
2208 TraceCallStack mDepthFunctionTrace;
2209 TraceCallStack mStencilFunctionTrace;
2210 TraceCallStack mScissorTrace;
2211 TraceCallStack mSetUniformTrace;
2213 // Shaders & Uniforms
2214 GLuint mLastShaderIdUsed;
2215 GLuint mLastProgramIdUsed;
2216 GLuint mLastUniformIdUsed;
2217 typedef std::map< std::string, GLint > UniformIDMap;
2218 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2219 ProgramUniformMap mUniforms;
2221 template <typename T>
2222 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2225 typedef std::map< GLint, T > UniformValueMap;
2226 typedef std::map< GLuint, UniformValueMap > Map;
2228 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2235 typename Map::iterator it = Map::find( program );
2236 if( it == Map::end() )
2238 // if its the first uniform for this program add it
2239 std::pair< typename Map::iterator, bool > result =
2240 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2244 UniformValueMap& uniforms = it->second;
2245 uniforms[uniform] = value;
2250 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2253 if ( GetUniformValue( program, uniform, uniformValue ) )
2255 return CompareType<T>(value, uniformValue, Math::MACHINE_EPSILON_10);
2261 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2268 typename Map::const_iterator it = Map::find( program );
2269 if( it == Map::end() )
2271 // Uniform values always initialised as 0
2276 const UniformValueMap& uniforms = it->second;
2277 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2278 if( it2 == uniforms.end() )
2280 // Uniform values always initialised as 0
2284 value = it2->second;
2291 ProgramUniformValue<int> mProgramUniforms1i;
2292 ProgramUniformValue<float> mProgramUniforms1f;
2293 ProgramUniformValue<Vector2> mProgramUniforms2f;
2294 ProgramUniformValue<Vector3> mProgramUniforms3f;
2295 ProgramUniformValue<Vector4> mProgramUniforms4f;
2296 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2297 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2299 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2301 return mProgramUniforms1i;
2303 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2305 return mProgramUniforms1f;
2307 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2309 return mProgramUniforms2f;
2311 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2313 return mProgramUniforms3f;
2315 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2317 return mProgramUniforms4f;
2319 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2321 return mProgramUniformsMat4;
2323 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2325 return mProgramUniformsMat3;
2327 inline void SetVertexAttribArray(GLuint index, bool state)
2329 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2334 mVertexAttribArrayState[ index ] = state;
2335 mVertexAttribArrayChanged = true;
2338 ScissorParams mScissorParams;
2339 ColorMaskParams mColorMaskParams;
2343 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2349 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2355 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2357 return Vector2::ZERO;
2361 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2363 return Vector3::ZERO;
2367 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2369 return Vector4::ZERO;
2373 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2379 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2381 return Matrix3( Matrix() );
2386 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2387 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2390 #endif // TEST_GL_ABSTRACTION_H