3#include <gmock/gmock.hpp>
4#include <alicorn/std/vector.hpp>
5#include <alicorn/std/string/encoding.hpp>
6#include <boost/algorithm/string/replace.hpp>
8#ifndef OpenGLShader_test
10class OpenGLShader_test :
11 public ::testing::Test
22TEST_F(OpenGLShader_test, Test_State_Sampler_Texture_Mipmapping)
24 using GLProxy_t = ::mock::GLProxy;
26 GLProxy_t::GetInstance() = &GLProxy;
28 const Tested_t Example{ Data_t{} };
29 const ITested_t & IExample = Example;
31 auto itStateCreator = IExample.GetCreators().find(uT(
"State"));
32 ASSERT_NE(IExample.GetCreators().end(), itStateCreator);
34 auto itTextureCreator = IExample.GetCreators().find(uT(
"Texture"));
35 ASSERT_NE(IExample.GetCreators().end(), itTextureCreator);
37 auto SamplerRender = itStateCreator->second(Component_t::Make(
39 { uT(
"kind"), uT(
"Sampler") }
41 ASSERT_NE(
nullptr, SamplerRender);
43 auto TextureRender = itTextureCreator->second(Component_t::Make(
45 { uT(
"mipmapping"),
true }
47 ASSERT_NE(
nullptr, TextureRender);
49 using namespace ::testing;
51 EXPECT_CALL(GLProxy, TexParameteri(_, _, _))
58 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, _))
61 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
62 GL_LINEAR_MIPMAP_LINEAR))
65 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
69 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT))
72 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT))
79TEST_F(OpenGLShader_test, Test_State_Sampler_TextureArray_Mipmapping)
81 using GLProxy_t = ::mock::GLProxy;
83 GLProxy_t::GetInstance() = &GLProxy;
85 const Tested_t Example{ Data_t{} };
86 const ITested_t & IExample = Example;
88 auto itStateCreator = IExample.GetCreators().find(uT(
"State"));
89 ASSERT_NE(IExample.GetCreators().end(), itStateCreator);
91 auto itTextureCreator = IExample.GetCreators().find(uT(
"TextureArray"));
92 ASSERT_NE(IExample.GetCreators().end(), itTextureCreator);
94 auto SamplerRender = itStateCreator->second(Component_t::Make(
96 { uT(
"kind"), uT(
"Sampler") }
98 ASSERT_NE(
nullptr, SamplerRender);
100 auto TextureRender = itTextureCreator->second(Component_t::Make(
102 { uT(
"mipmapping"),
true }
104 ASSERT_NE(
nullptr, TextureRender);
106 using namespace ::testing;
108 EXPECT_CALL(GLProxy, TexParameteri(_, _, _))
115 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, _))
118 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER,
119 GL_LINEAR_MIPMAP_LINEAR))
122 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER,
126 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT))
129 EXPECT_CALL(GLProxy, TexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT))
136TEST_F(OpenGLShader_test, Test_BkSurface_Fail)
138 using GLProxy_t = ::mock::GLProxy;
140 GLProxy_t::GetInstance() = &GLProxy;
142 const Tested_t Example{ Data_t{} };
143 const ITested_t & IExample = Example;
145 auto itCreator = IExample.GetCreators().find(uT(
"BkSurface"));
146 ASSERT_NE(IExample.GetCreators().end(), itCreator);
148 const ::mock::GLuint FrameBufferId = 1910041904;
150 using namespace ::testing;
154 EXPECT_CALL(GLProxy, GenFramebuffers(1))
156 .WillOnce(Return(FrameBufferId));
158 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
161 EXPECT_CALL(GLProxy, CheckFramebufferStatus(GL_FRAMEBUFFER))
163 .WillOnce(Return(1910041903));
165 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, 0))
168 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
171 EXPECT_THROW(itCreator->second(Component_t::Make({})), ::std::exception);
175TEST_F(OpenGLShader_test, Test_BkSurface)
177 const auto TestCall = [](
178 const Component_t::ComponentPtr_t & _pBkSurface,
179 const bool _IsUseMapper,
180 const int _Width,
const int _Height,
181 const int _ExpectedWidth,
const int _ExpectedHeight)
183 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
185 ::mock::GLProxy GLProxy;
188 SettingsData.ClientRect.Top = 34;
190 Tested_t Example{ SettingsData };
191 ITested_t & IExample = Example;
192 IExample.PresentFrame();
194 auto itCreator = IExample.GetCreators().find(uT(
"BkSurface"));
195 ASSERT_NE(IExample.GetCreators().end(), itCreator);
197 constexpr ::mock::GLint TextureId = 1910041735;
198 constexpr ::mock::GLint FrameBufferId = 1910041803;
199 constexpr ::mock::GLint BindingFrameBufferId = 2006162207;
201 const ::std::vector<String_t> Destinations =
213 Object_t TextureComponents;
215 for (::std::size_t i = 0; i < Destinations.size(); i++)
217 const auto pTexture = Component_t::Make(
219 { uT(
"kind"), uT(
"Texture") },
220 { uT(
"destination"), Destinations[i] },
223 if (_IsUseMapper) (*pTexture)[uT(
"mapper")] = BufferMapper_t{};
225 TextureComponents.push_back(pTexture);
228 using namespace ::testing;
232 const int Viewport[] = { 0, 0, _Width, _Height };
234 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
236 .WillOnce(Return(Viewport));
238 EXPECT_CALL(GLProxy, GenFramebuffers(1))
240 .WillOnce(Return(FrameBufferId));
242 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
244 .WillOnce(Return(&BindingFrameBufferId));
246 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
249 ::std::vector<::mock::GLenum> AttachmentIndexes;
251 for (::std::size_t i = 0; i < Destinations.size(); i++)
253 auto Format = GL_DEPTH_COMPONENT;
254 auto Attachment = GL_DEPTH_ATTACHMENT;
256 if (Destinations[i] != uT(
"depth"))
259 Attachment = GL_COLOR_ATTACHMENT0 +
260 static_cast<int>(AttachmentIndexes.size());
261 AttachmentIndexes.push_back(Attachment);
264 EXPECT_CALL(GLProxy, GenTextures(1))
266 .WillOnce(Return(TextureId + i));
268 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId + i))
271 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, _,
272 _ExpectedWidth, _ExpectedHeight, 0, Format, _, ::std::vector<uint8_t>{}))
275 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
278 EXPECT_CALL(GLProxy, GetError())
280 .WillOnce(Return(GL_NO_ERROR));
282 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER, Attachment,
283 GL_TEXTURE_2D, TextureId + i, 0))
287 EXPECT_CALL(GLProxy, CheckFramebufferStatus(GL_FRAMEBUFFER))
289 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE));
291 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, BindingFrameBufferId))
294 (*_pBkSurface)[uT(
"service")] = TextureComponents;
296 auto Render = itCreator->second(_pBkSurface);
297 ASSERT_NE(
nullptr, Render);
299 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
301 .WillOnce(Return(Viewport));
303 EXPECT_CALL(GLProxy, TexImage2D(_, _, _, _, _, _, _, _, _))
306 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
308 .WillOnce(Return(&BindingFrameBufferId));
310 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
313 EXPECT_CALL(GLProxy, DrawBuffers(AttachmentIndexes))
316 EXPECT_CALL(GLProxy, Viewport(_, _, _, _))
321 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
324 ASSERT_EQ(TextureComponents.size(), Destinations.size());
326 EXPECT_EQ(_ExpectedWidth, (
int)(*_pBkSurface)[uT(
"width")]);
327 EXPECT_EQ(_ExpectedHeight, (
int)(*_pBkSurface)[uT(
"height")]);
329 for (::std::size_t i = 0; i < TextureComponents.size(); i++)
331 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
333 const auto pTextureComponent = TextureComponents[i];
334 const Texture_t::Ptr_t pTexture =
335 (*pTextureComponent)[uT(
"entity")].Default(Texture_t::Ptr_t{});
336 ASSERT_NE(
nullptr, pTexture);
337 EXPECT_EQ(TextureId + i, pTexture->m_TextureId);
338 EXPECT_EQ(_IsUseMapper ? 4 * _ExpectedWidth * _ExpectedHeight : 0,
339 pTexture->m_ReadCopyData.size());
340 EXPECT_EQ(_ExpectedWidth, (
int)(*pTextureComponent)[uT(
"width")].Default(0));
341 EXPECT_EQ(_ExpectedHeight, (
int)(*pTextureComponent)[uT(
"height")].Default(0));
345 TestCall(Component_t::Make({ }),
346 false, 12, 45, 12, 45);
347 TestCall(Component_t::Make({ }),
348 true, 45, 12, 45, 12);
352TEST_F(OpenGLShader_test, Test_BkSurface_RenderDepthOnly)
354 using GLProxy_t = ::mock::GLProxy;
356 GLProxy_t::GetInstance() = &GLProxy;
358 const Tested_t Example{ Data_t{} };
359 const ITested_t & IExample = Example;
361 auto itCreator = IExample.GetCreators().find(uT(
"BkSurface"));
362 ASSERT_NE(IExample.GetCreators().end(), itCreator);
364 const ::mock::GLuint TextureId = 1910041735;
365 const ::mock::GLuint FrameBufferId = 1910041803;
367 using namespace ::testing;
371 const auto pTexture = Component_t::Make(
373 { uT(
"kind"), uT(
"Texture") },
374 { uT(
"destination"), uT(
"depth") },
377 EXPECT_CALL(GLProxy, CheckFramebufferStatus(GL_FRAMEBUFFER))
379 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE));
381 auto Render = itCreator->second(Component_t::Make(
383 { uT(
"service"), Object_t{ pTexture } }
385 ASSERT_NE(
nullptr, Render);
387 EXPECT_CALL(GLProxy, DrawBuffers(::std::vector<::mock::GLenum>{}))
394TEST_F(OpenGLShader_test, Test_BkSurface_ResizeWindow)
396 const auto TestCall = [](
397 const Component_t::ComponentPtr_t & _pBkSurface,
398 const bool _IsUseMapper,
399 const int _Width,
const int _Height,
400 const int _ExpectedWidth,
const int _ExpectedHeight,
401 const int _ExpectedWidth2,
const int _ExpectedHeight2)
403 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
404 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
406 ::mock::GLProxy GLProxy;
409 SettingsData.ClientRect.Top = 45;
411 Tested_t Example{ SettingsData };
412 ITested_t & IExample = Example;
413 IExample.PresentFrame();
415 auto itCreator = IExample.GetCreators().find(uT(
"BkSurface"));
416 ASSERT_NE(IExample.GetCreators().end(), itCreator);
418 constexpr ::mock::GLuint TextureId = 1910091302;
420 const ::std::vector<String_t> Destinations =
430 Object_t TextureComponents;
432 for (::std::size_t i = 0; i < Destinations.size(); i++)
434 const auto pTexture = Component_t::Make(
436 { uT(
"kind"), uT(
"Texture") },
437 { uT(
"destination"), Destinations[i] },
440 if (_IsUseMapper) (*pTexture)[uT(
"mapper")] = BufferMapper_t{};
442 TextureComponents.push_back(pTexture);
445 using namespace ::testing;
449 const int Viewport[] = { 0, 0, _Width, _Height };
451 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
453 .WillOnce(Return(Viewport));
455 EXPECT_CALL(GLProxy, GetIntegerv(_))
458 for (::std::size_t i = 0; i < Destinations.size(); i++)
460 EXPECT_CALL(GLProxy, GenTextures(1))
462 .WillOnce(Return(TextureId + i));
464 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId + i))
467 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, _, _,
468 _ExpectedWidth, _ExpectedHeight, _, _, _, ::std::vector<uint8_t>{}))
471 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
474 EXPECT_CALL(GLProxy, GetError())
476 .WillOnce(Return(GL_NO_ERROR));
479 EXPECT_CALL(GLProxy, CheckFramebufferStatus(GL_FRAMEBUFFER))
481 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE));
483 (*_pBkSurface)[uT(
"service")] = TextureComponents;
485 auto Render = itCreator->second(_pBkSurface);
486 ASSERT_NE(
nullptr, Render);
488 EXPECT_EQ(_ExpectedWidth, (
int)(*_pBkSurface)[uT(
"width")]);
489 EXPECT_EQ(_ExpectedHeight, (
int)(*_pBkSurface)[uT(
"height")]);
491 for (::std::size_t i = 0; i < TextureComponents.size(); i++)
493 const auto pTextureComponent = TextureComponents[i];
494 EXPECT_EQ(_ExpectedWidth, (
int)(*pTextureComponent)[uT(
"width")].Default(0));
495 EXPECT_EQ(_ExpectedHeight, (
int)(*pTextureComponent)[uT(
"height")].Default(0));
497 const Texture_t::Ptr_t pTexture =
498 (*pTextureComponent)[uT(
"entity")].Default(Texture_t::Ptr_t{});
499 ASSERT_NE(
nullptr, pTexture);
500 EXPECT_EQ(_IsUseMapper ? _ExpectedWidth * _ExpectedHeight * 4 : 0,
501 pTexture->m_ReadCopyData.size());
504 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
507 EXPECT_CALL(GLProxy, TexImage2D(_, _, _, _, _, _, _, _, _))
510 EXPECT_CALL(GLProxy, GetIntegerv(_))
513 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, _))
516 EXPECT_CALL(GLProxy, Viewport(_, _, _, _))
521 EXPECT_CALL(GLProxy, GetError())
523 .WillOnce(Return(GL_NO_ERROR));
525 IExample.PresentFrame();
527 const int Viewport2[] = { 0, 0, _Width * 2, _Height * 2 };
529 IExample.ResizeWindow(::covellite::Rect{ 0, 0, _Width * 2, _Height * 2 });
531 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
533 .WillOnce(Return(Viewport2));
535 for (::std::size_t i = 0; i < Destinations.size(); i++)
537 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId + i))
540 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, _, _,
541 _ExpectedWidth2, _ExpectedHeight2, _, _, _, ::std::vector<uint8_t>{}))
544 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
547 EXPECT_CALL(GLProxy, GetError())
549 .WillOnce(Return(GL_NO_ERROR));
552 EXPECT_CALL(GLProxy, GetIntegerv(_))
555 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, _))
558 EXPECT_CALL(GLProxy, Viewport(_, _, _, _))
563 EXPECT_CALL(GLProxy, GetError())
565 .WillOnce(Return(GL_NO_ERROR));
567 IExample.PresentFrame();
569 EXPECT_EQ(_ExpectedWidth2, (
int)(*_pBkSurface)[uT(
"width")]);
570 EXPECT_EQ(_ExpectedHeight2, (
int)(*_pBkSurface)[uT(
"height")]);
572 for (::std::size_t i = 0; i < TextureComponents.size(); i++)
574 const auto pTextureComponent = TextureComponents[i];
575 EXPECT_EQ(_ExpectedWidth2, (
int)(*pTextureComponent)[uT(
"width")].Default(0));
576 EXPECT_EQ(_ExpectedHeight2, (
int)(*pTextureComponent)[uT(
"height")].Default(0));
578 const Texture_t::Ptr_t pTexture =
579 (*pTextureComponent)[uT(
"entity")].Default(Texture_t::Ptr_t{});
580 ASSERT_NE(
nullptr, pTexture);
581 EXPECT_EQ(_IsUseMapper ? _ExpectedWidth2 * _ExpectedHeight2 * 4 : 0,
582 pTexture->m_ReadCopyData.size());
585 EXPECT_CALL(GLProxy, GetIntegerv(GL_VIEWPORT))
588 EXPECT_CALL(GLProxy, TexImage2D(_, _, _, _, _, _, _, _, _))
591 EXPECT_CALL(GLProxy, GetIntegerv(_))
594 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, _))
597 EXPECT_CALL(GLProxy, Viewport(_, _, _, _))
602 EXPECT_CALL(GLProxy, GetError())
604 .WillOnce(Return(GL_NO_ERROR));
606 IExample.PresentFrame();
609 TestCall(Component_t::Make({ }),
610 false, 45, 67, 45, 67, 90, 134);
611 TestCall(Component_t::Make({ }),
612 true, 45, 67, 45, 67, 90, 134);
616TEST_F(OpenGLShader_test, Test_Shader_InvalidType)
618 const ::std::string ShaderData =
619 "Pixel vs1(Polygon _Value)\r\n"
620 "Pixel vs2(Polyhedron _Value)\r\n";
622 using GLProxy_t = ::mock::GLProxy;
624 GLProxy_t::GetInstance() = &GLProxy;
626 const Tested_t Example{ Data_t{} };
627 const ITested_t & IExample = Example;
629 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
630 ASSERT_NE(IExample.GetCreators().end(), itCreator);
632 const ::mock::GLuint ShaderId = 1908250832;
634 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader)
636 using namespace ::testing;
640 EXPECT_CALL(GLProxy, CreateShader(_))
643 auto Render = itCreator->second(_pShader);
644 EXPECT_EQ(
nullptr, Render);
648 const auto pShader = Component_t::Make(
650 { uT(
"entry"), uT(
"vs1") },
651 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
658 const auto pData = Component_t::Make(
660 { uT(
"kind"), uT(
"Shader") },
661 { uT(
"entry"), uT(
"vs2") },
662 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
665 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
670TEST_F(OpenGLShader_test, Test_Shader_NotExistsEntryPoint)
672 using GLProxy_t = ::mock::GLProxy;
674 GLProxy_t::GetInstance() = &GLProxy;
676 const Tested_t Example{ Data_t{} };
677 const ITested_t & IExample = Example;
679 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
680 ASSERT_NE(IExample.GetCreators().end(), itCreator);
682 const ::mock::GLuint ShaderId = 1908250832;
684 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader)
686 using namespace ::testing;
690 EXPECT_CALL(GLProxy, CreateShader(_))
693 EXPECT_THROW(itCreator->second(_pShader), ::std::exception);
697 const auto pShader = Component_t::Make(
699 { uT(
"entry"), uT(
"vsUnknown") },
706 const auto pData = Component_t::Make(
708 { uT(
"kind"), uT(
"Shader") },
709 { uT(
"entry"), uT(
"vsUnknown") },
712 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
717TEST_F(OpenGLShader_test, Test_Shader_CompileFail)
719 using GLProxy_t = ::mock::GLProxy;
721 GLProxy_t::GetInstance() = &GLProxy;
723 const Tested_t Example{ Data_t{} };
724 const ITested_t & IExample = Example;
726 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
727 ASSERT_NE(IExample.GetCreators().end(), itCreator);
729 const ::mock::GLuint ShaderId = 1908251346;
730 const ::std::string ErrorText =
"Error1908251350";
732 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader)
734 using namespace ::testing;
738 EXPECT_CALL(GLProxy, CreateShader(_))
740 .WillOnce(Return(ShaderId));
742 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, _, _, _))
745 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
748 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
750 .WillOnce(Return(GL_FALSE));
752 EXPECT_CALL(GLProxy, GetShaderInfoLog(ShaderId, 512,
nullptr))
754 .WillOnce(Return(ErrorText.c_str()));
756 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
759 EXPECT_STDEXCEPTION(itCreator->second(_pShader),
760 (
".*Compile shader fail \\[header line: 175\\]: " + ErrorText).c_str());
764 const auto pShader = Component_t::Make(
766 { uT(
"entry"), uT(
"vsFlat") },
773 const auto pData = Component_t::Make(
775 { uT(
"kind"), uT(
"Shader") },
776 { uT(
"entry"), uT(
"vsVolume") },
779 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
783::std::string ConvertTextShader(const ::std::vector<uint8_t> & _ShaderText)
785 return ::std::string{ _ShaderText.cbegin(), _ShaderText.cend() };
789TEST_F(OpenGLShader_test, Test_Shader_CreateVertex_Default)
791 using GLProxy_t = ::mock::GLProxy;
793 GLProxy_t::GetInstance() = &GLProxy;
795 const Tested_t Example{ Data_t{} };
796 const ITested_t & IExample = Example;
798 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
799 ASSERT_NE(IExample.GetCreators().end(), itCreator);
801 const ::mock::GLuint ShaderId = 1908250832;
803 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
804 const ::std::string & _Entry)
806 using namespace ::alicorn::extension::std;
808 const auto ExpectedShaderText =
810 "#define COVELLITE_SHADER_GLSL\r\n"
811 "#define COVELLITE_SHADER_VERTEX\r\n" +
812 ConvertTextShader(::Predefined + ::Data + ::Input + ::Default) +
813 "out Pixel PixelValue;\r\n"
816 " Vertex InputData;\r\n"
817 " InputData.Position = Covellite_VertexPosition;\r\n"
818 " InputData.TexCoord = Covellite_VertexTexCoord;\r\n"
819 " InputData.Extra = Covellite_VertexExtra;\r\n"
820 " PixelValue = " + _Entry +
"(InputData);\r\n"
821 " gl_Position = PixelValue.ScreenPos;\r\n"
824 using namespace ::testing;
828 EXPECT_CALL(GLProxy, CreateShader(GL_VERTEX_SHADER))
830 .WillOnce(Return(ShaderId));
832 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
835 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
838 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
840 .WillOnce(Return(GL_TRUE));
842 auto Render = itCreator->second(_pShader);
843 ASSERT_NE(
nullptr, Render);
847 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
852 const auto pShader = Component_t::Make(
854 { uT(
"entry"), uT(
"vsFlat") },
857 TestCall(pShader,
"vsFlat");
861 const auto pData = Component_t::Make(
863 { uT(
"kind"), uT(
"Shader") },
864 { uT(
"entry"), uT(
"vsVolume") },
867 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"vsVolume");
872TEST_F(OpenGLShader_test, Test_Shader_CreateVertex)
874 const ::std::string ShaderData =
875 "Pixel vs1(Vertex _Value)\r\n"
876 "Pixel vs2_Dummy(Vertex _Value)\r\n"
877 "Pixel vs2(Vertex _Value)\r\n";
879 using GLProxy_t = ::mock::GLProxy;
881 GLProxy_t::GetInstance() = &GLProxy;
883 const Tested_t Example{ Data_t{} };
884 const ITested_t & IExample = Example;
886 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
887 ASSERT_NE(IExample.GetCreators().end(), itCreator);
889 const ::mock::GLuint ShaderId = 1908250832;
891 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
892 const ::std::string & _Entry)
894 using namespace ::alicorn::extension::std;
896 const auto ExpectedShaderText =
898 "#define COVELLITE_SHADER_GLSL\r\n"
899 "#define COVELLITE_SHADER_VERTEX\r\n" +
900 ConvertTextShader(::Predefined + ::Data + ::Input) + ShaderData +
901 "out Pixel PixelValue;\r\n"
904 " Vertex InputData;\r\n"
905 " InputData.Position = Covellite_VertexPosition;\r\n"
906 " InputData.TexCoord = Covellite_VertexTexCoord;\r\n"
907 " InputData.Extra = Covellite_VertexExtra;\r\n"
908 " PixelValue = " + _Entry +
"(InputData);\r\n"
909 " gl_Position = PixelValue.ScreenPos;\r\n"
912 using namespace ::testing;
916 EXPECT_CALL(GLProxy, CreateShader(GL_VERTEX_SHADER))
918 .WillOnce(Return(ShaderId));
920 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
923 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
926 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
928 .WillOnce(Return(GL_TRUE));
930 auto Render = itCreator->second(_pShader);
931 ASSERT_NE(
nullptr, Render);
935 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
940 const auto pShader = Component_t::Make(
942 { uT(
"entry"), uT(
"vs1") },
943 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
946 TestCall(pShader,
"vs1");
950 const auto pData = Component_t::Make(
952 { uT(
"kind"), uT(
"Shader") },
953 { uT(
"entry"), uT(
"vs2") },
954 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
957 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"vs2");
962TEST_F(OpenGLShader_test, Test_Shader_CreateVertex_Instance_InvalidValue)
964 const ::std::string ShaderData =
965 "Pixel vs1(Vertex _Value)\r\n"
966 "Pixel vs2(Vertex _Value)\r\n";
968 using GLProxy_t = ::mock::GLProxy;
970 GLProxy_t::GetInstance() = &GLProxy;
972 const Tested_t Example{ Data_t{} };
973 const ITested_t & IExample = Example;
975 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
976 ASSERT_NE(IExample.GetCreators().end(), itCreator);
978 using namespace ::testing;
980 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader)
982 EXPECT_CALL(GLProxy, CompileShader(_))
985 EXPECT_THROW(itCreator->second(_pShader), ::std::exception);
989 const auto pShader = Component_t::Make(
991 { uT(
"entry"), uT(
"vs1") },
992 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
993 { uT(
"instance"), uT(
"invalid1909231417") },
1000 const auto pData = Component_t::Make(
1002 { uT(
"kind"), uT(
"Shader") },
1003 { uT(
"entry"), uT(
"vs2") },
1004 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1005 { uT(
"instance"), uT(
"invalid1909231418") },
1008 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
1013TEST_F(OpenGLShader_test, Test_Shader_CreateVertex_Instance)
1015 const ::std::string ShaderData =
1016 "Pixel vs1(Vertex _Value)\r\n"
1017 "Pixel vs2(Vertex _Value)\r\n";
1019 using GLProxy_t = ::mock::GLProxy;
1021 GLProxy_t::GetInstance() = &GLProxy;
1023 const Tested_t Example{ Data_t{} };
1024 const ITested_t & IExample = Example;
1026 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1027 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1029 const ::mock::GLuint ShaderId = 1908250832;
1031 auto InputData = ConvertTextShader(::Input);
1033 ::boost::algorithm::replace_first(InputData,
1034 "/* place for instance variables */", ::std::string{} +
1035 "COVELLITE_IN float4 iValue1 COVELLITE_INPUT_SEMANTIC(TEXCOORD1);" + (char)0x5C +
"\r\n"
1036 "COVELLITE_IN float4 iValue2 COVELLITE_INPUT_SEMANTIC(TEXCOORD2);" + (char)0x5C +
"\r\n"
1037 "COVELLITE_IN int4 iValue3 COVELLITE_INPUT_SEMANTIC(TEXCOORD3);" + (char)0x5C +
"\r\n"
1038 "COVELLITE_IN float4 iValue4 COVELLITE_INPUT_SEMANTIC(TEXCOORD4);" + (char)0x5C +
"\r\n"
1041 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
1042 const ::std::string & _Entry)
1044 using namespace ::alicorn::extension::std;
1046 const auto ExpectedShaderText =
1048 "#define COVELLITE_SHADER_GLSL\r\n"
1049 "#define COVELLITE_SHADER_VERTEX\r\n" +
1050 ConvertTextShader(::Predefined + ::Data) + InputData + ShaderData +
1051 "out Pixel PixelValue;\r\n"
1054 " Vertex InputData;\r\n"
1055 " InputData.Position = Covellite_VertexPosition;\r\n"
1056 " InputData.TexCoord = Covellite_VertexTexCoord;\r\n"
1057 " InputData.Extra = Covellite_VertexExtra;\r\n"
1058 " InputData.iValue1 = iValue1;\r\n"
1059 " InputData.iValue2 = iValue2;\r\n"
1060 " InputData.iValue3 = iValue3;\r\n"
1061 " InputData.iValue4 = iValue4;\r\n"
1062 " PixelValue = " + _Entry +
"(InputData);\r\n"
1063 " gl_Position = PixelValue.ScreenPos;\r\n"
1066 using namespace ::testing;
1070 EXPECT_CALL(GLProxy, CreateShader(GL_VERTEX_SHADER))
1072 .WillOnce(Return(ShaderId));
1074 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
1077 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
1080 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
1082 .WillOnce(Return(GL_TRUE));
1084 auto Render = itCreator->second(_pShader);
1085 ASSERT_NE(
nullptr, Render);
1089 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
1094 const auto pShader = Component_t::Make(
1096 { uT(
"entry"), uT(
"vs1") },
1097 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1098 { uT(
"instance"), uT(
"f4f4i4f4") },
1101 TestCall(pShader,
"vs1");
1105 const auto pData = Component_t::Make(
1107 { uT(
"kind"), uT(
"Shader") },
1108 { uT(
"entry"), uT(
"vs2") },
1109 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1110 { uT(
"instance"), uT(
"f4f4i4f4") },
1113 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"vs2");
1118TEST_F(OpenGLShader_test, Test_Shader_CreatePixel_Default)
1120 using GLProxy_t = ::mock::GLProxy;
1122 GLProxy_t::GetInstance() = &GLProxy;
1124 const Tested_t Example{ Data_t{} };
1125 const ITested_t & IExample = Example;
1127 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1128 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1130 const ::mock::GLuint ShaderId = 1908250832;
1132 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
1133 const ::std::string & _Entry)
1135 using namespace ::alicorn::extension::std;
1137 const auto ExpectedShaderText =
1139 "#define COVELLITE_SHADER_GLSL\r\n"
1140 "#define COVELLITE_SHADER_PIXEL\r\n" +
1141 ConvertTextShader(::Predefined + ::Data + ::Input + ::Default) +
1142 "in Pixel PixelValue;\r\n"
1143 "out vec4 Covellite_OutPixelColor;\r\n"
1146 " Covellite_OutPixelColor = " + _Entry +
"(PixelValue);\r\n"
1149 using namespace ::testing;
1153 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1155 .WillOnce(Return(ShaderId));
1157 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
1160 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
1163 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
1165 .WillOnce(Return(GL_TRUE));
1167 auto Render = itCreator->second(_pShader);
1168 ASSERT_NE(
nullptr, Render);
1172 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
1177 const auto pShader = Component_t::Make(
1179 { uT(
"entry"), uT(
"psColored") },
1182 TestCall(pShader,
"psColored");
1186 const auto pData = Component_t::Make(
1188 { uT(
"kind"), uT(
"Shader") },
1189 { uT(
"entry"), uT(
"psTextured") },
1192 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"psTextured");
1197TEST_F(OpenGLShader_test, Test_Shader_CreatePixel_SingleTarget)
1199 const ::std::string ShaderData =
1200 "float4 ps1(Pixel _Value)\r\n"
1201 "vec4 ps2_Dummy(Pixel _Value)\r\n"
1202 "vec4 ps2(Pixel _Value)\r\n";
1204 using GLProxy_t = ::mock::GLProxy;
1206 GLProxy_t::GetInstance() = &GLProxy;
1208 const Tested_t Example{ Data_t{} };
1209 const ITested_t & IExample = Example;
1211 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1212 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1214 const ::mock::GLuint ShaderId = 1908250832;
1216 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
1217 const ::std::string & _Entry)
1219 using namespace ::alicorn::extension::std;
1221 const auto ExpectedShaderText =
1223 "#define COVELLITE_SHADER_GLSL\r\n"
1224 "#define COVELLITE_SHADER_PIXEL\r\n" +
1225 ConvertTextShader(::Predefined + ::Data + ::Input) + ShaderData +
1226 "in Pixel PixelValue;\r\n"
1227 "out vec4 Covellite_OutPixelColor;\r\n"
1230 " Covellite_OutPixelColor = " + _Entry +
"(PixelValue);\r\n"
1233 using namespace ::testing;
1237 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1239 .WillOnce(Return(ShaderId));
1241 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
1244 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
1247 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
1249 .WillOnce(Return(GL_TRUE));
1251 auto Render = itCreator->second(_pShader);
1252 ASSERT_NE(
nullptr, Render);
1256 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
1261 const auto pShader = Component_t::Make(
1263 { uT(
"entry"), uT(
"ps1") },
1264 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1267 TestCall(pShader,
"ps1");
1271 const auto pData = Component_t::Make(
1273 { uT(
"kind"), uT(
"Shader") },
1274 { uT(
"entry"), uT(
"ps2") },
1275 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1278 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"ps2");
1283TEST_F(OpenGLShader_test, Test_Shader_CreatePixel_MultiTarget)
1285 const ::std::string ShaderData =
1286 "Multi1910031832 ps(Pixel _Value)\r\n";
1288 using GLProxy_t = ::mock::GLProxy;
1290 GLProxy_t::GetInstance() = &GLProxy;
1292 const Tested_t Example{ Data_t{} };
1293 const ITested_t & IExample = Example;
1295 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1296 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1298 const ::mock::GLuint ShaderId = 1908250832;
1300 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
1301 const ::std::string & _Entry)
1303 using namespace ::alicorn::extension::std;
1305 const auto ExpectedShaderText =
1307 "#define COVELLITE_SHADER_GLSL\r\n"
1308 "#define COVELLITE_SHADER_PIXEL\r\n" +
1309 ConvertTextShader(::Predefined + ::Data + ::Input) + ShaderData +
1310 "in Pixel PixelValue;\r\n"
1313 " Covellite_MultiOutPixelColor = " + _Entry +
"(PixelValue).Target;\r\n"
1316 using namespace ::testing;
1320 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1322 .WillOnce(Return(ShaderId));
1324 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
1327 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
1330 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
1332 .WillOnce(Return(GL_TRUE));
1334 auto Render = itCreator->second(_pShader);
1335 ASSERT_NE(
nullptr, Render);
1339 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
1344 const auto pShader = Component_t::Make(
1346 { uT(
"entry"), uT(
"ps") },
1347 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1350 TestCall(pShader,
"ps");
1354 const auto pData = Component_t::Make(
1356 { uT(
"kind"), uT(
"Shader") },
1357 { uT(
"entry"), uT(
"ps") },
1358 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1361 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"ps");
1366TEST_F(OpenGLShader_test, Test_Shader_CreatePixel_NoReturn)
1368 const ::std::string ShaderData =
1369 "void ps(Pixel _Value)\r\n";
1371 using GLProxy_t = ::mock::GLProxy;
1373 GLProxy_t::GetInstance() = &GLProxy;
1375 const Tested_t Example{ Data_t{} };
1376 const ITested_t & IExample = Example;
1378 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1379 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1381 const ::mock::GLuint ShaderId = 1908250832;
1383 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pShader,
1384 const ::std::string & _Entry)
1386 using namespace ::alicorn::extension::std;
1388 const auto ExpectedShaderText =
1390 "#define COVELLITE_SHADER_GLSL\r\n"
1391 "#define COVELLITE_SHADER_PIXEL\r\n" +
1392 ConvertTextShader(::Predefined + ::Data + ::Input) + ShaderData +
1393 "in Pixel PixelValue;\r\n"
1396 " " + _Entry +
"(PixelValue);\r\n"
1399 using namespace ::testing;
1403 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1405 .WillOnce(Return(ShaderId));
1407 EXPECT_CALL(GLProxy, ShaderSource(ShaderId, 1, ExpectedShaderText,
nullptr))
1410 EXPECT_CALL(GLProxy, CompileShader(ShaderId))
1413 EXPECT_CALL(GLProxy, GetShaderiv(ShaderId, GL_COMPILE_STATUS))
1415 .WillOnce(Return(GL_TRUE));
1417 auto Render = itCreator->second(_pShader);
1418 ASSERT_NE(
nullptr, Render);
1422 EXPECT_CALL(GLProxy, DeleteShader(ShaderId))
1427 const auto pShader = Component_t::Make(
1429 { uT(
"entry"), uT(
"ps") },
1430 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1433 TestCall(pShader,
"ps");
1437 const auto pData = Component_t::Make(
1439 { uT(
"kind"), uT(
"Shader") },
1440 { uT(
"entry"), uT(
"ps") },
1441 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1444 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
"ps");
1449TEST_F(OpenGLShader_test, Test_Shader_UsingProgram_DeleteVertexShader)
1451 const ::std::string ShaderData =
1452 "Pixel vs(Vertex _Value)\r\n"
1453 "float4 ps(Pixel _Value)\r\n";
1455 using GLProxy_t = ::mock::GLProxy;
1457 GLProxy_t::GetInstance() = &GLProxy;
1459 const Tested_t Example{ Data_t{} };
1460 const ITested_t & IExample = Example;
1462 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1463 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1465 const auto pVertexShader0 = Component_t::Make(
1467 { uT(
"entry"), uT(
"vs") },
1468 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1471 const auto pVertexShader1 = Component_t::Make(
1473 { uT(
"entry"), uT(
"vs") },
1474 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1477 const auto pPixelShader0 = Component_t::Make(
1479 { uT(
"entry"), uT(
"ps") },
1480 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1483 const auto pPixelShader1 = Component_t::Make(
1485 { uT(
"entry"), uT(
"ps") },
1486 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1489 const ::mock::GLuint VertexShader0Id = 1908251613;
1490 const ::mock::GLuint VertexShader1Id = 1908251614;
1491 const ::mock::GLuint PixelShader0Id = 1908251615;
1492 const ::mock::GLuint PixelShader1Id = 1908251616;
1494 const ::mock::GLuint Program00Id = 1908251641;
1495 const ::mock::GLuint Program01Id = 1908251652;
1496 const ::mock::GLuint Program10Id = 1908251653;
1497 const ::mock::GLuint Program11Id = 1908251654;
1499 using namespace ::testing;
1501 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1503 .WillOnce(Return(PixelShader0Id))
1504 .WillOnce(Return(PixelShader1Id));
1506 EXPECT_CALL(GLProxy, CreateShader(GL_VERTEX_SHADER))
1508 .WillOnce(Return(VertexShader0Id))
1509 .WillOnce(Return(VertexShader1Id));
1511 auto PixelShaderRender0 = itCreator->second(pPixelShader0);
1512 ASSERT_NE(
nullptr, PixelShaderRender0);
1514 auto PixelShaderRender1 = itCreator->second(pPixelShader1);
1515 ASSERT_NE(
nullptr, PixelShaderRender1);
1517 auto VertexShaderRender0 = itCreator->second(pVertexShader0);
1518 ASSERT_NE(
nullptr, VertexShaderRender0);
1523 auto VertexShaderRender1 = itCreator->second(pVertexShader1);
1524 ASSERT_NE(
nullptr, VertexShaderRender1);
1526 const auto TestCreateProgram = [&](
1527 const ::mock::GLuint _ProgramId,
1528 const ::mock::GLuint _VertexShaderId,
1529 const ::mock::GLuint _PixelShaderId)
1531 EXPECT_CALL(GLProxy, CreateProgram())
1533 .WillOnce(Return(_ProgramId));
1535 EXPECT_CALL(GLProxy, AttachShader(_ProgramId, _VertexShaderId))
1538 EXPECT_CALL(GLProxy, AttachShader(_ProgramId, _PixelShaderId))
1541 EXPECT_CALL(GLProxy, LinkProgram(_ProgramId))
1544 EXPECT_CALL(GLProxy, GetProgramiv(_ProgramId, GL_LINK_STATUS))
1546 .WillOnce(Return(GL_TRUE));
1551 EXPECT_CALL(GLProxy, CreateProgram())
1554 VertexShaderRender0();
1556 TestCreateProgram(Program00Id, VertexShader0Id, PixelShader0Id);
1558 EXPECT_CALL(GLProxy, UseProgram(Program00Id))
1561 PixelShaderRender0();
1563 TestCreateProgram(Program10Id, VertexShader1Id, PixelShader0Id);
1565 EXPECT_CALL(GLProxy, UseProgram(Program10Id))
1568 VertexShaderRender1();
1570 TestCreateProgram(Program11Id, VertexShader1Id, PixelShader1Id);
1572 EXPECT_CALL(GLProxy, UseProgram(Program11Id))
1575 PixelShaderRender1();
1577 TestCreateProgram(Program01Id, VertexShader0Id, PixelShader1Id);
1579 EXPECT_CALL(GLProxy, UseProgram(Program01Id))
1582 VertexShaderRender0();
1586 EXPECT_CALL(GLProxy, CreateProgram())
1589 EXPECT_CALL(GLProxy, UseProgram(Program00Id))
1592 PixelShaderRender0();
1594 EXPECT_CALL(GLProxy, CreateProgram())
1597 EXPECT_CALL(GLProxy, UseProgram(Program10Id))
1600 VertexShaderRender1();
1602 EXPECT_CALL(GLProxy, CreateProgram())
1605 EXPECT_CALL(GLProxy, UseProgram(Program11Id))
1608 PixelShaderRender1();
1610 EXPECT_CALL(GLProxy, CreateProgram())
1613 EXPECT_CALL(GLProxy, UseProgram(Program01Id))
1616 VertexShaderRender0();
1618 EXPECT_CALL(GLProxy, DeleteProgram(Program10Id))
1621 EXPECT_CALL(GLProxy, DeleteProgram(Program11Id))
1624 EXPECT_CALL(GLProxy, DeleteShader(VertexShader1Id))
1628 EXPECT_CALL(GLProxy, DeleteProgram(Program00Id))
1631 EXPECT_CALL(GLProxy, DeleteProgram(Program01Id))
1634 EXPECT_CALL(GLProxy, DeleteShader(VertexShader0Id))
1637 EXPECT_CALL(GLProxy, DeleteShader(PixelShader1Id))
1640 EXPECT_CALL(GLProxy, DeleteShader(PixelShader0Id))
1645TEST_F(OpenGLShader_test, Test_Shader_UsingProgram_DeletePixelShader)
1647 const ::std::string ShaderData =
1648 "Pixel vs(Vertex _Value)\r\n"
1649 "float4 ps(Pixel _Value)\r\n";
1651 using GLProxy_t = ::mock::GLProxy;
1653 GLProxy_t::GetInstance() = &GLProxy;
1655 const Tested_t Example{ Data_t{} };
1656 const ITested_t & IExample = Example;
1658 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1659 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1661 const auto pVertexShader0 = Component_t::Make(
1663 { uT(
"entry"), uT(
"vs") },
1664 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1667 const auto pVertexShader1 = Component_t::Make(
1669 { uT(
"entry"), uT(
"vs") },
1670 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1673 const auto pPixelShader0 = Component_t::Make(
1675 { uT(
"entry"), uT(
"ps") },
1676 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1679 const auto pPixelShader1 = Component_t::Make(
1681 { uT(
"entry"), uT(
"ps") },
1682 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1685 const ::mock::GLuint VertexShader0Id = 1908251613;
1686 const ::mock::GLuint VertexShader1Id = 1908251614;
1687 const ::mock::GLuint PixelShader0Id = 1908251615;
1688 const ::mock::GLuint PixelShader1Id = 1908251616;
1690 const ::mock::GLuint Program00Id = 1908251641;
1691 const ::mock::GLuint Program01Id = 1908251652;
1692 const ::mock::GLuint Program10Id = 1908251653;
1693 const ::mock::GLuint Program11Id = 1908251654;
1695 using namespace ::testing;
1697 EXPECT_CALL(GLProxy, CreateShader(GL_VERTEX_SHADER))
1699 .WillOnce(Return(VertexShader0Id))
1700 .WillOnce(Return(VertexShader1Id));
1702 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1704 .WillOnce(Return(PixelShader0Id))
1705 .WillOnce(Return(PixelShader1Id));
1707 auto VertexShaderRender0 = itCreator->second(pVertexShader0);
1708 ASSERT_NE(
nullptr, VertexShaderRender0);
1710 auto VertexShaderRender1 = itCreator->second(pVertexShader1);
1711 ASSERT_NE(
nullptr, VertexShaderRender1);
1713 auto PixelShaderRender0 = itCreator->second(pPixelShader0);
1714 ASSERT_NE(
nullptr, PixelShaderRender0);
1719 auto PixelShaderRender1 = itCreator->second(pPixelShader1);
1720 ASSERT_NE(
nullptr, PixelShaderRender1);
1722 const auto TestCreateProgram = [&](
1723 const ::mock::GLuint _ProgramId,
1724 const ::mock::GLuint _VertexShaderId,
1725 const ::mock::GLuint _PixelShaderId)
1727 EXPECT_CALL(GLProxy, CreateProgram())
1729 .WillOnce(Return(_ProgramId));
1731 EXPECT_CALL(GLProxy, AttachShader(_ProgramId, _VertexShaderId))
1734 EXPECT_CALL(GLProxy, AttachShader(_ProgramId, _PixelShaderId))
1737 EXPECT_CALL(GLProxy, LinkProgram(_ProgramId))
1740 EXPECT_CALL(GLProxy, GetProgramiv(_ProgramId, GL_LINK_STATUS))
1742 .WillOnce(Return(GL_TRUE));
1747 EXPECT_CALL(GLProxy, CreateProgram())
1750 VertexShaderRender0();
1752 TestCreateProgram(Program00Id, VertexShader0Id, PixelShader0Id);
1754 EXPECT_CALL(GLProxy, UseProgram(Program00Id))
1757 PixelShaderRender0();
1759 TestCreateProgram(Program10Id, VertexShader1Id, PixelShader0Id);
1761 EXPECT_CALL(GLProxy, UseProgram(Program10Id))
1764 VertexShaderRender1();
1766 TestCreateProgram(Program11Id, VertexShader1Id, PixelShader1Id);
1768 EXPECT_CALL(GLProxy, UseProgram(Program11Id))
1771 PixelShaderRender1();
1773 TestCreateProgram(Program01Id, VertexShader0Id, PixelShader1Id);
1775 EXPECT_CALL(GLProxy, UseProgram(Program01Id))
1778 VertexShaderRender0();
1782 EXPECT_CALL(GLProxy, CreateProgram())
1785 EXPECT_CALL(GLProxy, UseProgram(Program00Id))
1788 PixelShaderRender0();
1790 EXPECT_CALL(GLProxy, CreateProgram())
1793 EXPECT_CALL(GLProxy, UseProgram(Program10Id))
1796 VertexShaderRender1();
1798 EXPECT_CALL(GLProxy, CreateProgram())
1801 EXPECT_CALL(GLProxy, UseProgram(Program11Id))
1804 PixelShaderRender1();
1806 EXPECT_CALL(GLProxy, CreateProgram())
1809 EXPECT_CALL(GLProxy, UseProgram(Program01Id))
1812 VertexShaderRender0();
1814 EXPECT_CALL(GLProxy, DeleteProgram(Program01Id))
1817 EXPECT_CALL(GLProxy, DeleteProgram(Program11Id))
1820 EXPECT_CALL(GLProxy, DeleteShader(PixelShader1Id))
1824 EXPECT_CALL(GLProxy, DeleteProgram(Program00Id))
1827 EXPECT_CALL(GLProxy, DeleteProgram(Program10Id))
1830 EXPECT_CALL(GLProxy, DeleteShader(PixelShader0Id))
1833 EXPECT_CALL(GLProxy, DeleteShader(VertexShader1Id))
1836 EXPECT_CALL(GLProxy, DeleteShader(VertexShader0Id))
1841TEST_F(OpenGLShader_test, Test_Shader_UsingProgram_LinkProgramFail)
1843 using namespace ::alicorn::extension::std;
1845 const ::std::string ShaderData =
1846 "Pixel vs(Vertex _Value)\r\n"
1847 "float4 ps(Pixel _Value)\r\n";
1849 const ::std::string ErrorText =
"Error1908291952";
1850 const auto LinkFailLogText = uT(
"Warning: Link program fail: ") +
1851 string_cast<String, Encoding::UTF8>(ErrorText);
1853 using LoggerProxy_t = ::mock::alicorn::modules::logger::LoggerProxy;
1854 LoggerProxy_t LoggerProxy;
1855 LoggerProxy_t::GetInstance() = &LoggerProxy;
1857 using GLProxy_t = ::mock::GLProxy;
1859 GLProxy_t::GetInstance() = &GLProxy;
1861 const Tested_t Example{ Data_t{} };
1862 const ITested_t & IExample = Example;
1864 auto itCreator = IExample.GetCreators().find(uT(
"Shader"));
1865 ASSERT_NE(IExample.GetCreators().end(), itCreator);
1867 const auto pVertexShader0 = Component_t::Make(
1869 { uT(
"entry"), uT(
"vs") },
1870 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1873 const auto pVertexShader1 = Component_t::Make(
1875 { uT(
"entry"), uT(
"vs") },
1876 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1879 const auto pPixelShader0 = Component_t::Make(
1881 { uT(
"entry"), uT(
"ps") },
1882 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1885 const auto pPixelShader1 = Component_t::Make(
1887 { uT(
"entry"), uT(
"ps") },
1888 { uT(
"content"), ::std::vector<uint8_t>{ ShaderData.begin(), ShaderData.end() } },
1891 const ::mock::GLuint VertexShader0Id = 1908251613;
1892 const ::mock::GLuint VertexShader1Id = 1908251614;
1893 const ::mock::GLuint PixelShader0Id = 1908251615;
1894 const ::mock::GLuint PixelShader1Id = 1908251616;
1896 const ::mock::GLuint Program00Id = 1908251641;
1897 const ::mock::GLuint Program01Id = 1908251652;
1898 const ::mock::GLuint Program10Id = 1908251653;
1899 const ::mock::GLuint Program11Id = 1908251654;
1901 using namespace ::testing;
1903 EXPECT_CALL(GLProxy, CreateShader(GL_VERTEX_SHADER))
1905 .WillOnce(Return(VertexShader0Id))
1906 .WillOnce(Return(VertexShader1Id));
1908 EXPECT_CALL(GLProxy, CreateShader(GL_FRAGMENT_SHADER))
1910 .WillOnce(Return(PixelShader0Id))
1911 .WillOnce(Return(PixelShader1Id));
1913 auto VertexShaderRender0 = itCreator->second(pVertexShader0);
1914 ASSERT_NE(
nullptr, VertexShaderRender0);
1916 auto VertexShaderRender1 = itCreator->second(pVertexShader1);
1917 ASSERT_NE(
nullptr, VertexShaderRender1);
1919 auto PixelShaderRender0 = itCreator->second(pPixelShader0);
1920 ASSERT_NE(
nullptr, PixelShaderRender0);
1925 auto PixelShaderRender1 = itCreator->second(pPixelShader1);
1926 ASSERT_NE(
nullptr, PixelShaderRender1);
1928 const auto TestCreateProgram = [&](
1929 const ::mock::GLuint _ProgramId,
1930 const ::mock::GLuint _VertexShaderId,
1931 const ::mock::GLuint _PixelShaderId,
1932 const Render_t & _Render)
1934 EXPECT_CALL(GLProxy, CreateProgram())
1936 .WillOnce(Return(_ProgramId));
1938 EXPECT_CALL(GLProxy, AttachShader(_ProgramId, _VertexShaderId))
1941 EXPECT_CALL(GLProxy, AttachShader(_ProgramId, _PixelShaderId))
1944 EXPECT_CALL(GLProxy, LinkProgram(_ProgramId))
1947 EXPECT_CALL(GLProxy, GetProgramiv(_ProgramId, GL_LINK_STATUS))
1949 .WillOnce(Return(GL_FALSE));
1951 EXPECT_CALL(GLProxy, GetProgramInfoLog(_ProgramId, 512,
nullptr))
1953 .WillOnce(Return(ErrorText.c_str()));
1955 EXPECT_CALL(LoggerProxy, ToLog(Eq(LinkFailLogText)))
1961 EXPECT_CALL(GLProxy, CreateProgram())
1964 EXPECT_CALL(GLProxy, UseProgram(_))
1967 VertexShaderRender0();
1969 TestCreateProgram(Program00Id, VertexShader0Id, PixelShader0Id,
1970 PixelShaderRender0);
1972 TestCreateProgram(Program10Id, VertexShader1Id, PixelShader0Id,
1973 VertexShaderRender1);
1975 TestCreateProgram(Program11Id, VertexShader1Id, PixelShader1Id,
1976 PixelShaderRender1);
1978 TestCreateProgram(Program01Id, VertexShader0Id, PixelShader1Id,
1979 VertexShaderRender0);
1981 EXPECT_CALL(GLProxy, DeleteProgram(Program01Id))
1984 EXPECT_CALL(GLProxy, DeleteProgram(Program11Id))
1988 EXPECT_CALL(GLProxy, DeleteProgram(Program00Id))
1991 EXPECT_CALL(GLProxy, DeleteProgram(Program10Id))
1996TEST_F(OpenGLShader_test, Test_Texture_Default)
1998 using GLProxy_t = ::mock::GLProxy;
2000 GLProxy_t::GetInstance() = &GLProxy;
2002 const Tested_t Example{ Data_t{} };
2003 const ITested_t & IExample = Example;
2005 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
2006 ASSERT_NE(IExample.GetCreators().end(), itCreator);
2008 const ::mock::GLuint TextureId = 1812181809;
2009 const ::mock::GLint ProgramId = 1908221258;
2010 const ::mock::GLint LocationId = 1908221259;
2012 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pTexture,
2013 const ::std::vector<uint8_t> & _Source,
const int _Width,
const int _Height)
2015 using namespace ::testing;
2019 EXPECT_CALL(GLProxy, GenTextures(1))
2021 .WillOnce(Return(TextureId));
2023 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2026 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
2028 GL_RGBA, GL_UNSIGNED_BYTE, _Source))
2031 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
2034 EXPECT_CALL(GLProxy, GetError())
2036 .WillOnce(Return(GL_NO_ERROR));
2038 auto Render = itCreator->second(_pTexture);
2039 ASSERT_NE(
nullptr, Render);
2041 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0))
2044 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2047 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
2049 .WillOnce(Return(&ProgramId));
2051 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"TexDiffuse")))
2053 .WillOnce(Return(LocationId));
2055 EXPECT_CALL(GLProxy, Uniform1i(LocationId, 0))
2060 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
2065 ::std::vector<uint8_t> Source =
2067 0x20, 0x06, 0x15, 0x12, 0x28,
2068 0x20, 0x06, 0x15, 0x12, 0x28,
2069 0x20, 0x06, 0x15, 0x12, 0x28,
2070 0x20, 0x06, 0x15, 0x12, 0x28,
2071 0x20, 0x06, 0x15, 0x12, 0x28,
2072 0x20, 0x06, 0x15, 0x12, 0x28,
2073 0x20, 0x06, 0x15, 0x12, 0x28,
2074 0x20, 0x06, 0x15, 0x12, 0x28,
2076 IntroduceBufferSize(Source);
2078 const int Width = 1812181807;
2079 const int Height = 1812181808;
2081 const auto pTexture = Component_t::Make(
2083 { uT(
"content"), Source },
2084 { uT(
"width"), Width },
2085 { uT(
"height"), Height },
2088 TestCall(pTexture, Source, Width, Height);
2092 ::std::vector<uint8_t> Source =
2094 0x20, 0x06, 0x15, 0x12, 0x29,
2095 0x20, 0x06, 0x15, 0x12, 0x29,
2096 0x20, 0x06, 0x15, 0x12, 0x29,
2097 0x20, 0x06, 0x15, 0x12, 0x29,
2098 0x20, 0x06, 0x15, 0x12, 0x29,
2100 IntroduceBufferSize(Source);
2102 const int Width = 1907251057;
2103 const int Height = 1907251058;
2105 const auto pData = Component_t::Make(
2107 { uT(
"kind"), uT(
"Texture") },
2108 { uT(
"content"), Source },
2109 { uT(
"width"), Width },
2110 { uT(
"height"), Height },
2113 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }), Source, Width, Height);
2118TEST_F(OpenGLShader_test, Test_Texture_NameAndIndex)
2120 using GLProxy_t = ::mock::GLProxy;
2122 GLProxy_t::GetInstance() = &GLProxy;
2124 const Tested_t Example{ Data_t{} };
2125 const ITested_t & IExample = Example;
2127 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
2128 ASSERT_NE(IExample.GetCreators().end(), itCreator);
2130 const ::mock::GLuint TextureId = 1908221839;
2131 const ::mock::GLint ProgramId = 1908221840;
2132 const ::mock::GLint LocationId = 1908221841;
2134 const auto TestCall = [&](
2135 const Component_t::ComponentPtr_t & _pTexture,
2136 const ::std::vector<uint8_t> & _Source,
2137 const int _Width,
const int _Height,
2138 const ::std::size_t _Index,
2139 const ::std::string & _TexName)
2141 const auto Index =
static_cast<::mock::GLint
>(_Index);
2143 using namespace ::testing;
2147 EXPECT_CALL(GLProxy, GenTextures(1))
2149 .WillOnce(Return(TextureId));
2151 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2154 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
2156 GL_RGBA, GL_UNSIGNED_BYTE, _Source))
2159 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
2162 EXPECT_CALL(GLProxy, GetError())
2164 .WillOnce(Return(GL_NO_ERROR));
2166 EXPECT_CALL(GLProxy, GenFramebuffers(1))
2169 auto Render = itCreator->second(_pTexture);
2170 ASSERT_NE(
nullptr, Render);
2172 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
2175 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2178 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
2180 .WillOnce(Return(&ProgramId));
2182 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
2184 .WillOnce(Return(LocationId));
2186 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
2189 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
2194 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
2198 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
2200 { uT(
"TexEnvironment"),
"TexEnvironment" },
2201 { uT(
"TexReflection"),
"TexReflection" },
2202 { uT(
"TexBaseColor"),
"TexBaseColor" },
2205 for (
int Index = 0; Index < Names.size(); Index++)
2207 ::std::vector<uint8_t> Source =
2209 0x20, 0x06, 0x15, 0x12, 0x30,
2210 0x20, 0x06, 0x15, 0x12, 0x30,
2211 0x20, 0x06, 0x15, 0x12, 0x30,
2212 0x20, 0x06, 0x15, 0x12, 0x30,
2213 0x20, 0x06, 0x15, 0x12, 0x30,
2215 IntroduceBufferSize(Source);
2218 const int Width = 1908221843;
2219 const int Height = 1908221844;
2221 const auto pTexture = Component_t::Make(
2223 { uT(
"content"), Source },
2224 { uT(
"width"), Width },
2225 { uT(
"height"), Height },
2226 { uT(
"name"), Names[Index].first },
2227 { uT(
"index"), Index },
2231 Source, Width, Height, Index, Names[Index].second);
2235 const int Width = 1908221845;
2236 const int Height = 1908221847;
2238 const auto pData = Component_t::Make(
2240 { uT(
"kind"), uT(
"Texture") },
2241 { uT(
"content"), Source },
2242 { uT(
"width"), Width },
2243 { uT(
"height"), Height },
2244 { uT(
"name"), Names[Index].first },
2245 { uT(
"index"), Index },
2248 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2249 Source, Width, Height, Index, Names[Index].second);
2253 const int Width = 1908221843;
2254 const int Height = 1908221844;
2256 const auto pTexture = Component_t::Make(
2258 { uT(
"content"), Source },
2259 { uT(
"width"), Width },
2260 { uT(
"height"), Height },
2261 { uT(
"name"), Names[Index].first },
2262 { uT(
"index"), Index },
2263 { uT(
"mipmapping"),
false },
2267 Source, Width, Height, Index, Names[Index].second);
2271 const int Width = 1908221845;
2272 const int Height = 1908221847;
2274 const auto pData = Component_t::Make(
2276 { uT(
"kind"), uT(
"Texture") },
2277 { uT(
"content"), Source },
2278 { uT(
"width"), Width },
2279 { uT(
"height"), Height },
2280 { uT(
"name"), Names[Index].first },
2281 { uT(
"index"), Index },
2282 { uT(
"mipmapping"),
false },
2285 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2286 Source, Width, Height, Index, Names[Index].second);
2289 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
2291 { uT(
"albedo"),
"TexAlbedo" },
2292 { uT(
"metalness"),
"TexMetalness" },
2293 { uT(
"roughness"),
"TexRoughness" },
2294 { uT(
"normal"),
"TexNormal" },
2295 { uT(
"occlusion"),
"TexOcclusion" },
2299 for (::std::size_t i = 0; i < Destinations.size(); i++)
2302 const int Width = 1908221843;
2303 const int Height = 1908221844;
2305 const auto pTexture = Component_t::Make(
2307 { uT(
"content"), Source },
2308 { uT(
"width"), Width },
2309 { uT(
"height"), Height },
2310 { uT(
"name"), Names[Index].first },
2311 { uT(
"index"), Index },
2312 { uT(
"destination"), Destinations[i].first },
2316 Source, Width, Height, Index, Names[Index].second);
2320 const int Width = 1908221845;
2321 const int Height = 1908221847;
2323 const auto pData = Component_t::Make(
2325 { uT(
"kind"), uT(
"Texture") },
2326 { uT(
"content"), Source },
2327 { uT(
"width"), Width },
2328 { uT(
"height"), Height },
2329 { uT(
"name"), Names[Index].first },
2330 { uT(
"index"), Index },
2331 { uT(
"destination"), Destinations[i].first },
2334 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2335 Source, Width, Height, Index, Names[Index].second);
2339 const int Width = 1908221843;
2340 const int Height = 1908221844;
2342 const auto pTexture = Component_t::Make(
2344 { uT(
"content"), Source },
2345 { uT(
"width"), Width },
2346 { uT(
"height"), Height },
2347 { uT(
"name"), Names[Index].first },
2348 { uT(
"index"), Index },
2349 { uT(
"destination"), Destinations[i].first },
2350 { uT(
"mipmapping"),
false },
2354 Source, Width, Height, Index, Names[Index].second);
2358 const int Width = 1908221845;
2359 const int Height = 1908221847;
2361 const auto pData = Component_t::Make(
2363 { uT(
"kind"), uT(
"Texture") },
2364 { uT(
"content"), Source },
2365 { uT(
"width"), Width },
2366 { uT(
"height"), Height },
2367 { uT(
"name"), Names[Index].first },
2368 { uT(
"index"), Index },
2369 { uT(
"destination"), Destinations[i].first },
2370 { uT(
"mipmapping"),
false },
2373 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2374 Source, Width, Height, Index, Names[Index].second);
2381TEST_F(OpenGLShader_test, Test_Texture_NameAndIndex_Capacity16)
2383 using GLProxy_t = ::mock::GLProxy;
2385 GLProxy_t::GetInstance() = &GLProxy;
2387 const Tested_t Example{ Data_t{} };
2388 const ITested_t & IExample = Example;
2390 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
2391 ASSERT_NE(IExample.GetCreators().end(), itCreator);
2393 const ::mock::GLuint TextureId = 1908221839;
2394 const ::mock::GLint ProgramId = 1908221840;
2395 const ::mock::GLint LocationId = 1908221841;
2397 const auto TestCall = [&](
2398 const Component_t::ComponentPtr_t & _pTexture,
2399 const ::std::vector<uint8_t> & _Source,
2400 const int _Width,
const int _Height,
2401 const ::std::size_t _Index,
2402 const ::std::string & _TexName)
2404 const auto Index =
static_cast<::mock::GLint
>(_Index);
2406 using namespace ::testing;
2410 EXPECT_CALL(GLProxy, GenTextures(1))
2412 .WillOnce(Return(TextureId));
2414 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2417 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
2419 GL_RGBA, GL_HALF_FLOAT, _Source))
2422 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
2425 EXPECT_CALL(GLProxy, GetError())
2427 .WillOnce(Return(GL_NO_ERROR));
2429 EXPECT_CALL(GLProxy, GenFramebuffers(1))
2432 auto Render = itCreator->second(_pTexture);
2433 ASSERT_NE(
nullptr, Render);
2435 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
2438 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2441 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
2443 .WillOnce(Return(&ProgramId));
2445 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
2447 .WillOnce(Return(LocationId));
2449 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
2452 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
2457 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
2461 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
2463 { uT(
"TexEnvironment"),
"TexEnvironment" },
2464 { uT(
"TexReflection"),
"TexReflection" },
2465 { uT(
"TexBaseColor"),
"TexBaseColor" },
2468 for (
int Index = 0; Index < Names.size(); Index++)
2470 ::std::vector<uint8_t> Source =
2472 0x20, 0x06, 0x15, 0x12, 0x30,
2473 0x20, 0x06, 0x15, 0x12, 0x30,
2474 0x20, 0x06, 0x15, 0x12, 0x30,
2475 0x20, 0x06, 0x15, 0x12, 0x30,
2476 0x20, 0x06, 0x15, 0x12, 0x30,
2478 IntroduceBufferSize(Source);
2481 const int Width = 1908221843;
2482 const int Height = 1908221844;
2484 const auto pTexture = Component_t::Make(
2486 { uT(
"content"), Source },
2487 { uT(
"width"), Width },
2488 { uT(
"height"), Height },
2489 { uT(
"name"), Names[Index].first },
2490 { uT(
"index"), Index },
2491 { uT(
"capacity"), 16 },
2495 Source, Width, Height, Index, Names[Index].second);
2499 const int Width = 1908221845;
2500 const int Height = 1908221847;
2502 const auto pData = Component_t::Make(
2504 { uT(
"kind"), uT(
"Texture") },
2505 { uT(
"content"), Source },
2506 { uT(
"width"), Width },
2507 { uT(
"height"), Height },
2508 { uT(
"name"), Names[Index].first },
2509 { uT(
"index"), Index },
2510 { uT(
"capacity"), 16 },
2513 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2514 Source, Width, Height, Index, Names[Index].second);
2518 const int Width = 1908221843;
2519 const int Height = 1908221844;
2521 const auto pTexture = Component_t::Make(
2523 { uT(
"content"), Source },
2524 { uT(
"width"), Width },
2525 { uT(
"height"), Height },
2526 { uT(
"name"), Names[Index].first },
2527 { uT(
"index"), Index },
2528 { uT(
"mipmapping"),
false },
2529 { uT(
"capacity"), 16 },
2533 Source, Width, Height, Index, Names[Index].second);
2537 const int Width = 1908221845;
2538 const int Height = 1908221847;
2540 const auto pData = Component_t::Make(
2542 { uT(
"kind"), uT(
"Texture") },
2543 { uT(
"content"), Source },
2544 { uT(
"width"), Width },
2545 { uT(
"height"), Height },
2546 { uT(
"name"), Names[Index].first },
2547 { uT(
"index"), Index },
2548 { uT(
"mipmapping"),
false },
2549 { uT(
"capacity"), 16 },
2552 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2553 Source, Width, Height, Index, Names[Index].second);
2556 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
2558 { uT(
"albedo"),
"TexAlbedo" },
2559 { uT(
"metalness"),
"TexMetalness" },
2560 { uT(
"roughness"),
"TexRoughness" },
2561 { uT(
"normal"),
"TexNormal" },
2562 { uT(
"occlusion"),
"TexOcclusion" },
2566 for (::std::size_t i = 0; i < Destinations.size(); i++)
2569 const int Width = 1908221843;
2570 const int Height = 1908221844;
2572 const auto pTexture = Component_t::Make(
2574 { uT(
"content"), Source },
2575 { uT(
"width"), Width },
2576 { uT(
"height"), Height },
2577 { uT(
"name"), Names[Index].first },
2578 { uT(
"index"), Index },
2579 { uT(
"destination"), Destinations[i].first },
2580 { uT(
"capacity"), 16 },
2584 Source, Width, Height, Index, Names[Index].second);
2588 const int Width = 1908221845;
2589 const int Height = 1908221847;
2591 const auto pData = Component_t::Make(
2593 { uT(
"kind"), uT(
"Texture") },
2594 { uT(
"content"), Source },
2595 { uT(
"width"), Width },
2596 { uT(
"height"), Height },
2597 { uT(
"name"), Names[Index].first },
2598 { uT(
"index"), Index },
2599 { uT(
"destination"), Destinations[i].first },
2600 { uT(
"capacity"), 16 },
2603 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2604 Source, Width, Height, Index, Names[Index].second);
2608 const int Width = 1908221843;
2609 const int Height = 1908221844;
2611 const auto pTexture = Component_t::Make(
2613 { uT(
"content"), Source },
2614 { uT(
"width"), Width },
2615 { uT(
"height"), Height },
2616 { uT(
"name"), Names[Index].first },
2617 { uT(
"index"), Index },
2618 { uT(
"destination"), Destinations[i].first },
2619 { uT(
"mipmapping"),
false },
2620 { uT(
"capacity"), 16 },
2624 Source, Width, Height, Index, Names[Index].second);
2628 const int Width = 1908221845;
2629 const int Height = 1908221847;
2631 const auto pData = Component_t::Make(
2633 { uT(
"kind"), uT(
"Texture") },
2634 { uT(
"content"), Source },
2635 { uT(
"width"), Width },
2636 { uT(
"height"), Height },
2637 { uT(
"name"), Names[Index].first },
2638 { uT(
"index"), Index },
2639 { uT(
"destination"), Destinations[i].first },
2640 { uT(
"mipmapping"),
false },
2641 { uT(
"capacity"), 16 },
2644 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2645 Source, Width, Height, Index, Names[Index].second);
2652TEST_F(OpenGLShader_test, Test_Texture_NameAndIndex_Capacity32)
2654 using GLProxy_t = ::mock::GLProxy;
2656 GLProxy_t::GetInstance() = &GLProxy;
2658 const Tested_t Example{ Data_t{} };
2659 const ITested_t & IExample = Example;
2661 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
2662 ASSERT_NE(IExample.GetCreators().end(), itCreator);
2664 const ::mock::GLuint TextureId = 1908221839;
2665 const ::mock::GLint ProgramId = 1908221840;
2666 const ::mock::GLint LocationId = 1908221841;
2668 const auto TestCall = [&](
2669 const Component_t::ComponentPtr_t & _pTexture,
2670 const ::std::vector<uint8_t> & _Source,
2671 const int _Width,
const int _Height,
2672 const ::std::size_t _Index,
2673 const ::std::string & _TexName)
2675 const auto Index =
static_cast<::mock::GLint
>(_Index);
2677 using namespace ::testing;
2681 EXPECT_CALL(GLProxy, GenTextures(1))
2683 .WillOnce(Return(TextureId));
2685 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2688 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
2690 GL_RGBA, GL_FLOAT, _Source))
2693 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
2696 EXPECT_CALL(GLProxy, GetError())
2698 .WillOnce(Return(GL_NO_ERROR));
2700 EXPECT_CALL(GLProxy, GenFramebuffers(1))
2703 auto Render = itCreator->second(_pTexture);
2704 ASSERT_NE(
nullptr, Render);
2706 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
2709 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2712 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
2714 .WillOnce(Return(&ProgramId));
2716 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
2718 .WillOnce(Return(LocationId));
2720 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
2723 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
2728 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
2732 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
2734 { uT(
"TexEnvironment"),
"TexEnvironment" },
2735 { uT(
"TexReflection"),
"TexReflection" },
2736 { uT(
"TexBaseColor"),
"TexBaseColor" },
2739 for (
int Index = 0; Index < Names.size(); Index++)
2741 ::std::vector<uint8_t> Source =
2743 0x20, 0x06, 0x15, 0x12, 0x30,
2744 0x20, 0x06, 0x15, 0x12, 0x30,
2745 0x20, 0x06, 0x15, 0x12, 0x30,
2746 0x20, 0x06, 0x15, 0x12, 0x30,
2747 0x20, 0x06, 0x15, 0x12, 0x30,
2749 IntroduceBufferSize(Source);
2752 const int Width = 1908221843;
2753 const int Height = 1908221844;
2755 const auto pTexture = Component_t::Make(
2757 { uT(
"content"), Source },
2758 { uT(
"width"), Width },
2759 { uT(
"height"), Height },
2760 { uT(
"name"), Names[Index].first },
2761 { uT(
"index"), Index },
2762 { uT(
"capacity"), 32 },
2766 Source, Width, Height, Index, Names[Index].second);
2770 const int Width = 1908221845;
2771 const int Height = 1908221847;
2773 const auto pData = Component_t::Make(
2775 { uT(
"kind"), uT(
"Texture") },
2776 { uT(
"content"), Source },
2777 { uT(
"width"), Width },
2778 { uT(
"height"), Height },
2779 { uT(
"name"), Names[Index].first },
2780 { uT(
"index"), Index },
2781 { uT(
"capacity"), 32 },
2784 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2785 Source, Width, Height, Index, Names[Index].second);
2789 const int Width = 1908221843;
2790 const int Height = 1908221844;
2792 const auto pTexture = Component_t::Make(
2794 { uT(
"content"), Source },
2795 { uT(
"width"), Width },
2796 { uT(
"height"), Height },
2797 { uT(
"name"), Names[Index].first },
2798 { uT(
"index"), Index },
2799 { uT(
"mipmapping"),
false },
2800 { uT(
"capacity"), 32 },
2804 Source, Width, Height, Index, Names[Index].second);
2808 const int Width = 1908221845;
2809 const int Height = 1908221847;
2811 const auto pData = Component_t::Make(
2813 { uT(
"kind"), uT(
"Texture") },
2814 { uT(
"content"), Source },
2815 { uT(
"width"), Width },
2816 { uT(
"height"), Height },
2817 { uT(
"name"), Names[Index].first },
2818 { uT(
"index"), Index },
2819 { uT(
"mipmapping"),
false },
2820 { uT(
"capacity"), 32 },
2823 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2824 Source, Width, Height, Index, Names[Index].second);
2827 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
2829 { uT(
"albedo"),
"TexAlbedo" },
2830 { uT(
"metalness"),
"TexMetalness" },
2831 { uT(
"roughness"),
"TexRoughness" },
2832 { uT(
"normal"),
"TexNormal" },
2833 { uT(
"occlusion"),
"TexOcclusion" },
2837 for (::std::size_t i = 0; i < Destinations.size(); i++)
2840 const int Width = 1908221843;
2841 const int Height = 1908221844;
2843 const auto pTexture = Component_t::Make(
2845 { uT(
"content"), Source },
2846 { uT(
"width"), Width },
2847 { uT(
"height"), Height },
2848 { uT(
"name"), Names[Index].first },
2849 { uT(
"index"), Index },
2850 { uT(
"destination"), Destinations[i].first },
2851 { uT(
"capacity"), 32 },
2855 Source, Width, Height, Index, Names[Index].second);
2859 const int Width = 1908221845;
2860 const int Height = 1908221847;
2862 const auto pData = Component_t::Make(
2864 { uT(
"kind"), uT(
"Texture") },
2865 { uT(
"content"), Source },
2866 { uT(
"width"), Width },
2867 { uT(
"height"), Height },
2868 { uT(
"name"), Names[Index].first },
2869 { uT(
"index"), Index },
2870 { uT(
"destination"), Destinations[i].first },
2871 { uT(
"capacity"), 32 },
2874 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2875 Source, Width, Height, Index, Names[Index].second);
2879 const int Width = 1908221843;
2880 const int Height = 1908221844;
2882 const auto pTexture = Component_t::Make(
2884 { uT(
"content"), Source },
2885 { uT(
"width"), Width },
2886 { uT(
"height"), Height },
2887 { uT(
"name"), Names[Index].first },
2888 { uT(
"index"), Index },
2889 { uT(
"destination"), Destinations[i].first },
2890 { uT(
"mipmapping"),
false },
2891 { uT(
"capacity"), 32 },
2895 Source, Width, Height, Index, Names[Index].second);
2899 const int Width = 1908221845;
2900 const int Height = 1908221847;
2902 const auto pData = Component_t::Make(
2904 { uT(
"kind"), uT(
"Texture") },
2905 { uT(
"content"), Source },
2906 { uT(
"width"), Width },
2907 { uT(
"height"), Height },
2908 { uT(
"name"), Names[Index].first },
2909 { uT(
"index"), Index },
2910 { uT(
"destination"), Destinations[i].first },
2911 { uT(
"mipmapping"),
false },
2912 { uT(
"capacity"), 32 },
2915 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
2916 Source, Width, Height, Index, Names[Index].second);
2923TEST_F(OpenGLShader_test, Test_Texture_Destination)
2925 using GLProxy_t = ::mock::GLProxy;
2927 GLProxy_t::GetInstance() = &GLProxy;
2929 const Tested_t Example{ Data_t{} };
2930 const ITested_t & IExample = Example;
2932 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
2933 ASSERT_NE(IExample.GetCreators().end(), itCreator);
2935 const ::mock::GLuint TextureId = 1908221839;
2936 const ::mock::GLint ProgramId = 1908221840;
2937 const ::mock::GLint LocationId = 1908221841;
2939 const auto TestCall = [&](
2940 const Component_t::ComponentPtr_t & _pTexture,
2941 const ::std::vector<uint8_t> & _Source,
2942 const int _Width,
const int _Height,
2943 const ::std::size_t _Index,
2944 const ::std::string & _TexName)
2946 const auto Index =
static_cast<::mock::GLint
>(_Index);
2948 using namespace ::testing;
2952 EXPECT_CALL(GLProxy, GenTextures(1))
2954 .WillOnce(Return(TextureId));
2956 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2959 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
2961 GL_RGBA, GL_UNSIGNED_BYTE, _Source))
2964 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
2967 EXPECT_CALL(GLProxy, GetError())
2969 .WillOnce(Return(GL_NO_ERROR));
2971 EXPECT_CALL(GLProxy, GenFramebuffers(1))
2974 auto Render = itCreator->second(_pTexture);
2975 ASSERT_NE(
nullptr, Render);
2977 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
2980 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
2983 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
2985 .WillOnce(Return(&ProgramId));
2987 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
2989 .WillOnce(Return(LocationId));
2991 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
2994 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
2999 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
3003 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
3005 { uT(
"albedo"),
"TexAlbedo" },
3006 { uT(
"metalness"),
"TexMetalness" },
3007 { uT(
"roughness"),
"TexRoughness" },
3008 { uT(
"normal"),
"TexNormal" },
3009 { uT(
"occlusion"),
"TexOcclusion" },
3013 ::std::vector<uint8_t> Source =
3015 0x20, 0x06, 0x15, 0x12, 0x30,
3016 0x20, 0x06, 0x15, 0x12, 0x30,
3017 0x20, 0x06, 0x15, 0x12, 0x30,
3018 0x20, 0x06, 0x15, 0x12, 0x30,
3019 0x20, 0x06, 0x15, 0x12, 0x30,
3021 IntroduceBufferSize(Source);
3023 for (::std::size_t i = 0; i < Destinations.size(); i++)
3026 const int Width = 1908221843;
3027 const int Height = 1908221844;
3029 const auto pTexture = Component_t::Make(
3031 { uT(
"content"), Source },
3032 { uT(
"width"), Width },
3033 { uT(
"height"), Height },
3034 { uT(
"destination"), Destinations[i].first },
3038 Source, Width, Height, i, Destinations[i].second);
3042 const int Width = 1908221845;
3043 const int Height = 1908221847;
3045 const auto pData = Component_t::Make(
3047 { uT(
"kind"), uT(
"Texture") },
3048 { uT(
"content"), Source },
3049 { uT(
"width"), Width },
3050 { uT(
"height"), Height },
3051 { uT(
"destination"), Destinations[i].first },
3054 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3055 Source, Width, Height, i, Destinations[i].second);
3059 const int Width = 1908221843;
3060 const int Height = 1908221844;
3062 const auto pTexture = Component_t::Make(
3064 { uT(
"content"), Source },
3065 { uT(
"width"), Width },
3066 { uT(
"height"), Height },
3067 { uT(
"destination"), Destinations[i].first },
3068 { uT(
"mipmapping"),
false },
3072 Source, Width, Height, i, Destinations[i].second);
3076 const int Width = 1908221845;
3077 const int Height = 1908221847;
3079 const auto pData = Component_t::Make(
3081 { uT(
"kind"), uT(
"Texture") },
3082 { uT(
"content"), Source },
3083 { uT(
"width"), Width },
3084 { uT(
"height"), Height },
3085 { uT(
"destination"), Destinations[i].first },
3086 { uT(
"mipmapping"),
false },
3089 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3090 Source, Width, Height, i, Destinations[i].second);
3096TEST_F(OpenGLShader_test, Test_Texture_Destination_Capacity16)
3098 using GLProxy_t = ::mock::GLProxy;
3100 GLProxy_t::GetInstance() = &GLProxy;
3102 const Tested_t Example{ Data_t{} };
3103 const ITested_t & IExample = Example;
3105 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
3106 ASSERT_NE(IExample.GetCreators().end(), itCreator);
3108 const ::mock::GLuint TextureId = 1908221839;
3109 const ::mock::GLint ProgramId = 1908221840;
3110 const ::mock::GLint LocationId = 1908221841;
3112 const auto TestCall = [&](
3113 const Component_t::ComponentPtr_t & _pTexture,
3114 const ::std::vector<uint8_t> & _Source,
3115 const int _Width,
const int _Height,
3116 const ::std::size_t _Index,
3117 const ::std::string & _TexName)
3119 const auto Index =
static_cast<::mock::GLint
>(_Index);
3121 using namespace ::testing;
3125 EXPECT_CALL(GLProxy, GenTextures(1))
3127 .WillOnce(Return(TextureId));
3129 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3132 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
3134 GL_RGBA, GL_HALF_FLOAT, _Source))
3137 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3140 EXPECT_CALL(GLProxy, GetError())
3142 .WillOnce(Return(GL_NO_ERROR));
3144 EXPECT_CALL(GLProxy, GenFramebuffers(1))
3147 auto Render = itCreator->second(_pTexture);
3148 ASSERT_NE(
nullptr, Render);
3150 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
3153 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3156 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
3158 .WillOnce(Return(&ProgramId));
3160 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
3162 .WillOnce(Return(LocationId));
3164 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
3167 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
3172 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
3176 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
3178 { uT(
"albedo"),
"TexAlbedo" },
3179 { uT(
"metalness"),
"TexMetalness" },
3180 { uT(
"roughness"),
"TexRoughness" },
3181 { uT(
"normal"),
"TexNormal" },
3182 { uT(
"occlusion"),
"TexOcclusion" },
3186 ::std::vector<uint8_t> Source =
3188 0x20, 0x06, 0x15, 0x12, 0x30,
3189 0x20, 0x06, 0x15, 0x12, 0x30,
3190 0x20, 0x06, 0x15, 0x12, 0x30,
3191 0x20, 0x06, 0x15, 0x12, 0x30,
3192 0x20, 0x06, 0x15, 0x12, 0x30,
3194 IntroduceBufferSize(Source);
3196 for (::std::size_t i = 0; i < Destinations.size(); i++)
3199 const int Width = 1908221843;
3200 const int Height = 1908221844;
3202 const auto pTexture = Component_t::Make(
3204 { uT(
"content"), Source },
3205 { uT(
"width"), Width },
3206 { uT(
"height"), Height },
3207 { uT(
"destination"), Destinations[i].first },
3208 { uT(
"capacity"), 16 },
3212 Source, Width, Height, i, Destinations[i].second);
3216 const int Width = 1908221845;
3217 const int Height = 1908221847;
3219 const auto pData = Component_t::Make(
3221 { uT(
"kind"), uT(
"Texture") },
3222 { uT(
"content"), Source },
3223 { uT(
"width"), Width },
3224 { uT(
"height"), Height },
3225 { uT(
"destination"), Destinations[i].first },
3226 { uT(
"capacity"), 16 },
3229 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3230 Source, Width, Height, i, Destinations[i].second);
3234 const int Width = 1908221843;
3235 const int Height = 1908221844;
3237 const auto pTexture = Component_t::Make(
3239 { uT(
"content"), Source },
3240 { uT(
"width"), Width },
3241 { uT(
"height"), Height },
3242 { uT(
"destination"), Destinations[i].first },
3243 { uT(
"mipmapping"),
false },
3244 { uT(
"capacity"), 16 },
3248 Source, Width, Height, i, Destinations[i].second);
3252 const int Width = 1908221845;
3253 const int Height = 1908221847;
3255 const auto pData = Component_t::Make(
3257 { uT(
"kind"), uT(
"Texture") },
3258 { uT(
"content"), Source },
3259 { uT(
"width"), Width },
3260 { uT(
"height"), Height },
3261 { uT(
"destination"), Destinations[i].first },
3262 { uT(
"mipmapping"),
false },
3263 { uT(
"capacity"), 16 },
3266 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3267 Source, Width, Height, i, Destinations[i].second);
3273TEST_F(OpenGLShader_test, Test_Texture_Destination_Capacity32)
3275 using GLProxy_t = ::mock::GLProxy;
3277 GLProxy_t::GetInstance() = &GLProxy;
3279 const Tested_t Example{ Data_t{} };
3280 const ITested_t & IExample = Example;
3282 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
3283 ASSERT_NE(IExample.GetCreators().end(), itCreator);
3285 const ::mock::GLuint TextureId = 1908221839;
3286 const ::mock::GLint ProgramId = 1908221840;
3287 const ::mock::GLint LocationId = 1908221841;
3289 const auto TestCall = [&](
3290 const Component_t::ComponentPtr_t & _pTexture,
3291 const ::std::vector<uint8_t> & _Source,
3292 const int _Width,
const int _Height,
3293 const ::std::size_t _Index,
3294 const ::std::string & _TexName)
3296 const auto Index =
static_cast<::mock::GLint
>(_Index);
3298 using namespace ::testing;
3302 EXPECT_CALL(GLProxy, GenTextures(1))
3304 .WillOnce(Return(TextureId));
3306 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3309 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
3311 GL_RGBA, GL_FLOAT, _Source))
3314 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3317 EXPECT_CALL(GLProxy, GetError())
3319 .WillOnce(Return(GL_NO_ERROR));
3321 EXPECT_CALL(GLProxy, GenFramebuffers(1))
3324 auto Render = itCreator->second(_pTexture);
3325 ASSERT_NE(
nullptr, Render);
3327 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
3330 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3333 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
3335 .WillOnce(Return(&ProgramId));
3337 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
3339 .WillOnce(Return(LocationId));
3341 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
3344 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
3349 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
3353 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
3355 { uT(
"albedo"),
"TexAlbedo" },
3356 { uT(
"metalness"),
"TexMetalness" },
3357 { uT(
"roughness"),
"TexRoughness" },
3358 { uT(
"normal"),
"TexNormal" },
3359 { uT(
"occlusion"),
"TexOcclusion" },
3363 ::std::vector<uint8_t> Source =
3365 0x20, 0x06, 0x15, 0x12, 0x30,
3366 0x20, 0x06, 0x15, 0x12, 0x30,
3367 0x20, 0x06, 0x15, 0x12, 0x30,
3368 0x20, 0x06, 0x15, 0x12, 0x30,
3369 0x20, 0x06, 0x15, 0x12, 0x30,
3371 IntroduceBufferSize(Source);
3373 for (::std::size_t i = 0; i < Destinations.size(); i++)
3376 const int Width = 1908221843;
3377 const int Height = 1908221844;
3379 const auto pTexture = Component_t::Make(
3381 { uT(
"content"), Source },
3382 { uT(
"width"), Width },
3383 { uT(
"height"), Height },
3384 { uT(
"destination"), Destinations[i].first },
3385 { uT(
"capacity"), 32 },
3389 Source, Width, Height, i, Destinations[i].second);
3393 const int Width = 1908221845;
3394 const int Height = 1908221847;
3396 const auto pData = Component_t::Make(
3398 { uT(
"kind"), uT(
"Texture") },
3399 { uT(
"content"), Source },
3400 { uT(
"width"), Width },
3401 { uT(
"height"), Height },
3402 { uT(
"destination"), Destinations[i].first },
3403 { uT(
"capacity"), 32 },
3406 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3407 Source, Width, Height, i, Destinations[i].second);
3411 const int Width = 1908221843;
3412 const int Height = 1908221844;
3414 const auto pTexture = Component_t::Make(
3416 { uT(
"content"), Source },
3417 { uT(
"width"), Width },
3418 { uT(
"height"), Height },
3419 { uT(
"destination"), Destinations[i].first },
3420 { uT(
"mipmapping"),
false },
3421 { uT(
"capacity"), 32 },
3425 Source, Width, Height, i, Destinations[i].second);
3429 const int Width = 1908221845;
3430 const int Height = 1908221847;
3432 const auto pData = Component_t::Make(
3434 { uT(
"kind"), uT(
"Texture") },
3435 { uT(
"content"), Source },
3436 { uT(
"width"), Width },
3437 { uT(
"height"), Height },
3438 { uT(
"destination"), Destinations[i].first },
3439 { uT(
"mipmapping"),
false },
3440 { uT(
"capacity"), 32 },
3443 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3444 Source, Width, Height, i, Destinations[i].second);
3450TEST_F(OpenGLShader_test, Test_Texture_Mipmapping_NameAndIndex)
3452 using GLProxy_t = ::mock::GLProxy;
3454 GLProxy_t::GetInstance() = &GLProxy;
3456 const Tested_t Example{ Data_t{} };
3457 const ITested_t & IExample = Example;
3459 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
3460 ASSERT_NE(IExample.GetCreators().end(), itCreator);
3462 const ::mock::GLuint TextureId = 1908221839;
3463 const ::mock::GLint ProgramId = 1908221840;
3464 const ::mock::GLint LocationId = 1908221841;
3466 const auto TestCall = [&](
3467 const Component_t::ComponentPtr_t & _pTexture,
3468 const ::std::vector<uint8_t> & _Source,
3469 const int _Width,
const int _Height,
3470 const ::std::size_t _Index,
3471 const ::std::string & _TexName)
3473 const auto Index =
static_cast<::mock::GLint
>(_Index);
3475 using namespace ::testing;
3479 EXPECT_CALL(GLProxy, GenTextures(1))
3481 .WillOnce(Return(TextureId));
3483 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3486 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
3488 GL_RGBA, GL_UNSIGNED_BYTE, _Source))
3491 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3494 EXPECT_CALL(GLProxy, GetError())
3496 .WillOnce(Return(GL_NO_ERROR));
3498 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3501 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D))
3504 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3507 EXPECT_CALL(GLProxy, GenFramebuffers(1))
3510 auto Render = itCreator->second(_pTexture);
3511 ASSERT_NE(
nullptr, Render);
3513 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
3516 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3519 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
3521 .WillOnce(Return(&ProgramId));
3523 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
3525 .WillOnce(Return(LocationId));
3527 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
3530 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
3535 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
3539 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
3541 { uT(
"TexEnvironment"),
"TexEnvironment" },
3542 { uT(
"TexReflection"),
"TexReflection" },
3543 { uT(
"TexBaseColor"),
"TexBaseColor" },
3546 for (
int Index = 0; Index < Names.size(); Index++)
3548 ::std::vector<uint8_t> Source =
3550 0x20, 0x06, 0x15, 0x12, 0x31,
3551 0x20, 0x06, 0x15, 0x12, 0x31,
3552 0x20, 0x06, 0x15, 0x12, 0x31,
3553 0x20, 0x06, 0x15, 0x12, 0x31,
3554 0x20, 0x06, 0x15, 0x12, 0x31,
3556 IntroduceBufferSize(Source);
3559 const int Width = 1908221843;
3560 const int Height = 1908221844;
3562 const auto pTexture = Component_t::Make(
3564 { uT(
"content"), Source },
3565 { uT(
"width"), Width },
3566 { uT(
"height"), Height },
3567 { uT(
"name"), Names[Index].first },
3568 { uT(
"index"), Index },
3569 { uT(
"mipmapping"),
true },
3573 Source, Width, Height, Index, Names[Index].second);
3577 const int Width = 1908221845;
3578 const int Height = 1908221847;
3580 const auto pData = Component_t::Make(
3582 { uT(
"kind"), uT(
"Texture") },
3583 { uT(
"content"), Source },
3584 { uT(
"width"), Width },
3585 { uT(
"height"), Height },
3586 { uT(
"name"), Names[Index].first },
3587 { uT(
"index"), Index },
3588 { uT(
"mipmapping"),
true },
3591 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3592 Source, Width, Height, Index, Names[Index].second);
3595 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
3597 { uT(
"albedo"),
"TexAlbedo" },
3598 { uT(
"metalness"),
"TexMetalness" },
3599 { uT(
"roughness"),
"TexRoughness" },
3600 { uT(
"normal"),
"TexNormal" },
3601 { uT(
"occlusion"),
"TexOcclusion" },
3604 for (::std::size_t i = 0; i < Destinations.size(); i++)
3607 const int Width = 1908221843;
3608 const int Height = 1908221844;
3610 const auto pTexture = Component_t::Make(
3612 { uT(
"content"), Source },
3613 { uT(
"width"), Width },
3614 { uT(
"height"), Height },
3615 { uT(
"name"), Names[Index].first },
3616 { uT(
"index"), Index },
3617 { uT(
"destination"), Destinations[i].first },
3618 { uT(
"mipmapping"),
true },
3622 Source, Width, Height, Index, Names[Index].second);
3626 const int Width = 1908221845;
3627 const int Height = 1908221847;
3629 const auto pData = Component_t::Make(
3631 { uT(
"kind"), uT(
"Texture") },
3632 { uT(
"content"), Source },
3633 { uT(
"width"), Width },
3634 { uT(
"height"), Height },
3635 { uT(
"name"), Names[Index].first },
3636 { uT(
"index"), Index },
3637 { uT(
"destination"), Destinations[i].first },
3638 { uT(
"mipmapping"),
true },
3641 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3642 Source, Width, Height, Index, Names[Index].second);
3649TEST_F(OpenGLShader_test, Test_Texture_Mipmapping_NameAndIndex_Capacity16)
3651 using GLProxy_t = ::mock::GLProxy;
3653 GLProxy_t::GetInstance() = &GLProxy;
3655 const Tested_t Example{ Data_t{} };
3656 const ITested_t & IExample = Example;
3658 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
3659 ASSERT_NE(IExample.GetCreators().end(), itCreator);
3661 const ::mock::GLuint TextureId = 1908221839;
3662 const ::mock::GLint ProgramId = 1908221840;
3663 const ::mock::GLint LocationId = 1908221841;
3665 const auto TestCall = [&](
3666 const Component_t::ComponentPtr_t & _pTexture,
3667 const ::std::vector<uint8_t> & _Source,
3668 const int _Width,
const int _Height,
3669 const ::std::size_t _Index,
3670 const ::std::string & _TexName)
3672 const auto Index =
static_cast<::mock::GLint
>(_Index);
3674 using namespace ::testing;
3678 EXPECT_CALL(GLProxy, GenTextures(1))
3680 .WillOnce(Return(TextureId));
3682 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3685 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
3687 GL_RGBA, GL_HALF_FLOAT, _Source))
3690 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3693 EXPECT_CALL(GLProxy, GetError())
3695 .WillOnce(Return(GL_NO_ERROR));
3697 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3700 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D))
3703 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3706 EXPECT_CALL(GLProxy, GenFramebuffers(1))
3709 auto Render = itCreator->second(_pTexture);
3710 ASSERT_NE(
nullptr, Render);
3712 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
3715 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3718 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
3720 .WillOnce(Return(&ProgramId));
3722 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
3724 .WillOnce(Return(LocationId));
3726 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
3729 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
3734 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
3738 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
3740 { uT(
"TexEnvironment"),
"TexEnvironment" },
3741 { uT(
"TexReflection"),
"TexReflection" },
3742 { uT(
"TexBaseColor"),
"TexBaseColor" },
3745 for (
int Index = 0; Index < Names.size(); Index++)
3747 ::std::vector<uint8_t> Source =
3749 0x20, 0x06, 0x15, 0x12, 0x31,
3750 0x20, 0x06, 0x15, 0x12, 0x31,
3751 0x20, 0x06, 0x15, 0x12, 0x31,
3752 0x20, 0x06, 0x15, 0x12, 0x31,
3753 0x20, 0x06, 0x15, 0x12, 0x31,
3755 IntroduceBufferSize(Source);
3758 const int Width = 1908221843;
3759 const int Height = 1908221844;
3761 const auto pTexture = Component_t::Make(
3763 { uT(
"content"), Source },
3764 { uT(
"width"), Width },
3765 { uT(
"height"), Height },
3766 { uT(
"name"), Names[Index].first },
3767 { uT(
"index"), Index },
3768 { uT(
"mipmapping"),
true },
3769 { uT(
"capacity"), 16 },
3773 Source, Width, Height, Index, Names[Index].second);
3777 const int Width = 1908221845;
3778 const int Height = 1908221847;
3780 const auto pData = Component_t::Make(
3782 { uT(
"kind"), uT(
"Texture") },
3783 { uT(
"content"), Source },
3784 { uT(
"width"), Width },
3785 { uT(
"height"), Height },
3786 { uT(
"name"), Names[Index].first },
3787 { uT(
"index"), Index },
3788 { uT(
"mipmapping"),
true },
3789 { uT(
"capacity"), 16 },
3792 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3793 Source, Width, Height, Index, Names[Index].second);
3796 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
3798 { uT(
"albedo"),
"TexAlbedo" },
3799 { uT(
"metalness"),
"TexMetalness" },
3800 { uT(
"roughness"),
"TexRoughness" },
3801 { uT(
"normal"),
"TexNormal" },
3802 { uT(
"occlusion"),
"TexOcclusion" },
3805 for (::std::size_t i = 0; i < Destinations.size(); i++)
3808 const int Width = 1908221843;
3809 const int Height = 1908221844;
3811 const auto pTexture = Component_t::Make(
3813 { uT(
"content"), Source },
3814 { uT(
"width"), Width },
3815 { uT(
"height"), Height },
3816 { uT(
"name"), Names[Index].first },
3817 { uT(
"index"), Index },
3818 { uT(
"destination"), Destinations[i].first },
3819 { uT(
"mipmapping"),
true },
3820 { uT(
"capacity"), 16 },
3824 Source, Width, Height, Index, Names[Index].second);
3828 const int Width = 1908221845;
3829 const int Height = 1908221847;
3831 const auto pData = Component_t::Make(
3833 { uT(
"kind"), uT(
"Texture") },
3834 { uT(
"content"), Source },
3835 { uT(
"width"), Width },
3836 { uT(
"height"), Height },
3837 { uT(
"name"), Names[Index].first },
3838 { uT(
"index"), Index },
3839 { uT(
"destination"), Destinations[i].first },
3840 { uT(
"mipmapping"),
true },
3841 { uT(
"capacity"), 16 },
3844 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3845 Source, Width, Height, Index, Names[Index].second);
3852TEST_F(OpenGLShader_test, Test_Texture_Mipmapping_NameAndIndex_Capacity32)
3854 using GLProxy_t = ::mock::GLProxy;
3856 GLProxy_t::GetInstance() = &GLProxy;
3858 const Tested_t Example{ Data_t{} };
3859 const ITested_t & IExample = Example;
3861 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
3862 ASSERT_NE(IExample.GetCreators().end(), itCreator);
3864 const ::mock::GLuint TextureId = 1908221839;
3865 const ::mock::GLint ProgramId = 1908221840;
3866 const ::mock::GLint LocationId = 1908221841;
3868 const auto TestCall = [&](
3869 const Component_t::ComponentPtr_t & _pTexture,
3870 const ::std::vector<uint8_t> & _Source,
3871 const int _Width,
const int _Height,
3872 const ::std::size_t _Index,
3873 const ::std::string & _TexName)
3875 const auto Index =
static_cast<::mock::GLint
>(_Index);
3877 using namespace ::testing;
3881 EXPECT_CALL(GLProxy, GenTextures(1))
3883 .WillOnce(Return(TextureId));
3885 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3888 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
3890 GL_RGBA, GL_FLOAT, _Source))
3893 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3896 EXPECT_CALL(GLProxy, GetError())
3898 .WillOnce(Return(GL_NO_ERROR));
3900 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3903 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D))
3906 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
3909 EXPECT_CALL(GLProxy, GenFramebuffers(1))
3912 auto Render = itCreator->second(_pTexture);
3913 ASSERT_NE(
nullptr, Render);
3915 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
3918 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
3921 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
3923 .WillOnce(Return(&ProgramId));
3925 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
3927 .WillOnce(Return(LocationId));
3929 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
3932 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
3937 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
3941 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
3943 { uT(
"TexEnvironment"),
"TexEnvironment" },
3944 { uT(
"TexReflection"),
"TexReflection" },
3945 { uT(
"TexBaseColor"),
"TexBaseColor" },
3948 for (
int Index = 0; Index < Names.size(); Index++)
3950 ::std::vector<uint8_t> Source =
3952 0x20, 0x06, 0x15, 0x12, 0x31,
3953 0x20, 0x06, 0x15, 0x12, 0x31,
3954 0x20, 0x06, 0x15, 0x12, 0x31,
3955 0x20, 0x06, 0x15, 0x12, 0x31,
3956 0x20, 0x06, 0x15, 0x12, 0x31,
3958 IntroduceBufferSize(Source);
3961 const int Width = 1908221843;
3962 const int Height = 1908221844;
3964 const auto pTexture = Component_t::Make(
3966 { uT(
"content"), Source },
3967 { uT(
"width"), Width },
3968 { uT(
"height"), Height },
3969 { uT(
"name"), Names[Index].first },
3970 { uT(
"index"), Index },
3971 { uT(
"mipmapping"),
true },
3972 { uT(
"capacity"), 32 },
3976 Source, Width, Height, Index, Names[Index].second);
3980 const int Width = 1908221845;
3981 const int Height = 1908221847;
3983 const auto pData = Component_t::Make(
3985 { uT(
"kind"), uT(
"Texture") },
3986 { uT(
"content"), Source },
3987 { uT(
"width"), Width },
3988 { uT(
"height"), Height },
3989 { uT(
"name"), Names[Index].first },
3990 { uT(
"index"), Index },
3991 { uT(
"mipmapping"),
true },
3992 { uT(
"capacity"), 32 },
3995 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
3996 Source, Width, Height, Index, Names[Index].second);
3999 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
4001 { uT(
"albedo"),
"TexAlbedo" },
4002 { uT(
"metalness"),
"TexMetalness" },
4003 { uT(
"roughness"),
"TexRoughness" },
4004 { uT(
"normal"),
"TexNormal" },
4005 { uT(
"occlusion"),
"TexOcclusion" },
4008 for (::std::size_t i = 0; i < Destinations.size(); i++)
4011 const int Width = 1908221843;
4012 const int Height = 1908221844;
4014 const auto pTexture = Component_t::Make(
4016 { uT(
"content"), Source },
4017 { uT(
"width"), Width },
4018 { uT(
"height"), Height },
4019 { uT(
"name"), Names[Index].first },
4020 { uT(
"index"), Index },
4021 { uT(
"destination"), Destinations[i].first },
4022 { uT(
"mipmapping"),
true },
4023 { uT(
"capacity"), 32 },
4027 Source, Width, Height, Index, Names[Index].second);
4031 const int Width = 1908221845;
4032 const int Height = 1908221847;
4034 const auto pData = Component_t::Make(
4036 { uT(
"kind"), uT(
"Texture") },
4037 { uT(
"content"), Source },
4038 { uT(
"width"), Width },
4039 { uT(
"height"), Height },
4040 { uT(
"name"), Names[Index].first },
4041 { uT(
"index"), Index },
4042 { uT(
"destination"), Destinations[i].first },
4043 { uT(
"mipmapping"),
true },
4044 { uT(
"capacity"), 32 },
4047 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
4048 Source, Width, Height, Index, Names[Index].second);
4055TEST_F(OpenGLShader_test, Test_Texture_Mipmapping_Destination)
4057 using GLProxy_t = ::mock::GLProxy;
4059 GLProxy_t::GetInstance() = &GLProxy;
4061 const Tested_t Example{ Data_t{} };
4062 const ITested_t & IExample = Example;
4064 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
4065 ASSERT_NE(IExample.GetCreators().end(), itCreator);
4067 const ::mock::GLuint TextureId = 1908221839;
4068 const ::mock::GLint ProgramId = 1908221840;
4069 const ::mock::GLint LocationId = 1908221841;
4071 const auto TestCall = [&](
4072 const Component_t::ComponentPtr_t & _pTexture,
4073 const ::std::vector<uint8_t> & _Source,
4074 const int _Width,
const int _Height,
4075 const ::std::size_t _Index,
4076 const ::std::string & _TexName)
4078 const auto Index =
static_cast<::mock::GLint
>(_Index);
4080 using namespace ::testing;
4084 EXPECT_CALL(GLProxy, GenTextures(1))
4086 .WillOnce(Return(TextureId));
4088 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4091 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
4093 GL_RGBA, GL_UNSIGNED_BYTE, _Source))
4096 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4099 EXPECT_CALL(GLProxy, GetError())
4101 .WillOnce(Return(GL_NO_ERROR));
4103 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4106 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D))
4109 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4112 EXPECT_CALL(GLProxy, GenFramebuffers(1))
4115 auto Render = itCreator->second(_pTexture);
4116 ASSERT_NE(
nullptr, Render);
4118 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
4121 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4124 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
4126 .WillOnce(Return(&ProgramId));
4128 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
4130 .WillOnce(Return(LocationId));
4132 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
4135 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
4140 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
4144 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
4146 { uT(
"albedo"),
"TexAlbedo" },
4147 { uT(
"metalness"),
"TexMetalness" },
4148 { uT(
"roughness"),
"TexRoughness" },
4149 { uT(
"normal"),
"TexNormal" },
4150 { uT(
"occlusion"),
"TexOcclusion" },
4153 ::std::vector<uint8_t> Source =
4155 0x20, 0x06, 0x15, 0x12, 0x31,
4156 0x20, 0x06, 0x15, 0x12, 0x31,
4157 0x20, 0x06, 0x15, 0x12, 0x31,
4158 0x20, 0x06, 0x15, 0x12, 0x31,
4159 0x20, 0x06, 0x15, 0x12, 0x31,
4161 IntroduceBufferSize(Source);
4163 for (::std::size_t i = 0; i < Destinations.size(); i++)
4166 const int Width = 1908221843;
4167 const int Height = 1908221844;
4169 const auto pTexture = Component_t::Make(
4171 { uT(
"content"), Source },
4172 { uT(
"width"), Width },
4173 { uT(
"height"), Height },
4174 { uT(
"destination"), Destinations[i].first },
4175 { uT(
"mipmapping"),
true },
4179 Source, Width, Height, i, Destinations[i].second);
4183 const int Width = 1908221845;
4184 const int Height = 1908221847;
4186 const auto pData = Component_t::Make(
4188 { uT(
"kind"), uT(
"Texture") },
4189 { uT(
"content"), Source },
4190 { uT(
"width"), Width },
4191 { uT(
"height"), Height },
4192 { uT(
"destination"), Destinations[i].first },
4193 { uT(
"mipmapping"),
true },
4196 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
4197 Source, Width, Height, i, Destinations[i].second);
4203TEST_F(OpenGLShader_test, Test_Texture_Mipmapping_Destination_Capacity16)
4205 using GLProxy_t = ::mock::GLProxy;
4207 GLProxy_t::GetInstance() = &GLProxy;
4209 const Tested_t Example{ Data_t{} };
4210 const ITested_t & IExample = Example;
4212 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
4213 ASSERT_NE(IExample.GetCreators().end(), itCreator);
4215 const ::mock::GLuint TextureId = 1908221839;
4216 const ::mock::GLint ProgramId = 1908221840;
4217 const ::mock::GLint LocationId = 1908221841;
4219 const auto TestCall = [&](
4220 const Component_t::ComponentPtr_t & _pTexture,
4221 const ::std::vector<uint8_t> & _Source,
4222 const int _Width,
const int _Height,
4223 const ::std::size_t _Index,
4224 const ::std::string & _TexName)
4226 const auto Index =
static_cast<::mock::GLint
>(_Index);
4228 using namespace ::testing;
4232 EXPECT_CALL(GLProxy, GenTextures(1))
4234 .WillOnce(Return(TextureId));
4236 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4239 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
4241 GL_RGBA, GL_HALF_FLOAT, _Source))
4244 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4247 EXPECT_CALL(GLProxy, GetError())
4249 .WillOnce(Return(GL_NO_ERROR));
4251 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4254 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D))
4257 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4260 EXPECT_CALL(GLProxy, GenFramebuffers(1))
4263 auto Render = itCreator->second(_pTexture);
4264 ASSERT_NE(
nullptr, Render);
4266 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
4269 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4272 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
4274 .WillOnce(Return(&ProgramId));
4276 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
4278 .WillOnce(Return(LocationId));
4280 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
4283 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
4288 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
4292 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
4294 { uT(
"albedo"),
"TexAlbedo" },
4295 { uT(
"metalness"),
"TexMetalness" },
4296 { uT(
"roughness"),
"TexRoughness" },
4297 { uT(
"normal"),
"TexNormal" },
4298 { uT(
"occlusion"),
"TexOcclusion" },
4301 ::std::vector<uint8_t> Source =
4303 0x20, 0x06, 0x15, 0x12, 0x31,
4304 0x20, 0x06, 0x15, 0x12, 0x31,
4305 0x20, 0x06, 0x15, 0x12, 0x31,
4306 0x20, 0x06, 0x15, 0x12, 0x31,
4307 0x20, 0x06, 0x15, 0x12, 0x31,
4309 IntroduceBufferSize(Source);
4311 for (::std::size_t i = 0; i < Destinations.size(); i++)
4314 const int Width = 1908221843;
4315 const int Height = 1908221844;
4317 const auto pTexture = Component_t::Make(
4319 { uT(
"content"), Source },
4320 { uT(
"width"), Width },
4321 { uT(
"height"), Height },
4322 { uT(
"destination"), Destinations[i].first },
4323 { uT(
"mipmapping"),
true },
4324 { uT(
"capacity"), 16 },
4328 Source, Width, Height, i, Destinations[i].second);
4332 const int Width = 1908221845;
4333 const int Height = 1908221847;
4335 const auto pData = Component_t::Make(
4337 { uT(
"kind"), uT(
"Texture") },
4338 { uT(
"content"), Source },
4339 { uT(
"width"), Width },
4340 { uT(
"height"), Height },
4341 { uT(
"destination"), Destinations[i].first },
4342 { uT(
"mipmapping"),
true },
4343 { uT(
"capacity"), 16 },
4346 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
4347 Source, Width, Height, i, Destinations[i].second);
4353TEST_F(OpenGLShader_test, Test_Texture_Mipmapping_Destination_Capacity32)
4355 using GLProxy_t = ::mock::GLProxy;
4357 GLProxy_t::GetInstance() = &GLProxy;
4359 const Tested_t Example{ Data_t{} };
4360 const ITested_t & IExample = Example;
4362 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
4363 ASSERT_NE(IExample.GetCreators().end(), itCreator);
4365 const ::mock::GLuint TextureId = 1908221839;
4366 const ::mock::GLint ProgramId = 1908221840;
4367 const ::mock::GLint LocationId = 1908221841;
4369 const auto TestCall = [&](
4370 const Component_t::ComponentPtr_t & _pTexture,
4371 const ::std::vector<uint8_t> & _Source,
4372 const int _Width,
const int _Height,
4373 const ::std::size_t _Index,
4374 const ::std::string & _TexName)
4376 const auto Index =
static_cast<::mock::GLint
>(_Index);
4378 using namespace ::testing;
4382 EXPECT_CALL(GLProxy, GenTextures(1))
4384 .WillOnce(Return(TextureId));
4386 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4389 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
4391 GL_RGBA, GL_FLOAT, _Source))
4394 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4397 EXPECT_CALL(GLProxy, GetError())
4399 .WillOnce(Return(GL_NO_ERROR));
4401 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4404 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D))
4407 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4410 EXPECT_CALL(GLProxy, GenFramebuffers(1))
4413 auto Render = itCreator->second(_pTexture);
4414 ASSERT_NE(
nullptr, Render);
4416 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
4419 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4422 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
4424 .WillOnce(Return(&ProgramId));
4426 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
4428 .WillOnce(Return(LocationId));
4430 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
4433 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
4438 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
4442 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
4444 { uT(
"albedo"),
"TexAlbedo" },
4445 { uT(
"metalness"),
"TexMetalness" },
4446 { uT(
"roughness"),
"TexRoughness" },
4447 { uT(
"normal"),
"TexNormal" },
4448 { uT(
"occlusion"),
"TexOcclusion" },
4451 ::std::vector<uint8_t> Source =
4453 0x20, 0x06, 0x15, 0x12, 0x31,
4454 0x20, 0x06, 0x15, 0x12, 0x31,
4455 0x20, 0x06, 0x15, 0x12, 0x31,
4456 0x20, 0x06, 0x15, 0x12, 0x31,
4457 0x20, 0x06, 0x15, 0x12, 0x31,
4459 IntroduceBufferSize(Source);
4461 for (::std::size_t i = 0; i < Destinations.size(); i++)
4464 const int Width = 1908221843;
4465 const int Height = 1908221844;
4467 const auto pTexture = Component_t::Make(
4469 { uT(
"content"), Source },
4470 { uT(
"width"), Width },
4471 { uT(
"height"), Height },
4472 { uT(
"destination"), Destinations[i].first },
4473 { uT(
"mipmapping"),
true },
4474 { uT(
"capacity"), 32 },
4478 Source, Width, Height, i, Destinations[i].second);
4482 const int Width = 1908221845;
4483 const int Height = 1908221847;
4485 const auto pData = Component_t::Make(
4487 { uT(
"kind"), uT(
"Texture") },
4488 { uT(
"content"), Source },
4489 { uT(
"width"), Width },
4490 { uT(
"height"), Height },
4491 { uT(
"destination"), Destinations[i].first },
4492 { uT(
"mipmapping"),
true },
4493 { uT(
"capacity"), 32 },
4496 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
4497 Source, Width, Height, i, Destinations[i].second);
4503TEST_F(OpenGLShader_test, Test_Texture_ReadData_NameAndIndex)
4505 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
4506 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
4508 using GLProxy_t = ::mock::GLProxy;
4510 GLProxy_t::GetInstance() = &GLProxy;
4513 public ::alicorn::extension::testing::Proxy<MapperProxy>
4516 MOCK_METHOD1(Map,
bool(
const void *));
4517 MOCK_METHOD1(CheckData,
void(::std::vector<uint32_t>));
4520 MapperProxy oMapperProxy;
4521 MapperProxy::GetInstance() = &oMapperProxy;
4523 const int Width = 3;
4524 const int Height = 4;
4526 const BufferMapper_t Mapper = [&](
const void * _pData)
4528 if (_pData !=
nullptr)
4530 ::std::vector<uint32_t> Data(Width * Height);
4531 memcpy(Data.data(), _pData, Width * Height * 4);
4532 oMapperProxy.CheckData(Data);
4535 return oMapperProxy.Map(_pData);
4538 const Tested_t Example{ Data_t{} };
4539 const ITested_t & IExample = Example;
4541 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
4542 ASSERT_NE(IExample.GetCreators().end(), itCreator);
4544 const ::mock::GLint TextureId = 1910221154;
4545 const ::mock::GLint ProgramId = 1910221155;
4546 const ::mock::GLint LocationId = 1910221156;
4547 const ::mock::GLint FrameBufferId = 1910221209;
4548 const ::mock::GLint DefaultFrameBufferId = 1910221236;
4550 const auto TestCall = [&](
4551 const Component_t::ComponentPtr_t & _pDataTexture,
4552 const ::std::size_t _Index,
4553 const ::std::string & _TexName,
4554 const ::std::vector<uint32_t> & _RawData,
4555 const ::std::vector<uint32_t> & _ExpectData)
4557 const auto Index =
static_cast<::mock::GLint
>(_Index);
4559 ::covellite::api::renderer::Component::Texture TextureData{ *_pDataTexture, uT(
"") };
4561 using namespace ::testing;
4565 EXPECT_CALL(GLProxy, GenTextures(1))
4567 .WillOnce(Return(TextureId));
4569 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4572 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
4574 GL_RGBA, GL_UNSIGNED_BYTE, ::std::vector<uint8_t>{}))
4577 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4580 EXPECT_CALL(GLProxy, GetError())
4582 .WillOnce(Return(GL_NO_ERROR));
4584 const auto pTexture = ::std::make_shared<Texture_t>(TextureData);
4585 ASSERT_EQ(Width * Height * 4, pTexture->m_ReadCopyData.size());
4587 (*_pDataTexture)[uT(
"entity")] = pTexture;
4589 EXPECT_CALL(GLProxy, GenFramebuffers(1))
4591 .WillOnce(Return(FrameBufferId));
4593 EXPECT_CALL(GLProxy, GenTextures(1))
4596 auto Render = itCreator->second(Component_t::Make(
4598 { uT(
"service"), Object_t{ _pDataTexture } }
4600 ASSERT_NE(
nullptr, Render);
4602 const auto TestCallActivateTexture = [&](void)
4604 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
4607 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4610 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
4612 .WillOnce(Return(&ProgramId));
4614 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
4616 .WillOnce(Return(LocationId));
4618 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
4621 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
4627 EXPECT_CALL(oMapperProxy, Map(
nullptr))
4629 .WillOnce(Return(
false));
4631 EXPECT_CALL(GLProxy, BindFramebuffer(_, _))
4634 TestCallActivateTexture();
4639 EXPECT_CALL(oMapperProxy, Map(
nullptr))
4641 .WillOnce(Return(
true));
4643 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
4645 .WillOnce(Return(&DefaultFrameBufferId));
4647 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
4650 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER,
4651 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureId, 0))
4654 EXPECT_CALL(GLProxy, GetReadPixelsRawData())
4656 .WillOnce(Return(_RawData));
4658 EXPECT_CALL(GLProxy, ReadPixels(0, 0, Width, Height, GL_RGBA,
4659 GL_UNSIGNED_BYTE, pTexture->m_ReadCopyData.data()))
4662 EXPECT_CALL(oMapperProxy, CheckData(_ExpectData))
4665 EXPECT_CALL(oMapperProxy, Map(pTexture->m_ReadCopyData.data()))
4668 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, DefaultFrameBufferId))
4671 TestCallActivateTexture();
4676 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
4679 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
4683 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
4685 { uT(
"TexEnvironment"),
"TexEnvironment" },
4686 { uT(
"TexReflection"),
"TexReflection" },
4687 { uT(
"TexBaseColor"),
"TexBaseColor" },
4690 for (
int Index = 0; Index < Names.size(); Index++)
4692 const ::std::vector<uint32_t> RawData =
4694 0x10221334, 0x10221335, 0x10221336,
4695 0x10221337, 0x10221338, 0x10221339,
4696 0x10221340, 0x10221341, 0x10221342,
4697 0x10221343, 0x10221344, 0x10221345,
4700 const ::std::vector<uint32_t> ExpectData =
4702 0x10221343, 0x10221344, 0x10221345,
4703 0x10221340, 0x10221341, 0x10221342,
4704 0x10221337, 0x10221338, 0x10221339,
4705 0x10221334, 0x10221335, 0x10221336,
4708 const auto pData = Component_t::Make(
4710 { uT(
"kind"), uT(
"Texture") },
4711 { uT(
"width"), Width },
4712 { uT(
"height"), Height },
4713 { uT(
"mapper"), Mapper },
4714 { uT(
"name"), Names[Index].first },
4715 { uT(
"index"), Index },
4718 TestCall(pData, Index, Names[Index].second, RawData, ExpectData);
4720 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
4722 { uT(
"albedo"),
"TexAlbedo" },
4723 { uT(
"metalness"),
"TexMetalness" },
4724 { uT(
"roughness"),
"TexRoughness" },
4725 { uT(
"normal"),
"TexNormal" },
4726 { uT(
"occlusion"),
"TexOcclusion" },
4729 for (::std::size_t i = 0; i < Destinations.size(); i++)
4731 const auto pData = Component_t::Make(
4733 { uT(
"kind"), uT(
"Texture") },
4734 { uT(
"width"), Width },
4735 { uT(
"height"), Height },
4736 { uT(
"mapper"), Mapper },
4737 { uT(
"name"), Names[Index].first },
4738 { uT(
"index"), Index },
4739 { uT(
"destination"), Destinations[i].first },
4742 TestCall(pData, Index, Names[Index].second, RawData, ExpectData);
4748TEST_F(OpenGLShader_test, Test_Texture_ReadData_NameAndIndex_Capacity16)
4750 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
4751 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
4753 using GLProxy_t = ::mock::GLProxy;
4755 GLProxy_t::GetInstance() = &GLProxy;
4758 public ::alicorn::extension::testing::Proxy<MapperProxy>
4761 MOCK_METHOD1(Map,
bool(
const void *));
4762 MOCK_METHOD1(CheckData,
void(::std::vector<uint32_t>));
4765 MapperProxy oMapperProxy;
4766 MapperProxy::GetInstance() = &oMapperProxy;
4768 const int Width = 3;
4769 const int Height = 4;
4771 const BufferMapper_t Mapper = [&](
const void * _pData)
4773 if (_pData !=
nullptr)
4775 ::std::vector<uint32_t> Data(Width * Height);
4776 memcpy(Data.data(), _pData, Width * Height * 4);
4777 oMapperProxy.CheckData(Data);
4780 return oMapperProxy.Map(_pData);
4783 const Tested_t Example{ Data_t{} };
4784 const ITested_t & IExample = Example;
4786 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
4787 ASSERT_NE(IExample.GetCreators().end(), itCreator);
4789 const ::mock::GLint TextureId = 1910221154;
4790 const ::mock::GLint ProgramId = 1910221155;
4791 const ::mock::GLint LocationId = 1910221156;
4792 const ::mock::GLint FrameBufferId = 1910221209;
4793 const ::mock::GLint DefaultFrameBufferId = 1910221236;
4795 const auto TestCall = [&](
4796 const Component_t::ComponentPtr_t & _pDataTexture,
4797 const ::std::size_t _Index,
4798 const ::std::string & _TexName,
4799 const ::std::vector<uint32_t> & _RawData,
4800 const ::std::vector<uint32_t> & _ExpectData)
4802 const auto Index =
static_cast<::mock::GLint
>(_Index);
4804 ::covellite::api::renderer::Component::Texture TextureData{ *_pDataTexture, uT(
"") };
4806 using namespace ::testing;
4810 EXPECT_CALL(GLProxy, GenTextures(1))
4812 .WillOnce(Return(TextureId));
4814 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4817 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
4819 GL_RGBA, GL_HALF_FLOAT, ::std::vector<uint8_t>{}))
4822 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
4825 EXPECT_CALL(GLProxy, GetError())
4827 .WillOnce(Return(GL_NO_ERROR));
4829 const auto pTexture = ::std::make_shared<Texture_t>(TextureData);
4830 ASSERT_EQ(Width * Height * 4, pTexture->m_ReadCopyData.size());
4832 (*_pDataTexture)[uT(
"entity")] = pTexture;
4834 EXPECT_CALL(GLProxy, GenFramebuffers(1))
4836 .WillOnce(Return(FrameBufferId));
4838 EXPECT_CALL(GLProxy, GenTextures(1))
4841 auto Render = itCreator->second(Component_t::Make(
4843 { uT(
"service"), Object_t{ _pDataTexture } }
4845 ASSERT_NE(
nullptr, Render);
4847 const auto TestCallActivateTexture = [&](void)
4849 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
4852 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
4855 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
4857 .WillOnce(Return(&ProgramId));
4859 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
4861 .WillOnce(Return(LocationId));
4863 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
4866 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
4872 EXPECT_CALL(oMapperProxy, Map(
nullptr))
4874 .WillOnce(Return(
false));
4876 EXPECT_CALL(GLProxy, BindFramebuffer(_, _))
4879 TestCallActivateTexture();
4884 EXPECT_CALL(oMapperProxy, Map(
nullptr))
4886 .WillOnce(Return(
true));
4888 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
4890 .WillOnce(Return(&DefaultFrameBufferId));
4892 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
4895 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER,
4896 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureId, 0))
4899 EXPECT_CALL(GLProxy, GetReadPixelsRawData())
4901 .WillOnce(Return(_RawData));
4903 EXPECT_CALL(GLProxy, ReadPixels(0, 0, Width, Height, GL_RGBA,
4904 GL_UNSIGNED_BYTE, pTexture->m_ReadCopyData.data()))
4907 EXPECT_CALL(oMapperProxy, CheckData(_ExpectData))
4910 EXPECT_CALL(oMapperProxy, Map(pTexture->m_ReadCopyData.data()))
4913 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, DefaultFrameBufferId))
4916 TestCallActivateTexture();
4921 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
4924 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
4928 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
4930 { uT(
"TexEnvironment"),
"TexEnvironment" },
4931 { uT(
"TexReflection"),
"TexReflection" },
4932 { uT(
"TexBaseColor"),
"TexBaseColor" },
4935 for (
int Index = 0; Index < Names.size(); Index++)
4937 const ::std::vector<uint32_t> RawData =
4939 0x10221334, 0x10221335, 0x10221336,
4940 0x10221337, 0x10221338, 0x10221339,
4941 0x10221340, 0x10221341, 0x10221342,
4942 0x10221343, 0x10221344, 0x10221345,
4945 const ::std::vector<uint32_t> ExpectData =
4947 0x10221343, 0x10221344, 0x10221345,
4948 0x10221340, 0x10221341, 0x10221342,
4949 0x10221337, 0x10221338, 0x10221339,
4950 0x10221334, 0x10221335, 0x10221336,
4953 const auto pData = Component_t::Make(
4955 { uT(
"kind"), uT(
"Texture") },
4956 { uT(
"width"), Width },
4957 { uT(
"height"), Height },
4958 { uT(
"mapper"), Mapper },
4959 { uT(
"name"), Names[Index].first },
4960 { uT(
"index"), Index },
4961 { uT(
"capacity"), 16 },
4964 TestCall(pData, Index, Names[Index].second, RawData, ExpectData);
4966 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
4968 { uT(
"albedo"),
"TexAlbedo" },
4969 { uT(
"metalness"),
"TexMetalness" },
4970 { uT(
"roughness"),
"TexRoughness" },
4971 { uT(
"normal"),
"TexNormal" },
4972 { uT(
"occlusion"),
"TexOcclusion" },
4975 for (::std::size_t i = 0; i < Destinations.size(); i++)
4977 const auto pData = Component_t::Make(
4979 { uT(
"kind"), uT(
"Texture") },
4980 { uT(
"width"), Width },
4981 { uT(
"height"), Height },
4982 { uT(
"mapper"), Mapper },
4983 { uT(
"name"), Names[Index].first },
4984 { uT(
"index"), Index },
4985 { uT(
"destination"), Destinations[i].first },
4986 { uT(
"capacity"), 16 },
4989 TestCall(pData, Index, Names[Index].second, RawData, ExpectData);
4995TEST_F(OpenGLShader_test, Test_Texture_ReadData_NameAndIndex_Capacity32)
4997 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
4998 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
5000 using GLProxy_t = ::mock::GLProxy;
5002 GLProxy_t::GetInstance() = &GLProxy;
5005 public ::alicorn::extension::testing::Proxy<MapperProxy>
5008 MOCK_METHOD1(Map,
bool(
const void *));
5009 MOCK_METHOD1(CheckData,
void(::std::vector<uint32_t>));
5012 MapperProxy oMapperProxy;
5013 MapperProxy::GetInstance() = &oMapperProxy;
5015 const int Width = 3;
5016 const int Height = 4;
5018 const BufferMapper_t Mapper = [&](
const void * _pData)
5020 if (_pData !=
nullptr)
5022 ::std::vector<uint32_t> Data(Width * Height);
5023 memcpy(Data.data(), _pData, Width * Height * 4);
5024 oMapperProxy.CheckData(Data);
5027 return oMapperProxy.Map(_pData);
5030 const Tested_t Example{ Data_t{} };
5031 const ITested_t & IExample = Example;
5033 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
5034 ASSERT_NE(IExample.GetCreators().end(), itCreator);
5036 const ::mock::GLint TextureId = 1910221154;
5037 const ::mock::GLint ProgramId = 1910221155;
5038 const ::mock::GLint LocationId = 1910221156;
5039 const ::mock::GLint FrameBufferId = 1910221209;
5040 const ::mock::GLint DefaultFrameBufferId = 1910221236;
5042 const auto TestCall = [&](
5043 const Component_t::ComponentPtr_t & _pDataTexture,
5044 const ::std::size_t _Index,
5045 const ::std::string & _TexName,
5046 const ::std::vector<uint32_t> & _RawData,
5047 const ::std::vector<uint32_t> & _ExpectData)
5049 const auto Index =
static_cast<::mock::GLint
>(_Index);
5051 ::covellite::api::renderer::Component::Texture TextureData{ *_pDataTexture, uT(
"") };
5053 using namespace ::testing;
5057 EXPECT_CALL(GLProxy, GenTextures(1))
5059 .WillOnce(Return(TextureId));
5061 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5064 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
5066 GL_RGBA, GL_FLOAT, ::std::vector<uint8_t>{}))
5069 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
5072 EXPECT_CALL(GLProxy, GetError())
5074 .WillOnce(Return(GL_NO_ERROR));
5076 const auto pTexture = ::std::make_shared<Texture_t>(TextureData);
5077 ASSERT_EQ(Width * Height * 4, pTexture->m_ReadCopyData.size());
5079 (*_pDataTexture)[uT(
"entity")] = pTexture;
5081 EXPECT_CALL(GLProxy, GenFramebuffers(1))
5083 .WillOnce(Return(FrameBufferId));
5085 EXPECT_CALL(GLProxy, GenTextures(1))
5088 auto Render = itCreator->second(Component_t::Make(
5090 { uT(
"service"), Object_t{ _pDataTexture } }
5092 ASSERT_NE(
nullptr, Render);
5094 const auto TestCallActivateTexture = [&](void)
5096 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
5099 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5102 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
5104 .WillOnce(Return(&ProgramId));
5106 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
5108 .WillOnce(Return(LocationId));
5110 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
5113 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
5119 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5121 .WillOnce(Return(
false));
5123 EXPECT_CALL(GLProxy, BindFramebuffer(_, _))
5126 TestCallActivateTexture();
5131 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5133 .WillOnce(Return(
true));
5135 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
5137 .WillOnce(Return(&DefaultFrameBufferId));
5139 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
5142 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER,
5143 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureId, 0))
5146 EXPECT_CALL(GLProxy, GetReadPixelsRawData())
5148 .WillOnce(Return(_RawData));
5150 EXPECT_CALL(GLProxy, ReadPixels(0, 0, Width, Height, GL_RGBA,
5151 GL_UNSIGNED_BYTE, pTexture->m_ReadCopyData.data()))
5154 EXPECT_CALL(oMapperProxy, CheckData(_ExpectData))
5157 EXPECT_CALL(oMapperProxy, Map(pTexture->m_ReadCopyData.data()))
5160 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, DefaultFrameBufferId))
5163 TestCallActivateTexture();
5168 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
5171 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
5175 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
5177 { uT(
"TexEnvironment"),
"TexEnvironment" },
5178 { uT(
"TexReflection"),
"TexReflection" },
5179 { uT(
"TexBaseColor"),
"TexBaseColor" },
5182 for (
int Index = 0; Index < Names.size(); Index++)
5184 const ::std::vector<uint32_t> RawData =
5186 0x10221334, 0x10221335, 0x10221336,
5187 0x10221337, 0x10221338, 0x10221339,
5188 0x10221340, 0x10221341, 0x10221342,
5189 0x10221343, 0x10221344, 0x10221345,
5192 const ::std::vector<uint32_t> ExpectData =
5194 0x10221343, 0x10221344, 0x10221345,
5195 0x10221340, 0x10221341, 0x10221342,
5196 0x10221337, 0x10221338, 0x10221339,
5197 0x10221334, 0x10221335, 0x10221336,
5200 const auto pData = Component_t::Make(
5202 { uT(
"kind"), uT(
"Texture") },
5203 { uT(
"width"), Width },
5204 { uT(
"height"), Height },
5205 { uT(
"mapper"), Mapper },
5206 { uT(
"name"), Names[Index].first },
5207 { uT(
"index"), Index },
5208 { uT(
"capacity"), 32 },
5211 TestCall(pData, Index, Names[Index].second, RawData, ExpectData);
5213 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
5215 { uT(
"albedo"),
"TexAlbedo" },
5216 { uT(
"metalness"),
"TexMetalness" },
5217 { uT(
"roughness"),
"TexRoughness" },
5218 { uT(
"normal"),
"TexNormal" },
5219 { uT(
"occlusion"),
"TexOcclusion" },
5222 for (::std::size_t i = 0; i < Destinations.size(); i++)
5224 const auto pData = Component_t::Make(
5226 { uT(
"kind"), uT(
"Texture") },
5227 { uT(
"width"), Width },
5228 { uT(
"height"), Height },
5229 { uT(
"mapper"), Mapper },
5230 { uT(
"name"), Names[Index].first },
5231 { uT(
"index"), Index },
5232 { uT(
"destination"), Destinations[i].first },
5233 { uT(
"capacity"), 32 },
5236 TestCall(pData, Index, Names[Index].second, RawData, ExpectData);
5242TEST_F(OpenGLShader_test, Test_Texture_ReadData_Destination)
5244 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
5245 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
5247 using GLProxy_t = ::mock::GLProxy;
5249 GLProxy_t::GetInstance() = &GLProxy;
5252 public ::alicorn::extension::testing::Proxy<MapperProxy>
5255 MOCK_METHOD1(Map,
bool(
const void *));
5256 MOCK_METHOD1(CheckData,
void(::std::vector<uint32_t>));
5259 MapperProxy oMapperProxy;
5260 MapperProxy::GetInstance() = &oMapperProxy;
5262 const int Width = 3;
5263 const int Height = 4;
5265 const BufferMapper_t Mapper = [&](
const void * _pData)
5267 if (_pData !=
nullptr)
5269 ::std::vector<uint32_t> Data(Width * Height);
5270 memcpy(Data.data(), _pData, Width * Height * 4);
5271 oMapperProxy.CheckData(Data);
5274 return oMapperProxy.Map(_pData);
5277 const Tested_t Example{ Data_t{} };
5278 const ITested_t & IExample = Example;
5280 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
5281 ASSERT_NE(IExample.GetCreators().end(), itCreator);
5283 const ::mock::GLint TextureId = 1910221154;
5284 const ::mock::GLint ProgramId = 1910221155;
5285 const ::mock::GLint LocationId = 1910221156;
5286 const ::mock::GLint FrameBufferId = 1910221209;
5287 const ::mock::GLint DefaultFrameBufferId = 1910221236;
5289 const auto TestCall = [&](
5290 const Component_t::ComponentPtr_t & _pDataTexture,
5291 const ::std::size_t _Index,
5292 const ::std::string & _TexName,
5293 const ::std::vector<uint32_t> & _RawData,
5294 const ::std::vector<uint32_t> & _ExpectData)
5296 const auto Index =
static_cast<::mock::GLint
>(_Index);
5298 ::covellite::api::renderer::Component::Texture TextureData{ *_pDataTexture, uT(
"") };
5300 using namespace ::testing;
5304 EXPECT_CALL(GLProxy, GenTextures(1))
5306 .WillOnce(Return(TextureId));
5308 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5311 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
5313 GL_RGBA, GL_UNSIGNED_BYTE, ::std::vector<uint8_t>{}))
5316 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
5319 EXPECT_CALL(GLProxy, GetError())
5321 .WillOnce(Return(GL_NO_ERROR));
5323 const auto pTexture = ::std::make_shared<Texture_t>(TextureData);
5324 ASSERT_EQ(Width * Height * 4, pTexture->m_ReadCopyData.size());
5326 (*_pDataTexture)[uT(
"entity")] = pTexture;
5328 EXPECT_CALL(GLProxy, GenFramebuffers(1))
5330 .WillOnce(Return(FrameBufferId));
5332 EXPECT_CALL(GLProxy, GenTextures(1))
5335 auto Render = itCreator->second(Component_t::Make(
5337 { uT(
"service"), Object_t{ _pDataTexture } }
5339 ASSERT_NE(
nullptr, Render);
5341 const auto TestCallActivateTexture = [&](void)
5343 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
5346 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5349 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
5351 .WillOnce(Return(&ProgramId));
5353 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
5355 .WillOnce(Return(LocationId));
5357 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
5360 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
5366 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5368 .WillOnce(Return(
false));
5370 EXPECT_CALL(GLProxy, BindFramebuffer(_, _))
5373 TestCallActivateTexture();
5378 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5380 .WillOnce(Return(
true));
5382 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
5384 .WillOnce(Return(&DefaultFrameBufferId));
5386 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
5389 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER,
5390 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureId, 0))
5393 EXPECT_CALL(GLProxy, GetReadPixelsRawData())
5395 .WillOnce(Return(_RawData));
5397 EXPECT_CALL(GLProxy, ReadPixels(0, 0, Width, Height, GL_RGBA,
5398 GL_UNSIGNED_BYTE, pTexture->m_ReadCopyData.data()))
5401 EXPECT_CALL(oMapperProxy, CheckData(_ExpectData))
5404 EXPECT_CALL(oMapperProxy, Map(pTexture->m_ReadCopyData.data()))
5407 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, DefaultFrameBufferId))
5410 TestCallActivateTexture();
5415 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
5418 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
5422 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
5424 { uT(
"albedo"),
"TexAlbedo" },
5425 { uT(
"metalness"),
"TexMetalness" },
5426 { uT(
"roughness"),
"TexRoughness" },
5427 { uT(
"normal"),
"TexNormal" },
5428 { uT(
"occlusion"),
"TexOcclusion" },
5431 for (::std::size_t i = 0; i < Destinations.size(); i++)
5433 const ::std::vector<uint32_t> RawData =
5435 0x10221334, 0x10221335, 0x10221336,
5436 0x10221337, 0x10221338, 0x10221339,
5437 0x10221340, 0x10221341, 0x10221342,
5438 0x10221343, 0x10221344, 0x10221345,
5441 const ::std::vector<uint32_t> ExpectData =
5443 0x10221343, 0x10221344, 0x10221345,
5444 0x10221340, 0x10221341, 0x10221342,
5445 0x10221337, 0x10221338, 0x10221339,
5446 0x10221334, 0x10221335, 0x10221336,
5449 const auto pData = Component_t::Make(
5451 { uT(
"kind"), uT(
"Texture") },
5452 { uT(
"width"), Width },
5453 { uT(
"height"), Height },
5454 { uT(
"mapper"), Mapper },
5455 { uT(
"destination"), Destinations[i].first },
5458 TestCall(pData, i, Destinations[i].second, RawData, ExpectData);
5463TEST_F(OpenGLShader_test, Test_Texture_ReadData_Destination_Capacity16)
5465 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
5466 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
5468 using GLProxy_t = ::mock::GLProxy;
5470 GLProxy_t::GetInstance() = &GLProxy;
5473 public ::alicorn::extension::testing::Proxy<MapperProxy>
5476 MOCK_METHOD1(Map,
bool(
const void *));
5477 MOCK_METHOD1(CheckData,
void(::std::vector<uint32_t>));
5480 MapperProxy oMapperProxy;
5481 MapperProxy::GetInstance() = &oMapperProxy;
5483 const int Width = 3;
5484 const int Height = 4;
5486 const BufferMapper_t Mapper = [&](
const void * _pData)
5488 if (_pData !=
nullptr)
5490 ::std::vector<uint32_t> Data(Width * Height);
5491 memcpy(Data.data(), _pData, Width * Height * 4);
5492 oMapperProxy.CheckData(Data);
5495 return oMapperProxy.Map(_pData);
5498 const Tested_t Example{ Data_t{} };
5499 const ITested_t & IExample = Example;
5501 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
5502 ASSERT_NE(IExample.GetCreators().end(), itCreator);
5504 const ::mock::GLint TextureId = 1910221154;
5505 const ::mock::GLint ProgramId = 1910221155;
5506 const ::mock::GLint LocationId = 1910221156;
5507 const ::mock::GLint FrameBufferId = 1910221209;
5508 const ::mock::GLint DefaultFrameBufferId = 1910221236;
5510 const auto TestCall = [&](
5511 const Component_t::ComponentPtr_t & _pDataTexture,
5512 const ::std::size_t _Index,
5513 const ::std::string & _TexName,
5514 const ::std::vector<uint32_t> & _RawData,
5515 const ::std::vector<uint32_t> & _ExpectData)
5517 const auto Index =
static_cast<::mock::GLint
>(_Index);
5519 ::covellite::api::renderer::Component::Texture TextureData{ *_pDataTexture, uT(
"") };
5521 using namespace ::testing;
5525 EXPECT_CALL(GLProxy, GenTextures(1))
5527 .WillOnce(Return(TextureId));
5529 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5532 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,
5534 GL_RGBA, GL_HALF_FLOAT, ::std::vector<uint8_t>{}))
5537 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
5540 EXPECT_CALL(GLProxy, GetError())
5542 .WillOnce(Return(GL_NO_ERROR));
5544 const auto pTexture = ::std::make_shared<Texture_t>(TextureData);
5545 ASSERT_EQ(Width * Height * 4, pTexture->m_ReadCopyData.size());
5547 (*_pDataTexture)[uT(
"entity")] = pTexture;
5549 EXPECT_CALL(GLProxy, GenFramebuffers(1))
5551 .WillOnce(Return(FrameBufferId));
5553 EXPECT_CALL(GLProxy, GenTextures(1))
5556 auto Render = itCreator->second(Component_t::Make(
5558 { uT(
"service"), Object_t{ _pDataTexture } }
5560 ASSERT_NE(
nullptr, Render);
5562 const auto TestCallActivateTexture = [&](void)
5564 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
5567 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5570 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
5572 .WillOnce(Return(&ProgramId));
5574 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
5576 .WillOnce(Return(LocationId));
5578 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
5581 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
5587 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5589 .WillOnce(Return(
false));
5591 EXPECT_CALL(GLProxy, BindFramebuffer(_, _))
5594 TestCallActivateTexture();
5599 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5601 .WillOnce(Return(
true));
5603 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
5605 .WillOnce(Return(&DefaultFrameBufferId));
5607 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
5610 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER,
5611 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureId, 0))
5614 EXPECT_CALL(GLProxy, GetReadPixelsRawData())
5616 .WillOnce(Return(_RawData));
5618 EXPECT_CALL(GLProxy, ReadPixels(0, 0, Width, Height, GL_RGBA,
5619 GL_UNSIGNED_BYTE, pTexture->m_ReadCopyData.data()))
5622 EXPECT_CALL(oMapperProxy, CheckData(_ExpectData))
5625 EXPECT_CALL(oMapperProxy, Map(pTexture->m_ReadCopyData.data()))
5628 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, DefaultFrameBufferId))
5631 TestCallActivateTexture();
5636 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
5639 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
5643 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
5645 { uT(
"albedo"),
"TexAlbedo" },
5646 { uT(
"metalness"),
"TexMetalness" },
5647 { uT(
"roughness"),
"TexRoughness" },
5648 { uT(
"normal"),
"TexNormal" },
5649 { uT(
"occlusion"),
"TexOcclusion" },
5652 for (::std::size_t i = 0; i < Destinations.size(); i++)
5654 const ::std::vector<uint32_t> RawData =
5656 0x10221334, 0x10221335, 0x10221336,
5657 0x10221337, 0x10221338, 0x10221339,
5658 0x10221340, 0x10221341, 0x10221342,
5659 0x10221343, 0x10221344, 0x10221345,
5662 const ::std::vector<uint32_t> ExpectData =
5664 0x10221343, 0x10221344, 0x10221345,
5665 0x10221340, 0x10221341, 0x10221342,
5666 0x10221337, 0x10221338, 0x10221339,
5667 0x10221334, 0x10221335, 0x10221336,
5670 const auto pData = Component_t::Make(
5672 { uT(
"kind"), uT(
"Texture") },
5673 { uT(
"width"), Width },
5674 { uT(
"height"), Height },
5675 { uT(
"mapper"), Mapper },
5676 { uT(
"destination"), Destinations[i].first },
5677 { uT(
"capacity"), 16 },
5680 TestCall(pData, i, Destinations[i].second, RawData, ExpectData);
5685TEST_F(OpenGLShader_test, Test_Texture_ReadData_Destination_Capacity32)
5687 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
5688 using BufferMapper_t = ::covellite::api::cbBufferMap_t<const void>;
5690 using GLProxy_t = ::mock::GLProxy;
5692 GLProxy_t::GetInstance() = &GLProxy;
5695 public ::alicorn::extension::testing::Proxy<MapperProxy>
5698 MOCK_METHOD1(Map,
bool(
const void *));
5699 MOCK_METHOD1(CheckData,
void(::std::vector<uint32_t>));
5702 MapperProxy oMapperProxy;
5703 MapperProxy::GetInstance() = &oMapperProxy;
5705 const int Width = 3;
5706 const int Height = 4;
5708 const BufferMapper_t Mapper = [&](
const void * _pData)
5710 if (_pData !=
nullptr)
5712 ::std::vector<uint32_t> Data(Width * Height);
5713 memcpy(Data.data(), _pData, Width * Height * 4);
5714 oMapperProxy.CheckData(Data);
5717 return oMapperProxy.Map(_pData);
5720 const Tested_t Example{ Data_t{} };
5721 const ITested_t & IExample = Example;
5723 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
5724 ASSERT_NE(IExample.GetCreators().end(), itCreator);
5726 const ::mock::GLint TextureId = 1910221154;
5727 const ::mock::GLint ProgramId = 1910221155;
5728 const ::mock::GLint LocationId = 1910221156;
5729 const ::mock::GLint FrameBufferId = 1910221209;
5730 const ::mock::GLint DefaultFrameBufferId = 1910221236;
5732 const auto TestCall = [&](
5733 const Component_t::ComponentPtr_t & _pDataTexture,
5734 const ::std::size_t _Index,
5735 const ::std::string & _TexName,
5736 const ::std::vector<uint32_t> & _RawData,
5737 const ::std::vector<uint32_t> & _ExpectData)
5739 const auto Index =
static_cast<::mock::GLint
>(_Index);
5741 ::covellite::api::renderer::Component::Texture TextureData{ *_pDataTexture, uT(
"") };
5743 using namespace ::testing;
5747 EXPECT_CALL(GLProxy, GenTextures(1))
5749 .WillOnce(Return(TextureId));
5751 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5754 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F,
5756 GL_RGBA, GL_FLOAT, ::std::vector<uint8_t>{}))
5759 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
5762 EXPECT_CALL(GLProxy, GetError())
5764 .WillOnce(Return(GL_NO_ERROR));
5766 const auto pTexture = ::std::make_shared<Texture_t>(TextureData);
5767 ASSERT_EQ(Width * Height * 4, pTexture->m_ReadCopyData.size());
5769 (*_pDataTexture)[uT(
"entity")] = pTexture;
5771 EXPECT_CALL(GLProxy, GenFramebuffers(1))
5773 .WillOnce(Return(FrameBufferId));
5775 EXPECT_CALL(GLProxy, GenTextures(1))
5778 auto Render = itCreator->second(Component_t::Make(
5780 { uT(
"service"), Object_t{ _pDataTexture } }
5782 ASSERT_NE(
nullptr, Render);
5784 const auto TestCallActivateTexture = [&](void)
5786 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
5789 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5792 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
5794 .WillOnce(Return(&ProgramId));
5796 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
5798 .WillOnce(Return(LocationId));
5800 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
5803 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
5809 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5811 .WillOnce(Return(
false));
5813 EXPECT_CALL(GLProxy, BindFramebuffer(_, _))
5816 TestCallActivateTexture();
5821 EXPECT_CALL(oMapperProxy, Map(
nullptr))
5823 .WillOnce(Return(
true));
5825 EXPECT_CALL(GLProxy, GetIntegerv(GL_FRAMEBUFFER_BINDING))
5827 .WillOnce(Return(&DefaultFrameBufferId));
5829 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, FrameBufferId))
5832 EXPECT_CALL(GLProxy, FramebufferTexture2D(GL_FRAMEBUFFER,
5833 GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureId, 0))
5836 EXPECT_CALL(GLProxy, GetReadPixelsRawData())
5838 .WillOnce(Return(_RawData));
5840 EXPECT_CALL(GLProxy, ReadPixels(0, 0, Width, Height, GL_RGBA,
5841 GL_UNSIGNED_BYTE, pTexture->m_ReadCopyData.data()))
5844 EXPECT_CALL(oMapperProxy, CheckData(_ExpectData))
5847 EXPECT_CALL(oMapperProxy, Map(pTexture->m_ReadCopyData.data()))
5850 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, DefaultFrameBufferId))
5853 TestCallActivateTexture();
5858 EXPECT_CALL(GLProxy, DeleteFramebuffers(1, FrameBufferId))
5861 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
5865 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
5867 { uT(
"albedo"),
"TexAlbedo" },
5868 { uT(
"metalness"),
"TexMetalness" },
5869 { uT(
"roughness"),
"TexRoughness" },
5870 { uT(
"normal"),
"TexNormal" },
5871 { uT(
"occlusion"),
"TexOcclusion" },
5874 for (::std::size_t i = 0; i < Destinations.size(); i++)
5876 const ::std::vector<uint32_t> RawData =
5878 0x10221334, 0x10221335, 0x10221336,
5879 0x10221337, 0x10221338, 0x10221339,
5880 0x10221340, 0x10221341, 0x10221342,
5881 0x10221343, 0x10221344, 0x10221345,
5884 const ::std::vector<uint32_t> ExpectData =
5886 0x10221343, 0x10221344, 0x10221345,
5887 0x10221340, 0x10221341, 0x10221342,
5888 0x10221337, 0x10221338, 0x10221339,
5889 0x10221334, 0x10221335, 0x10221336,
5892 const auto pData = Component_t::Make(
5894 { uT(
"kind"), uT(
"Texture") },
5895 { uT(
"width"), Width },
5896 { uT(
"height"), Height },
5897 { uT(
"mapper"), Mapper },
5898 { uT(
"destination"), Destinations[i].first },
5899 { uT(
"capacity"), 32 },
5902 TestCall(pData, i, Destinations[i].second, RawData, ExpectData);
5907TEST_F(OpenGLShader_test, Test_Texture_Depth_NameAndIndex)
5909 using GLProxy_t = ::mock::GLProxy;
5911 GLProxy_t::GetInstance() = &GLProxy;
5913 const Tested_t Example{ Data_t{} };
5914 const ITested_t & IExample = Example;
5916 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
5917 ASSERT_NE(IExample.GetCreators().end(), itCreator);
5919 const ::mock::GLuint TextureId = 1910041336;
5920 const ::mock::GLint ProgramId = 1910041337;
5921 const ::mock::GLint LocationId = 1910041338;
5923 const auto TestCall = [&](
5924 const Component_t::ComponentPtr_t & _pTexture,
5925 const ::std::vector<uint8_t> & _Source,
5926 const int _Width,
const int _Height,
5927 const ::std::size_t _Index,
5928 const ::std::string & _TexName)
5930 const auto Index =
static_cast<::mock::GLint
>(_Index);
5932 using namespace ::testing;
5936 EXPECT_CALL(GLProxy, GenTextures(1))
5938 .WillOnce(Return(TextureId));
5940 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5943 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
5945 GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, _Source))
5948 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
5951 EXPECT_CALL(GLProxy, GetError())
5953 .WillOnce(Return(GL_NO_ERROR));
5955 auto Render = itCreator->second(_pTexture);
5956 ASSERT_NE(
nullptr, Render);
5958 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
5961 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
5964 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
5966 .WillOnce(Return(&ProgramId));
5968 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
5970 .WillOnce(Return(LocationId));
5972 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
5975 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
5980 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
5984 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
5986 { uT(
"TexEnvironment"),
"TexEnvironment" },
5987 { uT(
"TexReflection"),
"TexReflection" },
5988 { uT(
"TexBaseColor"),
"TexBaseColor" },
5991 for (
int Index = 0; Index < Names.size(); Index++)
5993 ::std::vector<uint8_t> Source =
5995 0x20, 0x06, 0x15, 0x12, 0x32,
5996 0x20, 0x06, 0x15, 0x12, 0x32,
5997 0x20, 0x06, 0x15, 0x12, 0x32,
5998 0x20, 0x06, 0x15, 0x12, 0x32,
5999 0x20, 0x06, 0x15, 0x12, 0x32,
6001 IntroduceBufferSize(Source);
6004 const int Width = 1910041343;
6005 const int Height = 1910041344;
6007 const auto pTexture = Component_t::Make(
6009 { uT(
"content"), Source },
6010 { uT(
"width"), Width },
6011 { uT(
"height"), Height },
6012 { uT(
"name"), Names[Index].first },
6013 { uT(
"index"), Index },
6014 { uT(
"destination"), uT(
"depth") },
6017 TestCall(pTexture, Source, Width, Height, Index, Names[Index].second);
6021 const int Width = 1910041346;
6022 const int Height = 1910041347;
6024 const auto pData = Component_t::Make(
6026 { uT(
"kind"), uT(
"Texture") },
6027 { uT(
"content"), Source },
6028 { uT(
"width"), Width },
6029 { uT(
"height"), Height },
6030 { uT(
"name"), Names[Index].first },
6031 { uT(
"index"), Index },
6032 { uT(
"destination"), uT(
"depth") },
6035 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6036 Source, Width, Height, Index, Names[Index].second);
6042TEST_F(OpenGLShader_test, Test_Texture_Depth_Destination)
6044 using GLProxy_t = ::mock::GLProxy;
6046 GLProxy_t::GetInstance() = &GLProxy;
6048 const Tested_t Example{ Data_t{} };
6049 const ITested_t & IExample = Example;
6051 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
6052 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6054 const ::mock::GLuint TextureId = 1910041336;
6055 const ::mock::GLint ProgramId = 1910041337;
6056 const ::mock::GLint LocationId = 1910041338;
6058 const auto TestCall = [&](
6059 const Component_t::ComponentPtr_t & _pTexture,
6060 const ::std::vector<uint8_t> & _Source,
6061 const int _Width,
const int _Height,
6062 const ::std::size_t _Index,
6063 const ::std::string & _TexName)
6065 const auto Index =
static_cast<::mock::GLint
>(_Index);
6067 using namespace ::testing;
6071 EXPECT_CALL(GLProxy, GenTextures(1))
6073 .WillOnce(Return(TextureId));
6075 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
6078 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
6080 GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, _Source))
6083 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
6086 EXPECT_CALL(GLProxy, GetError())
6088 .WillOnce(Return(GL_NO_ERROR));
6090 auto Render = itCreator->second(_pTexture);
6091 ASSERT_NE(
nullptr, Render);
6093 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
6096 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
6099 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
6101 .WillOnce(Return(&ProgramId));
6103 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
6105 .WillOnce(Return(LocationId));
6107 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
6110 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
6115 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
6119 ::std::vector<uint8_t> Source =
6121 0x20, 0x06, 0x15, 0x12, 0x32,
6122 0x20, 0x06, 0x15, 0x12, 0x32,
6123 0x20, 0x06, 0x15, 0x12, 0x32,
6124 0x20, 0x06, 0x15, 0x12, 0x32,
6125 0x20, 0x06, 0x15, 0x12, 0x32,
6127 IntroduceBufferSize(Source);
6130 const int Width = 1910041343;
6131 const int Height = 1910041344;
6133 const auto pTexture = Component_t::Make(
6135 { uT(
"content"), Source },
6136 { uT(
"width"), Width },
6137 { uT(
"height"), Height },
6138 { uT(
"destination"), uT(
"depth") },
6141 TestCall(pTexture, Source, Width, Height, 5,
"TexDepth");
6145 const int Width = 1910041346;
6146 const int Height = 1910041347;
6148 const auto pData = Component_t::Make(
6150 { uT(
"kind"), uT(
"Texture") },
6151 { uT(
"content"), Source },
6152 { uT(
"width"), Width },
6153 { uT(
"height"), Height },
6154 { uT(
"destination"), uT(
"depth") },
6157 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6158 Source, Width, Height, 5,
"TexDepth");
6163TEST_F(OpenGLShader_test, Test_Texture_UsingExists_NameAndIndex)
6165 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
6167 using GLProxy_t = ::mock::GLProxy;
6169 GLProxy_t::GetInstance() = &GLProxy;
6171 const Tested_t Example{ Data_t{} };
6172 const ITested_t & IExample = Example;
6174 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
6175 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6177 const ::mock::GLuint TextureId = 1908221839;
6178 const ::mock::GLint ProgramId = 1908221840;
6179 const ::mock::GLint LocationId = 1908221841;
6181 const auto TestCall = [&](
6182 const Component_t::ComponentPtr_t & _pData,
6183 const Component_t::ComponentPtr_t & _pTexture,
6184 const ::std::vector<uint8_t> & _Source,
6185 const int _Width,
const int _Height,
6186 const ::std::size_t _Index,
6187 const ::std::string & _TexName)
6189 const ::covellite::api::renderer::Component::Texture TextureData{ *_pData, uT(
"") };
6190 const auto Index =
static_cast<::mock::GLint
>(_Index);
6192 using namespace ::testing;
6196 EXPECT_CALL(GLProxy, GenTextures(1))
6198 .WillOnce(Return(TextureId));
6200 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
6203 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, _,
6204 _Width, _Height, 0, _, _, _Source))
6207 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
6210 EXPECT_CALL(GLProxy, GetError())
6212 .WillOnce(Return(GL_NO_ERROR));
6214 (*_pData)[uT(
"entity")] = ::std::make_shared<Texture_t>(TextureData);
6216 EXPECT_CALL(GLProxy, GenTextures(_))
6219 auto Render = itCreator->second(_pTexture);
6220 ASSERT_NE(
nullptr, Render);
6222 const Texture_t::Ptr_t pEntity = (*_pData)[uT(
"entity")].Default(Texture_t::Ptr_t{});
6223 EXPECT_EQ(
nullptr, pEntity);
6225 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
6228 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
6231 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
6233 .WillOnce(Return(&ProgramId));
6235 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
6237 .WillOnce(Return(LocationId));
6239 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
6244 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
6248 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
6250 { uT(
"TexEnvironment"),
"TexEnvironment" },
6251 { uT(
"TexReflection"),
"TexReflection" },
6252 { uT(
"TexBaseColor"),
"TexBaseColor" },
6255 for (
int Index = 0; Index < Names.size(); Index++)
6257 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
6259 { uT(
"albedo"),
"TexAlbedo" },
6260 { uT(
"metalness"),
"TexMetalness" },
6261 { uT(
"roughness"),
"TexRoughness" },
6262 { uT(
"normal"),
"TexNormal" },
6263 { uT(
"occlusion"),
"TexOcclusion" },
6264 { uT(
"depth"),
"TexDepth" },
6267 ::std::vector<uint8_t> Source =
6269 0x20, 0x06, 0x15, 0x12, 0x33,
6270 0x20, 0x06, 0x15, 0x12, 0x33,
6271 0x20, 0x06, 0x15, 0x12, 0x33,
6272 0x20, 0x06, 0x15, 0x12, 0x33,
6273 0x20, 0x06, 0x15, 0x12, 0x33,
6275 IntroduceBufferSize(Source);
6277 for (::std::size_t i = 0; i < Destinations.size(); i++)
6279 const int Width = 1908221845;
6280 const int Height = 1908221847;
6282 const auto pData = Component_t::Make(
6284 { uT(
"kind"), uT(
"Texture") },
6285 { uT(
"content"), Source },
6286 { uT(
"width"), Width },
6287 { uT(
"height"), Height },
6288 { uT(
"name"), Names[Index].first },
6289 { uT(
"index"), Index },
6290 { uT(
"destination"), Destinations[i].first },
6293 TestCall(pData, Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6294 Source, Width, Height, Index, Names[Index].second);
6300TEST_F(OpenGLShader_test, Test_Texture_UsingExists_Destination)
6302 using Texture_t = ::covellite::api::renderer::OpenGLCommon::Texture;
6304 using GLProxy_t = ::mock::GLProxy;
6306 GLProxy_t::GetInstance() = &GLProxy;
6308 const Tested_t Example{ Data_t{} };
6309 const ITested_t & IExample = Example;
6311 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
6312 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6314 const ::mock::GLuint TextureId = 1908221839;
6315 const ::mock::GLint ProgramId = 1908221840;
6316 const ::mock::GLint LocationId = 1908221841;
6318 const auto TestCall = [&](
6319 const Component_t::ComponentPtr_t & _pData,
6320 const Component_t::ComponentPtr_t & _pTexture,
6321 const ::std::vector<uint8_t> & _Source,
6322 const int _Width,
const int _Height,
6323 const ::std::size_t _Index,
6324 const ::std::string & _TexName)
6326 const ::covellite::api::renderer::Component::Texture TextureData{ *_pData, uT(
"") };
6327 const auto Index =
static_cast<::mock::GLint
>(_Index);
6329 using namespace ::testing;
6333 EXPECT_CALL(GLProxy, GenTextures(1))
6335 .WillOnce(Return(TextureId));
6337 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
6340 EXPECT_CALL(GLProxy, TexImage2D(GL_TEXTURE_2D, 0, _,
6341 _Width, _Height, 0, _, _, _Source))
6344 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, 0))
6347 EXPECT_CALL(GLProxy, GetError())
6349 .WillOnce(Return(GL_NO_ERROR));
6351 (*_pData)[uT(
"entity")] = ::std::make_shared<Texture_t>(TextureData);
6353 EXPECT_CALL(GLProxy, GenTextures(_))
6356 auto Render = itCreator->second(_pTexture);
6357 ASSERT_NE(
nullptr, Render);
6359 const Texture_t::Ptr_t pEntity = (*_pData)[uT(
"entity")].Default(Texture_t::Ptr_t{});
6360 EXPECT_EQ(
nullptr, pEntity);
6362 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
6365 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D, TextureId))
6368 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
6370 .WillOnce(Return(&ProgramId));
6372 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
6374 .WillOnce(Return(LocationId));
6376 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
6381 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
6385 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
6387 { uT(
"albedo"),
"TexAlbedo" },
6388 { uT(
"metalness"),
"TexMetalness" },
6389 { uT(
"roughness"),
"TexRoughness" },
6390 { uT(
"normal"),
"TexNormal" },
6391 { uT(
"occlusion"),
"TexOcclusion" },
6392 { uT(
"depth"),
"TexDepth" },
6395 ::std::vector<uint8_t> Source =
6397 0x20, 0x06, 0x15, 0x12, 0x33,
6398 0x20, 0x06, 0x15, 0x12, 0x33,
6399 0x20, 0x06, 0x15, 0x12, 0x33,
6400 0x20, 0x06, 0x15, 0x12, 0x33,
6401 0x20, 0x06, 0x15, 0x12, 0x33,
6403 IntroduceBufferSize(Source);
6405 for (::std::size_t i = 0; i < Destinations.size(); i++)
6407 const int Width = 1908221845;
6408 const int Height = 1908221847;
6410 const auto pData = Component_t::Make(
6412 { uT(
"kind"), uT(
"Texture") },
6413 { uT(
"content"), Source },
6414 { uT(
"width"), Width },
6415 { uT(
"height"), Height },
6416 { uT(
"destination"), Destinations[i].first },
6419 TestCall(pData, Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6420 Source, Width, Height, i, Destinations[i].second);
6425TEST_F(OpenGLShader_test, Test_Texture_NoDeclaredInShader)
6427 using GLProxy_t = ::mock::GLProxy;
6429 GLProxy_t::GetInstance() = &GLProxy;
6431 const Tested_t Example{ Data_t{} };
6432 const ITested_t & IExample = Example;
6434 auto itCreator = IExample.GetCreators().find(uT(
"Texture"));
6435 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6437 const ::mock::GLuint TextureId = 1908221839;
6439 const auto TestCall = [&](
6440 const Component_t::ComponentPtr_t & _pTexture,
6441 const ::std::vector<uint8_t> & ,
6442 const int ,
const int ,
6443 const ::std::size_t _Index,
6444 const ::std::string & _TexName)
6446 const auto Index =
static_cast<::mock::GLint
>(_Index);
6448 using namespace ::testing;
6452 EXPECT_CALL(GLProxy, GenTextures(1))
6454 .WillOnce(Return(TextureId));
6456 auto Render = itCreator->second(_pTexture);
6457 ASSERT_NE(
nullptr, Render);
6459 EXPECT_CALL(GLProxy, GetUniformLocation(_, _TexName))
6461 .WillOnce(Return(-1));
6463 EXPECT_CALL(GLProxy, Uniform1i(_, _))
6468 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
6472 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
6474 { uT(
"albedo"),
"TexAlbedo" },
6475 { uT(
"metalness"),
"TexMetalness" },
6476 { uT(
"roughness"),
"TexRoughness" },
6477 { uT(
"normal"),
"TexNormal" },
6478 { uT(
"occlusion"),
"TexOcclusion" },
6479 { uT(
"depth"),
"TexDepth" },
6482 ::std::vector<uint8_t> Source =
6484 0x20, 0x06, 0x15, 0x12, 0x34,
6485 0x20, 0x06, 0x15, 0x12, 0x34,
6486 0x20, 0x06, 0x15, 0x12, 0x34,
6487 0x20, 0x06, 0x15, 0x12, 0x34,
6488 0x20, 0x06, 0x15, 0x12, 0x34,
6490 IntroduceBufferSize(Source);
6492 for (::std::size_t i = 0; i < Destinations.size(); i++)
6495 const uint8_t * pSource = (uint8_t *)1908221842;
6496 const int Width = 1908221843;
6497 const int Height = 1908221844;
6499 const auto pTexture = Component_t::Make(
6501 { uT(
"content"), Source },
6502 { uT(
"width"), Width },
6503 { uT(
"height"), Height },
6504 { uT(
"destination"), Destinations[i].first },
6508 Source, Width, Height, i, Destinations[i].second);
6512 const uint8_t * pSource = (uint8_t *)1908221846;
6513 const int Width = 1908221845;
6514 const int Height = 1908221847;
6516 const auto pData = Component_t::Make(
6518 { uT(
"kind"), uT(
"Texture") },
6519 { uT(
"content"), Source },
6520 { uT(
"width"), Width },
6521 { uT(
"height"), Height },
6522 { uT(
"destination"), Destinations[i].first },
6525 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6526 Source, Width, Height, i, Destinations[i].second);
6532TEST_F(OpenGLShader_test, Test_TextureArray_Default)
6534 using GLProxy_t = ::mock::GLProxy;
6536 GLProxy_t::GetInstance() = &GLProxy;
6538 const Tested_t Example{ Data_t{} };
6539 const ITested_t & IExample = Example;
6541 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
6542 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6544 const ::mock::GLuint TextureId = 1812181809;
6545 const ::mock::GLint ProgramId = 1908221258;
6546 const ::mock::GLint LocationId = 1908221259;
6548 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pTexture,
6549 const ::std::vector<uint8_t> & _Source,
const int _Width,
const int _Height)
6551 using namespace ::testing;
6555 EXPECT_CALL(GLProxy, GenTextures(1))
6557 .WillOnce(Return(TextureId));
6559 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
6562 EXPECT_CALL(GLProxy, TexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8,
6563 _Width, _Height, 1))
6566 EXPECT_CALL(GLProxy, TexSubImage3D_1(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0,
6570 EXPECT_CALL(GLProxy, TexSubImage3D_2(1, GL_RGBA,
6571 GL_UNSIGNED_BYTE, _Source))
6574 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, 0))
6577 EXPECT_CALL(GLProxy, GetError())
6579 .WillOnce(Return(GL_NO_ERROR));
6581 auto Render = itCreator->second(_pTexture);
6582 ASSERT_NE(
nullptr, Render);
6584 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0))
6587 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
6590 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
6592 .WillOnce(Return(&ProgramId));
6594 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"TexDiffuse")))
6596 .WillOnce(Return(LocationId));
6598 EXPECT_CALL(GLProxy, Uniform1i(LocationId, 0))
6603 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
6608 ::std::vector<uint8_t> Source =
6610 0x20, 0x06, 0x15, 0x12, 0x28,
6611 0x20, 0x06, 0x15, 0x12, 0x28,
6612 0x20, 0x06, 0x15, 0x12, 0x28,
6613 0x20, 0x06, 0x15, 0x12, 0x28,
6614 0x20, 0x06, 0x15, 0x12, 0x28,
6615 0x20, 0x06, 0x15, 0x12, 0x28,
6616 0x20, 0x06, 0x15, 0x12, 0x28,
6617 0x20, 0x06, 0x15, 0x12, 0x28,
6619 IntroduceBufferSize(Source);
6621 const int Width = 1812181807;
6622 const int Height = 1812181808;
6624 const auto pTexture = Component_t::Make(
6626 { uT(
"content"), ::std::vector{ Source } },
6627 { uT(
"width"), Width },
6628 { uT(
"height"), Height },
6631 TestCall(pTexture, Source, Width, Height);
6635 ::std::vector<uint8_t> Source =
6637 0x20, 0x06, 0x15, 0x12, 0x29,
6638 0x20, 0x06, 0x15, 0x12, 0x29,
6639 0x20, 0x06, 0x15, 0x12, 0x29,
6640 0x25, 0x04, 0x07, 0x21, 0x03,
6641 0x25, 0x04, 0x07, 0x21, 0x04,
6642 0x25, 0x04, 0x07, 0x21, 0x05,
6643 0x25, 0x04, 0x07, 0x21, 0x06
6645 IntroduceBufferSize(Source);
6647 const int Width = 1907251057;
6648 const int Height = 1907251058;
6650 const auto pData = Component_t::Make(
6652 { uT(
"kind"), uT(
"TextureArray") },
6653 { uT(
"content"), ::std::vector{ Source } },
6654 { uT(
"width"), Width },
6655 { uT(
"height"), Height },
6658 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6659 Source, Width, Height);
6664TEST_F(OpenGLShader_test, Test_TextureArray_NameAndIndex)
6666 using GLProxy_t = ::mock::GLProxy;
6668 GLProxy_t::GetInstance() = &GLProxy;
6670 const Tested_t Example{ Data_t{} };
6671 const ITested_t & IExample = Example;
6673 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
6674 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6676 const ::mock::GLuint TextureId = 1908221839;
6677 const ::mock::GLint ProgramId = 1908221840;
6678 const ::mock::GLint LocationId = 1908221841;
6680 const auto TestCall = [&](
6681 const Component_t::ComponentPtr_t & _pTexture,
6682 const ::std::vector<uint8_t> & _Source,
6683 const int _Width,
const int _Height,
6684 const ::std::size_t _Index,
6685 const ::std::string & _TexName)
6687 const auto Index =
static_cast<::mock::GLint
>(_Index);
6689 using namespace ::testing;
6693 EXPECT_CALL(GLProxy, GenTextures(1))
6695 .WillOnce(Return(TextureId));
6697 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
6700 EXPECT_CALL(GLProxy, TexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8,
6701 _Width, _Height, 1))
6704 EXPECT_CALL(GLProxy, TexSubImage3D_1(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0,
6708 EXPECT_CALL(GLProxy, TexSubImage3D_2(1, GL_RGBA,
6709 GL_UNSIGNED_BYTE, _Source))
6712 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, 0))
6715 EXPECT_CALL(GLProxy, GetError())
6717 .WillOnce(Return(GL_NO_ERROR));
6719 auto Render = itCreator->second(_pTexture);
6720 ASSERT_NE(
nullptr, Render);
6722 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
6725 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
6728 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
6730 .WillOnce(Return(&ProgramId));
6732 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
6734 .WillOnce(Return(LocationId));
6736 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
6739 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
6744 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
6748 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
6750 { uT(
"TexEnvironment"),
"TexEnvironment" },
6751 { uT(
"TexReflection"),
"TexReflection" },
6752 { uT(
"TexBaseColor"),
"TexBaseColor" },
6755 for (
int Index = 0; Index < Names.size(); Index++)
6757 ::std::vector<uint8_t> Source =
6759 0x20, 0x06, 0x15, 0x12, 0x30,
6760 0x20, 0x06, 0x15, 0x12, 0x30,
6761 0x20, 0x06, 0x15, 0x12, 0x30,
6762 0x20, 0x06, 0x15, 0x12, 0x30,
6763 0x20, 0x06, 0x15, 0x12, 0x30,
6765 IntroduceBufferSize(Source);
6768 const int Width = 1908221843;
6769 const int Height = 1908221844;
6771 const auto pTexture = Component_t::Make(
6773 { uT(
"content"), ::std::vector{ Source } },
6774 { uT(
"width"), Width },
6775 { uT(
"height"), Height },
6776 { uT(
"name"), Names[Index].first },
6777 { uT(
"index"), Index },
6781 Source, Width, Height, Index, Names[Index].second);
6785 const int Width = 1908221845;
6786 const int Height = 1908221847;
6788 const auto pData = Component_t::Make(
6790 { uT(
"kind"), uT(
"TextureArray") },
6791 { uT(
"content"), ::std::vector{ Source } },
6792 { uT(
"width"), Width },
6793 { uT(
"height"), Height },
6794 { uT(
"name"), Names[Index].first },
6795 { uT(
"index"), Index },
6798 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6799 Source, Width, Height, Index, Names[Index].second);
6803 const int Width = 1908221843;
6804 const int Height = 1908221844;
6806 const auto pTexture = Component_t::Make(
6808 { uT(
"content"), ::std::vector{ Source } },
6809 { uT(
"width"), Width },
6810 { uT(
"height"), Height },
6811 { uT(
"name"), Names[Index].first },
6812 { uT(
"index"), Index },
6813 { uT(
"mipmapping"),
false },
6817 Source, Width, Height, Index, Names[Index].second);
6821 const int Width = 1908221845;
6822 const int Height = 1908221847;
6824 const auto pData = Component_t::Make(
6826 { uT(
"kind"), uT(
"TextureArray") },
6827 { uT(
"content"), ::std::vector{ Source } },
6828 { uT(
"width"), Width },
6829 { uT(
"height"), Height },
6830 { uT(
"name"), Names[Index].first },
6831 { uT(
"index"), Index },
6832 { uT(
"mipmapping"),
false },
6835 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6836 Source, Width, Height, Index, Names[Index].second);
6839 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
6841 { uT(
"albedo"),
"TexAlbedo" },
6842 { uT(
"metalness"),
"TexMetalness" },
6843 { uT(
"roughness"),
"TexRoughness" },
6844 { uT(
"normal"),
"TexNormal" },
6845 { uT(
"occlusion"),
"TexOcclusion" },
6849 for (::std::size_t i = 0; i < Destinations.size(); i++)
6852 const int Width = 1908221843;
6853 const int Height = 1908221844;
6855 const auto pTexture = Component_t::Make(
6857 { uT(
"content"), ::std::vector{ Source } },
6858 { uT(
"width"), Width },
6859 { uT(
"height"), Height },
6860 { uT(
"name"), Names[Index].first },
6861 { uT(
"index"), Index },
6862 { uT(
"destination"), Destinations[i].first },
6866 Source, Width, Height, Index, Names[Index].second);
6870 const int Width = 1908221845;
6871 const int Height = 1908221847;
6873 const auto pData = Component_t::Make(
6875 { uT(
"kind"), uT(
"TextureArray") },
6876 { uT(
"content"), ::std::vector{ Source } },
6877 { uT(
"width"), Width },
6878 { uT(
"height"), Height },
6879 { uT(
"name"), Names[Index].first },
6880 { uT(
"index"), Index },
6881 { uT(
"destination"), Destinations[i].first },
6884 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6885 Source, Width, Height, Index, Names[Index].second);
6889 const int Width = 1908221843;
6890 const int Height = 1908221844;
6892 const auto pTexture = Component_t::Make(
6894 { uT(
"content"), ::std::vector{ Source } },
6895 { uT(
"width"), Width },
6896 { uT(
"height"), Height },
6897 { uT(
"name"), Names[Index].first },
6898 { uT(
"index"), Index },
6899 { uT(
"destination"), Destinations[i].first },
6900 { uT(
"mipmapping"),
false },
6904 Source, Width, Height, Index, Names[Index].second);
6908 const int Width = 1908221845;
6909 const int Height = 1908221847;
6911 const auto pData = Component_t::Make(
6913 { uT(
"kind"), uT(
"TextureArray") },
6914 { uT(
"content"), ::std::vector{ Source } },
6915 { uT(
"width"), Width },
6916 { uT(
"height"), Height },
6917 { uT(
"name"), Names[Index].first },
6918 { uT(
"index"), Index },
6919 { uT(
"destination"), Destinations[i].first },
6920 { uT(
"mipmapping"),
false },
6923 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
6924 Source, Width, Height, Index, Names[Index].second);
6931TEST_F(OpenGLShader_test, Test_TextureArray_Destination)
6933 using GLProxy_t = ::mock::GLProxy;
6935 GLProxy_t::GetInstance() = &GLProxy;
6937 const Tested_t Example{ Data_t{} };
6938 const ITested_t & IExample = Example;
6940 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
6941 ASSERT_NE(IExample.GetCreators().end(), itCreator);
6943 const ::mock::GLuint TextureId = 1908221839;
6944 const ::mock::GLint ProgramId = 1908221840;
6945 const ::mock::GLint LocationId = 1908221841;
6947 const auto TestCall = [&](
6948 const Component_t::ComponentPtr_t & _pTexture,
6949 const ::std::vector<uint8_t> & _Source,
6950 const int _Width,
const int _Height,
6951 const ::std::size_t _Index,
6952 const ::std::string & _TexName)
6954 const auto Index =
static_cast<::mock::GLint
>(_Index);
6956 using namespace ::testing;
6960 EXPECT_CALL(GLProxy, GenTextures(1))
6962 .WillOnce(Return(TextureId));
6964 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
6967 EXPECT_CALL(GLProxy, TexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8,
6968 _Width, _Height, 1))
6971 EXPECT_CALL(GLProxy, TexSubImage3D_1(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0,
6975 EXPECT_CALL(GLProxy, TexSubImage3D_2(1, GL_RGBA,
6976 GL_UNSIGNED_BYTE, _Source))
6979 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, 0))
6982 EXPECT_CALL(GLProxy, GetError())
6984 .WillOnce(Return(GL_NO_ERROR));
6986 auto Render = itCreator->second(_pTexture);
6987 ASSERT_NE(
nullptr, Render);
6989 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
6992 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
6995 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
6997 .WillOnce(Return(&ProgramId));
6999 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
7001 .WillOnce(Return(LocationId));
7003 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
7006 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
7011 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
7015 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
7017 { uT(
"albedo"),
"TexAlbedo" },
7018 { uT(
"metalness"),
"TexMetalness" },
7019 { uT(
"roughness"),
"TexRoughness" },
7020 { uT(
"normal"),
"TexNormal" },
7021 { uT(
"occlusion"),
"TexOcclusion" },
7025 ::std::vector<uint8_t> Source =
7027 0x20, 0x06, 0x15, 0x12, 0x30,
7028 0x20, 0x06, 0x15, 0x12, 0x30,
7029 0x20, 0x06, 0x15, 0x12, 0x30,
7030 0x20, 0x06, 0x15, 0x12, 0x30,
7031 0x20, 0x06, 0x15, 0x12, 0x30,
7033 IntroduceBufferSize(Source);
7035 for (::std::size_t i = 0; i < Destinations.size(); i++)
7038 const int Width = 1908221843;
7039 const int Height = 1908221844;
7041 const auto pTexture = Component_t::Make(
7043 { uT(
"content"), ::std::vector{ Source } },
7044 { uT(
"width"), Width },
7045 { uT(
"height"), Height },
7046 { uT(
"destination"), Destinations[i].first },
7050 Source, Width, Height, i, Destinations[i].second);
7054 const int Width = 1908221845;
7055 const int Height = 1908221847;
7057 const auto pData = Component_t::Make(
7059 { uT(
"kind"), uT(
"TextureArray") },
7060 { uT(
"content"), ::std::vector{ Source } },
7061 { uT(
"width"), Width },
7062 { uT(
"height"), Height },
7063 { uT(
"destination"), Destinations[i].first },
7066 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7067 Source, Width, Height, i, Destinations[i].second);
7071 const int Width = 1908221843;
7072 const int Height = 1908221844;
7074 const auto pTexture = Component_t::Make(
7076 { uT(
"content"), ::std::vector{ Source } },
7077 { uT(
"width"), Width },
7078 { uT(
"height"), Height },
7079 { uT(
"destination"), Destinations[i].first },
7080 { uT(
"mipmapping"),
false },
7084 Source, Width, Height, i, Destinations[i].second);
7088 const int Width = 1908221845;
7089 const int Height = 1908221847;
7091 const auto pData = Component_t::Make(
7093 { uT(
"kind"), uT(
"TextureArray") },
7094 { uT(
"content"), ::std::vector{ Source } },
7095 { uT(
"width"), Width },
7096 { uT(
"height"), Height },
7097 { uT(
"destination"), Destinations[i].first },
7098 { uT(
"mipmapping"),
false },
7101 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7102 Source, Width, Height, i, Destinations[i].second);
7108TEST_F(OpenGLShader_test, Test_TextureArray_Mipmapping_NameAndIndex)
7110 using GLProxy_t = ::mock::GLProxy;
7112 GLProxy_t::GetInstance() = &GLProxy;
7114 const Tested_t Example{ Data_t{} };
7115 const ITested_t & IExample = Example;
7117 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
7118 ASSERT_NE(IExample.GetCreators().end(), itCreator);
7120 const ::mock::GLuint TextureId = 1908221839;
7121 const ::mock::GLint ProgramId = 1908221840;
7122 const ::mock::GLint LocationId = 1908221841;
7124 const auto TestCall = [&](
7125 const Component_t::ComponentPtr_t & _pTexture,
7126 const ::std::vector<uint8_t> & _Source,
7127 const int _Width,
const int _Height,
7128 const ::std::size_t _Index,
7129 const ::std::string & _TexName)
7131 const auto Index =
static_cast<::mock::GLint
>(_Index);
7133 using namespace ::testing;
7137 EXPECT_CALL(GLProxy, GenTextures(1))
7139 .WillOnce(Return(TextureId));
7141 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
7144 EXPECT_CALL(GLProxy, TexStorage3D(GL_TEXTURE_2D_ARRAY, 8, GL_RGBA8,
7145 _Width, _Height, 1))
7148 EXPECT_CALL(GLProxy, TexSubImage3D_1(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0,
7152 EXPECT_CALL(GLProxy, TexSubImage3D_2(1, GL_RGBA,
7153 GL_UNSIGNED_BYTE, _Source))
7156 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D_ARRAY))
7159 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, 0))
7162 EXPECT_CALL(GLProxy, GetError())
7164 .WillOnce(Return(GL_NO_ERROR));
7166 auto Render = itCreator->second(_pTexture);
7167 ASSERT_NE(
nullptr, Render);
7169 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
7172 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
7175 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
7177 .WillOnce(Return(&ProgramId));
7179 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
7181 .WillOnce(Return(LocationId));
7183 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
7186 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
7191 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
7195 const ::std::vector<::std::pair<String_t, ::std::string>> Names =
7197 { uT(
"TexEnvironment"),
"TexEnvironment" },
7198 { uT(
"TexReflection"),
"TexReflection" },
7199 { uT(
"TexBaseColor"),
"TexBaseColor" },
7202 for (
int Index = 0; Index < Names.size(); Index++)
7204 ::std::vector<uint8_t> Source =
7206 0x20, 0x06, 0x15, 0x12, 0x31,
7207 0x20, 0x06, 0x15, 0x12, 0x31,
7208 0x20, 0x06, 0x15, 0x12, 0x31,
7209 0x20, 0x06, 0x15, 0x12, 0x31,
7210 0x20, 0x06, 0x15, 0x12, 0x31,
7212 IntroduceBufferSize(Source);
7215 const int Width = 1908221843;
7216 const int Height = 1908221844;
7218 const auto pTexture = Component_t::Make(
7220 { uT(
"content"), ::std::vector{ Source } },
7221 { uT(
"width"), Width },
7222 { uT(
"height"), Height },
7223 { uT(
"name"), Names[Index].first },
7224 { uT(
"index"), Index },
7225 { uT(
"mipmapping"),
true },
7229 Source, Width, Height, Index, Names[Index].second);
7233 const int Width = 1908221845;
7234 const int Height = 1908221847;
7236 const auto pData = Component_t::Make(
7238 { uT(
"kind"), uT(
"TextureArray") },
7239 { uT(
"content"), ::std::vector{ Source } },
7240 { uT(
"width"), Width },
7241 { uT(
"height"), Height },
7242 { uT(
"name"), Names[Index].first },
7243 { uT(
"index"), Index },
7244 { uT(
"mipmapping"),
true },
7247 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7248 Source, Width, Height, Index, Names[Index].second);
7251 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
7253 { uT(
"albedo"),
"TexAlbedo" },
7254 { uT(
"metalness"),
"TexMetalness" },
7255 { uT(
"roughness"),
"TexRoughness" },
7256 { uT(
"normal"),
"TexNormal" },
7257 { uT(
"occlusion"),
"TexOcclusion" },
7260 for (::std::size_t i = 0; i < Destinations.size(); i++)
7263 const int Width = 1908221843;
7264 const int Height = 1908221844;
7266 const auto pTexture = Component_t::Make(
7268 { uT(
"content"), ::std::vector{ Source } },
7269 { uT(
"width"), Width },
7270 { uT(
"height"), Height },
7271 { uT(
"name"), Names[Index].first },
7272 { uT(
"index"), Index },
7273 { uT(
"destination"), Destinations[i].first },
7274 { uT(
"mipmapping"),
true },
7278 Source, Width, Height, Index, Names[Index].second);
7282 const int Width = 1908221845;
7283 const int Height = 1908221847;
7285 const auto pData = Component_t::Make(
7287 { uT(
"kind"), uT(
"TextureArray") },
7288 { uT(
"content"), ::std::vector{ Source } },
7289 { uT(
"width"), Width },
7290 { uT(
"height"), Height },
7291 { uT(
"name"), Names[Index].first },
7292 { uT(
"index"), Index },
7293 { uT(
"destination"), Destinations[i].first },
7294 { uT(
"mipmapping"),
true },
7297 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7298 Source, Width, Height, Index, Names[Index].second);
7305TEST_F(OpenGLShader_test, Test_TextureArray_Mipmapping_Destination)
7307 using GLProxy_t = ::mock::GLProxy;
7309 GLProxy_t::GetInstance() = &GLProxy;
7311 const Tested_t Example{ Data_t{} };
7312 const ITested_t & IExample = Example;
7314 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
7315 ASSERT_NE(IExample.GetCreators().end(), itCreator);
7317 const ::mock::GLuint TextureId = 1908221839;
7318 const ::mock::GLint ProgramId = 1908221840;
7319 const ::mock::GLint LocationId = 1908221841;
7321 const auto TestCall = [&](
7322 const Component_t::ComponentPtr_t & _pTexture,
7323 const ::std::vector<uint8_t> & _Source,
7324 const int _Width,
const int _Height,
7325 const ::std::size_t _Index,
7326 const ::std::string & _TexName)
7328 const auto Index =
static_cast<::mock::GLint
>(_Index);
7330 using namespace ::testing;
7334 EXPECT_CALL(GLProxy, GenTextures(1))
7336 .WillOnce(Return(TextureId));
7338 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
7341 EXPECT_CALL(GLProxy, TexStorage3D(GL_TEXTURE_2D_ARRAY, 8, GL_RGBA8,
7342 _Width, _Height, 1))
7345 EXPECT_CALL(GLProxy, TexSubImage3D_1(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0,
7349 EXPECT_CALL(GLProxy, TexSubImage3D_2(1, GL_RGBA,
7350 GL_UNSIGNED_BYTE, _Source))
7353 EXPECT_CALL(GLProxy, GenerateMipmap(GL_TEXTURE_2D_ARRAY))
7356 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, 0))
7359 EXPECT_CALL(GLProxy, GetError())
7361 .WillOnce(Return(GL_NO_ERROR));
7363 auto Render = itCreator->second(_pTexture);
7364 ASSERT_NE(
nullptr, Render);
7366 EXPECT_CALL(GLProxy, ActiveTexture(GL_TEXTURE0 + Index))
7369 EXPECT_CALL(GLProxy, BindTexture(GL_TEXTURE_2D_ARRAY, TextureId))
7372 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
7374 .WillOnce(Return(&ProgramId));
7376 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, _TexName))
7378 .WillOnce(Return(LocationId));
7380 EXPECT_CALL(GLProxy, GetUniformLocation(_, Eq(
"TexDiffuse")))
7383 EXPECT_CALL(GLProxy, Uniform1i(LocationId, Index))
7388 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
7392 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
7394 { uT(
"albedo"),
"TexAlbedo" },
7395 { uT(
"metalness"),
"TexMetalness" },
7396 { uT(
"roughness"),
"TexRoughness" },
7397 { uT(
"normal"),
"TexNormal" },
7398 { uT(
"occlusion"),
"TexOcclusion" },
7401 ::std::vector<uint8_t> Source =
7403 0x20, 0x06, 0x15, 0x12, 0x31,
7404 0x20, 0x06, 0x15, 0x12, 0x31,
7405 0x20, 0x06, 0x15, 0x12, 0x31,
7406 0x20, 0x06, 0x15, 0x12, 0x31,
7407 0x20, 0x06, 0x15, 0x12, 0x31,
7409 IntroduceBufferSize(Source);
7411 for (::std::size_t i = 0; i < Destinations.size(); i++)
7414 const int Width = 1908221843;
7415 const int Height = 1908221844;
7417 const auto pTexture = Component_t::Make(
7419 { uT(
"content"), ::std::vector{ Source } },
7420 { uT(
"width"), Width },
7421 { uT(
"height"), Height },
7422 { uT(
"destination"), Destinations[i].first },
7423 { uT(
"mipmapping"),
true },
7427 Source, Width, Height, i, Destinations[i].second);
7431 const int Width = 1908221845;
7432 const int Height = 1908221847;
7434 const auto pData = Component_t::Make(
7436 { uT(
"kind"), uT(
"TextureArray") },
7437 { uT(
"content"), ::std::vector{ Source } },
7438 { uT(
"width"), Width },
7439 { uT(
"height"), Height },
7440 { uT(
"destination"), Destinations[i].first },
7441 { uT(
"mipmapping"),
true },
7444 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7445 Source, Width, Height, i, Destinations[i].second);
7451TEST_F(OpenGLShader_test, Test_TextureArray_NoDeclaredInShader)
7453 using GLProxy_t = ::mock::GLProxy;
7455 GLProxy_t::GetInstance() = &GLProxy;
7457 const Tested_t Example{ Data_t{} };
7458 const ITested_t & IExample = Example;
7460 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
7461 ASSERT_NE(IExample.GetCreators().end(), itCreator);
7463 const ::mock::GLuint TextureId = 1908221839;
7465 const auto TestCall = [&](
7466 const Component_t::ComponentPtr_t & _pTexture,
7467 const ::std::vector<uint8_t> & ,
7468 const int ,
const int ,
7469 const ::std::size_t _Index,
7470 const ::std::string & _TexName)
7472 const auto Index =
static_cast<::mock::GLint
>(_Index);
7474 using namespace ::testing;
7478 EXPECT_CALL(GLProxy, GenTextures(1))
7480 .WillOnce(Return(TextureId));
7482 auto Render = itCreator->second(_pTexture);
7483 ASSERT_NE(
nullptr, Render);
7485 EXPECT_CALL(GLProxy, GetUniformLocation(_, _TexName))
7487 .WillOnce(Return(-1));
7489 EXPECT_CALL(GLProxy, Uniform1i(_, _))
7494 EXPECT_CALL(GLProxy, DeleteTextures(1, TextureId))
7498 const ::std::vector<::std::pair<String_t, ::std::string>> Destinations =
7500 { uT(
"albedo"),
"TexAlbedo" },
7501 { uT(
"metalness"),
"TexMetalness" },
7502 { uT(
"roughness"),
"TexRoughness" },
7503 { uT(
"normal"),
"TexNormal" },
7504 { uT(
"occlusion"),
"TexOcclusion" },
7505 { uT(
"depth"),
"TexDepth" },
7508 ::std::vector<uint8_t> Source =
7510 0x20, 0x06, 0x15, 0x12, 0x34,
7511 0x20, 0x06, 0x15, 0x12, 0x34,
7512 0x20, 0x06, 0x15, 0x12, 0x34,
7513 0x20, 0x06, 0x15, 0x12, 0x34,
7514 0x20, 0x06, 0x15, 0x12, 0x34,
7516 IntroduceBufferSize(Source);
7518 for (::std::size_t i = 0; i < Destinations.size(); i++)
7521 const uint8_t * pSource = (uint8_t *)1908221842;
7522 const int Width = 1908221843;
7523 const int Height = 1908221844;
7525 const auto pTexture = Component_t::Make(
7527 { uT(
"content"), ::std::vector{ Source } },
7528 { uT(
"width"), Width },
7529 { uT(
"height"), Height },
7530 { uT(
"destination"), Destinations[i].first },
7534 Source, Width, Height, i, Destinations[i].second);
7538 const uint8_t * pSource = (uint8_t *)1908221846;
7539 const int Width = 1908221845;
7540 const int Height = 1908221847;
7542 const auto pData = Component_t::Make(
7544 { uT(
"kind"), uT(
"TextureArray") },
7545 { uT(
"content"), ::std::vector{ Source } },
7546 { uT(
"width"), Width },
7547 { uT(
"height"), Height },
7548 { uT(
"destination"), Destinations[i].first },
7551 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7552 Source, Width, Height, i, Destinations[i].second);
7558TEST_F(OpenGLShader_test, Test_TextureArray_MultiTextureData)
7560 using namespace ::alicorn::extension::std;
7562 using GLProxy_t = ::mock::GLProxy;
7564 GLProxy_t::GetInstance() = &GLProxy;
7566 const Tested_t Example{ Data_t{} };
7567 const ITested_t & IExample = Example;
7569 auto itCreator = IExample.GetCreators().find(uT(
"TextureArray"));
7570 ASSERT_NE(IExample.GetCreators().end(), itCreator);
7572 const ::mock::GLuint TextureId = 1812181809;
7573 const ::mock::GLint ProgramId = 1908221258;
7574 const ::mock::GLint LocationId = 1908221259;
7576 const auto TestCall = [&](
const Component_t::ComponentPtr_t & _pTexture,
7577 const ::std::vector<uint8_t> & _Source,
const size_t _ArrayCount,
7578 const int _Width,
const int _Height)
7580 using namespace ::testing;
7584 EXPECT_CALL(GLProxy, GenTextures(1))
7586 .WillOnce(Return(TextureId));
7588 EXPECT_CALL(GLProxy, BindTexture(_, _))
7591 EXPECT_CALL(GLProxy, TexStorage3D(_, _, _, _, _, _ArrayCount))
7594 EXPECT_CALL(GLProxy, TexSubImage3D_1(_, 0, 0, 0, 0, _, _))
7597 EXPECT_CALL(GLProxy, TexSubImage3D_2(_ArrayCount, _, _, _Source))
7600 EXPECT_CALL(GLProxy, BindTexture(_, 0))
7603 EXPECT_CALL(GLProxy, GetError())
7605 .WillOnce(Return(GL_NO_ERROR));
7607 auto Render = itCreator->second(_pTexture);
7608 ASSERT_NE(
nullptr, Render);
7612 ::std::vector<uint8_t> Source1 =
7614 0x20, 0x06, 0x15, 0x12, 0x28,
7615 0x20, 0x06, 0x15, 0x12, 0x28,
7616 0x20, 0x06, 0x15, 0x12, 0x28,
7617 0x20, 0x06, 0x15, 0x12, 0x28,
7618 0x20, 0x06, 0x15, 0x12, 0x28,
7620 IntroduceBufferSize(Source1,
false);
7622 ::std::vector<uint8_t> Source2 =
7624 0x20, 0x06, 0x15, 0x12, 0x28,
7625 0x20, 0x06, 0x15, 0x12, 0x28,
7626 0x20, 0x06, 0x15, 0x12, 0x28,
7627 0x20, 0x06, 0x15, 0x12, 0x28,
7628 0x20, 0x06, 0x15, 0x12, 0x28,
7629 0x20, 0x06, 0x15, 0x12, 0x28,
7631 IntroduceBufferSize(Source2,
false);
7633 ::std::vector<uint8_t> Source3 =
7635 0x20, 0x06, 0x15, 0x12, 0x28,
7636 0x20, 0x06, 0x15, 0x12, 0x28,
7637 0x20, 0x06, 0x15, 0x12, 0x28,
7638 0x20, 0x06, 0x15, 0x12, 0x28,
7639 0x20, 0x06, 0x15, 0x12, 0x28,
7640 0x20, 0x06, 0x15, 0x12, 0x28,
7641 0x20, 0x06, 0x15, 0x12, 0x28,
7642 0x20, 0x06, 0x15, 0x12, 0x28,
7644 IntroduceBufferSize(Source3);
7646 const int Width = 1812181807;
7647 const int Height = 1812181808;
7649 const auto pTexture = Component_t::Make(
7651 { uT(
"content"), ::std::vector{ Source1, Source2, Source3 } },
7652 { uT(
"width"), Width },
7653 { uT(
"height"), Height },
7656 TestCall(pTexture, Source1 + Source2 + Source3, 3, Width, Height);
7660 ::std::vector<uint8_t> Source1 =
7662 0x20, 0x06, 0x15, 0x12, 0x29,
7663 0x20, 0x06, 0x15, 0x12, 0x29,
7664 0x20, 0x06, 0x15, 0x12, 0x29,
7666 IntroduceBufferSize(Source1,
false);
7668 ::std::vector<uint8_t> Source2 =
7670 0x25, 0x04, 0x07, 0x21, 0x03,
7671 0x25, 0x04, 0x07, 0x21, 0x04,
7672 0x25, 0x04, 0x07, 0x21, 0x05,
7673 0x25, 0x04, 0x07, 0x21, 0x06
7675 IntroduceBufferSize(Source2,
true);
7677 const int Width = 1907251057;
7678 const int Height = 1907251058;
7680 const auto pData = Component_t::Make(
7682 { uT(
"kind"), uT(
"TextureArray") },
7683 { uT(
"content"), ::std::vector{ Source1, Source2 } },
7684 { uT(
"width"), Width },
7685 { uT(
"height"), Height },
7688 TestCall(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }),
7689 Source1 + Source2, 2, Width, Height);
7694TEST_F(OpenGLShader_test, Test_Buffer_Fail)
7696 using GLProxy_t = ::mock::GLProxy;
7698 GLProxy_t::GetInstance() = &GLProxy;
7700 const Tested_t Example{ Data_t{} };
7701 const ITested_t & IExample = Example;
7703 auto itCreator = IExample.GetCreators().find(uT(
"Buffer"));
7704 ASSERT_NE(IExample.GetCreators().end(), itCreator);
7706 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent)
7708 using namespace ::testing;
7712 EXPECT_CALL(GLProxy, GenBuffers(_))
7715 EXPECT_CALL(GLProxy, GetError())
7717 .WillOnce(Return(1908232144));
7719 EXPECT_THROW(itCreator->second(_pComponent), ::std::exception);
7723 const ::std::vector<::covellite::api::Vertex> Source;
7725 const auto pBuffer = Component_t::Make(
7727 { uT(
"content"), Source },
7730 TestCallRender(pBuffer);
7732 const auto pData = Component_t::Make(
7734 { uT(
"kind"), uT(
"Buffer") },
7735 { uT(
"content"), Source },
7738 TestCallRender(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
7742 using BufferMapper_t =
7743 ::covellite::api::cbBufferMap_t<::covellite::api::Vertex>;
7744 const ::std::vector<::covellite::api::Vertex> Source;
7748 const auto pBuffer = Component_t::Make(
7750 { uT(
"content"), Source },
7751 { uT(
"mapper"), Mapper },
7754 TestCallRender(pBuffer);
7756 const auto pData = Component_t::Make(
7758 { uT(
"kind"), uT(
"Buffer") },
7759 { uT(
"content"), Source },
7760 { uT(
"mapper"), Mapper },
7763 TestCallRender(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
7768TEST_F(OpenGLShader_test, Test_Buffer_Vertex_Static)
7772 using GLProxy_t = ::mock::GLProxy;
7774 GLProxy_t::GetInstance() = &GLProxy;
7776 const ::mock::GLuint BufferId = 1908231206;
7777 const ::mock::GLint ProgramId = 1908231246;
7778 const ::mock::GLint PositionId = 1908231301;
7779 const ::mock::GLint TexCoordId = 1908231302;
7780 const ::mock::GLint ExtraId = 1908231304;
7782 ::std::vector<Vertex_t> Source =
7785 1808261932.0f, 1808261933.0f, 1812161256.0f, 1808261934.0f,
7786 1812161257.0f, 1808261935.0f,
7787 1808261936.0f, 1812161258.0f, 1908201939.0f, 1908201940.0f
7790 1808261932.0f, 1808261933.0f, 1812161259.0f, 1808261934.0f,
7791 1812161300.0f, 1808261935.0f,
7792 1808261936.0f, 1812161301.0f, 1908201941.0f, 1908201942.0f
7794 { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
7797 IntroduceBufferSize(Source);
7799 const ::mock::GLProxy::Floats_t ExpectedVertexData =
7801 Source[0].px, Source[0].py, Source[0].pz,
7802 Source[1].px, Source[1].py, Source[1].pz,
7805 const ::mock::GLProxy::Floats_t ExpectedTexCoordData =
7807 Source[0].tu, Source[0].tv,
7808 Source[1].tu, Source[1].tv,
7811 const ::mock::GLProxy::Floats_t ExpectedNormalData =
7813 Source[0].ex, Source[0].ey, Source[0].ez,
7814 Source[1].ex, Source[1].ey, Source[1].ez,
7817 const Tested_t Example{ Data_t{} };
7818 const ITested_t & IExample = Example;
7820 auto itCreator = IExample.GetCreators().find(uT(
"Buffer"));
7821 ASSERT_NE(IExample.GetCreators().end(), itCreator);
7823 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent)
7825 using namespace ::testing;
7829 EXPECT_CALL(GLProxy, GenBuffers(1))
7831 .WillOnce(Return(BufferId));
7833 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
7837 static_cast<::mock::GLsizeiptr
>(Source.size() *
sizeof(Vertex_t));
7839 EXPECT_CALL(GLProxy, BufferData(GL_ARRAY_BUFFER, Size,
7840 GetExpected(Source), GL_STATIC_DRAW))
7843 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
7846 EXPECT_CALL(GLProxy, GetError())
7848 .WillOnce(Return(GL_NO_ERROR));
7850 const auto Render = itCreator->second(_pComponent);
7851 ASSERT_NE(
nullptr, Render);
7853 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
7856 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
7858 .WillOnce(Return(&ProgramId));
7860 EXPECT_CALL(GLProxy,
7861 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexPosition")))
7863 .WillOnce(Return(PositionId));
7865 EXPECT_CALL(GLProxy, EnableVertexAttribArray(PositionId))
7868 EXPECT_CALL(GLProxy, VertexAttribPointer(PositionId, 4, GL_FLOAT, GL_FALSE,
7869 sizeof(Vertex_t), (
void*)0))
7872 EXPECT_CALL(GLProxy, VertexAttribDivisor(PositionId, 0))
7875 EXPECT_CALL(GLProxy,
7876 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexTexCoord")))
7878 .WillOnce(Return(TexCoordId));
7880 EXPECT_CALL(GLProxy, EnableVertexAttribArray(TexCoordId))
7883 EXPECT_CALL(GLProxy, VertexAttribPointer(TexCoordId, 2, GL_FLOAT, GL_FALSE,
7884 sizeof(Vertex_t), (
void*)(
sizeof(
float) * 4)))
7887 EXPECT_CALL(GLProxy, VertexAttribDivisor(TexCoordId, 0))
7890 EXPECT_CALL(GLProxy,
7891 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexExtra")))
7893 .WillOnce(Return(ExtraId));
7895 EXPECT_CALL(GLProxy, EnableVertexAttribArray(ExtraId))
7898 EXPECT_CALL(GLProxy, VertexAttribPointer(ExtraId, 4, GL_FLOAT, GL_FALSE,
7899 sizeof(Vertex_t), (
void*)(
sizeof(
float) * 6)))
7902 EXPECT_CALL(GLProxy, VertexAttribDivisor(ExtraId, 0))
7905 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
7910 EXPECT_CALL(GLProxy, DeleteBuffers(1, BufferId))
7917 const auto pBuffer = Component_t::Make(
7919 { uT(
"content"), Source },
7922 TestCallRender(pBuffer);
7928 const auto pData = Component_t::Make(
7930 { uT(
"kind"), uT(
"Buffer") },
7931 { uT(
"content"), Source },
7934 TestCallRender(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
7939TEST_F(OpenGLShader_test, Test_Buffer_Vertex_Dynamic)
7942 using BufferMapper_t = ::covellite::api::cbBufferMap_t<Vertex_t>;
7945 public ::alicorn::extension::testing::Proxy<Proxy>
7948 MOCK_METHOD1(Mapper,
bool(Vertex_t *));
7952 Proxy::GetInstance() = &oProxy;
7954 using GLProxy_t = ::mock::GLProxy;
7956 GLProxy_t::GetInstance() = &GLProxy;
7958 const ::mock::GLuint BufferId = 1908232202;
7959 const ::mock::GLint ProgramId = 1908232203;
7960 const ::mock::GLint PositionId = 1908232204;
7961 const ::mock::GLint TexCoordId = 1908232205;
7962 const ::mock::GLint ExtraId = 1908232206;
7964 ::std::vector<Vertex_t> Source1 =
7967 1808261932.0f, 1808261933.0f, 1812161256.0f, 1808261934.0f,
7968 1812161257.0f, 1808261935.0f,
7969 1808261936.0f, 1812161258.0f, 1908201945.0f, 1908201946.0f
7972 1808261932.0f, 1808261933.0f, 1812161259.0f, 1808261934.0f,
7973 1812161300.0f, 1808261935.0f,
7974 1808261936.0f, 1812161301.0f, 1908201947.0f, 1908201948.0f
7976 { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
7979 IntroduceBufferSize(Source1);
7981 const ::std::vector<::mock::GLfloat> Source2 =
7983 1908011341.0f, 1908261933.0f, 1912161256.0f, 1908261934.0f,
7984 1912161257.0f, 1908261935.0f,
7985 1908261936.0f, 1912161258.0f, 1908201949.0f, 1908201950.0f,
7986 1908261932.0f, 1908261933.0f, 1912161259.0f, 1908261934.0f,
7987 1912161300.0f, 1908261935.0f,
7988 1908261936.0f, 1912161301.0f, 1908201951.0f, 1908201952.0f,
7991 const BufferMapper_t Mapper = [&](Vertex_t * _pData)
7993 if (_pData !=
nullptr)
7995 memcpy(_pData, Source2.data(),
sizeof(::mock::GLfloat) * Source2.size());
7998 return oProxy.Mapper(_pData);
8001 const Tested_t Example{ Data_t{} };
8002 const ITested_t & IExample = Example;
8004 auto itCreator = IExample.GetCreators().find(uT(
"Buffer"));
8005 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8007 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent)
8009 using namespace ::testing;
8013 EXPECT_CALL(GLProxy, GenBuffers(1))
8015 .WillOnce(Return(BufferId));
8017 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
8021 static_cast<::mock::GLsizeiptr
>(Source1.size() *
sizeof(Vertex_t));
8023 EXPECT_CALL(GLProxy, BufferData(GL_ARRAY_BUFFER, Size,
8024 GetExpected(Source1), GL_DYNAMIC_DRAW))
8027 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
8030 EXPECT_CALL(GLProxy, GetError())
8032 .WillOnce(Return(GL_NO_ERROR));
8034 const auto Render = itCreator->second(_pComponent);
8035 ASSERT_NE(
nullptr, Render);
8038 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
8041 EXPECT_CALL(oProxy, Mapper(
nullptr))
8043 .WillOnce(Return(
false));
8045 EXPECT_CALL(oProxy, Mapper(_))
8048 EXPECT_CALL(GLProxy, BufferSubData(_, _, _, _))
8051 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
8053 .WillOnce(Return(&ProgramId));
8055 EXPECT_CALL(GLProxy,
8056 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexPosition")))
8058 .WillOnce(Return(PositionId));
8060 EXPECT_CALL(GLProxy, EnableVertexAttribArray(PositionId))
8063 EXPECT_CALL(GLProxy, VertexAttribPointer(PositionId, 4, GL_FLOAT, GL_FALSE,
8064 sizeof(Vertex_t), (
void*)0))
8067 EXPECT_CALL(GLProxy, VertexAttribDivisor(PositionId, 0))
8070 EXPECT_CALL(GLProxy,
8071 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexTexCoord")))
8073 .WillOnce(Return(TexCoordId));
8075 EXPECT_CALL(GLProxy, EnableVertexAttribArray(TexCoordId))
8078 EXPECT_CALL(GLProxy, VertexAttribPointer(TexCoordId, 2, GL_FLOAT, GL_FALSE,
8079 sizeof(Vertex_t), (
void*)(
sizeof(
float) * 4)))
8082 EXPECT_CALL(GLProxy, VertexAttribDivisor(TexCoordId, 0))
8085 EXPECT_CALL(GLProxy,
8086 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexExtra")))
8088 .WillOnce(Return(ExtraId));
8090 EXPECT_CALL(GLProxy, EnableVertexAttribArray(ExtraId))
8093 EXPECT_CALL(GLProxy, VertexAttribPointer(ExtraId, 4, GL_FLOAT, GL_FALSE,
8094 sizeof(Vertex_t), (
void*)(
sizeof(
float) * 6)))
8097 EXPECT_CALL(GLProxy, VertexAttribDivisor(ExtraId, 0))
8100 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
8107 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
8110 EXPECT_CALL(oProxy, Mapper(
nullptr))
8112 .WillOnce(Return(
true));
8114 EXPECT_CALL(oProxy, Mapper(_))
8117 EXPECT_CALL(GLProxy, BufferSubData(GL_ARRAY_BUFFER, 0, Size, Source2))
8120 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
8122 .WillOnce(Return(&ProgramId));
8124 EXPECT_CALL(GLProxy,
8125 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexPosition")))
8127 .WillOnce(Return(PositionId));
8129 EXPECT_CALL(GLProxy, EnableVertexAttribArray(PositionId))
8132 EXPECT_CALL(GLProxy, VertexAttribPointer(PositionId, 4, GL_FLOAT, GL_FALSE,
8133 sizeof(Vertex_t), (
void*)0))
8136 EXPECT_CALL(GLProxy, VertexAttribDivisor(PositionId, 0))
8139 EXPECT_CALL(GLProxy,
8140 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexTexCoord")))
8142 .WillOnce(Return(TexCoordId));
8144 EXPECT_CALL(GLProxy, EnableVertexAttribArray(TexCoordId))
8147 EXPECT_CALL(GLProxy, VertexAttribPointer(TexCoordId, 2, GL_FLOAT, GL_FALSE,
8148 sizeof(Vertex_t), (
void*)(
sizeof(
float) * 4)))
8151 EXPECT_CALL(GLProxy, VertexAttribDivisor(TexCoordId, 0))
8154 EXPECT_CALL(GLProxy,
8155 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexExtra")))
8157 .WillOnce(Return(ExtraId));
8159 EXPECT_CALL(GLProxy, EnableVertexAttribArray(ExtraId))
8162 EXPECT_CALL(GLProxy, VertexAttribPointer(ExtraId, 4, GL_FLOAT, GL_FALSE,
8163 sizeof(Vertex_t), (
void*)(
sizeof(
float) * 6)))
8166 EXPECT_CALL(GLProxy, VertexAttribDivisor(ExtraId, 0))
8169 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
8175 EXPECT_CALL(GLProxy, DeleteBuffers(1, BufferId))
8182 const auto pBuffer = Component_t::Make(
8184 { uT(
"content"), Source1 },
8185 { uT(
"mapper"), Mapper },
8188 TestCallRender(pBuffer);
8194 const auto pData = Component_t::Make(
8196 { uT(
"kind"), uT(
"Buffer") },
8197 { uT(
"content"), Source1 },
8200 const auto pBuffer = Component_t::Make(
8202 { uT(
"mapper"), Mapper },
8203 { uT(
"service"), Object_t{ pData } }
8206 TestCallRender(pBuffer);
8211TEST_F(OpenGLShader_test, Test_Buffer_Vertex_IgnoreNotExistsVariables)
8214 using BufferMapper_t = ::covellite::api::cbBufferMap_t<Vertex_t>;
8216 using GLProxy_t = ::mock::GLProxy;
8218 GLProxy_t::GetInstance() = &GLProxy;
8220 const ::mock::GLuint BufferId = 1908231206;
8221 const ::mock::GLint ProgramId = 1908231246;
8223 ::std::vector<Vertex_t> Source =
8226 1808261932.0f, 1808261933.0f, 1812161256.0f, 1808261934.0f,
8227 1812161257.0f, 1808261935.0f,
8228 1808261936.0f, 1812161258.0f, 1908201939.0f, 1908201940.0f
8231 1808261932.0f, 1808261933.0f, 1812161259.0f, 1808261934.0f,
8232 1812161300.0f, 1808261935.0f,
8233 1808261936.0f, 1812161301.0f, 1908201941.0f, 1908201942.0f
8235 { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
8238 IntroduceBufferSize(Source);
8240 const Tested_t Example{ Data_t{} };
8241 const ITested_t & IExample = Example;
8243 auto itCreator = IExample.GetCreators().find(uT(
"Buffer"));
8244 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8246 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent)
8248 using namespace ::testing;
8252 EXPECT_CALL(GLProxy, GenBuffers(1))
8254 .WillOnce(Return(BufferId));
8256 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
8259 EXPECT_CALL(GLProxy, BufferData(GL_ARRAY_BUFFER, _, _, _))
8262 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
8265 EXPECT_CALL(GLProxy, GetError())
8267 .WillOnce(Return(GL_NO_ERROR));
8269 const auto Render = itCreator->second(_pComponent);
8270 ASSERT_NE(
nullptr, Render);
8272 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, BufferId))
8275 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
8277 .WillOnce(Return(&ProgramId));
8279 EXPECT_CALL(GLProxy,
8280 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexPosition")))
8282 .WillOnce(Return(-1));
8284 EXPECT_CALL(GLProxy, EnableVertexAttribArray(_))
8287 EXPECT_CALL(GLProxy, VertexAttribPointer(_, _, _, _, _, _))
8290 EXPECT_CALL(GLProxy, VertexAttribDivisor(_, _))
8293 EXPECT_CALL(GLProxy,
8294 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexTexCoord")))
8296 .WillOnce(Return(-1));
8298 EXPECT_CALL(GLProxy, EnableVertexAttribArray(_))
8301 EXPECT_CALL(GLProxy, VertexAttribPointer(_, _, _, _, _, _))
8304 EXPECT_CALL(GLProxy, VertexAttribDivisor(_, _))
8307 EXPECT_CALL(GLProxy,
8308 GetAttribLocation(ProgramId, Eq(
"Covellite_VertexExtra")))
8310 .WillOnce(Return(-1));
8312 EXPECT_CALL(GLProxy, EnableVertexAttribArray(_))
8315 EXPECT_CALL(GLProxy, VertexAttribPointer(_, _, _, _, _, _))
8318 EXPECT_CALL(GLProxy, VertexAttribDivisor(_, _))
8321 EXPECT_CALL(GLProxy, BindBuffer(GL_ARRAY_BUFFER, 0))
8326 EXPECT_CALL(GLProxy, DeleteBuffers(1, BufferId))
8333 const auto pBuffer = Component_t::Make(
8335 { uT(
"content"), Source },
8338 TestCallRender(pBuffer);
8344 const auto pData = Component_t::Make(
8346 { uT(
"kind"), uT(
"Buffer") },
8347 { uT(
"content"), Source },
8350 TestCallRender(Component_t::Make({ { uT(
"service"), Object_t{ pData } } }));
8358 const auto pBuffer = Component_t::Make(
8360 { uT(
"content"), Source },
8361 { uT(
"mapper"), BufferMapper_t{} },
8364 TestCallRender(pBuffer);
8370 const auto pData = Component_t::Make(
8372 { uT(
"kind"), uT(
"Buffer") },
8373 { uT(
"content"), Source },
8376 const auto pBuffer = Component_t::Make(
8378 { uT(
"mapper"), BufferMapper_t{} },
8379 { uT(
"service"), Object_t{ pData } }
8382 TestCallRender(pBuffer);
8387TEST_F(OpenGLShader_test, Test_Transform_Default)
8389 using GLProxy_t = ::mock::GLProxy;
8391 GLProxy_t::GetInstance() = &GLProxy;
8393 const Tested_t Example{ Data_t{} };
8394 const ITested_t & IExample = Example;
8396 const ::mock::GLint ProgramId = 1908241203;
8397 const ::mock::GLint MatrixWorldLocationId = 1908241207;
8398 const ::mock::GLint ExtraLocationId = 2608311427;
8400 auto itCreator = IExample.GetCreators().find(uT(
"Transform"));
8401 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8403 auto pPosition = Component_t::Make({ { uT(
"kind"), uT(
"Position") } });
8404 auto pRotation = Component_t::Make({ { uT(
"kind"), uT(
"Rotation") } });
8405 auto pScale = Component_t::Make({ { uT(
"kind"), uT(
"Scale") } });
8406 auto pTransform = Component_t::Make(
8408 { uT(
"service"), Object_t{ pPosition, pRotation, pScale } }
8411 const auto Render = itCreator->second(pTransform);
8412 ASSERT_NE(
nullptr, Render);
8414 auto WorldMatrix = ::glm::identity<::glm::mat4>();
8416 auto TestCallRender = [&](
8417 float _X,
float _Y,
float _Z,
8418 float _A,
float _B,
float _C,
8419 float _Sx,
float _Sy,
float _Sz,
8420 const ::glm::vec4 & _Extra)
8422 (*pPosition)[uT(
"x")] = _X;
8423 (*pPosition)[uT(
"y")] = _Y;
8424 (*pPosition)[uT(
"z")] = _Z;
8426 (*pRotation)[uT(
"x")] = _A;
8427 (*pRotation)[uT(
"y")] = _B;
8428 (*pRotation)[uT(
"z")] = _C;
8430 (*pScale)[uT(
"x")] = _Sx;
8431 (*pScale)[uT(
"y")] = _Sy;
8432 (*pScale)[uT(
"z")] = _Sz;
8434 WorldMatrix = ::glm::identity<::glm::mat4>();
8435 WorldMatrix = ::glm::scale(WorldMatrix, { _Sx, _Sy, _Sz });
8436 WorldMatrix = ::glm::rotate(WorldMatrix, _C, { 0.0f, 0.0f, 1.0f });
8437 WorldMatrix = ::glm::rotate(WorldMatrix, _B, { 0.0f, 1.0f, 0.0f });
8438 WorldMatrix = ::glm::rotate(WorldMatrix, _A, { 1.0f, 0.0f, 0.0f });
8439 WorldMatrix = ::glm::translate(WorldMatrix, { _X, _Y, _Z });
8440 WorldMatrix = ::glm::transpose(WorldMatrix);
8442 using namespace ::testing;
8446 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
8448 .WillOnce(Return(&ProgramId));
8450 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"ObjectData.World")))
8452 .WillOnce(Return(MatrixWorldLocationId));
8454 EXPECT_CALL(GLProxy,
8455 UniformMatrix4fv(MatrixWorldLocationId, 1, GL_FALSE, WorldMatrix))
8458 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"ObjectData.Extra")))
8460 .WillOnce(Return(ExtraLocationId));
8462 EXPECT_CALL(GLProxy,
8463 Uniform4fv(ExtraLocationId, 1, _Extra))
8473 1956.0f, 1957.0f, 1958.0f,
8474 1204.0f, 1205.0f, 1206.0f,
8475 1152.0f, 1153.0f, 1154.0f,
8478 const auto Extra = ::glm::vec4(1959.0f, 1960.0f, 1961.0f, 1962.0f);
8479 (*pTransform)[uT(
"extra")] = Extra;
8482 1959.0f, 1960.0f, 1961.0f,
8483 1145.0f, 1146.0f, 1147.0f,
8484 1155.0f, 1157.0f, 1158.0f,
8489TEST_F(OpenGLShader_test, Test_Transform_Static)
8491 using GLProxy_t = ::mock::GLProxy;
8493 GLProxy_t::GetInstance() = &GLProxy;
8495 const Tested_t Example{ Data_t{} };
8496 const ITested_t & IExample = Example;
8498 const ::mock::GLint ProgramId = 1908241203;
8499 const ::mock::GLint MatrixWorldLocationId = 1908241207;
8500 const ::mock::GLint ExtraLocationId = 2608311426;
8502 auto itCreator = IExample.GetCreators().find(uT(
"Transform"));
8503 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8505 auto pPosition = Component_t::Make({ { uT(
"kind"), uT(
"Position") } });
8506 auto pRotation = Component_t::Make({ { uT(
"kind"), uT(
"Rotation") } });
8507 auto pScale = Component_t::Make({ { uT(
"kind"), uT(
"Scale") } });
8509 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pTransform)
8511 auto WorldMatrix = ::glm::identity<::glm::mat4>();
8513 auto SetValues = [&](
const bool _IsBuildMatrix,
8514 float _X,
float _Y,
float _Z,
8515 float _A,
float _B,
float _C,
8516 float _Sx,
float _Sy,
float _Sz)
8518 (*pPosition)[uT(
"x")] = _X;
8519 (*pPosition)[uT(
"y")] = _Y;
8520 (*pPosition)[uT(
"z")] = _Z;
8522 (*pRotation)[uT(
"x")] = _A;
8523 (*pRotation)[uT(
"y")] = _B;
8524 (*pRotation)[uT(
"z")] = _C;
8526 (*pScale)[uT(
"x")] = _Sx;
8527 (*pScale)[uT(
"y")] = _Sy;
8528 (*pScale)[uT(
"z")] = _Sz;
8532 WorldMatrix = ::glm::identity<::glm::mat4>();
8533 WorldMatrix = ::glm::scale(WorldMatrix, { _Sx, _Sy, _Sz });
8534 WorldMatrix = ::glm::rotate(WorldMatrix, _C, { 0.0f, 0.0f, 1.0f });
8535 WorldMatrix = ::glm::rotate(WorldMatrix, _B, { 0.0f, 1.0f, 0.0f });
8536 WorldMatrix = ::glm::rotate(WorldMatrix, _A, { 1.0f, 0.0f, 0.0f });
8537 WorldMatrix = ::glm::translate(WorldMatrix, { _X, _Y, _Z });
8538 WorldMatrix = ::glm::transpose(WorldMatrix);
8543 1956.0f, 1957.0f, 1958.0f,
8544 1204.0f, 1205.0f, 1206.0f,
8545 1152.0f, 1153.0f, 1154.0f);
8547 const auto Render = itCreator->second(_pTransform);
8548 ASSERT_NE(
nullptr, Render);
8550 auto TestCallRender = [&](void)
8552 using namespace ::testing;
8556 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
8558 .WillOnce(Return(&ProgramId));
8560 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"ObjectData.World")))
8562 .WillOnce(Return(MatrixWorldLocationId));
8564 EXPECT_CALL(GLProxy,
8565 UniformMatrix4fv(MatrixWorldLocationId, 1, GL_FALSE, WorldMatrix))
8568 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"ObjectData.Extra")))
8570 .WillOnce(Return(ExtraLocationId));
8572 EXPECT_CALL(GLProxy,
8573 Uniform4fv(ExtraLocationId, 1, ::glm::vec4()))
8585 1959.0f, 1960.0f, 1961.0f,
8586 1145.0f, 1146.0f, 1147.0f,
8587 1155.0f, 1157.0f, 1158.0f);
8592 const auto pTransform = Component_t::Make(
8594 { uT(
"kind"), uT(
"Static") },
8595 { uT(
"service"), Object_t{ pPosition, pRotation, pScale } }
8598 TestCallRender(pTransform);
8602TEST_F(OpenGLShader_test, Test_Transform_Billboard)
8604 using GLProxy_t = ::mock::GLProxy;
8606 GLProxy_t::GetInstance() = &GLProxy;
8608 Tested_t Example{ Data_t{} };
8609 const ITested_t & IExample = Example;
8611 const ::mock::GLint ProgramId = 1908241203;
8612 const ::mock::GLint MatrixWorldLocationId = 1908241207;
8613 const ::mock::GLint ExtraLocationId = 2608311425;
8615 auto itCreator = IExample.GetCreators().find(uT(
"Transform"));
8616 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8618 auto pPosition = Component_t::Make({ { uT(
"kind"), uT(
"Position") } });
8620 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pTransform)
8622 const auto Render = itCreator->second(_pTransform);
8623 ASSERT_NE(
nullptr, Render);
8625 auto WorldMatrix = ::glm::identity<::glm::mat4>();
8627 auto TestCallRender = [&](
float _X,
float _Y,
float _Z)
8629 (*pPosition)[uT(
"x")] = _X;
8630 (*pPosition)[uT(
"y")] = _Y;
8631 (*pPosition)[uT(
"z")] = _Z;
8633 WorldMatrix = ::glm::identity<::glm::mat4>();
8634 WorldMatrix = ::glm::translate(WorldMatrix, { _X, _Y, _Z });
8636 const auto ViewMatrix = ::glm::mat4
8638 { 1.0f, 2.0f, 3.0f, 4.0f },
8639 { 5.0f, 6.0f, 7.0f, 8.0f },
8640 { 9.0f, 10.0f, 11.0f, 12.0f },
8641 { 13.0f, 14.0f, 15.0f, 16.0f },
8644 GetCameraMartix(Example).View = ViewMatrix;
8646 auto TransposeViewMatrix = ViewMatrix;
8647 TransposeViewMatrix[0][3] = 0.0f;
8648 TransposeViewMatrix[1][3] = 0.0f;
8649 TransposeViewMatrix[2][3] = 0.0f;
8650 TransposeViewMatrix[3][0] = 0.0f;
8651 TransposeViewMatrix[3][1] = 0.0f;
8652 TransposeViewMatrix[3][2] = 0.0f;
8653 TransposeViewMatrix[3][3] = 1.0f;
8655 WorldMatrix = TransposeViewMatrix *
8656 ::glm::translate(::glm::identity<::glm::mat4>(), { _X, _Y, _Z });
8657 WorldMatrix = ::glm::transpose(WorldMatrix);
8659 using namespace ::testing;
8663 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
8665 .WillOnce(Return(&ProgramId));
8667 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"ObjectData.World")))
8669 .WillOnce(Return(MatrixWorldLocationId));
8671 EXPECT_CALL(GLProxy,
8672 UniformMatrix4fv(MatrixWorldLocationId, 1, GL_FALSE, WorldMatrix))
8675 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"ObjectData.Extra")))
8677 .WillOnce(Return(ExtraLocationId));
8679 EXPECT_CALL(GLProxy,
8680 Uniform4fv(ExtraLocationId, 1, ::glm::vec4()))
8689 TestCallRender(1956.0f, 1957.0f, 1958.0f);
8690 TestCallRender(1959.0f, 1960.0f, 1961.0f);
8693 const auto pTransform = Component_t::Make(
8695 { uT(
"kind"), uT(
"Billboard") },
8696 { uT(
"service"), Object_t{ pPosition } }
8699 TestCallRender(pTransform);
8703TEST_F(OpenGLShader_test, Test_Transform_DefaultValues)
8705 using GLProxy_t = ::mock::GLProxy;
8707 GLProxy_t::GetInstance() = &GLProxy;
8709 Tested_t Example{ Data_t{} };
8710 const ITested_t & IExample = Example;
8712 auto itCreator = IExample.GetCreators().find(uT(
"Transform"));
8713 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8715 auto pPosition = Component_t::Make({ { uT(
"kind"), uT(
"Position") } });
8716 auto pRotation = Component_t::Make({ { uT(
"kind"), uT(
"Rotation") } });
8717 auto pScale = Component_t::Make({ { uT(
"kind"), uT(
"Scale") } });
8719 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent,
8720 const bool _IsFullTransform =
true)
8722 const auto Render = itCreator->second(_pComponent);
8723 ASSERT_NE(
nullptr, Render);
8725 const auto ViewMatrix = ::glm::mat4
8727 { 1.0f, 2.0f, 3.0f, 4.0f },
8728 { 5.0f, 6.0f, 7.0f, 8.0f },
8729 { 9.0f, 10.0f, 11.0f, 12.0f },
8730 { 13.0f, 14.0f, 15.0f, 16.0f },
8733 GetCameraMartix(Example).View = ViewMatrix;
8735 auto WorldMatrix = ::glm::identity<::glm::mat4>();
8737 if (_IsFullTransform)
8739 WorldMatrix = ::glm::scale(WorldMatrix, { 1.0f, 1.0f, 1.0f });
8740 WorldMatrix = ::glm::transpose(WorldMatrix);
8744 auto TransposeViewMatrix = ViewMatrix;
8745 TransposeViewMatrix[0][3] = 0.0f;
8746 TransposeViewMatrix[1][3] = 0.0f;
8747 TransposeViewMatrix[2][3] = 0.0f;
8748 TransposeViewMatrix[3][0] = 0.0f;
8749 TransposeViewMatrix[3][1] = 0.0f;
8750 TransposeViewMatrix[3][2] = 0.0f;
8751 TransposeViewMatrix[3][3] = 1.0f;
8753 WorldMatrix = TransposeViewMatrix;
8754 WorldMatrix = ::glm::transpose(WorldMatrix);
8757 using namespace ::testing;
8759 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, WorldMatrix))
8765 TestCallRender(Component_t::Make(
8767 { uT(
"service"), Object_t{ pPosition, pRotation, pScale } }
8770 TestCallRender(Component_t::Make(
8772 { uT(
"kind"), uT(
"Static") },
8773 { uT(
"service"), Object_t{ pPosition, pRotation, pScale } }
8776 TestCallRender(Component_t::Make(
8778 { uT(
"kind"), uT(
"Billboard") },
8779 { uT(
"service"), Object_t{ pPosition, pRotation, pScale } }
8784TEST_F(OpenGLShader_test, Test_Transform_Combine)
8786 using GLProxy_t = ::mock::GLProxy;
8788 GLProxy_t::GetInstance() = &GLProxy;
8790 Tested_t Example{ Data_t{} };
8791 const ITested_t & IExample = Example;
8793 auto itCreator = IExample.GetCreators().find(uT(
"Transform"));
8794 ASSERT_NE(IExample.GetCreators().end(), itCreator);
8796 auto MatrixIdentity = ::glm::identity<::glm::mat4>();
8798 ::std::deque<Component_t::ComponentPtr_t> Components;
8800 const auto SetPosition = [&](
float _X,
float _Y,
float _Z)
8802 Components.push_front(Component_t::Make(
8804 { uT(
"kind"), uT(
"Position") },
8810 MatrixIdentity = ::glm::translate(MatrixIdentity, { _X, _Y, _Z });
8813 const auto SetRotation = [&](
float _X,
float _Y,
float _Z)
8815 Components.push_front(Component_t::Make(
8817 { uT(
"kind"), uT(
"Rotation") },
8823 MatrixIdentity = ::glm::rotate(MatrixIdentity, _Z, { 0.0f, 0.0f, 1.0f });
8824 MatrixIdentity = ::glm::rotate(MatrixIdentity, _Y, { 0.0f, 1.0f, 0.0f });
8825 MatrixIdentity = ::glm::rotate(MatrixIdentity, _X, { 1.0f, 0.0f, 0.0f });
8828 const auto SetScale = [&](
float _X,
float _Y,
float _Z)
8830 Components.push_front(Component_t::Make(
8832 { uT(
"kind"), uT(
"Scale") },
8838 MatrixIdentity = ::glm::scale(MatrixIdentity, { _X, _Y, _Z });
8842 MatrixIdentity = ::glm::identity<::glm::mat4>();
8845 SetPosition(1.0f, 2.0f, 3.0f);
8846 SetRotation(4.0f, 5.0f, 6.0f);
8847 SetScale(7.0f, 8.0f, 9.0f);
8849 SetPosition(11.0f, 22.0f, 33.0f);
8850 SetRotation(44.0f, 55.0f, 66.0f);
8851 SetScale(77.0f, 88.0f, 99.0f);
8853 MatrixIdentity = ::glm::transpose(MatrixIdentity);
8855 auto Render = itCreator->second(Component_t::Make(
8857 { uT(
"service"), Object_t{ Components.begin(), Components.end() } }
8859 ASSERT_NE(
nullptr, Render);
8861 using namespace ::testing;
8865 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, MatrixIdentity))
8872 MatrixIdentity = ::glm::identity<::glm::mat4>();
8875 SetPosition(1.0f, 2.0f, 3.0f);
8876 SetRotation(4.0f, 5.0f, 6.0f);
8877 SetScale(7.0f, 8.0f, 9.0f);
8879 SetPosition(11.0f, 22.0f, 33.0f);
8880 SetRotation(44.0f, 55.0f, 66.0f);
8881 SetScale(77.0f, 88.0f, 99.0f);
8883 MatrixIdentity = ::glm::transpose(MatrixIdentity);
8885 auto Render = itCreator->second(Component_t::Make(
8887 { uT(
"kind"), uT(
"Static") },
8888 { uT(
"service"), Object_t{ Components.begin(), Components.end() } }
8890 ASSERT_NE(
nullptr, Render);
8892 using namespace ::testing;
8896 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, MatrixIdentity))
8903 const auto ViewMatrix = ::glm::mat4
8905 { 1.0f, 2.0f, 3.0f, 4.0f },
8906 { 5.0f, 6.0f, 7.0f, 8.0f },
8907 { 9.0f, 10.0f, 11.0f, 12.0f },
8908 { 13.0f, 14.0f, 15.0f, 16.0f },
8911 GetCameraMartix(Example).View = ViewMatrix;
8913 auto TransposeViewMatrix = ViewMatrix;
8914 TransposeViewMatrix[0][3] = 0.0f;
8915 TransposeViewMatrix[1][3] = 0.0f;
8916 TransposeViewMatrix[2][3] = 0.0f;
8917 TransposeViewMatrix[3][0] = 0.0f;
8918 TransposeViewMatrix[3][1] = 0.0f;
8919 TransposeViewMatrix[3][2] = 0.0f;
8920 TransposeViewMatrix[3][3] = 1.0f;
8922 MatrixIdentity = TransposeViewMatrix;
8925 SetPosition(1.0f, 2.0f, 3.0f);
8926 SetPosition(11.0f, 22.0f, 33.0f);
8927 SetPosition(111.0f, 222.0f, 333.0f);
8929 MatrixIdentity = ::glm::transpose(MatrixIdentity);
8931 auto Render = itCreator->second(Component_t::Make(
8933 { uT(
"kind"), uT(
"Billboard") },
8934 { uT(
"service"), Object_t{ Components.begin(), Components.end() } }
8936 ASSERT_NE(
nullptr, Render);
8938 using namespace ::testing;
8942 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, MatrixIdentity))
8950TEST_F(OpenGLShader_test, Test_Buffer_Constant_User_CreateBuffer_Error)
8952 using BufferMapper_t = ::covellite::api::cbBufferMap_t<void>;
8954 using GLProxy_t = ::mock::GLProxy;
8956 GLProxy_t::GetInstance() = &GLProxy;
8959 const BufferMapper_t BufferMapper = [&](
void *) {
return false; };
8961 const Tested_t oExample{ Data_t{} };
8962 const ITested_t & IExample = oExample;
8964 auto itConstBufferCreator = IExample.GetCreators().find(uT(
"Buffer"));
8965 ASSERT_NE(IExample.GetCreators().end(), itConstBufferCreator);
8967 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent)
8969 using namespace ::testing;
8973 EXPECT_CALL(GLProxy, GenBuffers(_))
8976 EXPECT_CALL(GLProxy, GetError())
8978 .WillOnce(Return(1909211243));
8980 EXPECT_THROW(itConstBufferCreator->second(_pComponent), ::std::exception);
8983 const auto pBuffer = Component_t::Make(
8985 { uT(
"mapper"), BufferMapper },
8986 { uT(
"size"),
sizeof(Data) },
8988 TestCallRender(pBuffer);
8992TEST_F(OpenGLShader_test, Test_Buffer_Constant_User_UpdateBuffer_NotExistsName)
8994 using BufferMapper_t = ::covellite::api::cbBufferMap_t<void>;
8996 using GLProxy_t = ::mock::GLProxy;
8998 GLProxy_t::GetInstance() = &GLProxy;
9000 const BufferMapper_t BufferMapper = [&](
void *) {
return false; };
9002 using namespace ::testing;
9004 const Tested_t oExample{ Data_t{} };
9005 const ITested_t & IExample = oExample;
9007 auto itConstBufferCreator = IExample.GetCreators().find(uT(
"Buffer"));
9008 ASSERT_NE(IExample.GetCreators().end(), itConstBufferCreator);
9010 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent)
9012 using namespace ::testing;
9014 const auto Render = itConstBufferCreator->second(_pComponent);
9015 ASSERT_NE(
nullptr, Render);
9019 EXPECT_CALL(GLProxy, GetUniformBlockIndex(_, _))
9021 .WillOnce(Return(GL_INVALID_INDEX));
9023 EXPECT_CALL(GLProxy, BindBuffer(_, _))
9026 EXPECT_CALL(GLProxy, UniformBufferSubData(_, _, _))
9029 EXPECT_CALL(GLProxy, BindBufferBase(_, _, _))
9032 EXPECT_CALL(GLProxy, UniformBlockBinding(_, _, _))
9038 const auto pBuffer = Component_t::Make(
9040 { uT(
"mapper"), BufferMapper },
9041 { uT(
"size"), ::std::size_t{ 4 } },
9044 TestCallRender(pBuffer);
9048TEST_F(OpenGLShader_test, Test_Buffer_Constant_User)
9050 using BufferMapper_t = ::covellite::api::cbBufferMap_t<void>;
9052 using GLProxy_t = ::mock::GLProxy;
9054 GLProxy_t::GetInstance() = &GLProxy;
9057 public ::alicorn::extension::testing::Proxy<MapperProxy>
9060 MOCK_METHOD1(DoMapper,
void(
const void *));
9063 MapperProxy oMapperProxy;
9064 MapperProxy::GetInstance() = &oMapperProxy;
9066 const ::mock::GLuint BufferId = 1909211301;
9067 const ::mock::GLint ProgramId = 1909211302;
9068 const ::mock::GLint BlockIndex = 1909211332;
9069 const ::std::size_t Size = 313;
9071 void * pData =
nullptr;
9073 const BufferMapper_t BufferMapper = [&](
void * _pData)
9076 oMapperProxy.DoMapper(_pData);
9080 const Tested_t oExample{ Data_t{} };
9081 const ITested_t & IExample = oExample;
9083 auto itConstBufferCreator = IExample.GetCreators().find(uT(
"Buffer"));
9084 ASSERT_NE(IExample.GetCreators().end(), itConstBufferCreator);
9086 auto TestCallRender = [&](
const Component_t::ComponentPtr_t & _pComponent,
9087 const ::std::string & _Name)
9089 using namespace ::testing;
9093 EXPECT_CALL(GLProxy, GenBuffers(1))
9095 .WillOnce(Return(BufferId));
9097 EXPECT_CALL(GLProxy, BindBuffer(GL_UNIFORM_BUFFER, BufferId))
9100 EXPECT_CALL(GLProxy,
9101 BufferData(GL_UNIFORM_BUFFER, Size, _, GL_DYNAMIC_DRAW))
9104 EXPECT_CALL(GLProxy, BindBuffer(GL_UNIFORM_BUFFER, 0))
9107 EXPECT_CALL(GLProxy, GetError())
9109 .WillOnce(Return(GL_NO_ERROR));
9111 const auto Render = itConstBufferCreator->second(_pComponent);
9112 ASSERT_NE(
nullptr, Render);
9114 EXPECT_CALL(oMapperProxy, DoMapper(_))
9117 EXPECT_CALL(GLProxy, GetIntegerv(_))
9120 EXPECT_CALL(GLProxy, GetUniformBlockIndex(_, _))
9122 .WillOnce(Return(BlockIndex));
9124 EXPECT_CALL(GLProxy, BindBuffer(_, _))
9127 EXPECT_CALL(GLProxy, UniformBufferSubData(_, _, _))
9130 EXPECT_CALL(GLProxy, BindBuffer(_, _))
9133 EXPECT_CALL(GLProxy, BindBufferBase(_, _, _))
9136 EXPECT_CALL(GLProxy, UniformBlockBinding(_, _, _))
9141 EXPECT_CALL(oMapperProxy, DoMapper(pData))
9144 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
9146 .WillOnce(Return(&ProgramId));
9148 EXPECT_CALL(GLProxy, GetUniformBlockIndex(ProgramId, _Name))
9150 .WillOnce(Return(BlockIndex));
9152 EXPECT_CALL(GLProxy, BindBuffer(GL_UNIFORM_BUFFER, BufferId))
9155 EXPECT_CALL(GLProxy, UniformBufferSubData(0, Size, pData))
9158 EXPECT_CALL(GLProxy, BindBuffer(GL_UNIFORM_BUFFER, 0))
9161 EXPECT_CALL(GLProxy,
9162 BindBufferBase(GL_UNIFORM_BUFFER, COVELLITE_BUFFER_INDEX_USER, BufferId))
9165 EXPECT_CALL(GLProxy,
9166 UniformBlockBinding(ProgramId, BlockIndex, COVELLITE_BUFFER_INDEX_USER))
9171 EXPECT_CALL(GLProxy, DeleteBuffers(1, BufferId))
9177 const auto pBuffer = Component_t::Make(
9179 { uT(
"mapper"), BufferMapper },
9180 { uT(
"size"), Size },
9183 TestCallRender(pBuffer,
"cbUserData");
9187 const ::std::string Name =
"Name1909211251";
9189 const auto pBuffer = Component_t::Make(
9191 { uT(
"mapper"), BufferMapper },
9192 { uT(
"size"), Size },
9193 { uT(
"name"), Name },
9196 TestCallRender(pBuffer, Name);
9201TEST_F(OpenGLShader_test, Test_Camera_Orthographic_DefaultPosition)
9203 Tested::GetValue() = 1;
9205 ::mock::GLProxy GLProxy;
9207 const Tested_t Example{ Data_t{} };
9208 const ITested_t & IExample = Example;
9210 auto itCreator = IExample.GetCreators().find(uT(
"Camera"));
9211 ASSERT_NE(IExample.GetCreators().end(), itCreator);
9213 auto Render = itCreator->second(Component_t::Make(
9215 { uT(
"kind"), uT(
"Orthographic") },
9217 ASSERT_NE(
nullptr, Render);
9219 auto itShaderCreator = IExample.GetCreators().find(uT(
"Shader"));
9220 ASSERT_NE(IExample.GetCreators().end(), itShaderCreator);
9222 auto VsRender = itShaderCreator->second(Component_t::Make(
9224 { uT(
"entry"), uT(
"vsFlat") },
9226 ASSERT_NE(
nullptr, VsRender);
9228 auto PsRender = itShaderCreator->second(Component_t::Make(
9230 { uT(
"entry"), uT(
"psColored") },
9232 ASSERT_NE(
nullptr, PsRender);
9234 const float Viewport[] =
9236 1812271148.0f, 1812271149.0f, 1812181722.0f, 1812181723.0f
9239 using namespace ::testing;
9241 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, 0))
9244 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
9247 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
9250 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
9253 EXPECT_CALL(GLProxy, Disable(GL_BLEND))
9256 EXPECT_CALL(GLProxy, Disable(GL_DITHER))
9259 EXPECT_CALL(GLProxy, Enable(GL_CULL_FACE))
9262 EXPECT_CALL(GLProxy, CullFace(GL_BACK))
9265 EXPECT_CALL(GLProxy, FrontFace(GL_CCW))
9268 EXPECT_CALL(GLProxy, Viewport(0, 0, _, _))
9271 EXPECT_CALL(GLProxy, GetFloatv(GL_VIEWPORT))
9273 .WillOnce(Return(Viewport));
9280 const ::mock::GLint ProgramId = 1908251932;
9281 const ::mock::GLint ProjectionLocationId = 1908251933;
9282 const ::mock::GLint ViewLocationId = 1908252005;
9283 const ::mock::GLint ViewInverseLocationId = 1908252013;
9285 const auto Projection = ::glm::transpose(::glm::ortho(
9286 Viewport[0], Viewport[0] + Viewport[2],
9287 Viewport[1] + Viewport[3], Viewport[1],
9289 auto View = ::glm::identity<::glm::mat4>();
9290 const auto ViewInverse = ::glm::transpose(::glm::inverse(View));
9291 View = ::glm::transpose(View);
9295 EXPECT_CALL(GLProxy, GetProgramiv(_, _))
9297 .WillOnce(Return(GL_TRUE));
9299 EXPECT_CALL(GLProxy, UseProgram(_))
9302 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
9304 .WillOnce(Return(&ProgramId));
9308 EXPECT_CALL(GLProxy, GetUniformLocation(_, _))
9311 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, _))
9316 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.Projection")))
9318 .WillOnce(Return(ProjectionLocationId));
9320 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.View")))
9322 .WillOnce(Return(ViewLocationId));
9324 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.ViewInverse")))
9326 .WillOnce(Return(ViewInverseLocationId));
9328 EXPECT_CALL(GLProxy,
9329 UniformMatrix4fv(ProjectionLocationId, 1, GL_FALSE, Projection))
9332 EXPECT_CALL(GLProxy,
9333 UniformMatrix4fv(ViewLocationId, 1, GL_FALSE, View))
9336 EXPECT_CALL(GLProxy,
9337 UniformMatrix4fv(ViewInverseLocationId, 1, GL_FALSE, ViewInverse))
9344TEST_F(OpenGLShader_test, Test_Camera_Orthographic)
9346 Tested::GetValue() = 1;
9348 using GLProxy_t = ::mock::GLProxy;
9350 GLProxy_t::GetInstance() = &GLProxy;
9352 const auto X = 11111.0f;
9353 const auto Y = 22222.0f;
9355 const float SourceViewport[] =
9357 19022.82014f, 19022.82015f, 19022.82016f, 19022.82017f
9360 const Tested_t Example{ Data_t{} };
9361 const ITested_t & IExample = Example;
9363 auto itCreator = IExample.GetCreators().find(uT(
"Camera"));
9364 ASSERT_NE(IExample.GetCreators().end(), itCreator);
9366 auto itShaderCreator = IExample.GetCreators().find(uT(
"Shader"));
9367 ASSERT_NE(IExample.GetCreators().end(), itShaderCreator);
9369 auto VsRender = itShaderCreator->second(Component_t::Make(
9371 { uT(
"entry"), uT(
"vsFlat") },
9373 ASSERT_NE(
nullptr, VsRender);
9375 auto PsRender = itShaderCreator->second(Component_t::Make(
9377 { uT(
"entry"), uT(
"psColored") },
9379 ASSERT_NE(
nullptr, PsRender);
9381 using namespace ::testing;
9383 const auto pPosition = Component_t::Make(
9385 { uT(
"kind"), uT(
"Position") },
9390 const auto pCameraComponent = Component_t::Make(
9392 { uT(
"kind"), uT(
"Orthographic") },
9393 { uT(
"service"), Object_t{ pPosition } },
9396 auto Render = itCreator->second(pCameraComponent);
9397 ASSERT_NE(
nullptr, Render);
9401 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, 0))
9404 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
9407 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
9410 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
9413 EXPECT_CALL(GLProxy, Disable(GL_BLEND))
9416 EXPECT_CALL(GLProxy, Disable(GL_DITHER))
9419 EXPECT_CALL(GLProxy, Enable(GL_CULL_FACE))
9422 EXPECT_CALL(GLProxy, CullFace(GL_BACK))
9425 EXPECT_CALL(GLProxy, FrontFace(GL_CCW))
9428 EXPECT_CALL(GLProxy, Viewport(0, 0, _, _))
9431 EXPECT_CALL(GLProxy, GetFloatv(GL_VIEWPORT))
9433 .WillOnce(Return(SourceViewport));
9437 const auto Projection = ::glm::transpose(::glm::ortho(
9438 SourceViewport[0] + X,
9439 SourceViewport[0] + SourceViewport[2] + X,
9440 SourceViewport[1] + SourceViewport[3] + Y,
9441 SourceViewport[1] + Y,
9444 auto View = ::glm::identity<::glm::mat4>();
9445 const auto ViewInverse = ::glm::transpose(::glm::inverse(View));
9446 View = ::glm::transpose(View);
9448 EXPECT_EQ(View, (::glm::mat4)(*pCameraComponent)[uT(
"view")].Default(::glm::mat4{ 1.0f }));
9449 EXPECT_EQ(Projection, (::glm::mat4)(*pCameraComponent)[uT(
"projection")].Default(::glm::mat4{ 1.0f }));
9454 EXPECT_CALL(GLProxy, GetProgramiv(_, _))
9456 .WillOnce(Return(GL_TRUE));
9458 EXPECT_CALL(GLProxy, UseProgram(_))
9461 const ::mock::GLint ProgramId = 1908251932;
9462 const ::mock::GLint ProjectionLocationId = 1908251933;
9463 const ::mock::GLint ViewLocationId = 1908252005;
9464 const ::mock::GLint ViewInverseLocationId = 1908252013;
9466 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
9468 .WillRepeatedly(Return(&ProgramId));
9472 EXPECT_CALL(GLProxy, GetUniformLocation(_, _))
9475 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, _))
9480 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.Projection")))
9482 .WillOnce(Return(ProjectionLocationId));
9484 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.View")))
9486 .WillOnce(Return(ViewLocationId));
9488 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.ViewInverse")))
9490 .WillOnce(Return(ViewInverseLocationId));
9492 EXPECT_CALL(GLProxy,
9493 UniformMatrix4fv(ProjectionLocationId, 1, GL_FALSE, Projection))
9496 EXPECT_CALL(GLProxy,
9497 UniformMatrix4fv(ViewLocationId, 1, GL_FALSE, View))
9500 EXPECT_CALL(GLProxy,
9501 UniformMatrix4fv(ViewInverseLocationId, 1, GL_FALSE, ViewInverse))
9508TEST_F(OpenGLShader_test, Test_Camera_Perspective)
9510 ::testing::DefaultValue<int>::Set(GL_TRUE);
9512 Tested::GetValue() = 1;
9514 using GLProxy_t = ::mock::GLProxy;
9516 GLProxy_t::GetInstance() = &GLProxy;
9518 const float Width = 1024.0f;
9519 const float Height = 768.0f;
9521 const Tested_t Example{ Data_t{} };
9522 const ITested_t & IExample = Example;
9524 auto itShaderCreator = IExample.GetCreators().find(uT(
"Shader"));
9525 ASSERT_NE(IExample.GetCreators().end(), itShaderCreator);
9527 auto VsRender = itShaderCreator->second(Component_t::Make(
9529 { uT(
"entry"), uT(
"vsFlat") },
9531 ASSERT_NE(
nullptr, VsRender);
9533 auto PsRender = itShaderCreator->second(Component_t::Make(
9535 { uT(
"entry"), uT(
"psColored") },
9537 ASSERT_NE(
nullptr, PsRender);
9539 using namespace ::testing;
9541 auto TestCallRender = [&](
9542 const Component_t::ComponentPtr_t & _pCameraComponent,
9544 float _AngleY,
float _zNear,
float _zFar,
9545 float _X,
float _Y,
float _Z,
9546 float _A,
float _B,
float _C,
9549 ASSERT_NE(
nullptr, _Render);
9551 const float AngleYRadians = _AngleY *
9552 ::alicorn::extension::cpp::math::Constant<float>::DegreeToRadian;
9556 EXPECT_CALL(GLProxy, BindFramebuffer(GL_FRAMEBUFFER, 0))
9559 EXPECT_CALL(GLProxy, Disable(GL_DEPTH_TEST))
9562 EXPECT_CALL(GLProxy, Enable(GL_DEPTH_TEST))
9565 EXPECT_CALL(GLProxy, Clear(GL_DEPTH_BUFFER_BIT))
9568 EXPECT_CALL(GLProxy, Disable(GL_BLEND))
9571 EXPECT_CALL(GLProxy, Disable(GL_DITHER))
9574 EXPECT_CALL(GLProxy, Enable(GL_CULL_FACE))
9577 EXPECT_CALL(GLProxy, CullFace(GL_BACK))
9580 EXPECT_CALL(GLProxy, FrontFace(GL_CCW))
9583 EXPECT_CALL(GLProxy, Viewport(0, 0, _, _))
9586 const float Viewport[] = { 0, 0, Width, Height };
9588 EXPECT_CALL(GLProxy, GetFloatv(GL_VIEWPORT))
9590 .WillOnce(Return(Viewport));
9594 const auto Projection = ::glm::transpose(::glm::perspectiveFovRH(
9595 AngleYRadians, Viewport[2], Viewport[3], _zFar, _zNear));
9597 auto GetEye = [&](void) -> ::glm::vec3
9599 const auto Distance = _Distance + 0.1f;
9601 ::glm::mat4 Transform = ::glm::identity<::glm::mat4>();
9603 Transform = ::glm::translate(Transform,
9604 ::glm::vec3{ _X, _Y, _Z });
9605 Transform = ::glm::rotate(Transform,
9606 _C, ::glm::vec3{ 0.0f, 0.0f, 1.0f });
9607 Transform = ::glm::rotate(Transform,
9608 _B, ::glm::vec3{ 0.0f, 1.0f, 0.0f });
9609 Transform = ::glm::rotate(Transform,
9610 _A, ::glm::vec3{ 1.0f, 0.0f, 0.0f });
9612 return Transform * ::glm::vec4{ Distance, 0.0f, 0.0f, 1.0f };
9615 auto View = ::glm::lookAtRH(
9617 ::glm::vec3{ _X, _Y, _Z },
9618 ::glm::vec3{ 0.0f, 0.0f, 1.0f });
9619 const auto ViewInverse = ::glm::transpose(::glm::inverse(View));
9620 View = ::glm::transpose(View);
9622 EXPECT_EQ(View, (::glm::mat4)(*_pCameraComponent)[uT(
"view")].Default(::glm::mat4{ 1.0f }));
9623 EXPECT_EQ(Projection, (::glm::mat4)(*_pCameraComponent)[uT(
"projection")].Default(::glm::mat4{ 1.0f }));
9625 EXPECT_CALL(GLProxy, UseProgram(_))
9631 const ::mock::GLint ProgramId = 1908251932;
9632 const ::mock::GLint ProjectionLocationId = 1908251933;
9633 const ::mock::GLint ViewLocationId = 1908252005;
9634 const ::mock::GLint ViewInverseLocationId = 1908252013;
9636 EXPECT_CALL(GLProxy, GetIntegerv(GL_CURRENT_PROGRAM))
9638 .WillRepeatedly(Return(&ProgramId));
9642 EXPECT_CALL(GLProxy, GetUniformLocation(_, _))
9645 EXPECT_CALL(GLProxy, UniformMatrix4fv(_, _, _, _))
9650 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.Projection")))
9652 .WillOnce(Return(ProjectionLocationId));
9654 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.View")))
9656 .WillOnce(Return(ViewLocationId));
9658 EXPECT_CALL(GLProxy, GetUniformLocation(ProgramId, Eq(
"CameraData.ViewInverse")))
9660 .WillOnce(Return(ViewInverseLocationId));
9662 EXPECT_CALL(GLProxy,
9663 UniformMatrix4fv(ProjectionLocationId, 1, GL_FALSE, Projection))
9666 EXPECT_CALL(GLProxy,
9667 UniformMatrix4fv(ViewLocationId, 1, GL_FALSE, View))
9670 EXPECT_CALL(GLProxy,
9671 UniformMatrix4fv(ViewInverseLocationId, 1, GL_FALSE, ViewInverse))
9676 ::testing::DefaultValue<int>::Clear();
9679 auto itCreator = IExample.GetCreators().find(uT(
"Camera"));
9680 ASSERT_NE(IExample.GetCreators().end(), itCreator);
9692 const ::std::vector<CameraInfo> CameraInfos =
9694 { 90.0f, 0.01f, 200.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
9695 { 91.0f, 1.11f, 10.1f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f },
9696 { 92.0f, 2.22f, 20.2f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f },
9702 const auto pCamera = Component_t::Make(
9704 { uT(
"kind"), uT(
"Perspective") },
9707 EXPECT_CALL(GLProxy, Viewport(0, 0, _, _))
9710 auto Render = itCreator->second(pCamera);
9712 auto Info = CameraInfos[0];
9716 Info.AngleY, Info.zNear, Info.zFar,
9717 Info.X, Info.Y, Info.Z,
9718 Info.A, Info.B, Info.C,
9722 const auto pPosition = Component_t::Make(
9724 { uT(
"kind"), uT(
"Position") },
9727 const auto pRotation = Component_t::Make(
9729 { uT(
"kind"), uT(
"Rotation") },
9735 const auto pCamera = Component_t::Make(
9737 { uT(
"kind"), uT(
"Perspective") },
9738 { uT(
"service"), Object_t{ pPosition, pRotation } },
9741 EXPECT_CALL(GLProxy, Viewport(0, 0, _, _))
9744 auto Render = itCreator->second(pCamera);
9746 auto Info = CameraInfos[0];
9750 Info.AngleY, Info.zNear, Info.zFar,
9751 Info.X, Info.Y, Info.Z,
9752 Info.A, Info.B, Info.C,
9759 const auto pCamera = Component_t::Make(
9761 { uT(
"kind"), uT(
"Perspective") },
9762 { uT(
"service"), Object_t{ pPosition, pRotation } },
9765 EXPECT_CALL(GLProxy, Viewport(0, 0, _, _))
9768 auto Render = itCreator->second(pCamera);
9770 for (
size_t i = 1; i < CameraInfos.size(); i++)
9772 auto Info = CameraInfos[i];
9774 (*pPosition)[uT(
"x")] = Info.X;
9775 (*pPosition)[uT(
"y")] = Info.Y;
9776 (*pPosition)[uT(
"z")] = Info.Z;
9778 (*pRotation)[uT(
"x")] = Info.A;
9779 (*pRotation)[uT(
"y")] = Info.B;
9780 (*pRotation)[uT(
"z")] = Info.C;
9782 (*pCamera)[uT(
"fov")] = Info.AngleY;
9783 (*pCamera)[uT(
"znear")] = Info.zNear;
9784 (*pCamera)[uT(
"zfar")] = Info.zFar;
9785 (*pCamera)[uT(
"distance")] = Info.Distance;
9789 Info.AngleY, Info.zNear, Info.zFar,
9790 Info.X, Info.Y, Info.Z,
9791 Info.A, Info.B, Info.C,
9798TEST_F(OpenGLShader_test, Test_Camera_SetWindowViewport)
9800 const auto TestCall = [](
const Component_t::ComponentPtr_t & _pCamera)
9802 ::mock::WindowsProxy WindowsProxy;
9803 ::mock::GLProxy GLProxy;
9806 Data.ClientRect.Top = 12345;
9807 Data.ClientRect.Width = 2008131258;
9808 Data.ClientRect.Height = 2008131259;
9810 using namespace ::testing;
9812 Tested_t Example{ Data };
9813 ITested_t & IExample = Example;
9815 auto itCreator = IExample.GetCreators().find(uT(
"Camera"));
9816 ASSERT_NE(IExample.GetCreators().end(), itCreator);
9818 EXPECT_CALL(GLProxy, Viewport(0, 0, Data.ClientRect.Width, Data.ClientRect.Height - Data.ClientRect.Top))
9821 auto Render = itCreator->second(_pCamera);
9822 ASSERT_NE(
nullptr, Render);
9824 EXPECT_CALL(GLProxy, Viewport(0, 0, Data.ClientRect.Width, Data.ClientRect.Height - Data.ClientRect.Top))
9829 IExample.ResizeWindow(::covellite::Rect{ 0, 54321, 2008131300, 2008131301 });
9831 EXPECT_CALL(GLProxy, Viewport(0, 0, 2008131300, 2008131301 - 54321))
9837 TestCall(Component_t::Make(
9839 { uT(
"kind"), uT(
"Orthographic") },
9842 TestCall(Component_t::Make(
9844 { uT(
"kind"), uT(
"Perspective") },
9849TEST_F(OpenGLShader_test, Test_Camera_SetScaleViewport)
9851 const auto TestCall = [](
const float _Scale,
9852 const Component_t::ComponentPtr_t & _pCamera)
9854 ::mock::WindowsProxy WindowsProxy;
9855 ::mock::GLProxy GLProxy;
9858 Data.ClientRect.Top = 123;
9859 Data.ClientRect.Width = 1024;
9860 Data.ClientRect.Height = 2048;
9862 const auto ExpectedWidth =
static_cast<int>(_Scale * Data.ClientRect.Width);
9863 const auto ExpectedHeight =
static_cast<int>(_Scale * (Data.ClientRect.Height - Data.ClientRect.Top));
9865 using namespace ::testing;
9867 Tested_t Example{ Data };
9868 ITested_t & IExample = Example;
9870 auto itCreator = IExample.GetCreators().find(uT(
"Camera"));
9871 ASSERT_NE(IExample.GetCreators().end(), itCreator);
9873 EXPECT_CALL(GLProxy, Viewport(0, 0, ExpectedWidth, ExpectedHeight))
9876 auto Render = itCreator->second(_pCamera);
9877 ASSERT_NE(
nullptr, Render);
9879 EXPECT_CALL(GLProxy, Viewport(0, 0, ExpectedWidth, ExpectedHeight))
9884 IExample.ResizeWindow(::covellite::Rect{ 0, 321, 2048, 4096 });
9886 const auto ExpectedWidth2 =
static_cast<int>(_Scale * 2048);
9887 const auto ExpectedHeight2 =
static_cast<int>(_Scale * (4096 - 321));
9889 EXPECT_CALL(GLProxy, Viewport(0, 0, ExpectedWidth2, ExpectedHeight2))
9895 TestCall(0.5f, Component_t::Make(
9897 { uT(
"kind"), uT(
"Orthographic") },
9898 { uT(
"scale"), 0.5f },
9901 TestCall(2.0f, Component_t::Make(
9903 { uT(
"kind"), uT(
"Perspective") },
9904 { uT(
"scale"), 2.0f },
9907 TestCall(0.25f, Component_t::Make(
9909 { uT(
"kind"), uT(
"Orthographic") },
9910 { uT(
"scale"), 0.25f },
9911 { uT(
"width"), 2009081959 },
9912 { uT(
"height"), 2009082000 },
9915 TestCall(4.0f, Component_t::Make(
9917 { uT(
"kind"), uT(
"Perspective") },
9918 { uT(
"scale"), 4.0f },
9919 { uT(
"width"), 2009081959 },
9920 { uT(
"height"), 2009082000 },
9925TEST_F(OpenGLShader_test, Test_Camera_SetUserViewport)
9927 const auto TestCall = [](
const int _Width,
const int _Height,
9928 const Component_t::ComponentPtr_t & _pCamera)
9930 ::mock::WindowsProxy WindowsProxy;
9931 ::mock::GLProxy GLProxy;
9934 Data.ClientRect.Top = 345;
9935 Data.ClientRect.Width = 2009082008;
9936 Data.ClientRect.Height = 2009082009;
9938 using namespace ::testing;
9940 Tested_t Example{ Data };
9941 ITested_t & IExample = Example;
9943 auto itCreator = IExample.GetCreators().find(uT(
"Camera"));
9944 ASSERT_NE(IExample.GetCreators().end(), itCreator);
9946 EXPECT_CALL(GLProxy, Viewport(0, 0, _Width, _Height))
9949 auto Render = itCreator->second(_pCamera);
9950 ASSERT_NE(
nullptr, Render);
9952 EXPECT_CALL(GLProxy, Viewport(0, 0, _Width, _Height))
9957 IExample.ResizeWindow(::covellite::Rect{ 0, 543, 2008131300, 2008131301 });
9959 EXPECT_CALL(GLProxy, Viewport(0, 0, _Width, _Height))
9965 TestCall(1024, 2048, Component_t::Make(
9967 { uT(
"kind"), uT(
"Orthographic") },
9968 { uT(
"width"), 1024 },
9969 { uT(
"height"), 2048 },
9972 TestCall(2048, 4096, Component_t::Make(
9974 { uT(
"kind"), uT(
"Perspective") },
9975 { uT(
"width"), 2048 },
9976 { uT(
"height"), 4096 },
Класс входит в проект Covellite.Api Класс формата вертексного буфера.
Определения Vertex.hpp:34