According to the tutorial, the IShaderConstantSetCallBack uses IrrlichtDevice* device to set some uniform data. In the tutorial the IrrlichtDevice* device is set as a global within the inherited IShaderConstantSetCallBack class. I am not fond of this as it kind of makes it seem a bit messy. I have instead created a utility class that will store the device as a global variable. The class is called in whatever file that uses device (it is set in main.cpp). I am not a fan of using global variables, but I find this more readable.
,
So my question is, is there a better method of setting device? I.e. I would rather set device in main.cpp and send a reference to it to the IShaderConstantSetCallBack. Or is there another way I can set the shader uniforms outside of IShaderConstantSetCallBack? I have more experience with OpenGL than irrlicht, but is there a way to set the current context with the shader ID, and then set the uniforms that way? Thanks!
Header:
Code: Select all
#ifndef UTILITY_VARS_H
#define UTILITY_VARS_H
#include <irrlicht.h>
class UtilityVars
{
public:
static irr::IrrlichtDevice* device;
};
#endif
Code: Select all
#include "UtilityVars.h"
irr::IrrlichtDevice* UtilityVars::device;