1 // Copyright (C) 2014 Patryk Nadrowski
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in Irrlicht.h
5 #include "Renderer2D.h"
7 #include "IGPUProgrammingServices.h"
12 #include "COpenGLCoreFeature.h"
13 #include "COpenGLCoreTexture.h"
14 #include "COpenGLCoreCacheHandler.h"
21 COpenGL3Renderer2D::COpenGL3Renderer2D(const c8
*vertexShaderProgram
, const c8
*pixelShaderProgram
, COpenGL3DriverBase
*driver
, bool withTexture
) :
22 COpenGL3MaterialRenderer(driver
, 0, EMT_SOLID
),
23 WithTexture(withTexture
)
26 setDebugName("Renderer2D");
31 init(Temp
, vertexShaderProgram
, pixelShaderProgram
, false);
33 COpenGL3CacheHandler
*cacheHandler
= Driver
->getCacheHandler();
35 cacheHandler
->setProgram(Program
);
37 // These states don't change later.
39 ThicknessID
= getPixelShaderConstantID("uThickness");
41 TextureUsageID
= getPixelShaderConstantID("uTextureUsage");
42 s32 TextureUnitID
= getPixelShaderConstantID("uTextureUnit");
45 setPixelShaderConstant(TextureUnitID
, &TextureUnit
, 1);
48 setPixelShaderConstant(TextureUsageID
, &TextureUsage
, 1);
51 cacheHandler
->setProgram(0);
54 COpenGL3Renderer2D::~COpenGL3Renderer2D()
58 void COpenGL3Renderer2D::OnSetMaterial(const video::SMaterial
&material
,
59 const video::SMaterial
&lastMaterial
,
60 bool resetAllRenderstates
,
61 video::IMaterialRendererServices
*services
)
63 Driver
->getCacheHandler()->setProgram(Program
);
64 Driver
->setBasicRenderStates(material
, lastMaterial
, resetAllRenderstates
);
66 f32 Thickness
= (material
.Thickness
> 0.f
) ? material
.Thickness
: 1.f
;
67 setPixelShaderConstant(ThicknessID
, &Thickness
, 1);
70 s32 TextureUsage
= material
.TextureLayers
[0].Texture
? 1 : 0;
71 setPixelShaderConstant(TextureUsageID
, &TextureUsage
, 1);
75 bool COpenGL3Renderer2D::OnRender(IMaterialRendererServices
*service
, E_VERTEX_TYPE vtxtype
)