1 #ifndef __TEST_GL_ABSTRACTION_H__
2 #define __TEST_GL_ABSTRACTION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
27 #include <cstring> // for strcmp
30 #include <dali/public-api/dali-core.h>
31 #include <dali/integration-api/core.h>
32 #include <dali/integration-api/gl-abstraction.h>
33 #include <dali/integration-api/gl-defines.h>
34 #include "test-trace-call-stack.h"
39 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
40 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
42 "aPosition", // ATTRIB_POSITION
43 "aNormal", // ATTRIB_NORMAL
44 "aTexCoord", // ATTRIB_TEXCOORD
45 "aColor", // ATTRIB_COLOR
46 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
47 "aBoneIndices" // ATTRIB_BONE_INDICES
50 class DALI_IMPORT_API TestGlAbstraction: public Dali::Integration::GlAbstraction
62 inline void ActiveTexture( GLenum textureUnit )
64 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
67 inline GLenum GetActiveTextureUnit() const
69 return mActiveTextureUnit + GL_TEXTURE0;
72 inline void AttachShader( GLuint program, GLuint shader )
74 std::stringstream out;
75 out << program << ", " << shader;
77 TraceCallStack::NamedParams namedParams;
78 namedParams["program"] = ToString(program);
79 namedParams["shader"] = ToString(shader);
80 mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
83 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
87 inline void BindBuffer( GLenum target, GLuint buffer )
91 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
94 mFramebufferStatus |= 2;
97 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
102 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
103 * @return A vector containing the IDs that were bound.
105 inline const std::vector<GLuint>& GetBoundTextures() const
107 return mBoundTextures;
111 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
112 * @param[in] activeTextureUnit The specific active texture unit.
113 * @return A vector containing the IDs that were bound.
115 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
117 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
121 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
123 inline void ClearBoundTextures()
125 mBoundTextures.clear();
127 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
129 mActiveTextures[ i ].mBoundTextures.clear();
133 inline void BindTexture( GLenum target, GLuint texture )
135 // Record the bound textures for future checks
138 mBoundTextures.push_back( texture );
140 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
142 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
146 std::stringstream out;
147 out << target << ", " << texture;
149 TraceCallStack::NamedParams namedParams;
150 namedParams["target"] = ToString(target);
151 namedParams["texture"] = ToString(texture);
153 mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
156 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
158 mLastBlendColor.r = red;
159 mLastBlendColor.g = green;
160 mLastBlendColor.b = blue;
161 mLastBlendColor.a = alpha;
164 inline const Vector4& GetLastBlendColor() const
166 return mLastBlendColor;
169 inline void BlendEquation( GLenum mode )
171 mLastBlendEquationRgb = mode;
172 mLastBlendEquationAlpha = mode;
175 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
177 mLastBlendEquationRgb = modeRgb;
178 mLastBlendEquationAlpha = modeAlpha;
181 inline GLenum GetLastBlendEquationRgb() const
183 return mLastBlendEquationRgb;
186 inline GLenum GetLastBlendEquationAlpha() const
188 return mLastBlendEquationAlpha;
191 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
193 mLastBlendFuncSrcRgb = sfactor;
194 mLastBlendFuncDstRgb = dfactor;
195 mLastBlendFuncSrcAlpha = sfactor;
196 mLastBlendFuncDstAlpha = dfactor;
199 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
201 mLastBlendFuncSrcRgb = srcRGB;
202 mLastBlendFuncDstRgb = dstRGB;
203 mLastBlendFuncSrcAlpha = srcAlpha;
204 mLastBlendFuncDstAlpha = dstAlpha;
207 inline GLenum GetLastBlendFuncSrcRgb() const
209 return mLastBlendFuncSrcRgb;
212 inline GLenum GetLastBlendFuncDstRgb() const
214 return mLastBlendFuncDstRgb;
217 inline GLenum GetLastBlendFuncSrcAlpha() const
219 return mLastBlendFuncSrcAlpha;
222 inline GLenum GetLastBlendFuncDstAlpha() const
224 return mLastBlendFuncDstAlpha;
227 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
229 mBufferDataCalls.push_back(size);
232 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
234 mBufferSubDataCalls.push_back(size);
237 inline GLenum CheckFramebufferStatus(GLenum target)
239 //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
240 //Framebuffer texture have been called
241 if( mFramebufferStatus == 7 )
243 return GL_FRAMEBUFFER_COMPLETE;
246 return mCheckFramebufferStatusResult;
249 inline GLenum CheckFramebufferColorAttachment()
251 return mFramebufferColorAttached;
254 inline GLenum CheckFramebufferDepthAttachment()
256 return mFramebufferDepthAttached;
259 inline GLenum CheckFramebufferStencilAttachment()
261 return mFramebufferStencilAttached;
264 inline void Clear(GLbitfield mask)
267 mLastClearBitMask = mask;
270 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
274 inline void ClearDepthf(GLclampf depth)
278 inline void ClearStencil(GLint s)
282 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
286 inline void CompileShader(GLuint shader)
288 std::stringstream out;
290 TraceCallStack::NamedParams namedParams;
291 namedParams["shader"] = ToString(shader);
293 mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
296 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
298 std::stringstream out;
299 out << target<<", "<<level<<", "<<width << ", " << height;
301 TraceCallStack::NamedParams namedParams;
302 namedParams["target"] = ToString(target);
303 namedParams["level"] = ToString(level);
304 namedParams["internalformat"] = ToString(internalformat);
305 namedParams["width"] = ToString(width);
306 namedParams["height"] = ToString(height);
307 namedParams["border"] = ToString(border);
308 namedParams["size"] = ToString(imageSize);
310 mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
313 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
315 std::stringstream out;
316 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
318 TraceCallStack::NamedParams namedParams;
319 namedParams["target"] = ToString(target);
320 namedParams["level"] = ToString(level);
321 namedParams["xoffset"] = ToString(xoffset);
322 namedParams["yoffset"] = ToString(yoffset);
323 namedParams["width"] = ToString(width);
324 namedParams["height"] = ToString(height);
325 mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
328 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
332 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
336 inline GLuint CreateProgram(void)
338 mShaderTrace.PushCall("CreateProgram", "");
340 ++mLastProgramIdUsed;
341 mUniforms[mLastProgramIdUsed] = UniformIDMap();
342 return mLastProgramIdUsed;
345 inline GLuint CreateShader(GLenum type)
347 std::stringstream out;
350 TraceCallStack::NamedParams namedParams;
351 namedParams["type"] = ToString(type);
352 mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
354 return ++mLastShaderIdUsed;
357 inline void CullFace(GLenum mode)
359 std::stringstream out;
362 TraceCallStack::NamedParams namedParams;
363 namedParams["program"] = ToString(mode);
365 mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
368 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
372 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
376 inline void DeleteProgram(GLuint program)
378 std::stringstream out;
381 TraceCallStack::NamedParams namedParams;
382 namedParams["program"] = ToString(program);
384 mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
387 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
391 inline void DeleteShader(GLuint shader)
393 std::stringstream out;
396 TraceCallStack::NamedParams namedParams;
397 namedParams["shader"] = ToString(shader);
399 mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
402 inline void DeleteTextures(GLsizei n, const GLuint* textures)
404 std::stringstream out;
405 out << n << ", " << textures << " = [";
407 TraceCallStack::NamedParams namedParams;
409 for(GLsizei i=0; i<n; i++)
411 out << textures[i] << ", ";
412 std::stringstream paramName;
413 paramName<<"texture["<<i<<"]";
414 namedParams[paramName.str()] = ToString(textures[i]);
415 mDeletedTextureIds.push_back(textures[i]);
419 mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
422 inline bool CheckNoTexturesDeleted()
424 return mDeletedTextureIds.size() == 0;
427 inline bool CheckTextureDeleted( GLuint textureId )
431 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
433 if(*iter == textureId)
442 inline void ClearDeletedTextures()
444 mDeletedTextureIds.clear();
447 inline void DepthFunc(GLenum func)
449 std::stringstream out;
452 TraceCallStack::NamedParams namedParams;
453 namedParams["func"] = ToString(func);
455 mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
458 inline void DepthMask(GLboolean flag)
462 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
466 inline void DetachShader(GLuint program, GLuint shader)
468 std::stringstream out;
469 out << program << ", " << shader;
470 TraceCallStack::NamedParams namedParams;
471 namedParams["program"] = ToString(program);
472 namedParams["shader"] = ToString(shader);
473 mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
476 inline void Disable(GLenum cap)
478 std::stringstream out;
480 TraceCallStack::NamedParams namedParams;
481 namedParams["cap"] = ToString(cap);
482 mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
485 inline void DisableVertexAttribArray(GLuint index)
487 SetVertexAttribArray( index, false );
490 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
492 std::stringstream out;
493 out << mode << ", " << first << ", " << count;
494 TraceCallStack::NamedParams namedParams;
495 namedParams["mode"] = ToString(mode);
496 namedParams["first"] = ToString(first);
497 namedParams["count"] = ToString(count);
498 mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
501 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
503 std::stringstream out;
504 out << mode << ", " << count << ", " << type << ", indices";
506 TraceCallStack::NamedParams namedParams;
507 namedParams["mode"] = ToString(mode);
508 namedParams["count"] = ToString(count);
509 namedParams["type"] = ToString(type);
510 // Skip void pointers - are they of any use?
511 mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
514 inline void Enable(GLenum cap)
516 std::stringstream out;
518 TraceCallStack::NamedParams namedParams;
519 namedParams["cap"] = ToString(cap);
520 mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
523 inline void EnableVertexAttribArray(GLuint index)
525 SetVertexAttribArray( index, true);
528 inline void Finish(void)
532 inline void Flush(void)
536 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
538 if (attachment == GL_DEPTH_ATTACHMENT)
540 mFramebufferDepthAttached = true;
542 else if (attachment == GL_STENCIL_ATTACHMENT)
544 mFramebufferStencilAttached = true;
548 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
551 mFramebufferStatus |= 4;
553 //We check 4 attachment colors
554 if ((attachment == GL_COLOR_ATTACHMENT0) || (attachment == GL_COLOR_ATTACHMENT1) || (attachment == GL_COLOR_ATTACHMENT2) || (attachment == GL_COLOR_ATTACHMENT4))
556 mFramebufferColorAttached = true;
560 inline void FrontFace(GLenum mode)
564 inline void GenBuffers(GLsizei n, GLuint* buffers)
566 // avoids an assert in GpuBuffers
570 inline void GenerateMipmap(GLenum target)
572 std::stringstream out;
574 TraceCallStack::NamedParams namedParams;
575 namedParams["target"] = ToString(target);
577 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
580 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
582 for( int i = 0; i < n; i++ )
584 framebuffers[i] = i + 1;
587 //Add 001 bit, this function needs to be called the first one in the chain
588 mFramebufferStatus = 1;
591 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
593 for( int i = 0; i < n; i++ )
595 renderbuffers[i] = i + 1;
600 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
601 * @param[in] ids A vector containing the next IDs to be generated
603 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
605 mNextTextureIds = ids;
608 inline const std::vector<GLuint>& GetNextTextureIds()
610 return mNextTextureIds;
613 inline void GenTextures(GLsizei count, GLuint* textures)
615 for( int i=0; i<count; ++i )
617 if( !mNextTextureIds.empty() )
619 *(textures+i) = mNextTextureIds[0];
620 mNextTextureIds.erase( mNextTextureIds.begin() );
624 *(textures+i) = ++mLastAutoTextureIdUsed;
628 TraceCallStack::NamedParams namedParams;
629 namedParams["count"] = ToString(count);
631 std::stringstream out;
632 for(int i=0; i<count; i++)
639 std::ostringstream oss;
640 oss<<"indices["<<i<<"]";
641 namedParams[oss.str()] = ToString(textures[i]);
644 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
647 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
651 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
656 *length = snprintf(name, bufsize, "sTexture");
657 *type = GL_SAMPLER_2D;
661 *length = snprintf(name, bufsize, "sEffect");
662 *type = GL_SAMPLER_2D;
670 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
674 inline int GetAttribLocation(GLuint program, const char* name)
676 std::string attribName(name);
678 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
680 if( mStdAttribs[i] == attribName )
686 // 0 is a valid location
690 inline void GetBooleanv(GLenum pname, GLboolean* params)
694 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
698 inline GLenum GetError(void)
700 return mGetErrorResult;
703 inline void GetFloatv(GLenum pname, GLfloat* params)
707 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
711 inline void GetIntegerv(GLenum pname, GLint* params)
715 case GL_MAX_TEXTURE_SIZE:
718 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
721 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
722 *params = mNumBinaryFormats;
724 case GL_PROGRAM_BINARY_FORMATS_OES:
725 *params = mBinaryFormats;
730 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
735 *params = mLinkStatus;
737 case GL_PROGRAM_BINARY_LENGTH_OES:
738 *params = mProgramBinaryLength;
740 case GL_ACTIVE_UNIFORMS:
741 *params = mNumberOfActiveUniforms;
743 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
749 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
753 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
757 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
760 case GL_COMPILE_STATUS:
761 *params = mCompileStatus;
766 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
770 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
774 inline const GLubyte* GetString(GLenum name)
776 return mGetStringResult;
779 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
783 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
787 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
791 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
795 inline GLint GetUniformLocation(GLuint program, const char* name)
797 ProgramUniformMap::iterator it = mUniforms.find(program);
798 if( it == mUniforms.end() )
800 // Not a valid program ID
801 mGetErrorResult = GL_INVALID_OPERATION;
805 UniformIDMap& uniformIDs = it->second;
806 UniformIDMap::iterator it2 = uniformIDs.find( name );
807 if( it2 == uniformIDs.end() )
809 // Uniform not found, so add it...
810 uniformIDs[name] = ++mLastUniformIdUsed;
811 return mLastUniformIdUsed;
817 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
821 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
825 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
829 inline void Hint(GLenum target, GLenum mode)
833 inline GLboolean IsBuffer(GLuint buffer)
835 return mIsBufferResult;
838 inline GLboolean IsEnabled(GLenum cap)
840 return mIsEnabledResult;
843 inline GLboolean IsFramebuffer(GLuint framebuffer)
845 return mIsFramebufferResult;
848 inline GLboolean IsProgram(GLuint program)
850 return mIsProgramResult;
853 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
855 return mIsRenderbufferResult;
858 inline GLboolean IsShader(GLuint shader)
860 return mIsShaderResult;
863 inline GLboolean IsTexture(GLuint texture)
865 return mIsTextureResult;
868 inline void LineWidth(GLfloat width)
872 inline void LinkProgram(GLuint program)
874 std::stringstream out;
877 TraceCallStack::NamedParams namedParams;
878 namedParams["program"] = ToString(program);
879 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
881 mNumberOfActiveUniforms=2;
882 GetUniformLocation(program, "sTexture");
883 GetUniformLocation(program, "sEffect");
886 inline void PixelStorei(GLenum pname, GLint param)
890 inline void PolygonOffset(GLfloat factor, GLfloat units)
894 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
898 inline void ReleaseShaderCompiler(void)
902 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
906 inline void SampleCoverage(GLclampf value, GLboolean invert)
910 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
912 mScissorParams.x = x;
913 mScissorParams.y = y;
914 mScissorParams.width = width;
915 mScissorParams.height = height;
918 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
922 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
924 std::string stringBuilder;
925 for(int i = 0; i < count; ++i)
927 stringBuilder += string[i];
929 mShaderSources[shader] = stringBuilder;
930 mLastShaderCompiled = shader;
933 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
935 const std::string shaderSource = mShaderSources[shader];
936 if( static_cast<int>(shaderSource.length()) < bufsize )
938 strcpy(source, shaderSource.c_str());
939 *length = shaderSource.length();
943 *length = bufsize -1;
944 strncpy(source, shaderSource.c_str(), *length);
945 source[*length] = 0x0;
949 inline std::string GetShaderSource(GLuint shader)
951 return mShaderSources[shader];
954 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
958 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
962 inline void StencilMask(GLuint mask)
966 inline void StencilMaskSeparate(GLenum face, GLuint mask)
970 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
974 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
978 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
980 std::stringstream out;
981 out << target<<", "<<level<<", "<<width << ", " << height;
983 TraceCallStack::NamedParams namedParams;
984 namedParams["target"] = ToString(target);
985 namedParams["level"] = ToString(level);
986 namedParams["internalformat"] = ToString(internalformat);
987 namedParams["width"] = ToString(width);
988 namedParams["height"] = ToString(height);
989 namedParams["border"] = ToString(border);
990 namedParams["format"] = ToString(format);
991 namedParams["type"] = ToString(type);
993 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
996 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
998 std::stringstream out;
999 out << target << ", " << pname << ", " << param;
1001 TraceCallStack::NamedParams namedParams;
1002 namedParams["target"] = ToString(target);
1003 namedParams["pname"] = ToString(pname);
1004 namedParams["param"] = ToString(param);
1006 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1009 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1011 std::stringstream out;
1012 out << target << ", " << pname << ", " << params[0];
1014 TraceCallStack::NamedParams namedParams;
1015 namedParams["target"] = ToString(target);
1016 namedParams["pname"] = ToString(pname);
1017 namedParams["params[0]"] = ToString(params[0]);
1019 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1022 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1024 std::stringstream out;
1025 out << target << ", " << pname << ", " << param;
1026 TraceCallStack::NamedParams namedParams;
1027 namedParams["target"] = ToString(target);
1028 namedParams["pname"] = ToString(pname);
1029 namedParams["param"] = ToString(param);
1030 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1033 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1035 std::stringstream out;
1036 out << target << ", " << pname << ", " << params[0];
1037 TraceCallStack::NamedParams namedParams;
1038 namedParams["target"] = ToString(target);
1039 namedParams["pname"] = ToString(pname);
1040 namedParams["params[0]"] = ToString(params[0]);
1041 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1044 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1046 std::stringstream out;
1047 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1049 TraceCallStack::NamedParams namedParams;
1050 namedParams["target"] = ToString(target);
1051 namedParams["level"] = ToString(level);
1052 namedParams["xoffset"] = ToString(xoffset);
1053 namedParams["yoffset"] = ToString(yoffset);
1054 namedParams["width"] = ToString(width);
1055 namedParams["height"] = ToString(height);
1056 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1059 inline void Uniform1f(GLint location, GLfloat x)
1061 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, x ) )
1063 mGetErrorResult = GL_INVALID_OPERATION;
1067 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1069 for( int i = 0; i < count; ++i )
1071 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1073 mGetErrorResult = GL_INVALID_OPERATION;
1079 inline void Uniform1i(GLint location, GLint x)
1081 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1083 mGetErrorResult = GL_INVALID_OPERATION;
1087 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1089 for( int i = 0; i < count; ++i )
1091 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1095 mGetErrorResult = GL_INVALID_OPERATION;
1101 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1103 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1107 mGetErrorResult = GL_INVALID_OPERATION;
1111 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1113 for( int i = 0; i < count; ++i )
1115 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1117 Vector2( v[2*i], v[2*i+1] ) ) )
1119 mGetErrorResult = GL_INVALID_OPERATION;
1125 inline void Uniform2i(GLint location, GLint x, GLint y)
1129 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1133 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1135 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1137 Vector3( x, y, z ) ) )
1139 mGetErrorResult = GL_INVALID_OPERATION;
1143 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1145 for( int i = 0; i < count; ++i )
1147 if( ! mProgramUniforms3f.SetUniformValue(
1150 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1152 mGetErrorResult = GL_INVALID_OPERATION;
1158 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1162 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1166 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1168 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1170 Vector4( x, y, z, w ) ) )
1172 mGetErrorResult = GL_INVALID_OPERATION;
1176 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1178 for( int i = 0; i < count; ++i )
1180 if( ! mProgramUniforms4f.SetUniformValue(
1183 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1185 mGetErrorResult = GL_INVALID_OPERATION;
1191 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1195 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1199 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1203 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1205 for( int i = 0; i < count; ++i )
1207 if( ! mProgramUniformsMat3.SetUniformValue(
1210 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1212 mGetErrorResult = GL_INVALID_OPERATION;
1218 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1220 for( int i = 0; i < count; ++i )
1222 if( ! mProgramUniformsMat4.SetUniformValue(
1227 mGetErrorResult = GL_INVALID_OPERATION;
1233 inline void UseProgram(GLuint program)
1235 mCurrentProgram = program;
1238 inline void ValidateProgram(GLuint program)
1242 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1246 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1250 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1254 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1258 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1262 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1266 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1270 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1274 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1278 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1284 inline void ReadBuffer(GLenum mode)
1288 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1292 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1296 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)
1300 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1304 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1308 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)
1312 inline void GenQueries(GLsizei n, GLuint* ids)
1316 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1320 inline GLboolean IsQuery(GLuint id)
1325 inline void BeginQuery(GLenum target, GLuint id)
1329 inline void EndQuery(GLenum target)
1333 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1337 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1341 inline GLboolean UnmapBuffer(GLenum target)
1346 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1350 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1354 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1358 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1362 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1366 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1370 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1374 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1378 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1382 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1386 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1390 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1395 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1399 inline void BindVertexArray(GLuint array)
1403 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1407 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1411 inline GLboolean IsVertexArray(GLuint array)
1416 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1420 inline void BeginTransformFeedback(GLenum primitiveMode)
1424 inline void EndTransformFeedback(void)
1428 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1432 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1436 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1440 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1444 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1448 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1452 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1456 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1460 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1464 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1468 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1472 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1476 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1481 inline void Uniform1ui(GLint location, GLuint v0)
1485 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1489 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1493 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1497 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1501 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1505 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1509 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1513 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1517 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1521 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1525 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1529 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1534 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1538 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1542 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1546 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1548 return GL_INVALID_INDEX;
1551 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1555 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1559 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1563 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1567 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1571 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1576 inline GLboolean IsSync(GLsync sync)
1581 inline void DeleteSync(GLsync sync)
1585 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1590 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1594 inline void GetInteger64v(GLenum pname, GLint64* params)
1598 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1602 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1606 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1610 inline void GenSamplers(GLsizei count, GLuint* samplers)
1614 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1618 inline GLboolean IsSampler(GLuint sampler)
1623 inline void BindSampler(GLuint unit, GLuint sampler)
1627 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1631 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1635 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1639 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1643 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1647 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1651 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1655 inline void BindTransformFeedback(GLenum target, GLuint id)
1659 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1663 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1667 inline GLboolean IsTransformFeedback(GLuint id)
1672 inline void PauseTransformFeedback(void)
1676 inline void ResumeTransformFeedback(void)
1680 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1682 mGetProgramBinaryCalled = true;
1685 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1689 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1693 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1697 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1701 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1705 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1709 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1713 public: // TEST FUNCTIONS
1714 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1715 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1716 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1717 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1718 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1719 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1720 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1721 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1722 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1723 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1724 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1725 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1726 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1727 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1728 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1729 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1731 inline bool GetVertexAttribArrayState(GLuint index)
1733 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1738 return mVertexAttribArrayState[ index ];
1740 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1741 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1743 //Methods for CullFace verification
1744 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1745 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1746 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1748 //Methods for Enable/Disable call verification
1749 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1750 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1751 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1753 //Methods for Shader verification
1754 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1755 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1756 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1758 //Methods for Texture verification
1759 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1760 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1761 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1763 //Methods for Texture verification
1764 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1765 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1766 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1768 //Methods for Draw verification
1769 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1770 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1771 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1773 //Methods for Depth function verification
1774 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1775 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1776 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1778 template <typename T>
1779 inline bool GetUniformValue( const char* name, T& value ) const
1781 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1782 program_it != mUniforms.end();
1785 const UniformIDMap &uniformIDs = program_it->second;
1787 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1788 if( uniform_it != uniformIDs.end() )
1790 // found one matching uniform name, lets check the value...
1791 GLuint programId = program_it->first;
1792 GLint uniformId = uniform_it->second;
1794 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1795 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
1802 template <typename T>
1803 inline bool CheckUniformValue( const char* name, const T& value ) const
1805 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1806 program_it != mUniforms.end();
1809 const UniformIDMap &uniformIDs = program_it->second;
1811 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1812 if( uniform_it != uniformIDs.end() )
1814 // found one matching uniform name, lets check the value...
1815 GLuint programId = program_it->first;
1816 GLint uniformId = uniform_it->second;
1818 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1819 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
1821 // the value matches
1827 fprintf(stderr, "Not found, printing possible values:\n" );
1828 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1829 program_it != mUniforms.end();
1832 const UniformIDMap &uniformIDs = program_it->second;
1834 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1835 if( uniform_it != uniformIDs.end() )
1837 // found one matching uniform name, lets check the value...
1838 GLuint programId = program_it->first;
1839 GLint uniformId = uniform_it->second;
1841 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
1843 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
1845 std::stringstream out;
1846 out << uniform_it->first << ": " << origValue;
1847 fprintf(stderr, "%s\n", out.str().c_str() );
1854 template <typename T>
1855 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
1857 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
1858 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
1861 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
1863 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
1864 program_it != mUniforms.end();
1867 const UniformIDMap &uniformIDs = program_it->second;
1869 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
1870 if( uniform_it != uniformIDs.end() )
1872 programId = program_it->first;
1873 uniformId = uniform_it->second;
1880 inline GLuint GetLastShaderCompiled() const
1882 return mLastShaderCompiled;
1885 inline GLuint GetLastProgramCreated() const
1887 return mLastProgramIdUsed;
1890 inline GLbitfield GetLastClearMask() const
1892 return mLastClearBitMask;
1897 ATTRIB_UNKNOWN = -1,
1902 ATTRIB_BONE_WEIGHTS,
1903 ATTRIB_BONE_INDICES,
1907 struct ScissorParams
1914 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
1917 // Methods to check scissor tests
1918 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
1920 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
1922 inline unsigned int GetClearCountCalled() const { return mClearCount; }
1924 typedef std::vector<size_t> BufferDataCalls;
1925 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
1926 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
1928 typedef std::vector<size_t> BufferSubDataCalls;
1929 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
1930 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
1933 GLuint mCurrentProgram;
1934 GLuint mCompileStatus;
1935 BufferDataCalls mBufferDataCalls;
1936 BufferSubDataCalls mBufferSubDataCalls;
1938 GLint mNumberOfActiveUniforms;
1939 GLint mGetAttribLocationResult;
1940 GLenum mGetErrorResult;
1941 GLubyte* mGetStringResult;
1942 GLboolean mIsBufferResult;
1943 GLboolean mIsEnabledResult;
1944 GLboolean mIsFramebufferResult;
1945 GLboolean mIsProgramResult;
1946 GLboolean mIsRenderbufferResult;
1947 GLboolean mIsShaderResult;
1948 GLboolean mIsTextureResult;
1949 GLenum mActiveTextureUnit;
1950 GLenum mCheckFramebufferStatusResult;
1951 GLint mFramebufferStatus;
1952 GLenum mFramebufferColorAttached;
1953 GLenum mFramebufferDepthAttached;
1954 GLenum mFramebufferStencilAttached;
1955 GLint mNumBinaryFormats;
1956 GLint mBinaryFormats;
1957 GLint mProgramBinaryLength;
1958 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
1959 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
1960 bool mGetProgramBinaryCalled;
1961 typedef std::map< GLuint, std::string> ShaderSourceMap;
1962 ShaderSourceMap mShaderSources;
1963 GLuint mLastShaderCompiled;
1964 GLbitfield mLastClearBitMask;
1965 unsigned int mClearCount;
1967 Vector4 mLastBlendColor;
1968 GLenum mLastBlendEquationRgb;
1969 GLenum mLastBlendEquationAlpha;
1970 GLenum mLastBlendFuncSrcRgb;
1971 GLenum mLastBlendFuncDstRgb;
1972 GLenum mLastBlendFuncSrcAlpha;
1973 GLenum mLastBlendFuncDstAlpha;
1975 // Data for manipulating the IDs returned by GenTextures
1976 GLuint mLastAutoTextureIdUsed;
1977 std::vector<GLuint> mNextTextureIds;
1978 std::vector<GLuint> mDeletedTextureIds;
1979 std::vector<GLuint> mBoundTextures;
1981 struct ActiveTextureType
1983 std::vector<GLuint> mBoundTextures;
1986 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
1988 TraceCallStack mCullFaceTrace;
1989 TraceCallStack mEnableDisableTrace;
1990 TraceCallStack mShaderTrace;
1991 TraceCallStack mTextureTrace;
1992 TraceCallStack mTexParamaterTrace;
1993 TraceCallStack mDrawTrace;
1994 TraceCallStack mDepthFunctionTrace;
1996 // Shaders & Uniforms
1997 GLuint mLastShaderIdUsed;
1998 GLuint mLastProgramIdUsed;
1999 GLuint mLastUniformIdUsed;
2000 typedef std::map< std::string, GLint > UniformIDMap;
2001 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2002 ProgramUniformMap mUniforms;
2004 template <typename T>
2005 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2008 typedef std::map< GLint, T > UniformValueMap;
2009 typedef std::map< GLuint, UniformValueMap > Map;
2011 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2018 typename Map::iterator it = Map::find( program );
2019 if( it == Map::end() )
2021 // if its the first uniform for this program add it
2022 std::pair< typename Map::iterator, bool > result =
2023 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2027 UniformValueMap& uniforms = it->second;
2028 uniforms[uniform] = value;
2033 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2036 if ( GetUniformValue( program, uniform, uniformValue ) )
2038 return value == uniformValue;
2044 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2051 typename Map::const_iterator it = Map::find( program );
2052 if( it == Map::end() )
2054 // Uniform values always initialised as 0
2059 const UniformValueMap& uniforms = it->second;
2060 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2061 if( it2 == uniforms.end() )
2063 // Uniform values always initialised as 0
2067 value = it2->second;
2074 ProgramUniformValue<int> mProgramUniforms1i;
2075 ProgramUniformValue<float> mProgramUniforms1f;
2076 ProgramUniformValue<Vector2> mProgramUniforms2f;
2077 ProgramUniformValue<Vector3> mProgramUniforms3f;
2078 ProgramUniformValue<Vector4> mProgramUniforms4f;
2079 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2080 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2082 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2084 return mProgramUniforms1i;
2086 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2088 return mProgramUniforms1f;
2090 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2092 return mProgramUniforms2f;
2094 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2096 return mProgramUniforms3f;
2098 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2100 return mProgramUniforms4f;
2102 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2104 return mProgramUniformsMat4;
2106 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2108 return mProgramUniformsMat3;
2110 inline void SetVertexAttribArray(GLuint index, bool state)
2112 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2117 mVertexAttribArrayState[ index ] = state;
2118 mVertexAttribArrayChanged = true;
2121 ScissorParams mScissorParams;
2125 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2131 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2137 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2139 return Vector2::ZERO;
2143 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2145 return Vector3::ZERO;
2149 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2151 return Vector4::ZERO;
2155 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2161 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2163 return Matrix3( Matrix() );
2168 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2169 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2174 #endif // __TEST_GL_ES_H__