Fixup parsing for `Plural-Forms` (#15519)
[minetest.git] / irr / src / OpenGL / Renderer2D.cpp
blobb625feda40183cd84e42f422f4c5100bcea8335f
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"
8 #include "os.h"
10 #include "Driver.h"
12 #include "COpenGLCoreFeature.h"
13 #include "COpenGLCoreTexture.h"
14 #include "COpenGLCoreCacheHandler.h"
16 namespace irr
18 namespace video
21 COpenGL3Renderer2D::COpenGL3Renderer2D(const c8 *vertexShaderProgram, const c8 *pixelShaderProgram, COpenGL3DriverBase *driver, bool withTexture) :
22 COpenGL3MaterialRenderer(driver, 0, EMT_SOLID),
23 WithTexture(withTexture)
25 #ifdef _DEBUG
26 setDebugName("Renderer2D");
27 #endif
29 int Temp = 0;
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");
40 if (WithTexture) {
41 TextureUsageID = getPixelShaderConstantID("uTextureUsage");
42 s32 TextureUnitID = getPixelShaderConstantID("uTextureUnit");
44 s32 TextureUnit = 0;
45 setPixelShaderConstant(TextureUnitID, &TextureUnit, 1);
47 s32 TextureUsage = 0;
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);
69 if (WithTexture) {
70 s32 TextureUsage = material.TextureLayers[0].Texture ? 1 : 0;
71 setPixelShaderConstant(TextureUsageID, &TextureUsage, 1);
75 bool COpenGL3Renderer2D::OnRender(IMaterialRendererServices *service, E_VERTEX_TYPE vtxtype)
77 return true;