Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Shader struct converted to a class with initialization function

  • Loading branch information...
commit 0b1f84103082b337ba3f9339c3b322a28719dd5d 1 parent 1e1919a
Thomas Noury authored
18 include/Shaders.h
View
@@ -8,14 +8,18 @@ is06.com. Permissions beyond the scope of this license may be available at
#ifndef __IS06_SHADERS_H__
#define __IS06_SHADERS_H__
-struct Shaders
+class Shaders
{
- s32 diffuse;
- s32 ice;
- s32 metal;
- s32 glass;
- s32 verticalBlur;
- s32 horizontalBlur;
+ public:
+ Shaders();
+ void createMaterials(video::IGPUProgrammingServices* gpuManager);
+
+ s32 diffuse;
+ s32 ice;
+ s32 metal;
+ s32 glass;
+ s32 verticalBlur;
+ s32 horizontalBlur;
};
#endif
2  include/shader/IceShaderCallback.h
View
@@ -9,6 +9,8 @@ is06.com. Permissions beyond the scope of this license may be available at
#define __ICE_SHADER_CALLBACK_H__
#include "../3d/Camera.h"
+#include "../scene/Scene.h"
+#include "../Game.h"
using namespace irr;
43 src/Game.cpp
View
@@ -16,8 +16,6 @@ is06.com. Permissions beyond the scope of this license may be available at
#include "../include/scene/Scene.h"
#include "../include/scene/SceneMenu.h"
#include "../include/scene/SceneGameplay.h"
-#include "../include/shader/DiffuseShaderCallback.h"
-#include "../include/shader/IceShaderCallback.h"
#include "../include/ref/maps.h"
#include "../include/Translation.h"
@@ -321,8 +319,6 @@ void Game::initScreenPositions()
screenHeight = 720;
screenWidth = screenHeight * ratio;
- cout << screenWidth << "x" << screenHeight << endl;
-
// Screen position info
screenPos.width = screenWidth;
screenPos.height = screenHeight;
@@ -340,43 +336,8 @@ void Game::initScreenPositions()
*/
void Game::initShaders()
{
- shaders.diffuse = 0;
- shaders.horizontalBlur = 0;
- shaders.verticalBlur = 0;
-
- if (gpuManager) {
- // Shader Diffuse (2D Elements)
- DiffuseShaderCallback* diffuseCallback = new DiffuseShaderCallback();
- shaders.diffuse = gpuManager->addHighLevelShaderMaterialFromFiles(
- "resource/shader/diffuse.vert", "vertexMain", video::EVST_VS_1_1,
- "resource/shader/diffuse.frag", "pixelMain", video::EPST_PS_1_1,
- diffuseCallback, video::EMT_TRANSPARENT_ALPHA_CHANNEL
- );
- diffuseCallback->drop();
-
- // Ice shader
- IceShaderCallback* iceCallback = new IceShaderCallback();
- shaders.ice = gpuManager->addHighLevelShaderMaterialFromFiles(
- "resource/shader/ice.vert", "vertexMain", video::EVST_VS_1_1,
- "resource/shader/ice.frag", "pixelMain", video::EPST_PS_1_1,
- iceCallback, video::EMT_SOLID
- );
- iceCallback->drop();
-
- // Horizontal Blur Shader
- shaders.horizontalBlur = gpuManager->addHighLevelShaderMaterialFromFiles(
- "resource/shader/blur.vert", "vertexMain", video::EVST_VS_1_1,
- "resource/shader/hBlur.frag", "pixelMain", video::EPST_PS_1_1,
- 0, video::EMT_SOLID
- );
-
- // Vertical Blur Shader
- shaders.verticalBlur = gpuManager->addHighLevelShaderMaterialFromFiles(
- "resource/shader/blur.vert", "vertexMain", video::EVST_VS_1_1,
- "resource/shader/vBlur.frag", "pixelMain", video::EPST_PS_1_1,
- 0, video::EMT_SOLID
- );
- }
+ shaders = Shaders();
+ shaders.createMaterials(gpuManager);
}
/**
60 src/Shaders.cpp
View
@@ -0,0 +1,60 @@
+/******************************************************************************
+Invisible Spirit by Thomas Noury is licensed under a Creative Commons
+Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at
+is06.com. Permissions beyond the scope of this license may be available at
+http://www.is06.com. Legal code in license.txt
+*******************************************************************************/
+
+#include "../include/ref/core.h"
+#include "../include/Shaders.h"
+#include "../include/shader/DiffuseShaderCallback.h"
+#include "../include/shader/IceShaderCallback.h"
+
+using namespace irr;
+
+Shaders::Shaders()
+{
+ diffuse = 0;
+ ice = 0;
+ metal = video::EMT_SOLID;
+ glass = video::EMT_SOLID;
+ horizontalBlur = 0;
+ verticalBlur = 0;
+}
+
+void Shaders::createMaterials(video::IGPUProgrammingServices* gpuManager)
+{
+ if (gpuManager) {
+ // Shader Diffuse (2D Elements)
+ DiffuseShaderCallback* diffuseCallback = new DiffuseShaderCallback();
+ diffuse = gpuManager->addHighLevelShaderMaterialFromFiles(
+ "resource/shader/diffuse.vert", "vertexMain", video::EVST_VS_1_1,
+ "resource/shader/diffuse.frag", "pixelMain", video::EPST_PS_1_1,
+ diffuseCallback, video::EMT_TRANSPARENT_ALPHA_CHANNEL
+ );
+ diffuseCallback->drop();
+
+ // Ice shader
+ IceShaderCallback* iceCallback = new IceShaderCallback();
+ ice = gpuManager->addHighLevelShaderMaterialFromFiles(
+ "resource/shader/ice.vert", "vertexMain", video::EVST_VS_1_1,
+ "resource/shader/ice.frag", "pixelMain", video::EPST_PS_1_1,
+ iceCallback, video::EMT_SOLID
+ );
+ iceCallback->drop();
+
+ // Horizontal Blur Shader
+ horizontalBlur = gpuManager->addHighLevelShaderMaterialFromFiles(
+ "resource/shader/blur.vert", "vertexMain", video::EVST_VS_1_1,
+ "resource/shader/hBlur.frag", "pixelMain", video::EPST_PS_1_1,
+ 0, video::EMT_SOLID
+ );
+
+ // Vertical Blur Shader
+ verticalBlur = gpuManager->addHighLevelShaderMaterialFromFiles(
+ "resource/shader/blur.vert", "vertexMain", video::EVST_VS_1_1,
+ "resource/shader/vBlur.frag", "pixelMain", video::EPST_PS_1_1,
+ 0, video::EMT_SOLID
+ );
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.