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");
42 TextureUsageID = getPixelShaderConstantID("uTextureUsage");
43 s32 TextureUnitID = getPixelShaderConstantID("uTextureUnit");
46 setPixelShaderConstant(TextureUnitID, &TextureUnit, 1);
49 setPixelShaderConstant(TextureUsageID, &TextureUsage, 1);
52 cacheHandler->setProgram(0);
55 COpenGL3Renderer2D::~COpenGL3Renderer2D()
59 void COpenGL3Renderer2D::OnSetMaterial(const video::SMaterial& material,
60 const video::SMaterial& lastMaterial,
61 bool resetAllRenderstates,
62 video::IMaterialRendererServices* services)
64 Driver->getCacheHandler()->setProgram(Program);
65 Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
67 f32 Thickness = (material.Thickness > 0.f) ? material.Thickness : 1.f;
68 setPixelShaderConstant(ThicknessID, &Thickness, 1);
72 s32 TextureUsage = material.TextureLayer[0].Texture ? 1 : 0;
73 setPixelShaderConstant(TextureUsageID, &TextureUsage, 1);
77 bool COpenGL3Renderer2D::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)