📄 eb_effect.h
字号:
/******************************************************************************
Copyright (C) 1999, 2000 NVIDIA Corporation
This file is provided without support, instruction, or implied warranty of any
kind. NVIDIA makes no guarantee of its fitness for a particular purpose and is
not liable under any circumstances for any damages or loss whatsoever arising
from the use or inability to use this file or items derived from it.
Comments:
******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
//
// EBEffect.h: interface for the EBEffect class
//
////////////////////////////////////////////////////////////////////////////////
#ifndef __EBEFFECT_H
#define __EBEFFECT_H
#include <windows.h>
#include <d3d8.h>
#include <d3dx8.h>
#include <dxerr8.h>
#include <GL/gl.h>
#pragma warning(disable: 4786)
#include <string.h>
#include <stdarg.h>
#include "eb_string.h"
#include "eb_timer.h"
#include "eb_property.h"
#include "eb_file.h"
////////////////////////////////////////////////////////////////////////////////
// EBEffect API versioning
//
// These defines declare the current major and minor version of the effect API.
// When changing the EBEffect class (the API), if your change is backward
// compatible, only increment the minor version number. If your change requires
// that effects compiled against the prior API be recompiled or updated, zero
// the minor version number and increment the major version number. That is,
// if an effect is compiled with API version X.Y, then it will run with browsers
// supporting any API numbered X.Z where Y <= Z. Also remember that you needn't
// change the API at all, if your change will not disrupt the EBEffect interface
// at all.
//
// NOTE: The versioning information will be 'burned into' each DLL as it is
// compiled (see __DECLARE_EFFECT_VERSION() below).
//
// This versioning system outdates the old EBEFFECT_VERSION system. This
// version provides the ability update the API and explicitly retain or remove
// backwards compatibility. It also changes the version to be associated with
// the entire DLL rather than each individual effect defined therein. This
// allows for more optimal DLL loading in the browser. Finally, this
// implementation is not upset by changes to the EBEffect class structure or
// virtual function table.
#define EBEFFECT_APIVERSION_MAJOR 6
#define EBEFFECT_APIVERSION_MINOR 0
////////////////////////////////////////////////////////////////////////////////
// EBEffect public function prototypes and macros
//
// Each effect deriving from EBEffect must include the DECLARE_EFFECT_MAIN()
// macro. This macro defines some mandatory exports and the DLL's DllMain()
// function. Additionally, each effect must export "C" style functions named
// 'CreateEffect' and 'GetEffectNum' that match the LPCREATEEFFECT and
// LPGETEFFECTNUM prototypes respectively. The four macros named below can be
// used to simplify this process.
typedef class EBEffect* (*LPCREATEEFFECT)(unsigned int);
typedef unsigned int (*LPGETEFFECTNUM)();
#define DECLARE_EFFECT_MAIN() \
__DECLARE_EFFECT_STATICS() \
__DECLARE_EFFECT_APIVERSION() \
__DECLARE_EFFECT_SCANFUNCS() \
__DECLARE_EFFECT_DLLMAIN()
// These macros provide a simple way to define the list of effects that can
// be created by your DLL. These macros can be used as follows:
//
// DECLARE_EFFECT_COUNT(3)
// DECLARE_EFFECT_CREATE_BEG()
// DECLARE_EFFECT_CREATE(0, MyFirstEffectClass())
// DECLARE_EFFECT_CREATE(1, MyOtherEffectClass(ARG_EFFECT_ONE, ARG_EFFECT_TWO))
// DECLARE_EFFECT_CREATE(2, MyOtherEffectClass(ARG_EFFECT))
// DECLARE_EFFECT_CREATE_END()
//
// OR
//
// DECLARE_EFFECT_JUST_ONE(MyOnlyEffect(Arg1, Arg2, Arg3))
//
// You can, of course, simply declare the functions yourself.
#define DECLARE_EFFECT_COUNT(num) \
extern "C" { \
__declspec(dllexport) unsigned int \
GetNumEffects() \
{ \
return num; \
} \
}
#define DECLARE_EFFECT_CREATE_BEG() \
extern "C" { \
__declspec(dllexport) EBEffect* \
CreateEffect(unsigned int num) \
{ \
switch (num) {
#define DECLARE_EFFECT_CREATE(n,c) \
case n: return new c; break;
#define DECLARE_EFFECT_CREATE_END() \
} \
return NULL; \
} \
}
#define DECLARE_EFFECT_JUST_ONE(c) \
DECLARE_EFFECT_COUNT(1) \
DECLARE_EFFECT_CREATE_BEG() \
DECLARE_EFFECT_CREATE(0,c) \
DECLARE_EFFECT_CREATE_END()
////////////////////////////////////////////////////////////////////////////////
// EBEffect enums
typedef enum tagButtonID
{
MOUSE_LEFTBUTTON = 0,
MOUSE_RIGHTBUTTON = 1,
MOUSE_MIDDLEBUTTON = 2
} eButtonID;
typedef enum tagEBGFXAPI
{
GFXAPI_D3D = 0,
GFXAPI_OPENGL = 1
} EBGFXAPI;
typedef enum tagEBKeyAction
{
// Required
EB_HELP = 0, // Show help
EB_WIREFRAME, // toggle wireframe
EB_RESET, // Reset to start conditions
// Reserved
EB_QUIT, // Quits - not used in effects browser
EB_HUD, // toggles HUD
EB_CONSOLE, // toggles console window
EB_PAUSE, // toggles Animation
EB_ADD, // Increase something
EB_SUBTRACT, // Decrease something
EB_MULTIPLY, // Multiply something
EB_DIVIDE, // Divide something
EB_PAGEUP, // Page up to move through options
EB_PAGEDOWN, // Page down to move through options
EB_POINTS, // sets point rendering mode
// Suggested
EB_CUBEMAP, // cycles cubemaps
EB_TEXTURES, // toggles textures
EB_NORMALMAP, // cycles normal maps
EB_MIPMAP, // toggles mipmapping
EB_LIGHTING, // toggles lighting
// Not recognized
EB_UNKNOWN = 0xFFFFFFFF
} eEBKeyAction;
#define EBEFFECT_DIRTY_PUBLICSTATE (1 << 0)
#define EBEFFECT_DIRTY_PIXELSHADERS (1 << 1)
#define EBEFFECT_DIRTY_VERTEXSHADERS (1 << 2)
#define EBEFFECT_DIRTY_REGCOMBSTATE (1 << 3)
// Defined below
//
extern "C" __declspec(dllexport) void GetEffectApiVersion(unsigned int*, unsigned int*);
////////////////////////////////////////////////////////////////////////////////
// EBEffect class definition
class EBEffect : public EBPropertySet
{
public:
EBEffect::EBEffect()
: m_pD3DDev(NULL),
m_strEffectName("Change EffectName property"),
m_strEffectLocation("Change EffectLocation property"),
m_strEffectVertexShader("Change EffectVertexShader property"),
m_strEffectPixelShader("Change EffectPixelShader property"),
m_strEffectVertexProgram("Change EffectVertexProgram property"),
m_strEffectTextureShader("Change EffectTextureShader property"),
m_strEffectRegCombState("Change EffectRegisterCombiner property"),
m_strLastError(""),
m_nAboutLines(0),
m_pAboutLabelEnum(NULL), m_pAboutValueEnum(NULL), m_pAboutLinkEnum(NULL),
m_idAboutIcon(-1),
m_dwEffectDirtyFlags(0)
{
GetEffectApiVersion(&m_apiMajorVersion, &m_apiMinorVersion);
m_hModule = hModule;
}
virtual ~EBEffect()
{}
// Destroy this effect (deletes it from memory)
virtual void DestroyEffect()
{ delete this; }
//////////////////////////////////////////////////////////////////////////////
// These methods must be overridden in each effect
//////////////////////////////////////////////////////////////////////////////
public:
// This method informs the browser of which graphics API the effect supports
//
// It returns D3D by default so that all of the current D3D
// effects will continue to function without code changes.
//
virtual EBGFXAPI API() const
{ return GFXAPI_D3D; };
// Must override for D3D effects
virtual HRESULT ConfirmDevice(D3DCAPS8* pCaps, DWORD dwBehavior, D3DFORMAT Format)
{ return E_FAIL; };
virtual HRESULT Initialize(LPDIRECT3DDEVICE8 pDev)
{ return E_FAIL; };
// Must override for OpenGL effects
virtual HRESULT ConfirmDevice(PIXELFORMATDESCRIPTOR *pFD)
{ return E_FAIL; };
virtual HRESULT Initialize(HGLRC hRC)
{ return E_FAIL; };
// Must override for both D3D and OpenGL effects
virtual HRESULT Free() = 0;
virtual HRESULT Start() = 0;
virtual HRESULT Tick(EBTimer* pTimer) = 0;
//////////////////////////////////////////////////////////////////////////////
// These methods may be overridden in each effect
//////////////////////////////////////////////////////////////////////////////
public:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -