1 #ifndef TEST_GL_ABSTRACTION_H
2 #define TEST_GL_ABSTRACTION_H
5 * Copyright (c) 2016 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_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
64 inline void ActiveTexture( GLenum textureUnit )
66 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
69 inline GLenum GetActiveTextureUnit() const
71 return mActiveTextureUnit + GL_TEXTURE0;
74 inline void AttachShader( GLuint program, GLuint shader )
76 std::stringstream out;
77 out << program << ", " << shader;
79 TraceCallStack::NamedParams namedParams;
80 namedParams["program"] = ToString(program);
81 namedParams["shader"] = ToString(shader);
82 mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
85 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
89 inline void BindBuffer( GLenum target, GLuint buffer )
93 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
96 mFramebufferStatus |= 2;
99 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
104 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
105 * @return A vector containing the IDs that were bound.
107 inline const std::vector<GLuint>& GetBoundTextures() const
109 return mBoundTextures;
113 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
114 * @param[in] activeTextureUnit The specific active texture unit.
115 * @return A vector containing the IDs that were bound.
117 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
119 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
123 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
125 inline void ClearBoundTextures()
127 mBoundTextures.clear();
129 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
131 mActiveTextures[ i ].mBoundTextures.clear();
135 inline void BindTexture( GLenum target, GLuint texture )
137 // Record the bound textures for future checks
140 mBoundTextures.push_back( texture );
142 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
144 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
148 std::stringstream out;
149 out << target << ", " << texture;
151 TraceCallStack::NamedParams namedParams;
152 namedParams["target"] = ToString(target);
153 namedParams["texture"] = ToString(texture);
155 mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
158 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
160 mLastBlendColor.r = red;
161 mLastBlendColor.g = green;
162 mLastBlendColor.b = blue;
163 mLastBlendColor.a = alpha;
166 inline const Vector4& GetLastBlendColor() const
168 return mLastBlendColor;
171 inline void BlendEquation( GLenum mode )
173 mLastBlendEquationRgb = mode;
174 mLastBlendEquationAlpha = mode;
177 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
179 mLastBlendEquationRgb = modeRgb;
180 mLastBlendEquationAlpha = modeAlpha;
183 inline GLenum GetLastBlendEquationRgb() const
185 return mLastBlendEquationRgb;
188 inline GLenum GetLastBlendEquationAlpha() const
190 return mLastBlendEquationAlpha;
193 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
195 mLastBlendFuncSrcRgb = sfactor;
196 mLastBlendFuncDstRgb = dfactor;
197 mLastBlendFuncSrcAlpha = sfactor;
198 mLastBlendFuncDstAlpha = dfactor;
201 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
203 mLastBlendFuncSrcRgb = srcRGB;
204 mLastBlendFuncDstRgb = dstRGB;
205 mLastBlendFuncSrcAlpha = srcAlpha;
206 mLastBlendFuncDstAlpha = dstAlpha;
209 inline GLenum GetLastBlendFuncSrcRgb() const
211 return mLastBlendFuncSrcRgb;
214 inline GLenum GetLastBlendFuncDstRgb() const
216 return mLastBlendFuncDstRgb;
219 inline GLenum GetLastBlendFuncSrcAlpha() const
221 return mLastBlendFuncSrcAlpha;
224 inline GLenum GetLastBlendFuncDstAlpha() const
226 return mLastBlendFuncDstAlpha;
229 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
231 mBufferDataCalls.push_back(size);
234 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
236 mBufferSubDataCalls.push_back(size);
239 inline GLenum CheckFramebufferStatus(GLenum target)
241 //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
242 //Framebuffer texture have been called
243 if( mFramebufferStatus == 7 )
245 return GL_FRAMEBUFFER_COMPLETE;
248 return mCheckFramebufferStatusResult;
251 inline GLenum CheckFramebufferColorAttachment()
253 return mFramebufferColorAttached;
256 inline GLenum CheckFramebufferDepthAttachment()
258 return mFramebufferDepthAttached;
261 inline GLenum CheckFramebufferStencilAttachment()
263 return mFramebufferStencilAttached;
266 inline void Clear(GLbitfield mask)
269 mLastClearBitMask = mask;
272 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
276 inline void ClearDepthf(GLclampf depth)
280 inline void ClearStencil(GLint s)
282 std::stringstream out;
285 TraceCallStack::NamedParams namedParams;
286 namedParams["s"] = ToString( s );
288 mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
291 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
293 mColorMaskParams.red = red;
294 mColorMaskParams.green = green;
295 mColorMaskParams.blue = blue;
296 mColorMaskParams.alpha = alpha;
299 inline void CompileShader(GLuint shader)
301 std::stringstream out;
303 TraceCallStack::NamedParams namedParams;
304 namedParams["shader"] = ToString(shader);
306 mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
309 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
311 std::stringstream out;
312 out << target<<", "<<level<<", "<<width << ", " << height;
314 TraceCallStack::NamedParams namedParams;
315 namedParams["target"] = ToString(target);
316 namedParams["level"] = ToString(level);
317 namedParams["internalformat"] = ToString(internalformat);
318 namedParams["width"] = ToString(width);
319 namedParams["height"] = ToString(height);
320 namedParams["border"] = ToString(border);
321 namedParams["size"] = ToString(imageSize);
323 mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
326 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
328 std::stringstream out;
329 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
331 TraceCallStack::NamedParams namedParams;
332 namedParams["target"] = ToString(target);
333 namedParams["level"] = ToString(level);
334 namedParams["xoffset"] = ToString(xoffset);
335 namedParams["yoffset"] = ToString(yoffset);
336 namedParams["width"] = ToString(width);
337 namedParams["height"] = ToString(height);
338 mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
341 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
345 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
349 inline GLuint CreateProgram(void)
351 mShaderTrace.PushCall("CreateProgram", "");
353 ++mLastProgramIdUsed;
354 mUniforms[mLastProgramIdUsed] = UniformIDMap();
355 return mLastProgramIdUsed;
358 inline GLuint CreateShader(GLenum type)
360 std::stringstream out;
363 TraceCallStack::NamedParams namedParams;
364 namedParams["type"] = ToString(type);
365 mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
367 return ++mLastShaderIdUsed;
370 inline void CullFace(GLenum mode)
372 std::stringstream out;
375 TraceCallStack::NamedParams namedParams;
376 namedParams["program"] = ToString(mode);
378 mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
381 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
385 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
389 inline void DeleteProgram(GLuint program)
391 std::stringstream out;
394 TraceCallStack::NamedParams namedParams;
395 namedParams["program"] = ToString(program);
397 mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
400 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
404 inline void DeleteShader(GLuint shader)
406 std::stringstream out;
409 TraceCallStack::NamedParams namedParams;
410 namedParams["shader"] = ToString(shader);
412 mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
415 inline void DeleteTextures(GLsizei n, const GLuint* textures)
417 std::stringstream out;
418 out << n << ", " << textures << " = [";
420 TraceCallStack::NamedParams namedParams;
422 for(GLsizei i=0; i<n; i++)
424 out << textures[i] << ", ";
425 std::stringstream paramName;
426 paramName<<"texture["<<i<<"]";
427 namedParams[paramName.str()] = ToString(textures[i]);
428 mDeletedTextureIds.push_back(textures[i]);
432 mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
435 inline bool CheckNoTexturesDeleted()
437 return mDeletedTextureIds.size() == 0;
440 inline bool CheckTextureDeleted( GLuint textureId )
444 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
446 if(*iter == textureId)
455 inline void ClearDeletedTextures()
457 mDeletedTextureIds.clear();
460 inline void DepthFunc(GLenum func)
462 std::stringstream out;
465 TraceCallStack::NamedParams namedParams;
466 namedParams["func"] = ToString(func);
468 mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
471 inline void DepthMask(GLboolean flag)
473 mLastDepthMask = flag;
476 inline bool GetLastDepthMask() const
478 return mLastDepthMask;
481 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
485 inline void DetachShader(GLuint program, GLuint shader)
487 std::stringstream out;
488 out << program << ", " << shader;
489 TraceCallStack::NamedParams namedParams;
490 namedParams["program"] = ToString(program);
491 namedParams["shader"] = ToString(shader);
492 mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
495 inline void Disable(GLenum cap)
497 std::stringstream out;
499 TraceCallStack::NamedParams namedParams;
500 namedParams["cap"] = ToString(cap);
501 mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
504 inline void DisableVertexAttribArray(GLuint index)
506 SetVertexAttribArray( index, false );
509 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
511 std::stringstream out;
512 out << mode << ", " << first << ", " << count;
513 TraceCallStack::NamedParams namedParams;
514 namedParams["mode"] = ToString(mode);
515 namedParams["first"] = ToString(first);
516 namedParams["count"] = ToString(count);
517 mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
520 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
522 std::stringstream out;
523 out << mode << ", " << count << ", " << type << ", indices";
525 TraceCallStack::NamedParams namedParams;
526 namedParams["mode"] = ToString(mode);
527 namedParams["count"] = ToString(count);
528 namedParams["type"] = ToString(type);
529 // Skip void pointers - are they of any use?
530 mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
533 inline void Enable(GLenum cap)
535 std::stringstream out;
537 TraceCallStack::NamedParams namedParams;
538 namedParams["cap"] = ToString(cap);
539 mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
542 inline void EnableVertexAttribArray(GLuint index)
544 SetVertexAttribArray( index, true);
547 inline void Finish(void)
551 inline void Flush(void)
555 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
557 if (attachment == GL_DEPTH_ATTACHMENT)
559 mFramebufferDepthAttached = true;
561 else if (attachment == GL_STENCIL_ATTACHMENT)
563 mFramebufferStencilAttached = true;
567 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
570 mFramebufferStatus |= 4;
572 //We check 4 attachment colors
573 if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
575 mFramebufferColorAttached = true;
579 inline void FrontFace(GLenum mode)
583 inline void GenBuffers(GLsizei n, GLuint* buffers)
585 // avoids an assert in GpuBuffers
589 inline void GenerateMipmap(GLenum target)
591 std::stringstream out;
593 TraceCallStack::NamedParams namedParams;
594 namedParams["target"] = ToString(target);
596 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
599 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
601 for( int i = 0; i < n; i++ )
603 framebuffers[i] = i + 1;
606 //Add 001 bit, this function needs to be called the first one in the chain
607 mFramebufferStatus = 1;
610 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
612 for( int i = 0; i < n; i++ )
614 renderbuffers[i] = i + 1;
619 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
620 * @param[in] ids A vector containing the next IDs to be generated
622 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
624 mNextTextureIds = ids;
627 inline const std::vector<GLuint>& GetNextTextureIds()
629 return mNextTextureIds;
632 inline void GenTextures(GLsizei count, GLuint* textures)
634 for( int i=0; i<count; ++i )
636 if( !mNextTextureIds.empty() )
638 *(textures+i) = mNextTextureIds[0];
639 mNextTextureIds.erase( mNextTextureIds.begin() );
643 *(textures+i) = ++mLastAutoTextureIdUsed;
647 TraceCallStack::NamedParams namedParams;
648 namedParams["count"] = ToString(count);
650 std::stringstream out;
651 for(int i=0; i<count; i++)
658 std::ostringstream oss;
659 oss<<"indices["<<i<<"]";
660 namedParams[oss.str()] = ToString(textures[i]);
663 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
666 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
670 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
675 *length = snprintf(name, bufsize, "sTexture");
676 *type = GL_SAMPLER_2D;
680 *length = snprintf(name, bufsize, "sEffect");
681 *type = GL_SAMPLER_2D;
685 *length = snprintf(name, bufsize, "sGloss");
686 *type = GL_SAMPLER_2D;
694 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
698 inline int GetAttribLocation(GLuint program, const char* name)
700 std::string attribName(name);
702 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
704 if( mStdAttribs[i] == attribName )
710 // 0 is a valid location
714 inline void GetBooleanv(GLenum pname, GLboolean* params)
718 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
722 inline GLenum GetError(void)
724 return mGetErrorResult;
727 inline void GetFloatv(GLenum pname, GLfloat* params)
731 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
735 inline void GetIntegerv(GLenum pname, GLint* params)
739 case GL_MAX_TEXTURE_SIZE:
742 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
745 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
746 *params = mNumBinaryFormats;
748 case GL_PROGRAM_BINARY_FORMATS_OES:
749 *params = mBinaryFormats;
754 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
759 *params = mLinkStatus;
761 case GL_PROGRAM_BINARY_LENGTH_OES:
762 *params = mProgramBinaryLength;
764 case GL_ACTIVE_UNIFORMS:
765 *params = mNumberOfActiveUniforms;
767 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
773 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
777 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
781 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
784 case GL_COMPILE_STATUS:
785 *params = mCompileStatus;
790 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
794 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
798 inline const GLubyte* GetString(GLenum name)
800 return mGetStringResult;
803 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
807 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
811 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
815 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
819 inline GLint GetUniformLocation(GLuint program, const char* name)
821 ProgramUniformMap::iterator it = mUniforms.find(program);
822 if( it == mUniforms.end() )
824 // Not a valid program ID
825 mGetErrorResult = GL_INVALID_OPERATION;
829 UniformIDMap& uniformIDs = it->second;
830 UniformIDMap::iterator it2 = uniformIDs.find( name );
831 if( it2 == uniformIDs.end() )
833 // Uniform not found, so add it...
834 uniformIDs[name] = ++mLastUniformIdUsed;
835 return mLastUniformIdUsed;
841 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
845 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
849 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
853 inline void Hint(GLenum target, GLenum mode)
857 inline GLboolean IsBuffer(GLuint buffer)
859 return mIsBufferResult;
862 inline GLboolean IsEnabled(GLenum cap)
864 return mIsEnabledResult;
867 inline GLboolean IsFramebuffer(GLuint framebuffer)
869 return mIsFramebufferResult;
872 inline GLboolean IsProgram(GLuint program)
874 return mIsProgramResult;
877 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
879 return mIsRenderbufferResult;
882 inline GLboolean IsShader(GLuint shader)
884 return mIsShaderResult;
887 inline GLboolean IsTexture(GLuint texture)
889 return mIsTextureResult;
892 inline void LineWidth(GLfloat width)
896 inline void LinkProgram(GLuint program)
898 std::stringstream out;
901 TraceCallStack::NamedParams namedParams;
902 namedParams["program"] = ToString(program);
903 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
905 mNumberOfActiveUniforms=3;
906 GetUniformLocation(program, "sTexture");
907 GetUniformLocation(program, "sEffect");
908 GetUniformLocation(program, "sGloss");
911 inline void PixelStorei(GLenum pname, GLint param)
915 inline void PolygonOffset(GLfloat factor, GLfloat units)
919 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
923 inline void ReleaseShaderCompiler(void)
927 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
931 inline void SampleCoverage(GLclampf value, GLboolean invert)
935 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
937 mScissorParams.x = x;
938 mScissorParams.y = y;
939 mScissorParams.width = width;
940 mScissorParams.height = height;
943 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
947 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
949 std::string stringBuilder;
950 for(int i = 0; i < count; ++i)
952 stringBuilder += string[i];
954 mShaderSources[shader] = stringBuilder;
955 mLastShaderCompiled = shader;
958 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
960 const std::string shaderSource = mShaderSources[shader];
961 const int shaderSourceLength = static_cast<int>(shaderSource.length());
962 if( shaderSourceLength < bufsize )
964 strncpy( source, shaderSource.c_str(), shaderSourceLength );
965 *length = shaderSourceLength;
969 *length = bufsize -1;
970 strncpy(source, shaderSource.c_str(), *length);
971 source[*length] = 0x0;
975 inline std::string GetShaderSource(GLuint shader)
977 return mShaderSources[shader];
980 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
982 std::stringstream out;
983 out << func << ", " << ref << ", " << mask;
985 TraceCallStack::NamedParams namedParams;
986 namedParams["func"] = ToString( func );
987 namedParams["ref"] = ToString( ref );
988 namedParams["mask"] = ToString( mask );
990 mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
993 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
995 std::stringstream out;
996 out << face << ", " << func << ", " << ref << ", " << mask;
998 TraceCallStack::NamedParams namedParams;
999 namedParams["face"] = ToString( face );
1000 namedParams["func"] = ToString( func );
1001 namedParams["ref"] = ToString( ref );
1002 namedParams["mask"] = ToString( mask );
1004 mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1007 inline void StencilMask(GLuint mask)
1009 std::stringstream out;
1012 TraceCallStack::NamedParams namedParams;
1013 namedParams["mask"] = ToString( mask );
1015 mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1018 inline void StencilMaskSeparate(GLenum face, GLuint mask)
1020 std::stringstream out;
1021 out << face << ", " << mask;
1023 TraceCallStack::NamedParams namedParams;
1024 namedParams["face"] = ToString( face );
1025 namedParams["mask"] = ToString( mask );
1027 mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1030 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1032 std::stringstream out;
1033 out << fail << ", " << zfail << ", " << zpass;
1035 TraceCallStack::NamedParams namedParams;
1036 namedParams["fail"] = ToString( fail );
1037 namedParams["zfail"] = ToString( zfail );
1038 namedParams["zpass"] = ToString( zpass );
1040 mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1043 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1045 std::stringstream out;
1046 out << face << ", " << fail << ", " << zfail << "," << zpass;
1048 TraceCallStack::NamedParams namedParams;
1049 namedParams["face"] = ToString( face );
1050 namedParams["fail"] = ToString( fail );
1051 namedParams["zfail"] = ToString( zfail );
1052 namedParams["zpass"] = ToString( zpass );
1054 mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1057 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1059 std::stringstream out;
1060 out << target<<", "<<level<<", "<<width << ", " << height;
1062 TraceCallStack::NamedParams namedParams;
1063 namedParams["target"] = ToString(target);
1064 namedParams["level"] = ToString(level);
1065 namedParams["internalformat"] = ToString(internalformat);
1066 namedParams["width"] = ToString(width);
1067 namedParams["height"] = ToString(height);
1068 namedParams["border"] = ToString(border);
1069 namedParams["format"] = ToString(format);
1070 namedParams["type"] = ToString(type);
1072 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1075 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1077 std::stringstream out;
1078 out << target << ", " << pname << ", " << param;
1080 TraceCallStack::NamedParams namedParams;
1081 namedParams["target"] = ToString(target);
1082 namedParams["pname"] = ToString(pname);
1083 namedParams["param"] = ToString(param);
1085 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1088 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1090 std::stringstream out;
1091 out << target << ", " << pname << ", " << params[0];
1093 TraceCallStack::NamedParams namedParams;
1094 namedParams["target"] = ToString(target);
1095 namedParams["pname"] = ToString(pname);
1096 namedParams["params[0]"] = ToString(params[0]);
1098 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1101 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1103 std::stringstream out;
1104 out << target << ", " << pname << ", " << param;
1105 TraceCallStack::NamedParams namedParams;
1106 namedParams["target"] = ToString(target);
1107 namedParams["pname"] = ToString(pname);
1108 namedParams["param"] = ToString(param);
1109 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1112 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1114 std::stringstream out;
1115 out << target << ", " << pname << ", " << params[0];
1116 TraceCallStack::NamedParams namedParams;
1117 namedParams["target"] = ToString(target);
1118 namedParams["pname"] = ToString(pname);
1119 namedParams["params[0]"] = ToString(params[0]);
1120 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1123 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1125 std::stringstream out;
1126 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1128 TraceCallStack::NamedParams namedParams;
1129 namedParams["target"] = ToString(target);
1130 namedParams["level"] = ToString(level);
1131 namedParams["xoffset"] = ToString(xoffset);
1132 namedParams["yoffset"] = ToString(yoffset);
1133 namedParams["width"] = ToString(width);
1134 namedParams["height"] = ToString(height);
1135 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1138 inline void Uniform1f(GLint location, GLfloat x)
1140 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
1142 mGetErrorResult = GL_INVALID_OPERATION;
1146 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1148 for( int i = 0; i < count; ++i )
1150 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1152 mGetErrorResult = GL_INVALID_OPERATION;
1158 inline void Uniform1i(GLint location, GLint x)
1160 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1162 mGetErrorResult = GL_INVALID_OPERATION;
1166 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1168 for( int i = 0; i < count; ++i )
1170 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1174 mGetErrorResult = GL_INVALID_OPERATION;
1180 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1182 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1186 mGetErrorResult = GL_INVALID_OPERATION;
1190 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1192 for( int i = 0; i < count; ++i )
1194 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1196 Vector2( v[2*i], v[2*i+1] ) ) )
1198 mGetErrorResult = GL_INVALID_OPERATION;
1204 inline void Uniform2i(GLint location, GLint x, GLint y)
1208 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1212 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1214 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1216 Vector3( x, y, z ) ) )
1218 mGetErrorResult = GL_INVALID_OPERATION;
1222 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1224 for( int i = 0; i < count; ++i )
1226 if( ! mProgramUniforms3f.SetUniformValue(
1229 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1231 mGetErrorResult = GL_INVALID_OPERATION;
1237 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1241 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1245 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1247 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1249 Vector4( x, y, z, w ) ) )
1251 mGetErrorResult = GL_INVALID_OPERATION;
1255 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1257 for( int i = 0; i < count; ++i )
1259 if( ! mProgramUniforms4f.SetUniformValue(
1262 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1264 mGetErrorResult = GL_INVALID_OPERATION;
1270 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1274 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1278 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1282 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1284 for( int i = 0; i < count; ++i )
1286 if( ! mProgramUniformsMat3.SetUniformValue(
1289 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1291 mGetErrorResult = GL_INVALID_OPERATION;
1297 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1299 for( int i = 0; i < count; ++i )
1301 if( ! mProgramUniformsMat4.SetUniformValue(
1306 mGetErrorResult = GL_INVALID_OPERATION;
1312 inline void UseProgram(GLuint program)
1314 mCurrentProgram = program;
1317 inline void ValidateProgram(GLuint program)
1321 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1325 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1329 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1333 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1337 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1341 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1345 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1349 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1353 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1357 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1363 inline void ReadBuffer(GLenum mode)
1367 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1371 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1375 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)
1379 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1383 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1387 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)
1391 inline void GenQueries(GLsizei n, GLuint* ids)
1395 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1399 inline GLboolean IsQuery(GLuint id)
1404 inline void BeginQuery(GLenum target, GLuint id)
1408 inline void EndQuery(GLenum target)
1412 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1416 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1420 inline GLboolean UnmapBuffer(GLenum target)
1425 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1429 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1433 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1437 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1441 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1445 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1449 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1453 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1457 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1461 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1465 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1469 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1474 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1478 inline void BindVertexArray(GLuint array)
1482 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1486 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1490 inline GLboolean IsVertexArray(GLuint array)
1495 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1499 inline void BeginTransformFeedback(GLenum primitiveMode)
1503 inline void EndTransformFeedback(void)
1507 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1511 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1515 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1519 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1523 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1527 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1531 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1535 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1539 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1543 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1547 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1551 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1555 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1560 inline void Uniform1ui(GLint location, GLuint v0)
1564 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1568 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1572 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1576 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1580 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1584 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1588 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1592 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1596 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1600 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1604 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1608 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1613 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1617 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1621 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1625 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1627 return GL_INVALID_INDEX;
1630 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1634 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1638 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1642 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1646 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1650 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1655 inline GLboolean IsSync(GLsync sync)
1660 inline void DeleteSync(GLsync sync)
1664 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1669 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1673 inline void GetInteger64v(GLenum pname, GLint64* params)
1677 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1681 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1685 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1689 inline void GenSamplers(GLsizei count, GLuint* samplers)
1693 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1697 inline GLboolean IsSampler(GLuint sampler)
1702 inline void BindSampler(GLuint unit, GLuint sampler)
1706 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1710 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1714 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1718 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1722 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1726 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1730 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1734 inline void BindTransformFeedback(GLenum target, GLuint id)
1738 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1742 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1746 inline GLboolean IsTransformFeedback(GLuint id)
1751 inline void PauseTransformFeedback(void)
1755 inline void ResumeTransformFeedback(void)
1759 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1761 mGetProgramBinaryCalled = true;
1764 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1768 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1772 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1776 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1780 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1784 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1788 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1792 public: // TEST FUNCTIONS
1793 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1794 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1795 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1796 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1797 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1798 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1799 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1800 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1801 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1802 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1803 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1804 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1805 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1806 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1807 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1808 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1810 inline bool GetVertexAttribArrayState(GLuint index)
1812 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1817 return mVertexAttribArrayState[ index ];
1819 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1820 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1822 //Methods for CullFace verification
1823 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1824 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1825 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1827 //Methods for Enable/Disable call verification
1828 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1829 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1830 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1832 //Methods for Shader verification
1833 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1834 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1835 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1837 //Methods for Texture verification
1838 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1839 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1840 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1842 //Methods for Texture verification
1843 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1844 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1845 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1847 //Methods for Draw verification
1848 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1849 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1850 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1852 //Methods for Depth function verification
1853 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1854 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1855 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1857 //Methods for Stencil function verification
1858 inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1859 inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1860 inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1862 template <typename T>
1863 inline bool GetUniformValue( const char* name, T& value ) const
1865 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1866 program_it != mUniforms.end();
1869 const UniformIDMap &uniformIDs = program_it->second;
1871 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1872 if( uniform_it != uniformIDs.end() )
1874 // found one matching uniform name, lets check the value...
1875 GLuint programId = program_it->first;
1876 GLint uniformId = uniform_it->second;
1878 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1879 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
1886 template <typename T>
1887 inline bool CheckUniformValue( const char* name, const T& value ) const
1889 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1890 program_it != mUniforms.end();
1893 const UniformIDMap &uniformIDs = program_it->second;
1895 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1896 if( uniform_it != uniformIDs.end() )
1898 // found one matching uniform name, lets check the value...
1899 GLuint programId = program_it->first;
1900 GLint uniformId = uniform_it->second;
1902 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1903 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1905 // the value matches
1911 fprintf(stderr, "Not found, printing possible values:\n" );
1912 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1913 program_it != mUniforms.end();
1916 const UniformIDMap &uniformIDs = program_it->second;
1918 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1919 if( uniform_it != uniformIDs.end() )
1921 // found one matching uniform name, lets check the value...
1922 GLuint programId = program_it->first;
1923 GLint uniformId = uniform_it->second;
1925 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1927 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1929 std::stringstream out;
1930 out << uniform_it->first << ": " << origValue;
1931 fprintf(stderr, "%s\n", out.str().c_str() );
1938 template <typename T>
1939 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1941 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1942 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1945 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1947 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1948 program_it != mUniforms.end();
1951 const UniformIDMap &uniformIDs = program_it->second;
1953 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1954 if( uniform_it != uniformIDs.end() )
1956 programId = program_it->first;
1957 uniformId = uniform_it->second;
1964 inline GLuint GetLastShaderCompiled() const
1966 return mLastShaderCompiled;
1969 inline GLuint GetLastProgramCreated() const
1971 return mLastProgramIdUsed;
1974 inline GLbitfield GetLastClearMask() const
1976 return mLastClearBitMask;
1981 ATTRIB_UNKNOWN = -1,
1986 ATTRIB_BONE_WEIGHTS,
1987 ATTRIB_BONE_INDICES,
1991 struct ScissorParams
1998 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
2001 // Methods to check scissor tests
2002 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2004 struct ColorMaskParams
2011 ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2014 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2016 inline unsigned int GetClearCountCalled() const { return mClearCount; }
2018 inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2020 typedef std::vector<size_t> BufferDataCalls;
2021 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2022 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2024 typedef std::vector<size_t> BufferSubDataCalls;
2025 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2026 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2029 GLuint mCurrentProgram;
2030 GLuint mCompileStatus;
2031 BufferDataCalls mBufferDataCalls;
2032 BufferSubDataCalls mBufferSubDataCalls;
2034 GLint mNumberOfActiveUniforms;
2035 GLint mGetAttribLocationResult;
2036 GLenum mGetErrorResult;
2037 GLubyte* mGetStringResult;
2038 GLboolean mIsBufferResult;
2039 GLboolean mIsEnabledResult;
2040 GLboolean mIsFramebufferResult;
2041 GLboolean mIsProgramResult;
2042 GLboolean mIsRenderbufferResult;
2043 GLboolean mIsShaderResult;
2044 GLboolean mIsTextureResult;
2045 GLenum mActiveTextureUnit;
2046 GLenum mCheckFramebufferStatusResult;
2047 GLint mFramebufferStatus;
2048 GLenum mFramebufferColorAttached;
2049 GLenum mFramebufferDepthAttached;
2050 GLenum mFramebufferStencilAttached;
2051 GLint mNumBinaryFormats;
2052 GLint mBinaryFormats;
2053 GLint mProgramBinaryLength;
2054 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2055 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
2056 bool mGetProgramBinaryCalled;
2057 typedef std::map< GLuint, std::string> ShaderSourceMap;
2058 ShaderSourceMap mShaderSources;
2059 GLuint mLastShaderCompiled;
2060 GLbitfield mLastClearBitMask;
2061 unsigned int mClearCount;
2063 Vector4 mLastBlendColor;
2064 GLenum mLastBlendEquationRgb;
2065 GLenum mLastBlendEquationAlpha;
2066 GLenum mLastBlendFuncSrcRgb;
2067 GLenum mLastBlendFuncDstRgb;
2068 GLenum mLastBlendFuncSrcAlpha;
2069 GLenum mLastBlendFuncDstAlpha;
2071 GLboolean mLastDepthMask;
2073 // Data for manipulating the IDs returned by GenTextures
2074 GLuint mLastAutoTextureIdUsed;
2075 std::vector<GLuint> mNextTextureIds;
2076 std::vector<GLuint> mDeletedTextureIds;
2077 std::vector<GLuint> mBoundTextures;
2079 struct ActiveTextureType
2081 std::vector<GLuint> mBoundTextures;
2084 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2086 TraceCallStack mCullFaceTrace;
2087 TraceCallStack mEnableDisableTrace;
2088 TraceCallStack mShaderTrace;
2089 TraceCallStack mTextureTrace;
2090 TraceCallStack mTexParamaterTrace;
2091 TraceCallStack mDrawTrace;
2092 TraceCallStack mDepthFunctionTrace;
2093 TraceCallStack mStencilFunctionTrace;
2095 // Shaders & Uniforms
2096 GLuint mLastShaderIdUsed;
2097 GLuint mLastProgramIdUsed;
2098 GLuint mLastUniformIdUsed;
2099 typedef std::map< std::string, GLint > UniformIDMap;
2100 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2101 ProgramUniformMap mUniforms;
2103 template <typename T>
2104 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2107 typedef std::map< GLint, T > UniformValueMap;
2108 typedef std::map< GLuint, UniformValueMap > Map;
2110 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2117 typename Map::iterator it = Map::find( program );
2118 if( it == Map::end() )
2120 // if its the first uniform for this program add it
2121 std::pair< typename Map::iterator, bool > result =
2122 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2126 UniformValueMap& uniforms = it->second;
2127 uniforms[uniform] = value;
2132 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2135 if ( GetUniformValue( program, uniform, uniformValue ) )
2137 return CompareType<T>(value, uniformValue, Math::MACHINE_EPSILON_10);
2143 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2150 typename Map::const_iterator it = Map::find( program );
2151 if( it == Map::end() )
2153 // Uniform values always initialised as 0
2158 const UniformValueMap& uniforms = it->second;
2159 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2160 if( it2 == uniforms.end() )
2162 // Uniform values always initialised as 0
2166 value = it2->second;
2173 ProgramUniformValue<int> mProgramUniforms1i;
2174 ProgramUniformValue<float> mProgramUniforms1f;
2175 ProgramUniformValue<Vector2> mProgramUniforms2f;
2176 ProgramUniformValue<Vector3> mProgramUniforms3f;
2177 ProgramUniformValue<Vector4> mProgramUniforms4f;
2178 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2179 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2184 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2186 return mProgramUniforms1i;
2188 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2190 return mProgramUniforms1f;
2192 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2194 return mProgramUniforms2f;
2196 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2198 return mProgramUniforms3f;
2200 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2202 return mProgramUniforms4f;
2204 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2206 return mProgramUniformsMat4;
2208 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2210 return mProgramUniformsMat3;
2212 inline void SetVertexAttribArray(GLuint index, bool state)
2214 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2219 mVertexAttribArrayState[ index ] = state;
2220 mVertexAttribArrayChanged = true;
2223 ScissorParams mScissorParams;
2224 ColorMaskParams mColorMaskParams;
2228 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2234 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2240 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2242 return Vector2::ZERO;
2246 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2248 return Vector3::ZERO;
2252 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2254 return Vector4::ZERO;
2258 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2264 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2266 return Matrix3( Matrix() );
2271 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2272 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2275 #endif // TEST_GL_ABSTRACTION_H