DemoGL::Reference::Classes::CEffect

CEffect

CEffect is the base class for all the effect classes used in your application.

class CEffect
{
public:
			CEffect();
	virtual		~CEffect();
	virtual int	Init(int iWidth, int iHeight);
	virtual void	RenderFrame(long lElapsedTime);
	virtual void	ReceiveParam(char *sParam);
	virtual void	Prepare(void);
	virtual void	End(void);
	virtual void	MessageHandler(HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM  lParam);
	virtual void	ReceiveInt(char *pszName, int iParam, long lLayer);
	virtual void	ReceiveFloat(char *pszName, float fParam, long lLayer);
	virtual void	ReceiveString(char *pszName, char *pszParam, long lLayer);
	virtual void	RenderFrameEx(long lElapsedTime, long lLayer);
};
Members.
CEffect()
Constructur for the class.
~CEffect()
Destructor for the class.
Init(int iWidth, int iHeight)
Method which will be called during the startup of the application, as long as the object is registered with DEMOGL_EffectRegister. iWidth and iHeight are the size in pixels of the client area of the window. This can be slightly smaller than the window resolution, due to size of a windowbar, in windowed mode. Always use these values instead of hard-coded resolution values. Do not place OpenGL related statements in this method because OpenGL is not yet available when the Init() method is called. Init() should return either SYS_OK when everything went all right or SYS_NOK if not. DemoGL will react on the return statement as set with the DGL_VF_INITFAILURERESPONSE variable settable with DEMOGL_SetVariable(3).
RenderFrame(long lElapsedTime)
Method which will be called every frame when the effect is placed on a visible layer using the script command [effect name];START;[layer number];. This method is not called when the console is visible. lElapsedTime is the amount of miliseconds passed since the start of the application, i.e. the current position on the timeline.
ReceiveParam(char *sParam)
Method which is called when a [effect name];SEND;[string]; command is executed and [effect name] is the name of the effect object. This method is deprecated and should not be used. Use ReceiveInt, ReceiveFloat and ReceiveString instead. sParam is pointing to the [string] value passed in the script command.
Prepare(void)
Method which is called when a [effect name];PREPARE; command is executed and [effect name] is the name of the effect object. You should do your OpenGL related initialisation of the effect in this method.
End(void)
Method which is called when a [effect name];END; command is executed and [effect name] is the name of the effect object, or when the application is terminated by the user or Windows and your application decently calls DEMOGL_AppEnd. You should place cleaning-up code for your effect in this method. The effect is removed from DemoGL and will not be executed.
MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Method which is called when a message arrives at the message pump inside DemoGL and the Message Handler is enabled for the effect, using DEMOGL_MessageHandlerEnable. The complete message as received by DemoGL is passed on to MessageHandler.
ReceiveInt(char *pszName, int iParam, long lLayer)
Method which is called when a [effect name];SENDINT;[variable name];[variable value];[layer]; command is executed and [effect name] is the name of the effect. pszName points to the value of [variable name], iParam contains the value of [variable value] and lLayer contains the value of [layer].
ReceiveFloat(char *pszName, float fParam, long lLayer)
Method which is called when a [effect name];SENDFLOAT;[variable name];[variable value];[layer]; command is executed and [effect name] is the name of the effect. pszName points to the value of [variable name], fParam contains the value of [variable value] and lLayer contains the value of [layer].
ReceiveString(char *pszName, char *pszParam, long lLayer)
Method which is called when a [effect name];SENDSTRING;[variable name];[variable value];[layer]; command is executed and [effect name] is the name of the effect. pszName points to the value of [variable name], pszParam points to the value of [variable value] and lLayer contains the value of [layer].
RenderFrameEx(long lElapsedTime, long lLayer)
Method which is exactly identical to RenderFrame but now also the layer number currently processed is passed. When you start an effect on two layers, the effect object's RenderFrame or RenderFrameEx methods are called twice: for each layer once. To distinquish for which layer this call is ment, you can use RenderFrameEx so you can determine the layer via lLayer. This method is not used by default, you should tell DemoGL to use this method instead of RenderFrame using DEMOGL_SetVariable(3) and set variable DGL_VF_USERENDERFRAMEEX. Setting that variable is for all registered effects, so you should then use RenderFrameEx instead of RenderFrame in all your effects.

Remarks.
You don't have to implement the methods you don't need. DemoGL itself contains for all methods empty equivalents that never fail, nor will report errors. It's recommended that you avoid deprecated material when using DemoGL v1.3 or higher.

Requirements.
DemoGL v1.3 (build 0112 or higher)

See also.
DEMOGL_EffectRegister, DEMOGL_SetVariable(3), DEMOGL_AppEnd, DEMOGL_MessageHandlerEnable

Last changed on 20-jan-2001

©1999-2001 Solutions Design