1 #ifndef TEST_GL_ABSTRACTION_H
2 #define TEST_GL_ABSTRACTION_H
5 * Copyright (c) 2020 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/devel-api/rendering/frame-buffer-devel.h>
33 #include <dali/integration-api/core.h>
34 #include <dali/integration-api/gl-abstraction.h>
35 #include <dali/integration-api/gl-defines.h>
36 #include <test-trace-call-stack.h>
37 #include <test-compare-types.h>
42 static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64;
43 static const char *mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] =
45 "aPosition", // ATTRIB_POSITION
46 "aNormal", // ATTRIB_NORMAL
47 "aTexCoord", // ATTRIB_TEXCOORD
48 "aColor", // ATTRIB_COLOR
49 "aBoneWeights", // ATTRIB_BONE_WEIGHTS
50 "aBoneIndices" // ATTRIB_BONE_INDICES
53 class DALI_CORE_API TestGlAbstraction: public Dali::Integration::GlAbstraction
63 bool IsSurfacelessContextSupported() const;
65 bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const;
69 inline void ActiveTexture( GLenum textureUnit )
71 mActiveTextureUnit = textureUnit - GL_TEXTURE0;
74 inline GLenum GetActiveTextureUnit() const
76 return mActiveTextureUnit + GL_TEXTURE0;
79 inline void AttachShader( GLuint program, GLuint shader )
81 std::stringstream out;
82 out << program << ", " << shader;
84 TraceCallStack::NamedParams namedParams;
85 namedParams["program"] = ToString(program);
86 namedParams["shader"] = ToString(shader);
87 mShaderTrace.PushCall("AttachShader", out.str(), namedParams);
90 inline void BindAttribLocation( GLuint program, GLuint index, const char* name )
94 inline void BindBuffer( GLenum target, GLuint buffer )
98 inline void BindFramebuffer( GLenum target, GLuint framebuffer )
101 mFramebufferStatus |= 2;
104 inline void BindRenderbuffer( GLenum target, GLuint renderbuffer )
109 * This method can be used by test cases, to query the texture IDs that have been bound by BindTexture.
110 * @return A vector containing the IDs that were bound.
112 inline const std::vector<GLuint>& GetBoundTextures() const
114 return mBoundTextures;
118 * Query the texture IDs that have been bound with BindTexture, with a specific active texture unit.
119 * @param[in] activeTextureUnit The specific active texture unit.
120 * @return A vector containing the IDs that were bound.
122 inline const std::vector<GLuint>& GetBoundTextures( GLuint activeTextureUnit ) const
124 return mActiveTextures[ activeTextureUnit - GL_TEXTURE0 ].mBoundTextures;
128 * This method can be used by test cases, to clear the record of texture IDs that have been bound by BindTexture.
130 inline void ClearBoundTextures()
132 mBoundTextures.clear();
134 for( unsigned int i=0; i<MIN_TEXTURE_UNIT_LIMIT; ++i )
136 mActiveTextures[ i ].mBoundTextures.clear();
140 inline void BindTexture( GLenum target, GLuint texture )
142 // Record the bound textures for future checks
145 mBoundTextures.push_back( texture );
147 if( mActiveTextureUnit < MIN_TEXTURE_UNIT_LIMIT )
149 mActiveTextures[ mActiveTextureUnit ].mBoundTextures.push_back( texture );
153 std::stringstream out;
154 out << target << ", " << texture;
156 TraceCallStack::NamedParams namedParams;
157 namedParams["target"] = ToString(target);
158 namedParams["texture"] = ToString(texture);
160 mTextureTrace.PushCall("BindTexture", out.str(), namedParams);
163 inline void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
165 mLastBlendColor.r = red;
166 mLastBlendColor.g = green;
167 mLastBlendColor.b = blue;
168 mLastBlendColor.a = alpha;
171 inline const Vector4& GetLastBlendColor() const
173 return mLastBlendColor;
176 inline void BlendEquation( GLenum mode )
178 mLastBlendEquationRgb = mode;
179 mLastBlendEquationAlpha = mode;
182 inline void BlendEquationSeparate( GLenum modeRgb, GLenum modeAlpha )
184 mLastBlendEquationRgb = modeRgb;
185 mLastBlendEquationAlpha = modeAlpha;
188 inline GLenum GetLastBlendEquationRgb() const
190 return mLastBlendEquationRgb;
193 inline GLenum GetLastBlendEquationAlpha() const
195 return mLastBlendEquationAlpha;
198 inline void BlendFunc(GLenum sfactor, GLenum dfactor)
200 mLastBlendFuncSrcRgb = sfactor;
201 mLastBlendFuncDstRgb = dfactor;
202 mLastBlendFuncSrcAlpha = sfactor;
203 mLastBlendFuncDstAlpha = dfactor;
206 inline void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
208 mLastBlendFuncSrcRgb = srcRGB;
209 mLastBlendFuncDstRgb = dstRGB;
210 mLastBlendFuncSrcAlpha = srcAlpha;
211 mLastBlendFuncDstAlpha = dstAlpha;
214 inline GLenum GetLastBlendFuncSrcRgb() const
216 return mLastBlendFuncSrcRgb;
219 inline GLenum GetLastBlendFuncDstRgb() const
221 return mLastBlendFuncDstRgb;
224 inline GLenum GetLastBlendFuncSrcAlpha() const
226 return mLastBlendFuncSrcAlpha;
229 inline GLenum GetLastBlendFuncDstAlpha() const
231 return mLastBlendFuncDstAlpha;
234 inline void BufferData(GLenum target, GLsizeiptr size, const void* data, GLenum usage)
236 mBufferDataCalls.push_back(size);
239 inline void BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const void* data)
241 mBufferSubDataCalls.push_back(size);
244 inline GLenum CheckFramebufferStatus(GLenum target)
246 //If it has the three last bits set to 1 - 111, then the three minimum functions to create a
247 //Framebuffer texture have been called
248 if( mFramebufferStatus == 7 )
250 return GL_FRAMEBUFFER_COMPLETE;
253 return mCheckFramebufferStatusResult;
256 inline GLuint CheckFramebufferColorAttachmentCount()
258 return mFramebufferColorAttachmentCount;
261 inline GLenum CheckFramebufferDepthAttachment()
263 return mFramebufferDepthAttached;
266 inline GLenum CheckFramebufferStencilAttachment()
268 return mFramebufferStencilAttached;
271 inline void Clear(GLbitfield mask)
274 mLastClearBitMask = mask;
277 inline void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
279 mLastClearColor.r = red;
280 mLastClearColor.g = green;
281 mLastClearColor.b = blue;
282 mLastClearColor.a = alpha;
285 inline const Vector4& GetLastClearColor() const
287 return mLastClearColor;
290 inline void ClearDepthf(GLclampf depth)
294 inline void ClearStencil(GLint s)
296 std::stringstream out;
299 TraceCallStack::NamedParams namedParams;
300 namedParams["s"] = ToString( s );
302 mStencilFunctionTrace.PushCall( "ClearStencil", out.str(), namedParams );
305 inline void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
307 mColorMaskParams.red = red;
308 mColorMaskParams.green = green;
309 mColorMaskParams.blue = blue;
310 mColorMaskParams.alpha = alpha;
313 inline void CompileShader(GLuint shader)
315 std::stringstream out;
317 TraceCallStack::NamedParams namedParams;
318 namedParams["shader"] = ToString(shader);
320 mShaderTrace.PushCall("CompileShader", out.str(), namedParams);
323 inline void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data)
325 std::stringstream out;
326 out << target<<", "<<level<<", "<<width << ", " << height;
328 TraceCallStack::NamedParams namedParams;
329 namedParams["target"] = ToString(target);
330 namedParams["level"] = ToString(level);
331 namedParams["internalformat"] = ToString(internalformat);
332 namedParams["width"] = ToString(width);
333 namedParams["height"] = ToString(height);
334 namedParams["border"] = ToString(border);
335 namedParams["size"] = ToString(imageSize);
337 mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams);
340 inline void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data)
342 std::stringstream out;
343 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
345 TraceCallStack::NamedParams namedParams;
346 namedParams["target"] = ToString(target);
347 namedParams["level"] = ToString(level);
348 namedParams["xoffset"] = ToString(xoffset);
349 namedParams["yoffset"] = ToString(yoffset);
350 namedParams["width"] = ToString(width);
351 namedParams["height"] = ToString(height);
352 mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams);
355 inline void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
359 inline void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
363 inline GLuint CreateProgram(void)
365 mShaderTrace.PushCall("CreateProgram", "");
367 ++mLastProgramIdUsed;
368 mUniforms[mLastProgramIdUsed] = UniformIDMap();
369 return mLastProgramIdUsed;
372 inline GLuint CreateShader(GLenum type)
374 std::stringstream out;
377 TraceCallStack::NamedParams namedParams;
378 namedParams["type"] = ToString(type);
379 mShaderTrace.PushCall("CreateShader", out.str(), namedParams);
381 return ++mLastShaderIdUsed;
384 inline void CullFace(GLenum mode)
386 std::stringstream out;
389 TraceCallStack::NamedParams namedParams;
390 namedParams["program"] = ToString(mode);
392 mCullFaceTrace.PushCall("CullFace", out.str(), namedParams);
395 inline void DeleteBuffers(GLsizei n, const GLuint* buffers)
399 inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
403 inline void DeleteProgram(GLuint program)
405 std::stringstream out;
408 TraceCallStack::NamedParams namedParams;
409 namedParams["program"] = ToString(program);
411 mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams);
414 inline void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
418 inline void DeleteShader(GLuint shader)
420 std::stringstream out;
423 TraceCallStack::NamedParams namedParams;
424 namedParams["shader"] = ToString(shader);
426 mShaderTrace.PushCall("DeleteShader", out.str(), namedParams);
429 inline void DeleteTextures(GLsizei n, const GLuint* textures)
431 std::stringstream out;
432 out << n << ", " << textures << " = [";
434 TraceCallStack::NamedParams namedParams;
436 for(GLsizei i=0; i<n; i++)
438 out << textures[i] << ", ";
439 std::stringstream paramName;
440 paramName<<"texture["<<i<<"]";
441 namedParams[paramName.str()] = ToString(textures[i]);
442 mDeletedTextureIds.push_back(textures[i]);
443 mNumGeneratedTextures--;
447 mTextureTrace.PushCall("DeleteTextures", out.str(), namedParams);
450 inline bool CheckNoTexturesDeleted()
452 return mDeletedTextureIds.size() == 0;
455 inline bool CheckTextureDeleted( GLuint textureId )
459 for(std::vector<GLuint>::iterator iter=mDeletedTextureIds.begin(); iter != mDeletedTextureIds.end(); ++iter)
461 if(*iter == textureId)
470 inline void ClearDeletedTextures()
472 mDeletedTextureIds.clear();
475 inline void DepthFunc(GLenum func)
477 std::stringstream out;
480 TraceCallStack::NamedParams namedParams;
481 namedParams["func"] = ToString(func);
483 mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams);
486 inline void DepthMask(GLboolean flag)
488 mLastDepthMask = flag;
491 inline bool GetLastDepthMask() const
493 return mLastDepthMask;
496 inline void DepthRangef(GLclampf zNear, GLclampf zFar)
500 inline void DetachShader(GLuint program, GLuint shader)
502 std::stringstream out;
503 out << program << ", " << shader;
504 TraceCallStack::NamedParams namedParams;
505 namedParams["program"] = ToString(program);
506 namedParams["shader"] = ToString(shader);
507 mShaderTrace.PushCall("DetachShader", out.str(), namedParams);
510 inline void Disable(GLenum cap)
512 std::stringstream out;
514 TraceCallStack::NamedParams namedParams;
515 namedParams["cap"] = ToString(cap);
516 mEnableDisableTrace.PushCall("Disable", out.str(), namedParams);
519 inline void DisableVertexAttribArray(GLuint index)
521 SetVertexAttribArray( index, false );
524 inline void DrawArrays(GLenum mode, GLint first, GLsizei count)
526 std::stringstream out;
527 out << mode << ", " << first << ", " << count;
528 TraceCallStack::NamedParams namedParams;
529 namedParams["mode"] = ToString(mode);
530 namedParams["first"] = ToString(first);
531 namedParams["count"] = ToString(count);
532 mDrawTrace.PushCall("DrawArrays", out.str(), namedParams);
535 inline void DrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
537 std::stringstream out;
538 out << mode << ", " << count << ", " << type << ", indices";
540 TraceCallStack::NamedParams namedParams;
541 namedParams["mode"] = ToString(mode);
542 namedParams["count"] = ToString(count);
543 namedParams["type"] = ToString(type);
544 // Skip void pointers - are they of any use?
545 mDrawTrace.PushCall("DrawElements", out.str(), namedParams);
548 inline void Enable(GLenum cap)
550 std::stringstream out;
552 TraceCallStack::NamedParams namedParams;
553 namedParams["cap"] = ToString(cap);
554 mEnableDisableTrace.PushCall("Enable", out.str(), namedParams);
557 inline void EnableVertexAttribArray(GLuint index)
559 SetVertexAttribArray( index, true);
562 inline void Finish(void)
566 inline void Flush(void)
570 inline void FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
572 if (attachment == GL_DEPTH_ATTACHMENT)
574 mFramebufferDepthAttached = true;
576 else if (attachment == GL_STENCIL_ATTACHMENT)
578 mFramebufferStencilAttached = true;
582 inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
585 mFramebufferStatus |= 4;
587 //We check 4 attachment colors
588 if ((attachment >= GL_COLOR_ATTACHMENT0) && (attachment < GL_COLOR_ATTACHMENT0 + Dali::DevelFrameBuffer::MAX_COLOR_ATTACHMENTS))
590 uint8_t mask = 1 << (attachment - GL_COLOR_ATTACHMENT0);
591 if ((mFrameBufferColorStatus & mask) == 0)
593 mFrameBufferColorStatus |= mask;
594 ++mFramebufferColorAttachmentCount;
599 inline void FrontFace(GLenum mode)
603 inline void GenBuffers(GLsizei n, GLuint* buffers)
605 // avoids an assert in GpuBuffers
609 inline void GenerateMipmap(GLenum target)
611 std::stringstream out;
613 TraceCallStack::NamedParams namedParams;
614 namedParams["target"] = ToString(target);
616 mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams);
619 inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
621 for( int i = 0; i < n; i++ )
623 framebuffers[i] = i + 1;
626 //Add 001 bit, this function needs to be called the first one in the chain
627 mFramebufferStatus = 1;
630 inline void GenRenderbuffers(GLsizei n, GLuint* renderbuffers)
632 for( int i = 0; i < n; i++ )
634 renderbuffers[i] = i + 1;
639 * This method can be used by test cases, to manipulate the texture IDs generated by GenTextures.
640 * @param[in] ids A vector containing the next IDs to be generated
642 inline void SetNextTextureIds( const std::vector<GLuint>& ids )
644 mNextTextureIds = ids;
647 inline const std::vector<GLuint>& GetNextTextureIds()
649 return mNextTextureIds;
652 inline void GenTextures(GLsizei count, GLuint* textures)
654 for( int i=0; i<count; ++i )
656 if( !mNextTextureIds.empty() )
658 *(textures+i) = mNextTextureIds[0];
659 mNextTextureIds.erase( mNextTextureIds.begin() );
663 *(textures+i) = ++mLastAutoTextureIdUsed;
665 mNumGeneratedTextures++;
668 TraceCallStack::NamedParams namedParams;
669 namedParams["count"] = ToString(count);
671 std::stringstream out;
672 for(int i=0; i<count; i++)
679 std::ostringstream oss;
680 oss<<"indices["<<i<<"]";
681 namedParams[oss.str()] = ToString(textures[i]);
684 mTextureTrace.PushCall("GenTextures", out.str(), namedParams);
687 inline GLuint GetLastGenTextureId()
689 return mLastAutoTextureIdUsed;
691 inline GLuint GetNumGeneratedTextures()
693 return mNumGeneratedTextures;
696 inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
700 inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name)
705 *length = snprintf(name, bufsize, "sTexture");
706 *type = GL_SAMPLER_2D;
710 *length = snprintf(name, bufsize, "sEffect");
711 *type = GL_SAMPLER_2D;
715 *length = snprintf(name, bufsize, "sGloss");
716 *type = GL_SAMPLER_2D;
724 inline void GetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
728 inline int GetAttribLocation(GLuint program, const char* name)
730 std::string attribName(name);
732 for( unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i )
734 if( mStdAttribs[i] == attribName )
740 // 0 is a valid location
744 inline void GetBooleanv(GLenum pname, GLboolean* params)
748 inline void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
752 inline GLenum GetError(void)
754 return mGetErrorResult;
757 inline void GetFloatv(GLenum pname, GLfloat* params)
761 inline void GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
765 inline void GetIntegerv(GLenum pname, GLint* params)
769 case GL_MAX_TEXTURE_SIZE:
772 case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
775 case GL_NUM_PROGRAM_BINARY_FORMATS_OES:
776 *params = mNumBinaryFormats;
778 case GL_PROGRAM_BINARY_FORMATS_OES:
779 *params = mBinaryFormats;
784 inline void GetProgramiv(GLuint program, GLenum pname, GLint* params)
789 *params = mLinkStatus;
791 case GL_PROGRAM_BINARY_LENGTH_OES:
792 *params = mProgramBinaryLength;
794 case GL_ACTIVE_UNIFORMS:
795 *params = mNumberOfActiveUniforms;
797 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
803 inline void GetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog)
807 inline void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
811 inline void GetShaderiv(GLuint shader, GLenum pname, GLint* params)
814 case GL_COMPILE_STATUS:
815 *params = mCompileStatus;
820 inline void GetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog)
824 inline void GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
828 inline const GLubyte* GetString(GLenum name)
830 return mGetStringResult;
833 inline void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
837 inline void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
841 inline void GetUniformfv(GLuint program, GLint location, GLfloat* params)
845 inline void GetUniformiv(GLuint program, GLint location, GLint* params)
849 inline GLint GetUniformLocation(GLuint program, const char* name)
851 ProgramUniformMap::iterator it = mUniforms.find(program);
852 if( it == mUniforms.end() )
854 // Not a valid program ID
855 mGetErrorResult = GL_INVALID_OPERATION;
859 UniformIDMap& uniformIDs = it->second;
860 UniformIDMap::iterator it2 = uniformIDs.find( name );
861 if( it2 == uniformIDs.end() )
863 // Uniform not found, so add it...
864 uniformIDs[name] = ++mLastUniformIdUsed;
865 return mLastUniformIdUsed;
871 inline void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
875 inline void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
879 inline void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer)
883 inline void Hint(GLenum target, GLenum mode)
887 inline GLboolean IsBuffer(GLuint buffer)
889 return mIsBufferResult;
892 inline GLboolean IsEnabled(GLenum cap)
894 return mIsEnabledResult;
897 inline GLboolean IsFramebuffer(GLuint framebuffer)
899 return mIsFramebufferResult;
902 inline GLboolean IsProgram(GLuint program)
904 return mIsProgramResult;
907 inline GLboolean IsRenderbuffer(GLuint renderbuffer)
909 return mIsRenderbufferResult;
912 inline GLboolean IsShader(GLuint shader)
914 return mIsShaderResult;
917 inline GLboolean IsTexture(GLuint texture)
919 return mIsTextureResult;
922 inline void LineWidth(GLfloat width)
926 inline void LinkProgram(GLuint program)
928 std::stringstream out;
931 TraceCallStack::NamedParams namedParams;
932 namedParams["program"] = ToString(program);
933 mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
935 mNumberOfActiveUniforms=3;
936 GetUniformLocation(program, "sTexture");
937 GetUniformLocation(program, "sEffect");
938 GetUniformLocation(program, "sGloss");
941 inline void PixelStorei(GLenum pname, GLint param)
945 inline void PolygonOffset(GLfloat factor, GLfloat units)
949 inline void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
953 inline void ReleaseShaderCompiler(void)
957 inline void RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
961 inline void SampleCoverage(GLclampf value, GLboolean invert)
965 inline void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
967 mScissorParams.x = x;
968 mScissorParams.y = y;
969 mScissorParams.width = width;
970 mScissorParams.height = height;
972 std::stringstream out;
973 out << x << ", " << y << ", " << width << ", " << height;
974 TraceCallStack::NamedParams namedParams;
975 namedParams["x"] = ToString( x );
976 namedParams["y"] = ToString( y );
977 namedParams["width"] = ToString( width );
978 namedParams["height"] = ToString( height );
979 mScissorTrace.PushCall( "Scissor", out.str(), namedParams );
982 inline void ShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length)
986 inline void ShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
988 std::string stringBuilder;
989 for(int i = 0; i < count; ++i)
991 stringBuilder += string[i];
993 mShaderSources[shader] = stringBuilder;
994 mLastShaderCompiled = shader;
997 inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
999 const std::string shaderSource = mShaderSources[shader];
1000 const int shaderSourceLength = static_cast<int>(shaderSource.length());
1001 if( shaderSourceLength < bufsize )
1003 strncpy( source, shaderSource.c_str(), shaderSourceLength );
1004 *length = shaderSourceLength;
1008 *length = bufsize -1;
1009 strncpy(source, shaderSource.c_str(), *length);
1010 source[*length] = 0x0;
1014 inline std::string GetShaderSource(GLuint shader)
1016 return mShaderSources[shader];
1019 inline void StencilFunc(GLenum func, GLint ref, GLuint mask)
1021 std::stringstream out;
1022 out << func << ", " << ref << ", " << mask;
1024 TraceCallStack::NamedParams namedParams;
1025 namedParams["func"] = ToString( func );
1026 namedParams["ref"] = ToString( ref );
1027 namedParams["mask"] = ToString( mask );
1029 mStencilFunctionTrace.PushCall( "StencilFunc", out.str(), namedParams );
1032 inline void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
1034 std::stringstream out;
1035 out << face << ", " << func << ", " << ref << ", " << mask;
1037 TraceCallStack::NamedParams namedParams;
1038 namedParams["face"] = ToString( face );
1039 namedParams["func"] = ToString( func );
1040 namedParams["ref"] = ToString( ref );
1041 namedParams["mask"] = ToString( mask );
1043 mStencilFunctionTrace.PushCall( "StencilFuncSeparate", out.str(), namedParams );
1046 inline void StencilMask(GLuint mask)
1048 std::stringstream out;
1051 TraceCallStack::NamedParams namedParams;
1052 namedParams["mask"] = ToString( mask );
1054 mStencilFunctionTrace.PushCall( "StencilMask", out.str(), namedParams );
1057 inline void StencilMaskSeparate(GLenum face, GLuint mask)
1059 std::stringstream out;
1060 out << face << ", " << mask;
1062 TraceCallStack::NamedParams namedParams;
1063 namedParams["face"] = ToString( face );
1064 namedParams["mask"] = ToString( mask );
1066 mStencilFunctionTrace.PushCall( "StencilMaskSeparate", out.str(), namedParams );
1069 inline void StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
1071 std::stringstream out;
1072 out << fail << ", " << zfail << ", " << zpass;
1074 TraceCallStack::NamedParams namedParams;
1075 namedParams["fail"] = ToString( fail );
1076 namedParams["zfail"] = ToString( zfail );
1077 namedParams["zpass"] = ToString( zpass );
1079 mStencilFunctionTrace.PushCall( "StencilOp", out.str(), namedParams );
1082 inline void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
1084 std::stringstream out;
1085 out << face << ", " << fail << ", " << zfail << "," << zpass;
1087 TraceCallStack::NamedParams namedParams;
1088 namedParams["face"] = ToString( face );
1089 namedParams["fail"] = ToString( fail );
1090 namedParams["zfail"] = ToString( zfail );
1091 namedParams["zpass"] = ToString( zpass );
1093 mStencilFunctionTrace.PushCall( "StencilOpSeparate", out.str(), namedParams );
1096 inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
1098 std::stringstream out;
1099 out << target<<", "<<level<<", "<<width << ", " << height;
1101 TraceCallStack::NamedParams namedParams;
1102 namedParams["target"] = ToString(target);
1103 namedParams["level"] = ToString(level);
1104 namedParams["internalformat"] = ToString(internalformat);
1105 namedParams["width"] = ToString(width);
1106 namedParams["height"] = ToString(height);
1107 namedParams["border"] = ToString(border);
1108 namedParams["format"] = ToString(format);
1109 namedParams["type"] = ToString(type);
1111 mTextureTrace.PushCall("TexImage2D", out.str(), namedParams);
1114 inline void TexParameterf(GLenum target, GLenum pname, GLfloat param)
1116 std::stringstream out;
1117 out << target << ", " << pname << ", " << param;
1119 TraceCallStack::NamedParams namedParams;
1120 namedParams["target"] = ToString(target);
1121 namedParams["pname"] = ToString(pname);
1122 namedParams["param"] = ToString(param);
1124 mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams);
1127 inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
1129 std::stringstream out;
1130 out << target << ", " << pname << ", " << params[0];
1132 TraceCallStack::NamedParams namedParams;
1133 namedParams["target"] = ToString(target);
1134 namedParams["pname"] = ToString(pname);
1135 namedParams["params[0]"] = ToString(params[0]);
1137 mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams);
1140 inline void TexParameteri(GLenum target, GLenum pname, GLint param)
1142 std::stringstream out;
1143 out << target << ", " << pname << ", " << param;
1144 TraceCallStack::NamedParams namedParams;
1145 namedParams["target"] = ToString(target);
1146 namedParams["pname"] = ToString(pname);
1147 namedParams["param"] = ToString(param);
1148 mTexParamaterTrace.PushCall("TexParameteri", out.str(), namedParams);
1151 inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params)
1153 std::stringstream out;
1154 out << target << ", " << pname << ", " << params[0];
1155 TraceCallStack::NamedParams namedParams;
1156 namedParams["target"] = ToString(target);
1157 namedParams["pname"] = ToString(pname);
1158 namedParams["params[0]"] = ToString(params[0]);
1159 mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams);
1162 inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
1164 std::stringstream out;
1165 out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
1167 TraceCallStack::NamedParams namedParams;
1168 namedParams["target"] = ToString(target);
1169 namedParams["level"] = ToString(level);
1170 namedParams["xoffset"] = ToString(xoffset);
1171 namedParams["yoffset"] = ToString(yoffset);
1172 namedParams["width"] = ToString(width);
1173 namedParams["height"] = ToString(height);
1174 mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams);
1177 inline void Uniform1f(GLint location, GLfloat value )
1179 std::string params = ToString( value );
1180 AddUniformCallToTraceStack( location, params );
1182 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, value ) )
1184 mGetErrorResult = GL_INVALID_OPERATION;
1188 inline void Uniform1fv(GLint location, GLsizei count, const GLfloat* v)
1191 for( int i = 0; i < count; ++i )
1193 params = params + ToString( v[i] ) + ",";
1196 AddUniformCallToTraceStack( location, params );
1198 for( int i = 0; i < count; ++i )
1200 if( ! mProgramUniforms1f.SetUniformValue( mCurrentProgram, location, v[i] ) )
1202 mGetErrorResult = GL_INVALID_OPERATION;
1208 inline void Uniform1i(GLint location, GLint x)
1210 std::string params = ToString( x );
1212 AddUniformCallToTraceStack( location, params );
1214 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram, location, x ) )
1216 mGetErrorResult = GL_INVALID_OPERATION;
1220 inline void Uniform1iv(GLint location, GLsizei count, const GLint* v)
1222 std::string params = ToString( v );
1223 AddUniformCallToTraceStack( location, params );
1225 for( int i = 0; i < count; ++i )
1227 if( ! mProgramUniforms1i.SetUniformValue( mCurrentProgram,
1231 mGetErrorResult = GL_INVALID_OPERATION;
1237 inline void Uniform2f(GLint location, GLfloat x, GLfloat y)
1239 std::string params = ToString( x ) + "," + ToString( y );
1240 AddUniformCallToTraceStack( location, params );
1242 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1246 mGetErrorResult = GL_INVALID_OPERATION;
1250 inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v)
1252 std::string params = ToString( v );
1253 AddUniformCallToTraceStack( location, params );
1255 for( int i = 0; i < count; ++i )
1257 if( ! mProgramUniforms2f.SetUniformValue( mCurrentProgram,
1259 Vector2( v[2*i], v[2*i+1] ) ) )
1261 mGetErrorResult = GL_INVALID_OPERATION;
1267 inline void Uniform2i(GLint location, GLint x, GLint y)
1269 std::string params = ToString( x ) + "," + ToString( y );
1270 AddUniformCallToTraceStack( location, params );
1273 inline void Uniform2iv(GLint location, GLsizei count, const GLint* v)
1275 std::string params = ToString( v );
1276 AddUniformCallToTraceStack( location, params );
1279 inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
1281 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1282 AddUniformCallToTraceStack( location, params );
1284 if( ! mProgramUniforms3f.SetUniformValue( mCurrentProgram,
1286 Vector3( x, y, z ) ) )
1288 mGetErrorResult = GL_INVALID_OPERATION;
1292 inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v)
1294 std::string params = ToString( v );
1295 AddUniformCallToTraceStack( location, params );
1297 for( int i = 0; i < count; ++i )
1299 if( ! mProgramUniforms3f.SetUniformValue(
1302 Vector3( v[3*i], v[3*i+1], v[3*i+2] ) ) )
1304 mGetErrorResult = GL_INVALID_OPERATION;
1310 inline void Uniform3i(GLint location, GLint x, GLint y, GLint z)
1312 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z );
1313 AddUniformCallToTraceStack( location, params );
1316 inline void Uniform3iv(GLint location, GLsizei count, const GLint* v)
1318 std::string params = ToString( v );
1319 AddUniformCallToTraceStack( location, params );
1322 inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1324 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1325 AddUniformCallToTraceStack( location, params );
1327 if( ! mProgramUniforms4f.SetUniformValue( mCurrentProgram,
1329 Vector4( x, y, z, w ) ) )
1331 mGetErrorResult = GL_INVALID_OPERATION;
1335 inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v)
1337 std::string params = ToString( v );
1338 AddUniformCallToTraceStack( location, params );
1340 for( int i = 0; i < count; ++i )
1342 if( ! mProgramUniforms4f.SetUniformValue(
1345 Vector4( v[4*i], v[4*i+1], v[4*i+2], v[4*i+3] ) ) )
1347 mGetErrorResult = GL_INVALID_OPERATION;
1353 inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
1355 std::string params = ToString( x ) + "," + ToString( y ) + "," + ToString( z ) + "," + ToString( w );
1356 AddUniformCallToTraceStack( location, params );
1359 inline void Uniform4iv(GLint location, GLsizei count, const GLint* v)
1361 std::string params = ToString( v );
1362 AddUniformCallToTraceStack( location, params );
1365 inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1367 std::string params = ToString( value );
1368 AddUniformCallToTraceStack( location, params );
1371 inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1373 std::string params = ToString( value );
1374 AddUniformCallToTraceStack( location, params );
1376 for( int i = 0; i < count; ++i )
1378 if( ! mProgramUniformsMat3.SetUniformValue(
1381 Matrix3( value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8] ) ) )
1383 mGetErrorResult = GL_INVALID_OPERATION;
1389 inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1391 std::string params = ToString( value );
1392 AddUniformCallToTraceStack( location, params );
1394 for( int i = 0; i < count; ++i )
1396 if( ! mProgramUniformsMat4.SetUniformValue(
1401 mGetErrorResult = GL_INVALID_OPERATION;
1407 inline void UseProgram(GLuint program)
1409 mCurrentProgram = program;
1412 inline void ValidateProgram(GLuint program)
1416 inline void VertexAttrib1f(GLuint indx, GLfloat x)
1420 inline void VertexAttrib1fv(GLuint indx, const GLfloat* values)
1424 inline void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
1428 inline void VertexAttrib2fv(GLuint indx, const GLfloat* values)
1432 inline void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
1436 inline void VertexAttrib3fv(GLuint indx, const GLfloat* values)
1440 inline void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
1444 inline void VertexAttrib4fv(GLuint indx, const GLfloat* values)
1448 inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr)
1452 inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
1454 std::string commaString(", ");
1455 std::string params( std::to_string(x) + commaString + std::to_string(y) + commaString + std::to_string(width) + commaString + std::to_string(height) );
1457 mViewportTrace.PushCall("Viewport", params);
1462 inline void ReadBuffer(GLenum mode)
1466 inline void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
1470 inline void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
1474 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)
1478 inline void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1482 inline void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
1486 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)
1490 inline void GenQueries(GLsizei n, GLuint* ids)
1494 inline void DeleteQueries(GLsizei n, const GLuint* ids)
1498 inline GLboolean IsQuery(GLuint id)
1503 inline void BeginQuery(GLenum target, GLuint id)
1507 inline void EndQuery(GLenum target)
1511 inline void GetQueryiv(GLenum target, GLenum pname, GLint* params)
1515 inline void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
1519 inline GLboolean UnmapBuffer(GLenum target)
1524 inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
1528 inline void DrawBuffers(GLsizei n, const GLenum* bufs)
1532 inline void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1536 inline void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1540 inline void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1544 inline void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1548 inline void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1552 inline void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
1556 inline void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1560 inline void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
1564 inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
1568 inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
1573 inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
1577 inline void BindVertexArray(GLuint array)
1581 inline void DeleteVertexArrays(GLsizei n, const GLuint* arrays)
1585 inline void GenVertexArrays(GLsizei n, GLuint* arrays)
1589 inline GLboolean IsVertexArray(GLuint array)
1594 inline void GetIntegeri_v(GLenum target, GLuint index, GLint* data)
1598 inline void BeginTransformFeedback(GLenum primitiveMode)
1602 inline void EndTransformFeedback(void)
1606 inline void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
1610 inline void BindBufferBase(GLenum target, GLuint index, GLuint buffer)
1614 inline void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
1618 inline void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
1622 inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
1626 inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
1630 inline void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
1634 inline void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
1638 inline void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
1642 inline void VertexAttribI4iv(GLuint index, const GLint* v)
1646 inline void VertexAttribI4uiv(GLuint index, const GLuint* v)
1650 inline void GetUniformuiv(GLuint program, GLint location, GLuint* params)
1654 inline GLint GetFragDataLocation(GLuint program, const GLchar *name)
1659 inline void Uniform1ui(GLint location, GLuint v0)
1663 inline void Uniform2ui(GLint location, GLuint v0, GLuint v1)
1667 inline void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
1671 inline void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
1675 inline void Uniform1uiv(GLint location, GLsizei count, const GLuint* value)
1679 inline void Uniform2uiv(GLint location, GLsizei count, const GLuint* value)
1683 inline void Uniform3uiv(GLint location, GLsizei count, const GLuint* value)
1687 inline void Uniform4uiv(GLint location, GLsizei count, const GLuint* value)
1691 inline void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
1695 inline void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
1699 inline void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
1703 inline void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
1707 inline const GLubyte* GetStringi(GLenum name, GLuint index)
1712 inline void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
1716 inline void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
1720 inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
1724 inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
1726 return GL_INVALID_INDEX;
1729 inline void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
1733 inline void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
1737 inline void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1741 inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
1745 inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
1749 inline GLsync FenceSync(GLenum condition, GLbitfield flags)
1754 inline GLboolean IsSync(GLsync sync)
1759 inline void DeleteSync(GLsync sync)
1763 inline GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1768 inline void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
1772 inline void GetInteger64v(GLenum pname, GLint64* params)
1776 inline void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
1780 inline void GetInteger64i_v(GLenum target, GLuint index, GLint64* data)
1784 inline void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
1788 inline void GenSamplers(GLsizei count, GLuint* samplers)
1792 inline void DeleteSamplers(GLsizei count, const GLuint* samplers)
1796 inline GLboolean IsSampler(GLuint sampler)
1801 inline void BindSampler(GLuint unit, GLuint sampler)
1805 inline void SamplerParameteri(GLuint sampler, GLenum pname, GLint param)
1809 inline void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
1813 inline void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
1817 inline void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
1821 inline void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
1825 inline void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
1829 inline void VertexAttribDivisor(GLuint index, GLuint divisor)
1833 inline void BindTransformFeedback(GLenum target, GLuint id)
1837 inline void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
1841 inline void GenTransformFeedbacks(GLsizei n, GLuint* ids)
1845 inline GLboolean IsTransformFeedback(GLuint id)
1850 inline void PauseTransformFeedback(void)
1854 inline void ResumeTransformFeedback(void)
1858 inline void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
1860 mGetProgramBinaryCalled = true;
1863 inline void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
1867 inline void ProgramParameteri(GLuint program, GLenum pname, GLint value)
1871 inline void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
1875 inline void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
1879 inline void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
1883 inline void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
1887 inline void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
1893 inline void AddUniformCallToTraceStack( GLint location, std::string& value )
1895 std::string name = "<not found>";
1896 bool matched = false;
1898 UniformIDMap& map = mUniforms[mCurrentProgram];
1899 for (UniformIDMap::iterator it=map.begin(); it!=map.end(); ++it)
1901 if( it->second == location )
1911 mSetUniformTrace.PushCall( name, value );
1916 public: // TEST FUNCTIONS
1917 inline void SetCompileStatus( GLuint value ) { mCompileStatus = value; }
1918 inline void SetLinkStatus( GLuint value ) { mLinkStatus = value; }
1919 inline void SetGetAttribLocationResult( int result) { mGetAttribLocationResult = result; }
1920 inline void SetGetErrorResult( GLenum result) { mGetErrorResult = result; }
1921 inline void SetGetStringResult( GLubyte* result) { mGetStringResult = result; }
1922 inline void SetIsBufferResult( GLboolean result) { mIsBufferResult = result; }
1923 inline void SetIsEnabledResult( GLboolean result) { mIsEnabledResult = result; }
1924 inline void SetIsFramebufferResult( GLboolean result) { mIsFramebufferResult = result; }
1925 inline void SetIsProgramResult( GLboolean result) { mIsProgramResult = result; }
1926 inline void SetIsRenderbufferResult( GLboolean result) { mIsRenderbufferResult = result; }
1927 inline void SetIsShaderResult( GLboolean result) { mIsShaderResult = result; }
1928 inline void SetIsTextureResult( GLboolean result) { mIsTextureResult = result; }
1929 inline void SetCheckFramebufferStatusResult( GLenum result) { mCheckFramebufferStatusResult = result; }
1930 inline void SetNumBinaryFormats( GLint numFormats ) { mNumBinaryFormats = numFormats; }
1931 inline void SetBinaryFormats( GLint binaryFormats ) { mBinaryFormats = binaryFormats; }
1932 inline void SetProgramBinaryLength( GLint length ) { mProgramBinaryLength = length; }
1934 inline bool GetVertexAttribArrayState(GLuint index)
1936 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
1941 return mVertexAttribArrayState[ index ];
1943 inline void ClearVertexAttribArrayChanged() { mVertexAttribArrayChanged = false; }
1944 inline bool GetVertexAttribArrayChanged() { return mVertexAttribArrayChanged; }
1946 //Methods for CullFace verification
1947 inline void EnableCullFaceCallTrace(bool enable) { mCullFaceTrace.Enable(enable); }
1948 inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
1949 inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
1951 //Methods for Enable/Disable call verification
1952 inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
1953 inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
1954 inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
1956 //Methods for Shader verification
1957 inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
1958 inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
1959 inline TraceCallStack& GetShaderTrace() { return mShaderTrace; }
1961 //Methods for Texture verification
1962 inline void EnableTextureCallTrace(bool enable) { mTextureTrace.Enable(enable); }
1963 inline void ResetTextureCallStack() { mTextureTrace.Reset(); }
1964 inline TraceCallStack& GetTextureTrace() { return mTextureTrace; }
1966 //Methods for Texture verification
1967 inline void EnableTexParameterCallTrace(bool enable) { mTexParamaterTrace.Enable(enable); }
1968 inline void ResetTexParameterCallStack() { mTexParamaterTrace.Reset(); }
1969 inline TraceCallStack& GetTexParameterTrace() { return mTexParamaterTrace; }
1971 //Methods for Draw verification
1972 inline void EnableDrawCallTrace(bool enable) { mDrawTrace.Enable(enable); }
1973 inline void ResetDrawCallStack() { mDrawTrace.Reset(); }
1974 inline TraceCallStack& GetDrawTrace() { return mDrawTrace; }
1976 //Methods for Depth function verification
1977 inline void EnableDepthFunctionCallTrace(bool enable) { mDepthFunctionTrace.Enable(enable); }
1978 inline void ResetDepthFunctionCallStack() { mDepthFunctionTrace.Reset(); }
1979 inline TraceCallStack& GetDepthFunctionTrace() { return mDepthFunctionTrace; }
1981 //Methods for Stencil function verification
1982 inline void EnableStencilFunctionCallTrace(bool enable) { mStencilFunctionTrace.Enable(enable); }
1983 inline void ResetStencilFunctionCallStack() { mStencilFunctionTrace.Reset(); }
1984 inline TraceCallStack& GetStencilFunctionTrace() { return mStencilFunctionTrace; }
1986 //Methods for Scissor verification
1987 inline void EnableScissorCallTrace(bool enable) { mScissorTrace.Enable(enable); }
1988 inline void ResetScissorCallStack() { mScissorTrace.Reset(); }
1989 inline TraceCallStack& GetScissorTrace() { return mScissorTrace; }
1991 //Methods for Uniform function verification
1992 inline void EnableSetUniformCallTrace(bool enable) { mSetUniformTrace.Enable(enable); }
1993 inline void ResetSetUniformCallStack() { mSetUniformTrace.Reset(); }
1994 inline TraceCallStack& GetSetUniformTrace() { return mSetUniformTrace; }
1996 //Methods for Viewport verification
1997 inline void EnableViewportCallTrace(bool enable) { mViewportTrace.Enable(enable); }
1998 inline void ResetViewportCallStack() { mViewportTrace.Reset(); }
1999 inline TraceCallStack& GetViewportTrace() { return mViewportTrace; }
2001 template <typename T>
2002 inline bool GetUniformValue( const char* name, T& value ) const
2004 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2005 program_it != mUniforms.end();
2008 const UniformIDMap &uniformIDs = program_it->second;
2010 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2011 if( uniform_it != uniformIDs.end() )
2013 // found one matching uniform name, lets check the value...
2014 GLuint programId = program_it->first;
2015 GLint uniformId = uniform_it->second;
2017 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2018 return mProgramUniforms.GetUniformValue( programId, uniformId, value );
2025 template <typename T>
2026 inline bool CheckUniformValue( const char* name, const T& value ) const
2028 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2029 program_it != mUniforms.end();
2032 const UniformIDMap &uniformIDs = program_it->second;
2034 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2035 if( uniform_it != uniformIDs.end() )
2037 // found one matching uniform name, lets check the value...
2038 GLuint programId = program_it->first;
2039 GLint uniformId = uniform_it->second;
2041 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2042 if( mProgramUniforms.CheckUniformValue( programId, uniformId, value ) )
2044 // the value matches
2050 fprintf(stderr, "Not found, printing possible values:\n" );
2051 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2052 program_it != mUniforms.end();
2055 const UniformIDMap &uniformIDs = program_it->second;
2057 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2058 if( uniform_it != uniformIDs.end() )
2060 // found one matching uniform name, lets check the value...
2061 GLuint programId = program_it->first;
2062 GLint uniformId = uniform_it->second;
2064 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( value );
2066 if ( mProgramUniforms.GetUniformValue(programId, uniformId, origValue) )
2068 std::stringstream out;
2069 out << uniform_it->first << ": " << origValue;
2070 fprintf(stderr, "%s\n", out.str().c_str() );
2077 template <typename T>
2078 inline bool GetUniformValue( GLuint programId, GLuint uniformId, T& outValue) const
2080 const ProgramUniformValue<T> &mProgramUniforms = GetProgramUniformsForType( outValue );
2081 return mProgramUniforms.GetUniformValue( programId, uniformId, outValue );
2084 inline bool GetUniformIds( const char* name, GLuint& programId, GLuint& uniformId ) const
2086 for( ProgramUniformMap::const_iterator program_it = mUniforms.begin();
2087 program_it != mUniforms.end();
2090 const UniformIDMap &uniformIDs = program_it->second;
2092 UniformIDMap::const_iterator uniform_it = uniformIDs.find( name );
2093 if( uniform_it != uniformIDs.end() )
2095 programId = program_it->first;
2096 uniformId = uniform_it->second;
2103 inline GLuint GetLastShaderCompiled() const
2105 return mLastShaderCompiled;
2108 inline GLuint GetLastProgramCreated() const
2110 return mLastProgramIdUsed;
2113 inline GLbitfield GetLastClearMask() const
2115 return mLastClearBitMask;
2120 ATTRIB_UNKNOWN = -1,
2125 ATTRIB_BONE_WEIGHTS,
2126 ATTRIB_BONE_INDICES,
2130 struct ScissorParams
2137 ScissorParams() : x( 0 ), y( 0 ), width( 0 ), height( 0 ) { }
2140 // Methods to check scissor tests
2141 inline const ScissorParams& GetScissorParams() const { return mScissorParams; }
2143 struct ColorMaskParams
2150 ColorMaskParams() : red( true ), green( true ), blue( true ), alpha( true ) { }
2153 inline bool GetProgramBinaryCalled() const { return mGetProgramBinaryCalled; }
2155 inline unsigned int GetClearCountCalled() const { return mClearCount; }
2157 inline const ColorMaskParams& GetColorMaskParams() const { return mColorMaskParams; }
2159 typedef std::vector<size_t> BufferDataCalls;
2160 inline const BufferDataCalls& GetBufferDataCalls() const { return mBufferDataCalls; }
2161 inline void ResetBufferDataCalls() { mBufferDataCalls.clear(); }
2163 typedef std::vector<size_t> BufferSubDataCalls;
2164 inline const BufferSubDataCalls& GetBufferSubDataCalls() const { return mBufferSubDataCalls; }
2165 inline void ResetBufferSubDataCalls() { mBufferSubDataCalls.clear(); }
2168 GLuint mCurrentProgram;
2169 GLuint mCompileStatus;
2170 BufferDataCalls mBufferDataCalls;
2171 BufferSubDataCalls mBufferSubDataCalls;
2173 GLint mNumberOfActiveUniforms;
2174 GLint mGetAttribLocationResult;
2175 GLenum mGetErrorResult;
2176 GLubyte* mGetStringResult;
2177 GLboolean mIsBufferResult;
2178 GLboolean mIsEnabledResult;
2179 GLboolean mIsFramebufferResult;
2180 GLboolean mIsProgramResult;
2181 GLboolean mIsRenderbufferResult;
2182 GLboolean mIsShaderResult;
2183 GLboolean mIsTextureResult;
2184 GLenum mActiveTextureUnit;
2185 GLenum mCheckFramebufferStatusResult;
2186 GLint mFramebufferStatus;
2187 GLenum mFramebufferDepthAttached;
2188 GLenum mFramebufferStencilAttached;
2189 GLuint mFramebufferColorAttachmentCount;
2190 GLuint mFrameBufferColorStatus;
2191 GLint mNumBinaryFormats;
2192 GLint mBinaryFormats;
2193 GLint mProgramBinaryLength;
2194 bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE];
2195 bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed
2196 bool mGetProgramBinaryCalled;
2197 typedef std::map< GLuint, std::string> ShaderSourceMap;
2198 ShaderSourceMap mShaderSources;
2199 GLuint mLastShaderCompiled;
2200 GLbitfield mLastClearBitMask;
2201 Vector4 mLastClearColor;
2202 unsigned int mClearCount;
2204 Vector4 mLastBlendColor;
2205 GLenum mLastBlendEquationRgb;
2206 GLenum mLastBlendEquationAlpha;
2207 GLenum mLastBlendFuncSrcRgb;
2208 GLenum mLastBlendFuncDstRgb;
2209 GLenum mLastBlendFuncSrcAlpha;
2210 GLenum mLastBlendFuncDstAlpha;
2212 GLboolean mLastDepthMask;
2214 // Data for manipulating the IDs returned by GenTextures
2215 GLuint mLastAutoTextureIdUsed;
2216 GLuint mNumGeneratedTextures;
2217 std::vector<GLuint> mNextTextureIds;
2218 std::vector<GLuint> mDeletedTextureIds;
2219 std::vector<GLuint> mBoundTextures;
2221 struct ActiveTextureType
2223 std::vector<GLuint> mBoundTextures;
2226 ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
2228 TraceCallStack mCullFaceTrace;
2229 TraceCallStack mEnableDisableTrace;
2230 TraceCallStack mShaderTrace;
2231 TraceCallStack mTextureTrace;
2232 TraceCallStack mTexParamaterTrace;
2233 TraceCallStack mDrawTrace;
2234 TraceCallStack mDepthFunctionTrace;
2235 TraceCallStack mStencilFunctionTrace;
2236 TraceCallStack mScissorTrace;
2237 TraceCallStack mSetUniformTrace;
2238 TraceCallStack mViewportTrace;
2240 // Shaders & Uniforms
2241 GLuint mLastShaderIdUsed;
2242 GLuint mLastProgramIdUsed;
2243 GLuint mLastUniformIdUsed;
2244 typedef std::map< std::string, GLint > UniformIDMap;
2245 typedef std::map< GLuint, UniformIDMap > ProgramUniformMap;
2246 ProgramUniformMap mUniforms;
2248 template <typename T>
2249 struct ProgramUniformValue : public std::map< GLuint, std::map< GLint, T > >
2252 typedef std::map< GLint, T > UniformValueMap;
2253 typedef std::map< GLuint, UniformValueMap > Map;
2255 bool SetUniformValue( GLuint program, GLuint uniform, const T& value )
2262 typename Map::iterator it = Map::find( program );
2263 if( it == Map::end() )
2265 // if its the first uniform for this program add it
2266 std::pair< typename Map::iterator, bool > result =
2267 Map::insert( typename Map::value_type( program, UniformValueMap() ) );
2271 UniformValueMap& uniforms = it->second;
2272 uniforms[uniform] = value;
2277 bool CheckUniformValue( GLuint program, GLuint uniform, const T& value ) const
2280 if ( GetUniformValue( program, uniform, uniformValue ) )
2282 return CompareType<T>(value, uniformValue, Math::MACHINE_EPSILON_10);
2288 bool GetUniformValue( GLuint program, GLuint uniform, T& value ) const
2295 typename Map::const_iterator it = Map::find( program );
2296 if( it == Map::end() )
2298 // Uniform values always initialised as 0
2303 const UniformValueMap& uniforms = it->second;
2304 typename UniformValueMap::const_iterator it2 = uniforms.find( uniform );
2305 if( it2 == uniforms.end() )
2307 // Uniform values always initialised as 0
2311 value = it2->second;
2318 ProgramUniformValue<int> mProgramUniforms1i;
2319 ProgramUniformValue<float> mProgramUniforms1f;
2320 ProgramUniformValue<Vector2> mProgramUniforms2f;
2321 ProgramUniformValue<Vector3> mProgramUniforms3f;
2322 ProgramUniformValue<Vector4> mProgramUniforms4f;
2323 ProgramUniformValue<Matrix> mProgramUniformsMat4;
2324 ProgramUniformValue<Matrix3> mProgramUniformsMat3;
2326 inline const ProgramUniformValue<int>& GetProgramUniformsForType( const int ) const
2328 return mProgramUniforms1i;
2330 inline const ProgramUniformValue<float>& GetProgramUniformsForType( const float ) const
2332 return mProgramUniforms1f;
2334 inline const ProgramUniformValue<Vector2>& GetProgramUniformsForType( const Vector2& ) const
2336 return mProgramUniforms2f;
2338 inline const ProgramUniformValue<Vector3>& GetProgramUniformsForType( const Vector3& ) const
2340 return mProgramUniforms3f;
2342 inline const ProgramUniformValue<Vector4>& GetProgramUniformsForType( const Vector4& ) const
2344 return mProgramUniforms4f;
2346 inline const ProgramUniformValue<Matrix>& GetProgramUniformsForType( const Matrix& ) const
2348 return mProgramUniformsMat4;
2350 inline const ProgramUniformValue<Matrix3>& GetProgramUniformsForType( const Matrix3& ) const
2352 return mProgramUniformsMat3;
2354 inline void SetVertexAttribArray(GLuint index, bool state)
2356 if( index >= MAX_ATTRIBUTE_CACHE_SIZE )
2361 mVertexAttribArrayState[ index ] = state;
2362 mVertexAttribArrayChanged = true;
2365 ScissorParams mScissorParams;
2366 ColorMaskParams mColorMaskParams;
2370 inline int TestGlAbstraction::ProgramUniformValue<int>::GetZero() const
2376 inline float TestGlAbstraction::ProgramUniformValue<float>::GetZero() const
2382 inline Vector2 TestGlAbstraction::ProgramUniformValue<Vector2>::GetZero() const
2384 return Vector2::ZERO;
2388 inline Vector3 TestGlAbstraction::ProgramUniformValue<Vector3>::GetZero() const
2390 return Vector3::ZERO;
2394 inline Vector4 TestGlAbstraction::ProgramUniformValue<Vector4>::GetZero() const
2396 return Vector4::ZERO;
2400 inline Matrix TestGlAbstraction::ProgramUniformValue<Matrix>::GetZero() const
2406 inline Matrix3 TestGlAbstraction::ProgramUniformValue<Matrix3>::GetZero() const
2408 return Matrix3( Matrix() );
2413 bool BlendEnabled(const Dali::TraceCallStack& callStack);
2414 bool BlendDisabled(const Dali::TraceCallStack& callStack);
2417 #endif // TEST_GL_ABSTRACTION_H