123
This commit is contained in:
369
RenderDll/XRenderOGL/CG/cg.h
Normal file
369
RenderDll/XRenderOGL/CG/cg.h
Normal file
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _cg_h
|
||||
#define _cg_h
|
||||
|
||||
|
||||
#define CG_VERSION_1_2 1
|
||||
#define CG_VERSION_NUM 1200
|
||||
|
||||
|
||||
//
|
||||
// This #define foreces the old API for now. This will be removed soon, but
|
||||
// the user will still have the ability to enable it.
|
||||
//
|
||||
// #define CG_DEPRECATED_1_1_API 1
|
||||
|
||||
// Set up for either Win32 import/export/lib.
|
||||
#ifndef CGDLL_API
|
||||
#ifdef WIN32
|
||||
#ifdef CGDLL_EXPORTS
|
||||
#define CGDLL_API __declspec(dllexport)
|
||||
#elif defined (CG_LIB)
|
||||
#define CGDLL_API
|
||||
#else
|
||||
#define CGDLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CGDLL_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*************************************************************************/
|
||||
/*** CG Run-Time Library API ***/
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/*** Data types and enumerants ***/
|
||||
/*************************************************************************/
|
||||
|
||||
typedef int CGbool;
|
||||
|
||||
#define CG_FALSE ((CGbool)0)
|
||||
#define CG_TRUE ((CGbool)1)
|
||||
|
||||
typedef struct _CGcontext *CGcontext;
|
||||
typedef struct _CGprogram *CGprogram;
|
||||
typedef struct _CGparameter *CGparameter;
|
||||
|
||||
|
||||
//!!! PREPROCESS BEGIN
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CG_UNKNOWN_TYPE,
|
||||
CG_STRUCT,
|
||||
CG_ARRAY,
|
||||
|
||||
CG_TYPE_START_ENUM = 1024,
|
||||
# define CG_DATATYPE_MACRO(name, compiler_name, enum_name, ncols, nrows) \
|
||||
enum_name ,
|
||||
|
||||
#include "Cg/cg_datatypes.h"
|
||||
|
||||
} CGtype;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
# define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,\
|
||||
enum_int,addressable,param_type) \
|
||||
enum_name = enum_int,
|
||||
|
||||
#include "Cg/cg_bindlocations.h"
|
||||
|
||||
CG_UNDEFINED,
|
||||
|
||||
} CGresource;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CG_PROFILE_START = 6144,
|
||||
CG_PROFILE_UNKNOWN,
|
||||
|
||||
# define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
|
||||
CG_PROFILE_##compiler_id_caps = int_id,
|
||||
|
||||
#include "Cg/cg_profiles.h"
|
||||
|
||||
CG_PROFILE_MAX = 7100,
|
||||
} CGprofile;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
# define CG_ERROR_MACRO(code, enum_name, message) \
|
||||
enum_name = code,
|
||||
# include "Cg/cg_errors.h"
|
||||
} CGerror;
|
||||
|
||||
//!!! PREPROCESS END
|
||||
|
||||
typedef enum
|
||||
{
|
||||
# define CG_ENUM_MACRO(enum_name, enum_val) \
|
||||
enum_name = enum_val,
|
||||
# include "Cg/cg_enums.h"
|
||||
} CGenum;
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*CGerrorCallbackFunc)(void);
|
||||
|
||||
/*************************************************************************/
|
||||
/*** Functions ***/
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef CG_EXPLICIT
|
||||
|
||||
/*** Context functions ***/
|
||||
|
||||
CGDLL_API CGcontext cgCreateContext(void);
|
||||
CGDLL_API void cgDestroyContext(CGcontext ctx);
|
||||
CGDLL_API CGbool cgIsContext(CGcontext ctx);
|
||||
CGDLL_API const char *cgGetLastListing(CGcontext ctx);
|
||||
CGDLL_API void cgSetAutoCompile(CGcontext ctx, CGenum flag);
|
||||
|
||||
/*** Program functions ***/
|
||||
CGDLL_API CGprogram cgCreateProgram(CGcontext ctx,
|
||||
CGenum program_type,
|
||||
const char *program,
|
||||
CGprofile profile,
|
||||
const char *entry,
|
||||
const char **args);
|
||||
CGDLL_API CGprogram cgCreateProgramFromFile(CGcontext ctx,
|
||||
CGenum program_type,
|
||||
const char *program_file,
|
||||
CGprofile profile,
|
||||
const char *entry,
|
||||
const char **args);
|
||||
CGDLL_API CGprogram cgCopyProgram(CGprogram program);
|
||||
CGDLL_API void cgDestroyProgram(CGprogram program);
|
||||
|
||||
CGDLL_API CGprogram cgGetFirstProgram(CGcontext ctx);
|
||||
CGDLL_API CGprogram cgGetNextProgram(CGprogram current);
|
||||
CGDLL_API CGcontext cgGetProgramContext(CGprogram prog);
|
||||
CGDLL_API CGbool cgIsProgram(CGprogram program);
|
||||
|
||||
CGDLL_API void cgCompileProgram(CGprogram program);
|
||||
CGDLL_API CGbool cgIsProgramCompiled(CGprogram program);
|
||||
CGDLL_API const char *cgGetProgramString(CGprogram prog, CGenum pname);
|
||||
CGDLL_API CGprofile cgGetProgramProfile(CGprogram prog);
|
||||
|
||||
/*** Parameter functions ***/
|
||||
|
||||
CGDLL_API CGparameter cgCreateParameter(CGcontext ctx, CGtype type);
|
||||
CGDLL_API CGparameter cgCreateParameterArray(CGcontext ctx,
|
||||
CGtype type,
|
||||
int length);
|
||||
CGDLL_API CGparameter cgCreateParameterMultiDimArray(CGcontext ctx,
|
||||
CGtype type,
|
||||
int dim,
|
||||
const int *lengths);
|
||||
CGDLL_API void cgDestroyParameter(CGparameter param);
|
||||
CGDLL_API void cgConnectParameter(CGparameter from, CGparameter to);
|
||||
CGDLL_API void cgDisconnectParameter(CGparameter param);
|
||||
CGDLL_API CGparameter cgGetConnectedParameter(CGparameter param);
|
||||
|
||||
CGDLL_API int cgGetNumConnectedToParameters(CGparameter param);
|
||||
CGDLL_API CGparameter cgGetConnectedToParameter(CGparameter param, int index);
|
||||
|
||||
CGDLL_API CGparameter cgGetNamedParameter(CGprogram prog, const char *name);
|
||||
CGDLL_API CGparameter cgGetNamedProgramParameter(CGprogram prog,
|
||||
CGenum name_space,
|
||||
const char *name);
|
||||
|
||||
CGDLL_API CGparameter cgGetFirstParameter(CGprogram prog, CGenum name_space);
|
||||
CGDLL_API CGparameter cgGetNextParameter(CGparameter current);
|
||||
CGDLL_API CGparameter cgGetFirstLeafParameter(CGprogram prog, CGenum name_space);
|
||||
CGDLL_API CGparameter cgGetNextLeafParameter(CGparameter current);
|
||||
|
||||
CGDLL_API CGparameter cgGetFirstStructParameter(CGparameter param);
|
||||
CGDLL_API CGparameter cgGetNamedStructParameter(CGparameter param,
|
||||
const char *name);
|
||||
|
||||
CGDLL_API CGparameter cgGetFirstDependentParameter(CGparameter param);
|
||||
|
||||
CGDLL_API CGparameter cgGetArrayParameter(CGparameter aparam, int index);
|
||||
CGDLL_API int cgGetArrayDimension(CGparameter param);
|
||||
CGDLL_API CGtype cgGetArrayType(CGparameter param);
|
||||
CGDLL_API int cgGetArraySize(CGparameter param, int dimension);
|
||||
CGDLL_API void cgSetArraySize(CGparameter param, int size);
|
||||
CGDLL_API void cgSetMultiDimArraySize(CGparameter param, const int *sizes);
|
||||
|
||||
CGDLL_API CGprogram cgGetParameterProgram(CGparameter param);
|
||||
CGDLL_API CGcontext cgGetParameterContext(CGparameter param);
|
||||
CGDLL_API CGbool cgIsParameter(CGparameter param);
|
||||
CGDLL_API const char *cgGetParameterName(CGparameter param);
|
||||
CGDLL_API CGtype cgGetParameterType(CGparameter param);
|
||||
CGDLL_API CGtype cgGetParameterNamedType(CGparameter param);
|
||||
CGDLL_API const char *cgGetParameterSemantic(CGparameter param);
|
||||
CGDLL_API CGresource cgGetParameterResource(CGparameter param);
|
||||
CGDLL_API CGresource cgGetParameterBaseResource(CGparameter param);
|
||||
CGDLL_API unsigned long cgGetParameterResourceIndex(CGparameter param);
|
||||
CGDLL_API CGenum cgGetParameterVariability(CGparameter param);
|
||||
CGDLL_API CGenum cgGetParameterDirection(CGparameter param);
|
||||
CGDLL_API CGbool cgIsParameterReferenced(CGparameter param);
|
||||
CGDLL_API const double *cgGetParameterValues(CGparameter param,
|
||||
CGenum value_type,
|
||||
int *nvalues);
|
||||
CGDLL_API int cgGetParameterOrdinalNumber(CGparameter param);
|
||||
CGDLL_API CGbool cgIsParameterGlobal(CGparameter param);
|
||||
CGDLL_API int cgGetParameterIndex(CGparameter param);
|
||||
|
||||
CGDLL_API void cgSetParameterVariability(CGparameter param, CGenum vary);
|
||||
CGDLL_API void cgSetParameterSemantic(CGparameter param, const char *semantic);
|
||||
|
||||
|
||||
CGDLL_API void cgSetParameter1f(CGparameter param, float x);
|
||||
CGDLL_API void cgSetParameter2f(CGparameter param, float x, float y);
|
||||
CGDLL_API void cgSetParameter3f(CGparameter param, float x, float y, float z);
|
||||
CGDLL_API void cgSetParameter4f(CGparameter param,
|
||||
float x,
|
||||
float y,
|
||||
float z,
|
||||
float w);
|
||||
CGDLL_API void cgSetParameter1d(CGparameter param, double x);
|
||||
CGDLL_API void cgSetParameter2d(CGparameter param, double x, double y);
|
||||
CGDLL_API void cgSetParameter3d(CGparameter param,
|
||||
double x,
|
||||
double y,
|
||||
double z);
|
||||
CGDLL_API void cgSetParameter4d(CGparameter param,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double w);
|
||||
|
||||
|
||||
CGDLL_API void cgSetParameter1fv(CGparameter param, const float *v);
|
||||
CGDLL_API void cgSetParameter2fv(CGparameter param, const float *v);
|
||||
CGDLL_API void cgSetParameter3fv(CGparameter param, const float *v);
|
||||
CGDLL_API void cgSetParameter4fv(CGparameter param, const float *v);
|
||||
CGDLL_API void cgSetParameter1dv(CGparameter param, const double *v);
|
||||
CGDLL_API void cgSetParameter2dv(CGparameter param, const double *v);
|
||||
CGDLL_API void cgSetParameter3dv(CGparameter param, const double *v);
|
||||
CGDLL_API void cgSetParameter4dv(CGparameter param, const double *v);
|
||||
|
||||
CGDLL_API void cgSetMatrixParameterdr(CGparameter param, const double *matrix);
|
||||
CGDLL_API void cgSetMatrixParameterfr(CGparameter param, const float *matrix);
|
||||
CGDLL_API void cgSetMatrixParameterdc(CGparameter param, const double *matrix);
|
||||
CGDLL_API void cgSetMatrixParameterfc(CGparameter param, const float *matrix);
|
||||
|
||||
|
||||
/*** Type Functions ***/
|
||||
|
||||
CGDLL_API const char *cgGetTypeString(CGtype type);
|
||||
CGDLL_API CGtype cgGetType(const char *type_string);
|
||||
|
||||
CGDLL_API CGtype cgGetNamedUserType(CGprogram program, const char *name);
|
||||
|
||||
CGDLL_API int cgGetNumUserTypes(CGprogram program);
|
||||
CGDLL_API CGtype cgGetUserType(CGprogram program, int index);
|
||||
|
||||
CGDLL_API int cgGetNumParentTypes(CGtype type);
|
||||
CGDLL_API CGtype cgGetParentType(CGtype type, int index);
|
||||
|
||||
CGDLL_API CGbool cgIsParentType(CGtype parent, CGtype child);
|
||||
CGDLL_API CGbool cgIsInterfaceType(CGtype type);
|
||||
|
||||
/*** Resource Functions ***/
|
||||
|
||||
CGDLL_API const char *cgGetResourceString(CGresource resource);
|
||||
CGDLL_API CGresource cgGetResource(const char *resource_string);
|
||||
|
||||
/*** Enum Functions ***/
|
||||
|
||||
CGDLL_API const char *cgGetEnumString(CGenum en);
|
||||
CGDLL_API CGenum cgGetEnum(const char *enum_string);
|
||||
|
||||
/*** Profile Functions ***/
|
||||
|
||||
CGDLL_API const char *cgGetProfileString(CGprofile profile);
|
||||
CGDLL_API CGprofile cgGetProfile(const char *profile_string);
|
||||
|
||||
/*** Error Functions ***/
|
||||
|
||||
CGDLL_API CGerror cgGetError(void);
|
||||
CGDLL_API const char *cgGetErrorString(CGerror error);
|
||||
CGDLL_API const char *cgGetLastErrorString(CGerror *error);
|
||||
CGDLL_API void cgSetErrorCallback(CGerrorCallbackFunc func);
|
||||
CGDLL_API CGerrorCallbackFunc cgGetErrorCallback(void);
|
||||
|
||||
/*** Misc Functions ***/
|
||||
|
||||
CGDLL_API const char *cgGetString(CGenum sname);
|
||||
|
||||
|
||||
/*** Support for deprecated Cg 1.1 API ***/
|
||||
|
||||
CGDLL_API CGparameter cgGetNextParameter_depr1_1(CGparameter current);
|
||||
CGDLL_API CGparameter cgGetNextLeafParameter_depr1_1(CGparameter current);
|
||||
|
||||
#ifdef CG_DEPRECATED_1_1_API
|
||||
|
||||
#define cgGetNextParameter cgGetNextParameter_depr1_1
|
||||
#define cgGetNextLeafParameter cgGetNextLeafParameter_depr1_1
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
200
RenderDll/XRenderOGL/CG/cgContextManager.h
Normal file
200
RenderDll/XRenderOGL/CG/cgContextManager.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************************************************************NVMH2****
|
||||
File: cgContextManager.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:
|
||||
|
||||
cgContextManager - a class for loading various cg programs,
|
||||
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef __NV_CG_MANAGER_H
|
||||
#define __NV_CG_MANAGER_H
|
||||
|
||||
#if WIN32
|
||||
|
||||
#pragma warning (disable:4786) // identifier was truncated to '255' characters in the browser information
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include <Cg/cgTemplates.h>
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgProgramManager.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cgContextManager;
|
||||
|
||||
|
||||
class cgContextContainer
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
// retrieve the listing file for the last compile
|
||||
const char *GetLastListing();
|
||||
|
||||
|
||||
// loads and compiles the cg program
|
||||
cgProgramContainer * LoadCGProgramFromFile(
|
||||
const char * filename, // filename of the Cg program
|
||||
const char * title, // title of the program
|
||||
cgProfileType type, // profile of the program
|
||||
cgVertexDefinition * va = 0, // optionally, set streams or allow different vetex definitions
|
||||
DWORD * outIndex = 0,
|
||||
const char * entry = 0);
|
||||
|
||||
cgProgramContainer * LoadCGProgramFromMemory(
|
||||
const char * memory, // memory location that contain the cg program
|
||||
const char * title, // name of the program
|
||||
cgProfileType type, // profile of the program
|
||||
cgVertexDefinition * va = 0, // optionally, set the streams for each vertex entry
|
||||
DWORD * outIndex = 0,
|
||||
const char * entry = 0);
|
||||
|
||||
|
||||
// use outIndex returned from LoadCGProgramFrom to retriece the program iterator
|
||||
cgProgramContainer * GetProgramIterator(DWORD index);
|
||||
|
||||
|
||||
// program operators (for multiple programs(vertex, pixel) in one cg
|
||||
// pass NULL to get first program
|
||||
cgProgramIter *GetNextProgram(cgProgramIter *iter);
|
||||
|
||||
// get a specific program
|
||||
cgProgramIter *ProgramByName(const char *name);
|
||||
|
||||
|
||||
// get the vertexshader or pixel shader handle that is passed to
|
||||
// SetVertexShader and SetPixelShader
|
||||
DWORD GetShaderHandle(cgProfileType type)
|
||||
{
|
||||
return pm.GetShaderHandle( type);
|
||||
}
|
||||
|
||||
~cgContextContainer( );
|
||||
|
||||
friend class cgContextManager;
|
||||
protected:
|
||||
|
||||
cgContextContainer( LPDIRECT3DDEVICE8 pd3dDevice, cgContext * context);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
cgProgramContainer * CreateProgramContainer(DWORD * outIndex = 0);
|
||||
|
||||
cgProgramContainer * CreateProgramContainer(
|
||||
cgProgramIter *ProgramIter,
|
||||
LPDIRECT3DDEVICE8 pd3dDevice,
|
||||
DWORD * outIndex = 0); // index of this
|
||||
|
||||
// loads and compiles the cg program
|
||||
HRESULT AddProgramFromFile(const char * filename, const char * name, cgProfileType type, const char * entry = 0);
|
||||
HRESULT AddProgramFromMemory(const char * memory, const char * name, cgProfileType type, const char * entry = 0);
|
||||
|
||||
|
||||
void Free();
|
||||
cgProgramManager pm; // manage the vertex or pixel shader that is derived from this
|
||||
cgContext * m_Context;
|
||||
cg_string m_ContextDefinition;
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class cgContextManager
|
||||
{
|
||||
private:
|
||||
|
||||
cg_vector < cgContextContainer *> m_ContextContainers;
|
||||
cg_vector < DWORD > m_ContextIndices; // indirection to m_Shaders
|
||||
// Programs hold an index to this array for
|
||||
// their shaders. The array int at that index
|
||||
// holds the index into the m_Shaders array.
|
||||
|
||||
// each context has a list of programs (up to one for each profile)
|
||||
|
||||
|
||||
public:
|
||||
cgContextManager();
|
||||
~cgContextManager();
|
||||
|
||||
cgError Free();
|
||||
|
||||
cgContextContainer *CreateContextContainer(LPDIRECT3DDEVICE8 pd3dDevice, DWORD * outIndex);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#endif
|
||||
375
RenderDll/XRenderOGL/CG/cgGL.h
Normal file
375
RenderDll/XRenderOGL/CG/cgGL.h
Normal file
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _cggl_h
|
||||
#define _cggl_h
|
||||
|
||||
|
||||
|
||||
#include "Cg/cg.h"
|
||||
|
||||
/* Set up for either Win32 import/export/lib. */
|
||||
#ifndef CGGLDLL_API
|
||||
#if WIN32
|
||||
# include <windows.h>
|
||||
#ifdef CGGLDLL_EXPORTS
|
||||
#define CGGLDLL_API __declspec(dllexport)
|
||||
#elif defined (CG_LIB)
|
||||
#define CGGLDLL_API
|
||||
#else
|
||||
#define CGGLDLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CGGLDLL_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** cgGL Type Definitions ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CG_GL_MATRIX_IDENTITY = 0,
|
||||
CG_GL_MATRIX_TRANSPOSE = 1,
|
||||
CG_GL_MATRIX_INVERSE = 2,
|
||||
CG_GL_MATRIX_INVERSE_TRANSPOSE = 3,
|
||||
|
||||
CG_GL_MODELVIEW_MATRIX,
|
||||
CG_GL_PROJECTION_MATRIX,
|
||||
CG_GL_TEXTURE_MATRIX,
|
||||
CG_GL_MODELVIEW_PROJECTION_MATRIX,
|
||||
|
||||
CG_GL_VERTEX,
|
||||
CG_GL_FRAGMENT,
|
||||
|
||||
} CGGLenum;
|
||||
|
||||
|
||||
#ifndef CGGL_EXPLICIT
|
||||
|
||||
/******************************************************************************
|
||||
*** Profile Functions
|
||||
*****************************************************************************/
|
||||
|
||||
CGGLDLL_API CGbool cgGLIsProfileSupported(CGprofile profile);
|
||||
|
||||
CGGLDLL_API void cgGLEnableProfile(CGprofile profile);
|
||||
CGGLDLL_API void cgGLDisableProfile(CGprofile profile);
|
||||
|
||||
CGGLDLL_API CGprofile cgGLGetLatestProfile(CGGLenum profile_type);
|
||||
CGGLDLL_API void cgGLSetOptimalOptions(CGprofile profile);
|
||||
|
||||
/******************************************************************************
|
||||
*** Program Managment Functions
|
||||
*****************************************************************************/
|
||||
|
||||
CGGLDLL_API void cgGLLoadProgram(CGprogram program);
|
||||
CGGLDLL_API CGbool cgGLIsProgramLoaded(CGprogram program);
|
||||
CGGLDLL_API void cgGLBindProgram(CGprogram program);
|
||||
CGGLDLL_API void cgGLUnbindProgram(CGprofile profile);
|
||||
CGGLDLL_API GLuint cgGLGetProgramID(CGprogram program);
|
||||
|
||||
/******************************************************************************
|
||||
*** Parameter Managment Functions
|
||||
*****************************************************************************/
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter1f(CGparameter param,
|
||||
float x);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter2f(CGparameter param,
|
||||
float x,
|
||||
float y);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter3f(CGparameter param,
|
||||
float x,
|
||||
float y,
|
||||
float z);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter4f(CGparameter param,
|
||||
float x,
|
||||
float y,
|
||||
float z,
|
||||
float w);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter1fv(CGparameter param, const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter2fv(CGparameter param, const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter3fv(CGparameter param, const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter4fv(CGparameter param, const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter1d(CGparameter param,
|
||||
double x);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter2d(CGparameter param,
|
||||
double x,
|
||||
double y);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter3d(CGparameter param,
|
||||
double x,
|
||||
double y,
|
||||
double z);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter4d(CGparameter param,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double w);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter1dv(CGparameter param, const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter2dv(CGparameter param, const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter3dv(CGparameter param, const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter4dv(CGparameter param, const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameter4dv(CGparameter param, const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter1f(CGparameter param, float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter2f(CGparameter param, float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter3f(CGparameter param, float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter4f(CGparameter param, float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter1d(CGparameter param, double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter2d(CGparameter param, double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter3d(CGparameter param, double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameter4d(CGparameter param, double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray1f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray2f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray3f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray4f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const float *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray1d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray2d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray3d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterArray4d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray1f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray2f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray3f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray4f(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
float *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray1d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray2d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray3d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
double *v);
|
||||
|
||||
CGGLDLL_API void cgGLGetParameterArray4d(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
double *v);
|
||||
|
||||
CGGLDLL_API void cgGLSetParameterPointer(CGparameter param,
|
||||
GLint fsize,
|
||||
GLenum type,
|
||||
GLsizei stride,
|
||||
const GLvoid *pointer);
|
||||
|
||||
CGGLDLL_API void cgGLEnableClientState(CGparameter param);
|
||||
CGGLDLL_API void cgGLDisableClientState(CGparameter param);
|
||||
|
||||
/******************************************************************************
|
||||
*** Matrix Parameter Managment Functions
|
||||
*****************************************************************************/
|
||||
|
||||
CGGLDLL_API void cgGLSetMatrixParameterdr(CGparameter param,
|
||||
const double *matrix);
|
||||
CGGLDLL_API void cgGLSetMatrixParameterfr(CGparameter param,
|
||||
const float *matrix);
|
||||
CGGLDLL_API void cgGLSetMatrixParameterdc(CGparameter param,
|
||||
const double *matrix);
|
||||
CGGLDLL_API void cgGLSetMatrixParameterfc(CGparameter param,
|
||||
const float *matrix);
|
||||
|
||||
CGGLDLL_API void cgGLGetMatrixParameterdr(CGparameter param, double *matrix);
|
||||
CGGLDLL_API void cgGLGetMatrixParameterfr(CGparameter param, float *matrix);
|
||||
CGGLDLL_API void cgGLGetMatrixParameterdc(CGparameter param, double *matrix);
|
||||
CGGLDLL_API void cgGLGetMatrixParameterfc(CGparameter param, float *matrix);
|
||||
|
||||
CGGLDLL_API void cgGLSetStateMatrixParameter(CGparameter param,
|
||||
CGGLenum matrix,
|
||||
CGGLenum transform);
|
||||
|
||||
CGGLDLL_API void cgGLSetMatrixParameterArrayfc(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const float *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLSetMatrixParameterArrayfr(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const float *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLSetMatrixParameterArraydc(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const double *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLSetMatrixParameterArraydr(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
const double *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLGetMatrixParameterArrayfc(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
float *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLGetMatrixParameterArrayfr(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
float *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLGetMatrixParameterArraydc(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
double *matrices);
|
||||
|
||||
CGGLDLL_API void cgGLGetMatrixParameterArraydr(CGparameter param,
|
||||
long offset,
|
||||
long nelements,
|
||||
double *matrices);
|
||||
|
||||
/******************************************************************************
|
||||
*** Texture Parameter Managment Functions
|
||||
*****************************************************************************/
|
||||
|
||||
CGGLDLL_API void cgGLSetTextureParameter(CGparameter param, GLuint texobj);
|
||||
CGGLDLL_API GLuint cgGLGetTextureParameter(CGparameter param);
|
||||
CGGLDLL_API void cgGLEnableTextureParameter(CGparameter param);
|
||||
CGGLDLL_API void cgGLDisableTextureParameter(CGparameter param);
|
||||
CGGLDLL_API GLenum cgGLGetTextureEnum(CGparameter param);
|
||||
CGGLDLL_API void cgGLSetManageTextureParameters(CGcontext ctx, CGbool flag);
|
||||
CGGLDLL_API CGbool cgGLGetManageTextureParameters(CGcontext ctx);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
325
RenderDll/XRenderOGL/CG/cgGL_deprecated_api.h
Normal file
325
RenderDll/XRenderOGL/CG/cgGL_deprecated_api.h
Normal file
@@ -0,0 +1,325 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _cgGL_deprecated_api_h
|
||||
#define _cgGL_deprecated_api_h
|
||||
|
||||
#include <Cg/cg.h>
|
||||
|
||||
// Set up for either Win32 import/export/lib.
|
||||
#ifndef CGGLDLL_API
|
||||
#if WIN32
|
||||
# include <windows.h>
|
||||
#ifdef CGGLDLL_EXPORTS
|
||||
#define CGGLDLL_API __declspec(dllexport)
|
||||
#elif defined (CG_LIB)
|
||||
#define CGGLDLL_API
|
||||
#else
|
||||
#define CGGLDLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CGGLDLL_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** cgGL Type Definitions ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cgGLMatrixIdentity = 0,
|
||||
cgGLMatrixTranspose = 1,
|
||||
cgGLMatrixInverse = 2,
|
||||
} cgGLMatrixFormat;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cgGLModelViewMatrix,
|
||||
cgGLProjectionMatrix,
|
||||
cgGLTextureMatrix,
|
||||
cgGLModelViewProjectionMatrix,
|
||||
} cgGLMatrixType;
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Resource Aliases ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define cgBindPosition cgBindPosition0
|
||||
#define cgBindNormal cgBindNormal0
|
||||
#define cgBindCol cgBindCol0
|
||||
#define cgBindColor cgBindColor0
|
||||
#define cgBindBlendWeight cgBindBlendWeight0
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Program Loading and Binding Functions ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
CGGLDLL_API cgError cgGLLoadProgram(cgProgramIter *program, GLuint prog_id);
|
||||
CGGLDLL_API cgError cgGLBindProgram(cgProgramIter *program);
|
||||
|
||||
CGGLDLL_API cgError cgGLEnableProgramType(cgProfileType profile);
|
||||
CGGLDLL_API cgError cgGLDisableProgramType(cgProfileType profile);
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Texture Unit Identifier Functions ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
CGGLDLL_API GLenum cgGLTextureUnit(const cgBindIter *param);
|
||||
CGGLDLL_API cgError cgGLActiveTexture(const cgBindIter *param);
|
||||
CGGLDLL_API cgError cgGLClientActiveTexture(const cgBindIter *param);
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Uniform Parameter Binding Functions ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniform4f(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
float x,
|
||||
float y,
|
||||
float z,
|
||||
float w);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniform4d(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
double w);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniform4fv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const float v[]);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniform4dv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const double v[]);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniformMatrixrf(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const float *matrix);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniformMatrixrd(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const double *matrix);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniformMatrixcf(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const float *matrix);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniformMatrixcd(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const double *matrix);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindUniformStateMatrix(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
cgGLMatrixType matrix_type,
|
||||
int format);
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Varying Parameter Binding Functions ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
CGGLDLL_API cgError cgGLEnableClientState(cgProgramIter *program,
|
||||
cgBindIter *param);
|
||||
|
||||
CGGLDLL_API cgError cgGLDisableClientState(cgProgramIter *program,
|
||||
cgBindIter *param);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVaryingPointer(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLint fsize,
|
||||
GLenum type,
|
||||
GLsizei stride,
|
||||
GLvoid *pointer);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying1s(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLshort x);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying1f(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLfloat x);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying1d(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLdouble x);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying2s(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLshort x,
|
||||
GLshort y);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying2f(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLfloat x,
|
||||
GLfloat y);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying2d(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLdouble x,
|
||||
GLdouble y);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying3s(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLshort x,
|
||||
GLshort y,
|
||||
GLshort z);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying3f(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLfloat x,
|
||||
GLfloat y,
|
||||
GLfloat z);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying3d(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLdouble x,
|
||||
GLdouble y,
|
||||
GLdouble z);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4s(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLshort x,
|
||||
GLshort y,
|
||||
GLshort z,
|
||||
GLshort w);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4f(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLfloat x,
|
||||
GLfloat y,
|
||||
GLfloat z,
|
||||
GLfloat w);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4d(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLdouble x,
|
||||
GLdouble y,
|
||||
GLdouble z,
|
||||
GLdouble w);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4ub(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
GLubyte x,
|
||||
GLubyte y,
|
||||
GLubyte z,
|
||||
GLubyte w);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying1sv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLshort *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying1fv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLfloat *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying1dv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLdouble *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying2sv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLshort *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying2fv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLfloat *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying2dv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLdouble *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying3sv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLshort *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying3fv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLfloat *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying3dv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLdouble *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4sv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLshort *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4fv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLfloat *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4dv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLdouble *v);
|
||||
|
||||
CGGLDLL_API cgError cgGLBindVarying4ubv(cgProgramIter *program,
|
||||
cgBindIter *param,
|
||||
const GLubyte *v);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
64
RenderDll/XRenderOGL/CG/cgGL_profiles.h
Normal file
64
RenderDll/XRenderOGL/CG/cgGL_profiles.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
CG_PROFILE_MACRO(Vertex,vp20,VP20,"vp20",6146,1)
|
||||
CG_PROFILE_MACRO(Fragment20,fp20,FP20,"fp20",6147,0)
|
||||
CG_PROFILE_MACRO(Vertex30,vp30,VP30,"vp30",6148,1)
|
||||
CG_PROFILE_MACRO(Fragment,fp30,FP30,"fp30",6149,0)
|
||||
CG_PROFILE_MACRO(ARBVertex,arbvp1,ARBVP1,"arbvp1",6150,1)
|
||||
CG_PROFILE_MACRO(ARBVertex,arbvp2,ARBVP2,"arbvp2",6151,1)
|
||||
CG_PROFILE_MACRO(ARBFragment,arbfp1,ARBFP1,"arbfp1",7000,0)
|
||||
CG_PROFILE_MACRO(ARBFragment,arbfp2,ARBFP2,"arbfp2",7001,0)
|
||||
|
||||
#ifndef CG_IN_PROFILES_INCLUDE
|
||||
# undef CG_PROFILE_MACRO
|
||||
#endif
|
||||
326
RenderDll/XRenderOGL/CG/cgProgramManager.h
Normal file
326
RenderDll/XRenderOGL/CG/cgProgramManager.h
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************************************************************NVMH2****
|
||||
File: cgProgramManager.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:
|
||||
|
||||
cgProgramManager - a class for loading various pixel & vertex shaders
|
||||
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef __NV_PROGRAM_MANAGER_H
|
||||
#define __NV_PROGRAM_MANAGER_H
|
||||
|
||||
#if WIN32
|
||||
|
||||
#pragma warning (disable:4786) // identifier was truncated to '255' characters in the browser information
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include <Cg/cgTemplates.h>
|
||||
#include <Cg/cg.h>
|
||||
|
||||
|
||||
|
||||
// to allow multiple streams and user specifed vertex type
|
||||
// D3DVSDT_FLOAT1 0x00 // 1D float expanded to (value, 0., 0., 1.)
|
||||
// D3DVSDT_FLOAT2 0x01 // 2D float expanded to (value, value, 0., 1.)
|
||||
// D3DVSDT_FLOAT3 0x02 // 3D float expanded to (value, value, value, 1.)
|
||||
// D3DVSDT_FLOAT4 0x03 // 4D float
|
||||
// D3DVSDT_D3DCOLOR 0x04 // 4D packed unsigned bytes mapped to 0. to 1. range
|
||||
// // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A)
|
||||
// D3DVSDT_UBYTE4 0x05 // 4D unsigned byte
|
||||
// D3DVSDT_SHORT2 0x06 // 2D signed short expanded to (value, value, 0., 1.)
|
||||
// D3DVSDT_SHORT4 0x07 // 4D signed short
|
||||
|
||||
|
||||
// was cgVertexAttribute
|
||||
typedef struct cgVertexDefinition
|
||||
{
|
||||
int D3DVSDT_type; // one of D3DVSDT_*
|
||||
char * name; // name of the entry
|
||||
int stream; // stream to put the vertex in
|
||||
} cgVertexDefinition;
|
||||
|
||||
|
||||
#define CGVERTEXDEFINITIONEND {-1, 0, 0}
|
||||
|
||||
// internal cgDirect3D data structure
|
||||
typedef struct cgiVertexAttribute
|
||||
{
|
||||
char name[64];
|
||||
int D3DVSDT_type;
|
||||
int bind_location;
|
||||
cgBindIter * BindIter;
|
||||
} cgiVertexAttribute;
|
||||
|
||||
|
||||
|
||||
typedef cg_vector<cgiVertexAttribute> cgiVertexAttributeList;
|
||||
typedef cg_list<cgBindIter *> cgBindIterList;
|
||||
|
||||
|
||||
class cgProgramManager;
|
||||
class cgContextContainer;
|
||||
|
||||
class cgProgramContainer
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// get a text definition of what the runtime expects for the vertex
|
||||
const char * GetVertexDeclaration();
|
||||
/*
|
||||
Example: returns string containing
|
||||
"struct stream0
|
||||
{
|
||||
D3DXVECTOR3 position;
|
||||
D3DXVECTOR2 tex0;
|
||||
};"
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// convert D3DXMATRIX class to type specified in cg program
|
||||
// even if your cg program uses 3x3, you can use this to pass a matrix to it
|
||||
// upper left hand part of D3DXMATRIX is used to fill the cg matrix
|
||||
HRESULT SetShaderConstantD3DXMATRIX(cgBindIter * iter, const D3DXMATRIX *, int nArrayElements = 0, int ArrayOffset = 0);
|
||||
|
||||
|
||||
|
||||
// All other data formats use this interface
|
||||
// The D3D runtime records the size of your data and puts that in the constant fields
|
||||
HRESULT SetShaderConstant(cgBindIter * iter, void * data, int nArrayElements = 0, int ArrayOffset = 0);
|
||||
// for arrays:
|
||||
// if nArrayElements is specified, write this number of elements rather than the whole array
|
||||
// if ArrayOffset is specified, start writing at this array element
|
||||
// otherwise nArrayElements and ArrayOffset are not specified
|
||||
|
||||
|
||||
// returns texture position 0-8 for the iterator
|
||||
// -1 is failure
|
||||
int GetTexturePosition(cgBindIter * BindIter);
|
||||
int GetTexturePosition(const char * name);
|
||||
|
||||
// set the texture via name (needs to search bindings by name, so this is the slowest
|
||||
// not recommended
|
||||
HRESULT SetTexture(const char * name, LPDIRECT3DBASETEXTURE8 pTexture);
|
||||
|
||||
// does a GetTexturePosition, then settexture(n, nTexture)
|
||||
HRESULT SetTexture(cgBindIter * BindIter, LPDIRECT3DBASETEXTURE8 pTexture);
|
||||
|
||||
// does a GetTexturePosition, then SetTextureStageState(n, nTexture, Value)
|
||||
HRESULT SetTextureStageState(cgBindIter * BindIter, D3DTEXTURESTAGESTATETYPE Type,DWORD Value);
|
||||
|
||||
// Direct3D hardcodes wrap state, D3DRS_WRAP1, D3DWRAPCOORD_0 | D3DWRAPCOORD_1
|
||||
// WrapCoords : 0, D3DWRAPCOORD_0, D3DWRAPCOORD_1 or'd together
|
||||
HRESULT SetTextureWrapMode(cgBindIter * BindIter, DWORD WrapCoords);
|
||||
|
||||
|
||||
// activate this shader (SetVertexShader or SetPixelShader)
|
||||
HRESULT SetShaderActive();
|
||||
|
||||
|
||||
// locate a binding within a program by parameter name
|
||||
// it is recommended to do this once and use the cgBindIter to reference data
|
||||
cgBindIter *GetVertexBindByName(const char *vertex_attr_name);
|
||||
cgBindIter *GetTextureBindByName(const char *texture_name);
|
||||
cgBindIter *GetParameterBindByName(const char *parameter_name);
|
||||
|
||||
void FreeBindIter(cgBindIter *);
|
||||
|
||||
|
||||
|
||||
|
||||
// Get the type for this bind iterator
|
||||
cgValueType GetBindValueType(const cgBindIter *BindIter, int *array_size)
|
||||
{
|
||||
return cgGetBindValueType(BindIter, array_size);
|
||||
}
|
||||
|
||||
|
||||
// locate and bindinf iterator by full name
|
||||
// e.g. appdata.texcoord0
|
||||
cgBindIter *GetBindByFullName(const char *parameter_name);
|
||||
|
||||
// from the iterator, get the name of the program
|
||||
const char *GetProgramName();
|
||||
|
||||
const char *GetProgramObjectCode();
|
||||
|
||||
cgProfileType GetProgramProfile() { return m_ProfileType;}
|
||||
|
||||
// get the shader handle passed to Direct3D
|
||||
DWORD GetShaderHandle() {return m_dwShaderHandle;}
|
||||
|
||||
private:
|
||||
|
||||
cgBindIter *AllocBind();
|
||||
void SaveBind(cgBindIter * BindIter); // for deleting
|
||||
|
||||
cgBindIterList m_BindIterList;
|
||||
|
||||
void GetParameterConstantPosition(cgBindIter * iter, int * pos, int *width, int * num4vectors, int *nArrayElements);
|
||||
void GetParameterConstantPosition(const char * name, int * pos, int *width, int * num4vectors, int *nArrayElements);
|
||||
|
||||
|
||||
HRESULT CreateProgramShader();
|
||||
HRESULT CreateVertexShader();
|
||||
HRESULT CreatePixelShader();
|
||||
|
||||
// take asm code, assembles it and create a handle
|
||||
HRESULT CreateShaderHandleFromFile(
|
||||
const cg_string & strFilePath,
|
||||
const cg_string & strSourceFile,
|
||||
const DWORD * pDeclaration,
|
||||
DWORD Usage);
|
||||
|
||||
HRESULT CreateShaderHandleFromMemory(
|
||||
const char * pShaderText,
|
||||
const DWORD * pDeclaration,
|
||||
DWORD Usage);
|
||||
|
||||
|
||||
HRESULT Free();
|
||||
|
||||
|
||||
// cgDX8VertexProfile or cgDX8PixelProfile (cg_profiles.h)
|
||||
// These types are defined with macros:
|
||||
// CG_PROFILE_MACRO(DX8Vertex,dx8vs,"dx8vs")
|
||||
// CG_PROFILE_MACRO(DX8Pixel,dx8ps,"dx8ps")
|
||||
|
||||
|
||||
friend cgProgramManager;
|
||||
friend cgContextContainer;
|
||||
DWORD m_dwShaderHandle; // DWORD handle returned by DX8 runtime
|
||||
cgProfileType m_ProfileType; // profile for this program
|
||||
HRESULT SetVertexDefinition(cgVertexDefinition * streams);
|
||||
|
||||
|
||||
cgProgramContainer(LPDIRECT3DDEVICE8 pDev, cgProgramIter *m_ProgramIter,
|
||||
cgProfileType ProfileType);
|
||||
~cgProgramContainer();
|
||||
|
||||
|
||||
HRESULT LoadShaderConstants();
|
||||
cg_string m_ProgramSourceFile; // text file name
|
||||
cg_string m_ProgramObjectFile; // compiled shader object file (.vso, .pso)
|
||||
|
||||
// for declaration of vertex positions
|
||||
cgiVertexAttributeList m_VertexAttributes[MAX_STREAMS];
|
||||
|
||||
cgProgramIter *m_ProgramIter;
|
||||
|
||||
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class cgProgramManager
|
||||
{
|
||||
private:
|
||||
cg_vector < cgProgramContainer * > m_ProgramContainers; // m_Shaders[0] is always = 0
|
||||
cg_vector < DWORD > m_ProgramIndices; // indirection to m_Shaders
|
||||
// Programs hold an index to this array for
|
||||
// their shaders. The array int at that index
|
||||
// holds the index into the m_Shaders array.
|
||||
|
||||
public:
|
||||
|
||||
|
||||
cgProgramManager(LPDIRECT3DDEVICE8 pDev);
|
||||
~cgProgramManager();
|
||||
|
||||
HRESULT Free();
|
||||
|
||||
|
||||
cgProgramContainer * CreateProgramContainer(LPDIRECT3DDEVICE8 pDev,
|
||||
cgProgramIter * ProgramIter,
|
||||
DWORD Usage,
|
||||
cgProfileType ProfileType,
|
||||
DWORD * outIndex );
|
||||
|
||||
|
||||
|
||||
DWORD GetShaderHandle( DWORD Index );
|
||||
DWORD GetShaderHandle( cgProfileType ProfileType );
|
||||
|
||||
//
|
||||
cgProgramContainer * GetProgramIterator(DWORD index);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
// for creating programs
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||
|
||||
};
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
#endif
|
||||
366
RenderDll/XRenderOGL/CG/cgTemplates.h
Normal file
366
RenderDll/XRenderOGL/CG/cgTemplates.h
Normal file
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************************************************************NVMH2****
|
||||
File: cgTemplates.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:
|
||||
|
||||
cgTemplates - cg utility templates
|
||||
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CG_TEMPLATE_H
|
||||
#define CG_TEMPLATE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
//
|
||||
// templated cg_vector class
|
||||
//
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
template <class T>
|
||||
class cg_vector{
|
||||
public:
|
||||
typedef int size_type;
|
||||
|
||||
cg_vector();
|
||||
cg_vector( cg_vector<T>& v );
|
||||
~cg_vector();
|
||||
|
||||
void clear();
|
||||
int size() const;
|
||||
T& operator [] ( int i );
|
||||
void push_back( const T& t );
|
||||
|
||||
private:
|
||||
T* data;
|
||||
int num;
|
||||
int capacity;
|
||||
const static int initSize;
|
||||
};
|
||||
|
||||
|
||||
//definitions of cg_vector methods
|
||||
|
||||
template <class T>
|
||||
const int cg_vector<T>::initSize = 16;
|
||||
|
||||
template <class T>
|
||||
cg_vector<T>::cg_vector(){
|
||||
data = NULL;
|
||||
clear();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
cg_vector<T>::cg_vector( cg_vector<T>& v ){
|
||||
data = NULL;
|
||||
clear();
|
||||
for( int i=0; i<v.size(); i++ ){
|
||||
push_back( v[i] );
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
cg_vector<T>::~cg_vector(){
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_vector<T>::clear(){
|
||||
if( data ){
|
||||
delete[] data;
|
||||
}
|
||||
data = (T*)new T[initSize];
|
||||
num = 0;
|
||||
capacity = initSize;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int cg_vector<T>::size() const{
|
||||
return num;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_vector<T>::push_back( const T& t ){
|
||||
if( num >= capacity ){
|
||||
T* temp = new T[ 2 * capacity ];
|
||||
for( int i = 0; i < num; i++ ){
|
||||
temp[i] = data[i];
|
||||
}
|
||||
delete[] data;
|
||||
data = temp;
|
||||
capacity *= 2;
|
||||
}
|
||||
data[num] = t;
|
||||
num++;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T& cg_vector<T>::operator [] ( int i ){
|
||||
if( i>=0 && i < num ){
|
||||
return data[i];
|
||||
}else{
|
||||
return data[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
//
|
||||
// templated cg_list class
|
||||
//
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
template <class T>
|
||||
class cg_list{
|
||||
public:
|
||||
class Node{
|
||||
public:
|
||||
Node( const T& _data, Node* _next, Node* _prev ){
|
||||
data = _data;
|
||||
next = _next;
|
||||
prev = _prev;
|
||||
}
|
||||
|
||||
T data;
|
||||
Node* next;
|
||||
Node* prev;
|
||||
};
|
||||
|
||||
class iterator{
|
||||
public:
|
||||
iterator( Node* _node ){
|
||||
node = _node;
|
||||
}
|
||||
iterator(){
|
||||
node = NULL;
|
||||
}
|
||||
|
||||
bool operator == ( const iterator& it ) const{
|
||||
return node == it.node;
|
||||
}
|
||||
bool operator != ( const iterator& it ) const{
|
||||
return !( *this == it );
|
||||
}
|
||||
T& operator * (){
|
||||
return node -> data;
|
||||
}
|
||||
void operator ++ (){
|
||||
node = node -> next;
|
||||
}
|
||||
void operator ++ (int){
|
||||
node = node -> next;
|
||||
}
|
||||
|
||||
Node* node;
|
||||
};
|
||||
|
||||
cg_list();
|
||||
cg_list( const cg_list<T>& l );
|
||||
~cg_list();
|
||||
iterator begin();
|
||||
iterator end();
|
||||
void push_back( const T& t );
|
||||
void clear();
|
||||
void remove( const T& value );
|
||||
|
||||
private:
|
||||
Node* head;
|
||||
Node* tail;
|
||||
|
||||
void insert( const T& t, Node* node );
|
||||
void remove( Node* node );
|
||||
};
|
||||
|
||||
|
||||
// definitions of cg_list methods
|
||||
|
||||
template <class T>
|
||||
cg_list<T>::cg_list(){
|
||||
head = tail = new Node( T(), NULL, NULL );
|
||||
}
|
||||
|
||||
template <class T>
|
||||
cg_list<T>::~cg_list(){
|
||||
clear();
|
||||
delete head;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
cg_list<T>::cg_list( const cg_list<T>& l ){
|
||||
head = tail = new Node( T(), NULL, NULL );
|
||||
cg_list<T>::iterator it = l.begin();
|
||||
while( it != l.end() ){
|
||||
push_back( *it );
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
cg_list<T>::iterator cg_list<T>::begin(){
|
||||
return head;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
cg_list<T>::iterator cg_list<T>::end(){
|
||||
return tail;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_list<T>::push_back( const T& t ){
|
||||
insert( t, tail );
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_list<T>::clear(){
|
||||
while( head != tail ){
|
||||
remove( head );
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_list<T>::remove( const T& value ){
|
||||
Node* curr = head;
|
||||
Node* temp;
|
||||
while( curr != tail ){
|
||||
temp = curr;
|
||||
curr = curr -> next;
|
||||
if( temp -> data == value ){
|
||||
remove( temp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_list<T>::insert( const T& t, cg_list<T>::Node* node ){
|
||||
Node* newNode = new Node( t, node, node -> prev );
|
||||
if( node -> prev == NULL ){
|
||||
head = newNode;
|
||||
}else{
|
||||
node -> prev -> next = newNode;
|
||||
}
|
||||
node -> prev = newNode;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void cg_list<T>::remove( cg_list<T>::Node* node ){
|
||||
if( node == tail ){
|
||||
return;
|
||||
}
|
||||
node -> next -> prev = node -> prev;
|
||||
if( node -> prev == NULL ){
|
||||
head = node -> next;
|
||||
}else{
|
||||
node -> prev -> next = node -> next;
|
||||
}
|
||||
delete node;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
//
|
||||
// cg_string class
|
||||
//
|
||||
//////////////////////////////////////////
|
||||
|
||||
|
||||
class cg_string{
|
||||
public:
|
||||
typedef int size_type;
|
||||
cg_string();
|
||||
cg_string( const char* s);
|
||||
cg_string( const cg_string& s );
|
||||
~cg_string();
|
||||
|
||||
int size() const;
|
||||
const char* c_str() const;
|
||||
void resize( int n, char c = '\0' );
|
||||
cg_string& erase( int pos = 0, int n = npos );
|
||||
int find_last_of( const cg_string& s, int pos = npos ) const;
|
||||
cg_string substr( int pos = 0, int len = npos ) const;
|
||||
|
||||
char& operator [] ( int i );
|
||||
const char& operator [] ( int i ) const;
|
||||
cg_string& operator = ( const cg_string& s );
|
||||
cg_string& operator += ( const cg_string& s );
|
||||
cg_string operator + ( const cg_string& s ) const;
|
||||
|
||||
const static int npos;
|
||||
|
||||
private:
|
||||
char* data;
|
||||
int num; //length of the string, not counting the trailing '\0'.
|
||||
int capacity;
|
||||
const static int initSize;
|
||||
|
||||
void set( const char* s, int n );
|
||||
};
|
||||
|
||||
#endif
|
||||
332
RenderDll/XRenderOGL/CG/cg_bindlocations.h
Normal file
332
RenderDll/XRenderOGL/CG/cg_bindlocations.h
Normal file
@@ -0,0 +1,332 @@
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The following macro invocations define the supported CG basic hardware
|
||||
* bind locations.
|
||||
*
|
||||
* The macros have the form :
|
||||
*
|
||||
* CG_BINDLOCATION_MACRO(name, compiler_name, enum_int)
|
||||
*
|
||||
* name : The name of the location.
|
||||
* enum_name : The C enumerant.
|
||||
* compiler_name : The name of the location within the compiler syntax.
|
||||
* int_id : Integer enumerant associated with this bind location.
|
||||
* addressable : The bind location must have an integer address
|
||||
* associated with it.
|
||||
* ParamType : the cgParamType of this register.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
CG_BINDLOCATION_MACRO(TexUnit0,CG_TEXUNIT0,"texunit 0",2048,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit1,CG_TEXUNIT1,"texunit 1",2049,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit2,CG_TEXUNIT2,"texunit 2",2050,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit3,CG_TEXUNIT3,"texunit 3",2051,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit4,CG_TEXUNIT4,"texunit 4",2052,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit5,CG_TEXUNIT5,"texunit 5",2053,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit6,CG_TEXUNIT6,"texunit 6",2054,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit7,CG_TEXUNIT7,"texunit 7",2055,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit8,CG_TEXUNIT8,"texunit 8",2056,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit9,CG_TEXUNIT9,"texunit 9",2057,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit10,CG_TEXUNIT10,"texunit 10",2058,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit11,CG_TEXUNIT11,"texunit 11",2059,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit12,CG_TEXUNIT12,"texunit 12",2060,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit13,CG_TEXUNIT13,"texunit 13",2061,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit14,CG_TEXUNIT14,"texunit 14",2062,0,CG_TEXOBJ_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexUnit15,CG_TEXUNIT15,"texunit 15",2063,0,CG_TEXOBJ_PARAM)
|
||||
|
||||
CG_BINDLOCATION_MACRO(Attr0,CG_ATTR0,"ATTR0",2113,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr1,CG_ATTR1,"ATTR1",2114,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr2,CG_ATTR2,"ATTR2",2115,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr3,CG_ATTR3,"ATTR3",2116,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr4,CG_ATTR4,"ATTR4",2117,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr5,CG_ATTR5,"ATTR5",2118,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr6,CG_ATTR6,"ATTR6",2119,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr7,CG_ATTR7,"ATTR7",2120,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr8,CG_ATTR8,"ATTR8",2121,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr9,CG_ATTR9,"ATTR9",2122,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr10,CG_ATTR10,"ATTR10",2123,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr11,CG_ATTR11,"ATTR11",2124,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr12,CG_ATTR12,"ATTR12",2125,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr13,CG_ATTR13,"ATTR13",2126,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr14,CG_ATTR14,"ATTR14",2127,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Attr15,CG_ATTR15,"ATTR15",2128,0,CG_VARYING_PARAM)
|
||||
|
||||
CG_BINDLOCATION_MACRO(VertUniform,CG_C,"c",2178,1,CGI_UNIFORM_PARAM)
|
||||
|
||||
CG_BINDLOCATION_MACRO(Tex0,CG_TEX0,"TEX0",2179,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex1,CG_TEX1,"TEX1",2180,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex2,CG_TEX2,"TEX2",2181,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex3,CG_TEX3,"TEX3",2192,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex4,CG_TEX4,"TEX4",2193,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex5,CG_TEX5,"TEX5",2194,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex6,CG_TEX6,"TEX6",2195,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tex7,CG_TEX7,"TEX7",2196,0,CG_VARYING_PARAM)
|
||||
|
||||
CG_BINDLOCATION_MACRO(HPos,CG_HPOS,"HPOS",2243,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Col0,CG_COL0,"COL0",2245,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Col1,CG_COL1,"COL1",2246,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Col2,CG_COL2,"COL2",2247,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Col3,CG_COL3,"COL3",2248,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSiz,CG_PSIZ,"PSIZ",2309,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(WPos,CG_WPOS,"WPOS",2373,0,CG_VARYING_PARAM)
|
||||
|
||||
CG_BINDLOCATION_MACRO(Position0,CG_POSITION0,"POSITION0",2437,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position1,CG_POSITION1,"POSITION1",2438,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position2,CG_POSITION2,"POSITION2",2439,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position3,CG_POSITION3,"POSITION3",2440,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position4,CG_POSITION4,"POSITION4",2441,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position5,CG_POSITION5,"POSITION5",2442,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position6,CG_POSITION6,"POSITION6",2443,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position7,CG_POSITION7,"POSITION7",2444,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position8,CG_POSITION8,"POSITION8",2445,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position9,CG_POSITION9,"POSITION9",2446,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position10,CG_POSITION10,"POSITION10",2447,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position11,CG_POSITION11,"POSITION11",2448,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position12,CG_POSITION12,"POSITION12",2449,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position13,CG_POSITION13,"POSITION13",2450,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position14,CG_POSITION14,"POSITION14",2451,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Position15,CG_POSITION15,"POSITION15",2452,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Diffuse0,CG_DIFFUSE0,"DIFFUSE0",2501,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent0,CG_TANGENT0,"TANGENT0",2565,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent1,CG_TANGENT1,"TANGENT1",2566,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent2,CG_TANGENT2,"TANGENT2",2567,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent3,CG_TANGENT3,"TANGENT3",2568,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent4,CG_TANGENT4,"TANGENT4",2569,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent5,CG_TANGENT5,"TANGENT5",2570,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent6,CG_TANGENT6,"TANGENT6",2571,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent7,CG_TANGENT7,"TANGENT7",2572,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent8,CG_TANGENT8,"TANGENT8",2573,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent9,CG_TANGENT9,"TANGENT9",2574,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent10,CG_TANGENT10,"TANGENT10",2575,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent11,CG_TANGENT11,"TANGENT11",2576,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent12,CG_TANGENT12,"TANGENT12",2577,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent13,CG_TANGENT13,"TANGENT13",2578,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent14,CG_TANGENT14,"TANGENT14",2579,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Tangent15,CG_TANGENT15,"TANGENT15",2580,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Specular0,CG_SPECULAR0,"SPECULAR0",2629,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices0,CG_BLENDINDICES0,"BLENDINDICES0",2693,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices1,CG_BLENDINDICES1,"BLENDINDICES1",2694,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices2,CG_BLENDINDICES2,"BLENDINDICES2",2695,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices3,CG_BLENDINDICES3,"BLENDINDICES3",2696,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices4,CG_BLENDINDICES4,"BLENDINDICES4",2697,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices5,CG_BLENDINDICES5,"BLENDINDICES5",2698,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices6,CG_BLENDINDICES6,"BLENDINDICES6",2699,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices7,CG_BLENDINDICES7,"BLENDINDICES7",2700,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices8,CG_BLENDINDICES8,"BLENDINDICES8",2701,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices9,CG_BLENDINDICES9,"BLENDINDICES9",2702,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices10,CG_BLENDINDICES10,"BLENDINDICES10",2703,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices11,CG_BLENDINDICES11,"BLENDINDICES11",2704,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices12,CG_BLENDINDICES12,"BLENDINDICES12",2705,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices13,CG_BLENDINDICES13,"BLENDINDICES13",2706,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices14,CG_BLENDINDICES14,"BLENDINDICES14",2707,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendIndices15,CG_BLENDINDICES15,"BLENDINDICES15",2708,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color0,CG_COLOR0,"COLOR0",2757,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color1,CG_COLOR1,"COLOR1",2758,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color2,CG_COLOR2,"COLOR2",2759,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color3,CG_COLOR3,"COLOR3",2760,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color4,CG_COLOR4,"COLOR4",2761,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color5,CG_COLOR5,"COLOR5",2762,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color6,CG_COLOR6,"COLOR6",2763,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color7,CG_COLOR7,"COLOR7",2764,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color8,CG_COLOR8,"COLOR8",2765,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color9,CG_COLOR9,"COLOR9",2766,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color10,CG_COLOR10,"COLOR10",2767,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color11,CG_COLOR11,"COLOR11",2768,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color12,CG_COLOR12,"COLOR12",2769,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color13,CG_COLOR13,"COLOR13",2770,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color14,CG_COLOR14,"COLOR14",2771,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Color15,CG_COLOR15,"COLOR15",2772,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize0,CG_PSIZE0,"PSIZE0",2821,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize1,CG_PSIZE1,"PSIZE1",2822,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize2,CG_PSIZE2,"PSIZE2",2823,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize3,CG_PSIZE3,"PSIZE3",2824,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize4,CG_PSIZE4,"PSIZE4",2825,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize5,CG_PSIZE5,"PSIZE5",2826,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize6,CG_PSIZE6,"PSIZE6",2827,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize7,CG_PSIZE7,"PSIZE7",2828,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize8,CG_PSIZE8,"PSIZE8",2829,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize9,CG_PSIZE9,"PSIZE9",2830,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize10,CG_PSIZE10,"PSIZE10",2831,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize11,CG_PSIZE11,"PSIZE11",2832,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize12,CG_PSIZE12,"PSIZE12",2833,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize13,CG_PSIZE13,"PSIZE13",2834,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize14,CG_PSIZE14,"PSIZE14",2835,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(PSize15,CG_PSIZE15,"PSIZE15",2836,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal0,CG_BINORMAL0,"BINORMAL0",2885,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal1,CG_BINORMAL1,"BINORMAL1",2886,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal2,CG_BINORMAL2,"BINORMAL2",2887,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal3,CG_BINORMAL3,"BINORMAL3",2888,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal4,CG_BINORMAL4,"BINORMAL4",2889,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal5,CG_BINORMAL5,"BINORMAL5",2890,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal6,CG_BINORMAL6,"BINORMAL6",2891,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal7,CG_BINORMAL7,"BINORMAL7",2892,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal8,CG_BINORMAL8,"BINORMAL8",2893,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal9,CG_BINORMAL9,"BINORMAL9",2894,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal10,CG_BINORMAL10,"BINORMAL10",2895,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal11,CG_BINORMAL11,"BINORMAL11",2896,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal12,CG_BINORMAL12,"BINORMAL12",2897,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal13,CG_BINORMAL13,"BINORMAL13",2898,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal14,CG_BINORMAL14,"BINORMAL14",2899,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BiNormal15,CG_BINORMAL15,"BINORMAL15",2900,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG0,CG_FOG0,"FOG0",2917,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG1,CG_FOG1,"FOG1",2918,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG2,CG_FOG2,"FOG2",2919,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG3,CG_FOG3,"FOG3",2920,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG4,CG_FOG4,"FOG4",2921,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG5,CG_FOG5,"FOG5",2922,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG6,CG_FOG6,"FOG6",2923,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG7,CG_FOG7,"FOG7",2924,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG8,CG_FOG8,"FOG8",2925,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG9,CG_FOG9,"FOG9",2926,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG10,CG_FOG10,"FOG10",2927,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG11,CG_FOG11,"FOG11",2928,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG12,CG_FOG12,"FOG12",2929,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG13,CG_FOG13,"FOG13",2930,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG14,CG_FOG14,"FOG14",2931,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FOG15,CG_FOG15,"FOG15",2932,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH0,CG_DEPTH0,"DEPTH0",2933,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH1,CG_DEPTH1,"DEPTH1",2934,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH2,CG_DEPTH2,"DEPTH2",2935,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH3,CG_DEPTH3,"DEPTH3",2936,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH4,CG_DEPTH4,"DEPTH4",2937,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH5,CG_DEPTH5,"DEPTH5",2938,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH6,CG_DEPTH6,"DEPTH6",2939,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH7,CG_DEPTH7,"DEPTH7",2940,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH8,CG_DEPTH8,"DEPTH8",2941,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH9,CG_DEPTH9,"DEPTH9",29542,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH10,CG_DEPTH10,"DEPTH10",2943,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH11,CG_DEPTH11,"DEPTH11",2944,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH12,CG_DEPTH12,"DEPTH12",2945,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH13,CG_DEPTH13,"DEPTH13",2946,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH14,CG_DEPTH14,"DEPTH14",2947,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(DEPTH15,CG_DEPTH15,"DEPTH15",2948,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE0,CG_SAMPLE0,"SAMPLE0",2949,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE1,CG_SAMPLE1,"SAMPLE1",2950,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE2,CG_SAMPLE2,"SAMPLE2",2951,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE3,CG_SAMPLE3,"SAMPLE3",2952,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE4,CG_SAMPLE4,"SAMPLE4",2953,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE5,CG_SAMPLE5,"SAMPLE5",2954,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE6,CG_SAMPLE6,"SAMPLE6",2955,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE7,CG_SAMPLE7,"SAMPLE7",2956,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE8,CG_SAMPLE8,"SAMPLE8",2957,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE9,CG_SAMPLE9,"SAMPLE9",2958,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE10,CG_SAMPLE10,"SAMPLE10",2959,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE11,CG_SAMPLE11,"SAMPLE11",2960,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE12,CG_SAMPLE12,"SAMPLE12",2961,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE13,CG_SAMPLE13,"SAMPLE13",2962,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE14,CG_SAMPLE14,"SAMPLE14",2963,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(SAMPLE15,CG_SAMPLE15,"SAMPLE15",2964,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight0,CG_BLENDWEIGHT0,"BLENDWEIGHT0",3028,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight1,CG_BLENDWEIGHT1,"BLENDWEIGHT1",3029,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight2,CG_BLENDWEIGHT2,"BLENDWEIGHT2",3030,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight3,CG_BLENDWEIGHT3,"BLENDWEIGHT3",3031,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight4,CG_BLENDWEIGHT4,"BLENDWEIGHT4",3032,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight5,CG_BLENDWEIGHT5,"BLENDWEIGHT5",3033,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight6,CG_BLENDWEIGHT6,"BLENDWEIGHT6",3034,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight7,CG_BLENDWEIGHT7,"BLENDWEIGHT7",3035,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight8,CG_BLENDWEIGHT8,"BLENDWEIGHT8",3036,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight9,CG_BLENDWEIGHT9,"BLENDWEIGHT9",3037,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight10,CG_BLENDWEIGHT10,"BLENDWEIGHT10",3038,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight11,CG_BLENDWEIGHT11,"BLENDWEIGHT11",3039,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight12,CG_BLENDWEIGHT12,"BLENDWEIGHT12",3040,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight13,CG_BLENDWEIGHT13,"BLENDWEIGHT13",3041,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight14,CG_BLENDWEIGHT14,"BLENDWEIGHT14",3042,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(BlendWeight15,CG_BLENDWEIGHT15,"BLENDWEIGHT15",3043,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal0,CG_NORMAL0,"NORMAL0",3092,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal1,CG_NORMAL1,"NORMAL1",3093,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal2,CG_NORMAL2,"NORMAL2",3094,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal3,CG_NORMAL3,"NORMAL3",3095,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal4,CG_NORMAL4,"NORMAL4",3096,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal5,CG_NORMAL5,"NORMAL5",3097,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal6,CG_NORMAL6,"NORMAL6",3098,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal7,CG_NORMAL7,"NORMAL7",3099,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal8,CG_NORMAL8,"NORMAL8",3100,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal9,CG_NORMAL9,"NORMAL9",3101,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal10,CG_NORMAL10,"NORMAL10",3102,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal11,CG_NORMAL11,"NORMAL11",3103,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal12,CG_NORMAL12,"NORMAL12",3104,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal13,CG_NORMAL13,"NORMAL13",3105,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal14,CG_NORMAL14,"NORMAL14",3106,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(Normal15,CG_NORMAL15,"NORMAL15",3107,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(FogCoord,CG_FOGCOORD,"FOGCOORD",3156,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord0,CG_TEXCOORD0,"TEXCOORD0",3220,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord1,CG_TEXCOORD1,"TEXCOORD1",3221,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord2,CG_TEXCOORD2,"TEXCOORD2",3222,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord3,CG_TEXCOORD3,"TEXCOORD3",3223,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord4,CG_TEXCOORD4,"TEXCOORD4",3224,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord5,CG_TEXCOORD5,"TEXCOORD5",3225,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord6,CG_TEXCOORD6,"TEXCOORD6",3226,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord7,CG_TEXCOORD7,"TEXCOORD7",3227,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord8,CG_TEXCOORD8,"TEXCOORD8",3228,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord9,CG_TEXCOORD9,"TEXCOORD9",3229,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord10,CG_TEXCOORD10,"TEXCOORD10",3230,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord11,CG_TEXCOORD11,"TEXCOORD11",3231,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord12,CG_TEXCOORD12,"TEXCOORD12",3232,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord13,CG_TEXCOORD13,"TEXCOORD13",3233,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord14,CG_TEXCOORD14,"TEXCOORD14",3234,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TexCoord15,CG_TEXCOORD15,"TEXCOORD15",3235,0,CG_VARYING_PARAM)
|
||||
CG_BINDLOCATION_MACRO(CombinerConst0,CG_COMBINER_CONST0,"COMBINER_CONST0",3284,0,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(CombinerConst1,CG_COMBINER_CONST1,"COMBINER_CONST1",3285,0,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(CombinerStageConst0,CG_COMBINER_STAGE_CONST0,"COMBINER_STAGE_CONST0",3286,1,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(CombinerStageConst1,CG_COMBINER_STAGE_CONST1,"COMBINER_STAGE_CONST1",3287,1,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(OffsetTextureMatrix,CG_OFFSET_TEXTURE_MATRIX,"OFFSET_TEXTURE_MATRIX",3288,0,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(OffsetTextureScale,CG_OFFSET_TEXTURE_SCALE,"OFFSET_TEXTURE_SCALE",3289,0,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(OffsetTextureBias,CG_OFFSET_TEXTURE_BIAS,"OFFSET_TEXTURE_BIAS",3290,0,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(ConstEye,CG_CONST_EYE,"CONST_EYE",3291,0,CGI_UNIFORM_PARAM)
|
||||
CG_BINDLOCATION_MACRO(TessFactor,CG_TESSFACTOR,"TESSFACTOR",3255,0,CG_VARYING_PARAM)
|
||||
|
||||
#undef CG_BINDLOCATION_MACRO
|
||||
184
RenderDll/XRenderOGL/CG/cg_datatypes.h
Normal file
184
RenderDll/XRenderOGL/CG/cg_datatypes.h
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The following macro invocations define the supported CG basic data types.
|
||||
*
|
||||
* The macros have the form :
|
||||
*
|
||||
* CG_DATATYPE_MACRO(name, compiler_name, nrows, ncols)
|
||||
*
|
||||
* name : The name of the data type.
|
||||
* compiler_name : The name of the data type within the compiler syntax.
|
||||
* enum_name : The C enumerant.
|
||||
* nrows : Number of rows for matrix types. Should be 0 other-wise.
|
||||
* ncols : Number of columns for matrix types. Should be 0
|
||||
* other-wise.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
CG_DATATYPE_MACRO(Half,half,CG_HALF,0,1)
|
||||
CG_DATATYPE_MACRO(Half2,half2,CG_HALF2,0,2)
|
||||
CG_DATATYPE_MACRO(Half3,half3,CG_HALF3,0,3)
|
||||
CG_DATATYPE_MACRO(Half4,half4,CG_HALF4,0,4)
|
||||
CG_DATATYPE_MACRO(Half1x1,half1x1,CG_HALF1x1,1,1)
|
||||
CG_DATATYPE_MACRO(Half1x2,half1x2,CG_HALF1x2,1,2)
|
||||
CG_DATATYPE_MACRO(Half1x3,half1x3,CG_HALF1x3,1,3)
|
||||
CG_DATATYPE_MACRO(Half1x4,half1x4,CG_HALF1x4,1,4)
|
||||
CG_DATATYPE_MACRO(Half2x1,half2x1,CG_HALF2x1,2,1)
|
||||
CG_DATATYPE_MACRO(Half2x2,half2x2,CG_HALF2x2,2,2)
|
||||
CG_DATATYPE_MACRO(Half2x3,half2x3,CG_HALF2x3,2,3)
|
||||
CG_DATATYPE_MACRO(Half2x4,half2x4,CG_HALF2x4,2,4)
|
||||
CG_DATATYPE_MACRO(Half3x1,half3x1,CG_HALF3x1,3,1)
|
||||
CG_DATATYPE_MACRO(Half3x2,half3x2,CG_HALF3x2,3,2)
|
||||
CG_DATATYPE_MACRO(Half3x3,half3x3,CG_HALF3x3,3,3)
|
||||
CG_DATATYPE_MACRO(Half3x4,half3x4,CG_HALF3x4,3,4)
|
||||
CG_DATATYPE_MACRO(Half4x1,half4x1,CG_HALF4x1,4,1)
|
||||
CG_DATATYPE_MACRO(Half4x2,half4x2,CG_HALF4x2,4,2)
|
||||
CG_DATATYPE_MACRO(Half4x3,half4x3,CG_HALF4x3,4,3)
|
||||
CG_DATATYPE_MACRO(Half4x4,half4x4,CG_HALF4x4,4,4)
|
||||
CG_DATATYPE_MACRO(Float,float,CG_FLOAT,0,1)
|
||||
CG_DATATYPE_MACRO(Float2,float2,CG_FLOAT2,0,2)
|
||||
CG_DATATYPE_MACRO(Float3,float3,CG_FLOAT3,0,3)
|
||||
CG_DATATYPE_MACRO(Float4,float4,CG_FLOAT4,0,4)
|
||||
CG_DATATYPE_MACRO(Float1x1,float1x1,CG_FLOAT1x1,1,1)
|
||||
CG_DATATYPE_MACRO(Float1x2,float1x2,CG_FLOAT1x2,1,2)
|
||||
CG_DATATYPE_MACRO(Float1x3,float1x3,CG_FLOAT1x3,1,3)
|
||||
CG_DATATYPE_MACRO(Float1x4,float1x4,CG_FLOAT1x4,1,4)
|
||||
CG_DATATYPE_MACRO(Float2x1,float2x1,CG_FLOAT2x1,2,1)
|
||||
CG_DATATYPE_MACRO(Float2x2,float2x2,CG_FLOAT2x2,2,2)
|
||||
CG_DATATYPE_MACRO(Float2x3,float2x3,CG_FLOAT2x3,2,3)
|
||||
CG_DATATYPE_MACRO(Float2x4,float2x4,CG_FLOAT2x4,2,4)
|
||||
CG_DATATYPE_MACRO(Float3x1,float3x1,CG_FLOAT3x1,3,1)
|
||||
CG_DATATYPE_MACRO(Float3x2,float3x2,CG_FLOAT3x2,3,2)
|
||||
CG_DATATYPE_MACRO(Float3x3,float3x3,CG_FLOAT3x3,3,3)
|
||||
CG_DATATYPE_MACRO(Float3x4,float3x4,CG_FLOAT3x4,3,4)
|
||||
CG_DATATYPE_MACRO(Float4x1,float4x1,CG_FLOAT4x1,4,1)
|
||||
CG_DATATYPE_MACRO(Float4x2,float4x2,CG_FLOAT4x2,4,2)
|
||||
CG_DATATYPE_MACRO(Float4x3,float4x3,CG_FLOAT4x3,4,3)
|
||||
CG_DATATYPE_MACRO(Float4x4,float4x4,CG_FLOAT4x4,4,4)
|
||||
CG_DATATYPE_MACRO(Sampler1D,sampler1D,CG_SAMPLER1D,0,0)
|
||||
CG_DATATYPE_MACRO(Sampler2D,sampler2D,CG_SAMPLER2D,0,0)
|
||||
CG_DATATYPE_MACRO(Sampler3D,sampler3D,CG_SAMPLER3D,0,0)
|
||||
CG_DATATYPE_MACRO(SamplerRECT,samplerRECT,CG_SAMPLERRECT,0,0)
|
||||
CG_DATATYPE_MACRO(SamplerCUBE,samplerCUBE,CG_SAMPLERCUBE,0,0)
|
||||
CG_DATATYPE_MACRO(Fixed,fixed,CG_FIXED,0,1)
|
||||
CG_DATATYPE_MACRO(Fixed2,fixed2,CG_FIXED2,0,2)
|
||||
CG_DATATYPE_MACRO(Fixed3,fixed3,CG_FIXED3,0,3)
|
||||
CG_DATATYPE_MACRO(Fixed4,fixed4,CG_FIXED4,0,4)
|
||||
CG_DATATYPE_MACRO(Fixed1x1,fixed1x1,CG_FIXED1x1,1,1)
|
||||
CG_DATATYPE_MACRO(Fixed1x2,fixed1x2,CG_FIXED1x2,1,2)
|
||||
CG_DATATYPE_MACRO(Fixed1x3,fixed1x3,CG_FIXED1x3,1,3)
|
||||
CG_DATATYPE_MACRO(Fixed1x4,fixed1x4,CG_FIXED1x4,1,4)
|
||||
CG_DATATYPE_MACRO(Fixed2x1,fixed2x1,CG_FIXED2x1,2,1)
|
||||
CG_DATATYPE_MACRO(Fixed2x2,fixed2x2,CG_FIXED2x2,2,2)
|
||||
CG_DATATYPE_MACRO(Fixed2x3,fixed2x3,CG_FIXED2x3,2,3)
|
||||
CG_DATATYPE_MACRO(Fixed2x4,fixed2x4,CG_FIXED2x4,2,4)
|
||||
CG_DATATYPE_MACRO(Fixed3x1,fixed3x1,CG_FIXED3x1,3,1)
|
||||
CG_DATATYPE_MACRO(Fixed3x2,fixed3x2,CG_FIXED3x2,3,2)
|
||||
CG_DATATYPE_MACRO(Fixed3x3,fixed3x3,CG_FIXED3x3,3,3)
|
||||
CG_DATATYPE_MACRO(Fixed3x4,fixed3x4,CG_FIXED3x4,3,4)
|
||||
CG_DATATYPE_MACRO(Fixed4x1,fixed4x1,CG_FIXED4x1,4,1)
|
||||
CG_DATATYPE_MACRO(Fixed4x2,fixed4x2,CG_FIXED4x2,4,2)
|
||||
CG_DATATYPE_MACRO(Fixed4x3,fixed4x3,CG_FIXED4x3,4,3)
|
||||
CG_DATATYPE_MACRO(Fixed4x4,fixed4x4,CG_FIXED4x4,4,4)
|
||||
CG_DATATYPE_MACRO(Half1,half1,CG_HALF1,0,1)
|
||||
CG_DATATYPE_MACRO(Float1,float1,CG_FLOAT1,0,1)
|
||||
CG_DATATYPE_MACRO(Fixed1,fixed1,CG_FIXED1,0,1)
|
||||
CG_DATATYPE_MACRO(Int,int,CG_INT,0,1)
|
||||
CG_DATATYPE_MACRO(Int1,int1,CG_INT1,0,1)
|
||||
CG_DATATYPE_MACRO(Int2,int2,CG_INT2,0,2)
|
||||
CG_DATATYPE_MACRO(Int3,int3,CG_INT3,0,3)
|
||||
CG_DATATYPE_MACRO(Int4,int4,CG_INT4,0,4)
|
||||
CG_DATATYPE_MACRO(Int1x1,int1x1,CG_INT1x1,1,1)
|
||||
CG_DATATYPE_MACRO(Int1x2,int1x2,CG_INT1x2,1,2)
|
||||
CG_DATATYPE_MACRO(Int1x3,int1x3,CG_INT1x3,1,3)
|
||||
CG_DATATYPE_MACRO(Int1x4,int1x4,CG_INT1x4,1,4)
|
||||
CG_DATATYPE_MACRO(Int2x1,int2x1,CG_INT2x1,2,1)
|
||||
CG_DATATYPE_MACRO(Int2x2,int2x2,CG_INT2x2,2,2)
|
||||
CG_DATATYPE_MACRO(Int2x3,int2x3,CG_INT2x3,2,3)
|
||||
CG_DATATYPE_MACRO(Int2x4,int2x4,CG_INT2x4,2,4)
|
||||
CG_DATATYPE_MACRO(Int3x1,int3x1,CG_INT3x1,3,1)
|
||||
CG_DATATYPE_MACRO(Int3x2,int3x2,CG_INT3x2,3,2)
|
||||
CG_DATATYPE_MACRO(Int3x3,int3x3,CG_INT3x3,3,3)
|
||||
CG_DATATYPE_MACRO(Int3x4,int3x4,CG_INT3x4,3,4)
|
||||
CG_DATATYPE_MACRO(Int4x1,int4x1,CG_INT4x1,4,1)
|
||||
CG_DATATYPE_MACRO(Int4x2,int4x2,CG_INT4x2,4,2)
|
||||
CG_DATATYPE_MACRO(Int4x3,int4x3,CG_INT4x3,4,3)
|
||||
CG_DATATYPE_MACRO(Int4x4,int4x4,CG_INT4x4,4,4)
|
||||
CG_DATATYPE_MACRO(Bool,bool,CG_BOOL,0,1)
|
||||
CG_DATATYPE_MACRO(Bool1,bool1,CG_BOOL1,0,1)
|
||||
CG_DATATYPE_MACRO(Bool2,bool2,CG_BOOL2,0,2)
|
||||
CG_DATATYPE_MACRO(Bool3,bool3,CG_BOOL3,0,3)
|
||||
CG_DATATYPE_MACRO(Bool4,bool4,CG_BOOL4,0,4)
|
||||
CG_DATATYPE_MACRO(Bool1x1,bool1x1,CG_BOOL1x1,1,1)
|
||||
CG_DATATYPE_MACRO(Bool1x2,bool1x2,CG_BOOL1x2,1,2)
|
||||
CG_DATATYPE_MACRO(Bool1x3,bool1x3,CG_BOOL1x3,1,3)
|
||||
CG_DATATYPE_MACRO(Bool1x4,bool1x4,CG_BOOL1x4,1,4)
|
||||
CG_DATATYPE_MACRO(Bool2x1,bool2x1,CG_BOOL2x1,2,1)
|
||||
CG_DATATYPE_MACRO(Bool2x2,bool2x2,CG_BOOL2x2,2,2)
|
||||
CG_DATATYPE_MACRO(Bool2x3,bool2x3,CG_BOOL2x3,2,3)
|
||||
CG_DATATYPE_MACRO(Bool2x4,bool2x4,CG_BOOL2x4,2,4)
|
||||
CG_DATATYPE_MACRO(Bool3x1,bool3x1,CG_BOOL3x1,3,1)
|
||||
CG_DATATYPE_MACRO(Bool3x2,bool3x2,CG_BOOL3x2,3,2)
|
||||
CG_DATATYPE_MACRO(Bool3x3,bool3x3,CG_BOOL3x3,3,3)
|
||||
CG_DATATYPE_MACRO(Bool3x4,bool3x4,CG_BOOL3x4,3,4)
|
||||
CG_DATATYPE_MACRO(Bool4x1,bool4x1,CG_BOOL4x1,4,1)
|
||||
CG_DATATYPE_MACRO(Bool4x2,bool4x2,CG_BOOL4x2,4,2)
|
||||
CG_DATATYPE_MACRO(Bool4x3,bool4x3,CG_BOOL4x3,4,3)
|
||||
CG_DATATYPE_MACRO(Bool4x4,bool4x4,CG_BOOL4x4,4,4)
|
||||
|
||||
#undef CG_DATATYPE_MACRO
|
||||
|
||||
|
||||
273
RenderDll/XRenderOGL/CG/cg_deprecated_api.h
Normal file
273
RenderDll/XRenderOGL/CG/cg_deprecated_api.h
Normal file
@@ -0,0 +1,273 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _cg_deprecated_api_h
|
||||
#define _cg_deprecated_api_h
|
||||
|
||||
|
||||
// Set up for either Win32 import/export/lib.
|
||||
#ifndef CGDLL_API
|
||||
#ifdef WIN32
|
||||
#ifdef CGDLL_EXPORTS
|
||||
#define CGDLL_API __declspec(dllexport)
|
||||
#elif defined (CG_LIB)
|
||||
#define CGDLL_API
|
||||
#else
|
||||
#define CGDLL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define CGDLL_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*************************************************************************/
|
||||
/*** CG Run-Time Library API ***/
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/*** Data types and structures ***/
|
||||
/*************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
# define CG_ERROR_MACRO(code, enum_name, new_enum_name, message) \
|
||||
cg##enum_name = code,
|
||||
# include <Cg/cg_errors.h>
|
||||
} cgError;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Opaque structure */
|
||||
void *Data;
|
||||
} cgContext;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Opaque structure */
|
||||
void *Data;
|
||||
} cgProgramIter;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Opaque structure */
|
||||
void *Data;
|
||||
} cgBindIter;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cgUnknownValueType,
|
||||
|
||||
cgTypeStartEnum = 1024,
|
||||
# define CG_DATATYPE_MACRO(name, compiler_name, enum_name, ncols, nrows) \
|
||||
cg##name##ValueType,
|
||||
|
||||
#include <Cg/cg_datatypes.h>
|
||||
} cgValueType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cgConstParam,
|
||||
cgUniformParam,
|
||||
cgConnectorMemberParam,
|
||||
cgVaryingParam = cgConnectorMemberParam,
|
||||
cgTexObjParam,
|
||||
cgAnyParam,
|
||||
cgUndefinedParam,
|
||||
} cgParamType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
# define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,\
|
||||
enum_int,addressable,param_type) \
|
||||
cgBind##name = enum_int,
|
||||
#include <Cg/cg_bindlocations.h>
|
||||
|
||||
cgBindUndefined
|
||||
} cgBindLocation;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
cgProfileStart = 6144,
|
||||
|
||||
CG_PROFILE_UNKNOWN,
|
||||
cgUnknownProfile = CG_PROFILE_UNKNOWN,
|
||||
|
||||
# define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
|
||||
cg##name##Profile = int_id,
|
||||
# include "Cg/cg_profiles.h"
|
||||
|
||||
cgNProfiles,
|
||||
} cgProfileType;
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*** Function Prototypes ***/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*** cg Misc Functions ****/
|
||||
/*******************************************************************/
|
||||
|
||||
CGDLL_API void cgCleanup(void);
|
||||
|
||||
/* This will probably be deprecated in future releases */
|
||||
CGDLL_API void cgSetCompilerExe(const char *exe);
|
||||
|
||||
CGDLL_API const char *cgErrorMsg(cgError error);
|
||||
|
||||
/*******************************************************************/
|
||||
/*** cgContext Functions ****/
|
||||
/*******************************************************************/
|
||||
|
||||
CGDLL_API cgContext *cgCreateContext(void);
|
||||
|
||||
CGDLL_API void cgFreeContext(cgContext *context);
|
||||
|
||||
CGDLL_API cgError cgAddProgram(cgContext *context,
|
||||
const char *text,
|
||||
cgProfileType profile,
|
||||
const char *entry);
|
||||
|
||||
CGDLL_API cgError cgAddProgramFromFile(cgContext *context,
|
||||
const char *filename,
|
||||
cgProfileType profile,
|
||||
const char *entry);
|
||||
|
||||
CGDLL_API cgError cgAddProgramArgs(cgContext *context,
|
||||
const char *text,
|
||||
cgProfileType profile,
|
||||
const char *entry,
|
||||
int nargs,
|
||||
const char **args);
|
||||
|
||||
CGDLL_API cgError cgAddProgramFromFileArgs(cgContext *context,
|
||||
const char *filename,
|
||||
cgProfileType profile,
|
||||
const char *entry,
|
||||
int nargs,
|
||||
const char **args);
|
||||
|
||||
CGDLL_API cgError cgAddPrecompiledProgram(cgContext *context,
|
||||
const char *text,
|
||||
cgProfileType profile,
|
||||
const char *entry);
|
||||
|
||||
CGDLL_API cgError cgAddPrecompiledProgramFromFile(cgContext *context,
|
||||
const char *filename,
|
||||
cgProfileType profile,
|
||||
const char *entry);
|
||||
|
||||
CGDLL_API const char *cgGetLastListing(cgContext *context);
|
||||
|
||||
/*******************************************************************/
|
||||
/*** cgProgram Functions ***/
|
||||
/*******************************************************************/
|
||||
|
||||
CGDLL_API cgProgramIter *cgGetNextProgram(cgContext *context,
|
||||
cgProgramIter *iter);
|
||||
|
||||
CGDLL_API cgProgramIter *cgProgramByName(cgContext *context,
|
||||
const char *name);
|
||||
|
||||
|
||||
CGDLL_API cgProgramIter *cgGetLastProgram(cgContext *context);
|
||||
|
||||
CGDLL_API void cgFreeProgramIter(cgProgramIter *program);
|
||||
|
||||
CGDLL_API const char *cgGetProgramName(const cgProgramIter *program);
|
||||
|
||||
CGDLL_API cgProfileType cgGetProgramProfile(const cgProgramIter *program);
|
||||
|
||||
CGDLL_API const char *cgGetProgramObjectCode(const cgProgramIter *program);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*** Parameter and Binding Functions ****/
|
||||
/*******************************************************************/
|
||||
|
||||
CGDLL_API cgBindIter *cgGetNextBind(cgProgramIter *program,
|
||||
cgBindIter *iter);
|
||||
|
||||
CGDLL_API cgBindIter *cgGetBindByName(cgProgramIter *program,
|
||||
const char *parameter_name);
|
||||
|
||||
CGDLL_API cgBindIter *cgDuplicateBindIter(cgBindIter *bind);
|
||||
|
||||
CGDLL_API void cgFreeBindIter(cgBindIter *iter);
|
||||
|
||||
CGDLL_API const char *cgGetBindParamName(const cgBindIter *bind);
|
||||
|
||||
CGDLL_API cgParamType cgGetBindParamType(const cgBindIter *bind);
|
||||
|
||||
CGDLL_API cgBindLocation cgGetBindLocation(const cgBindIter *bind);
|
||||
|
||||
CGDLL_API unsigned long cgGetBindAddress(const cgBindIter *bind);
|
||||
|
||||
CGDLL_API cgValueType cgGetBindValueType(const cgBindIter *bind,
|
||||
int *array_size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
95
RenderDll/XRenderOGL/CG/cg_enums.h
Normal file
95
RenderDll/XRenderOGL/CG/cg_enums.h
Normal file
@@ -0,0 +1,95 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The following macro invocations define the supported CG basic data types.
|
||||
*
|
||||
* The macros have the form :
|
||||
*
|
||||
* CG_DATATYPE_MACRO(enum_name, enum_val)
|
||||
*
|
||||
* enum_name : The C enumerant name.
|
||||
* enum_val : The enumerant value.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
CG_ENUM_MACRO(CG_UNKNOWN, 4096)
|
||||
CG_ENUM_MACRO(CG_IN, 4097)
|
||||
CG_ENUM_MACRO(CG_OUT, 4098)
|
||||
CG_ENUM_MACRO(CG_INOUT, 4099)
|
||||
CG_ENUM_MACRO(CG_MIXED, 4100)
|
||||
CG_ENUM_MACRO(CG_VARYING, 4101)
|
||||
CG_ENUM_MACRO(CG_UNIFORM, 4102)
|
||||
CG_ENUM_MACRO(CG_CONSTANT, 4103)
|
||||
CG_ENUM_MACRO(CG_PROGRAM_SOURCE, 4104)
|
||||
CG_ENUM_MACRO(CG_PROGRAM_ENTRY, 4105)
|
||||
CG_ENUM_MACRO(CG_COMPILED_PROGRAM, 4106)
|
||||
CG_ENUM_MACRO(CG_PROGRAM_PROFILE, 4107)
|
||||
CG_ENUM_MACRO(CG_GLOBAL, 4108)
|
||||
CG_ENUM_MACRO(CG_PROGRAM, 4109)
|
||||
CG_ENUM_MACRO(CG_DEFAULT, 4110)
|
||||
CG_ENUM_MACRO(CG_ERROR, 4111)
|
||||
CG_ENUM_MACRO(CG_SOURCE, 4112)
|
||||
CG_ENUM_MACRO(CG_OBJECT, 4113)
|
||||
CG_ENUM_MACRO(CG_COMPILE_MANUAL, 4114)
|
||||
CG_ENUM_MACRO(CG_COMPILE_IMMEDIATE, 4115)
|
||||
CG_ENUM_MACRO(CG_COMPILE_LAZY, 4116)
|
||||
CG_ENUM_MACRO(CG_CURRENT, 4117)
|
||||
CG_ENUM_MACRO(CG_LITERAL, 4118)
|
||||
CG_ENUM_MACRO(CG_VERSION, 4119)
|
||||
|
||||
#undef CG_ENUM_MACRO
|
||||
|
||||
|
||||
235
RenderDll/XRenderOGL/CG/cg_errors.h
Normal file
235
RenderDll/XRenderOGL/CG/cg_errors.h
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following macro invocations define error codes returned by various cg
|
||||
* API functions.
|
||||
*
|
||||
* The macros have the form :
|
||||
*
|
||||
* CG_ERROR_MACRO(code, enum_name, message)
|
||||
*
|
||||
* code : The integer error code associated with the error.
|
||||
* enum_name : The name of enumerant of the error code in the API.
|
||||
* message : A description string associated with the error.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
CG_ERROR_MACRO(0,
|
||||
CG_NO_ERROR,
|
||||
"No error has occurred.")
|
||||
|
||||
CG_ERROR_MACRO(1,
|
||||
CG_COMPILER_ERROR,
|
||||
"The compile returned an error.")
|
||||
|
||||
CG_ERROR_MACRO(2,
|
||||
CG_INVALID_PARAMETER_ERROR,
|
||||
"The parameter used is invalid.")
|
||||
|
||||
CG_ERROR_MACRO(3,
|
||||
CG_INVALID_PROFILE_ERROR,
|
||||
"The profile is not supported.")
|
||||
|
||||
CG_ERROR_MACRO(4,
|
||||
CG_PROGRAM_LOAD_ERROR,
|
||||
"The program could not load.")
|
||||
|
||||
CG_ERROR_MACRO(5,
|
||||
CG_PROGRAM_BIND_ERROR,
|
||||
"The program could not bind.")
|
||||
|
||||
CG_ERROR_MACRO(6,
|
||||
CG_PROGRAM_NOT_LOADED_ERROR,
|
||||
"The program must be loaded before this operation may be used.")
|
||||
|
||||
CG_ERROR_MACRO(7,
|
||||
CG_UNSUPPORTED_GL_EXTENSION_ERROR,
|
||||
"An unsupported GL extension was required to perform this operation.")
|
||||
|
||||
CG_ERROR_MACRO(8,
|
||||
CG_INVALID_VALUE_TYPE_ERROR,
|
||||
"An unknown value type was assigned to a parameter.")
|
||||
|
||||
CG_ERROR_MACRO(9,
|
||||
CG_NOT_MATRIX_PARAM_ERROR,
|
||||
"The parameter is not of matrix type.")
|
||||
|
||||
CG_ERROR_MACRO(10,
|
||||
CG_INVALID_ENUMERANT_ERROR,
|
||||
"The enumerant parameter has an invalid value.")
|
||||
|
||||
CG_ERROR_MACRO(11,
|
||||
CG_NOT_4x4_MATRIX_ERROR,
|
||||
"The parameter must be a 4x4 matrix type.")
|
||||
|
||||
CG_ERROR_MACRO(12,
|
||||
CG_FILE_READ_ERROR,
|
||||
"The file could not be read.")
|
||||
|
||||
CG_ERROR_MACRO(13,
|
||||
CG_FILE_WRITE_ERROR,
|
||||
"The file could not be written.")
|
||||
|
||||
CG_ERROR_MACRO(14,
|
||||
CG_NVPARSE_ERROR,
|
||||
"nvparse could not successfully parse the output from the Cg "
|
||||
"compiler backend.")
|
||||
|
||||
CG_ERROR_MACRO(15,
|
||||
CG_MEMORY_ALLOC_ERROR,
|
||||
"Memory allocation failed.")
|
||||
|
||||
CG_ERROR_MACRO(16,
|
||||
CG_INVALID_CONTEXT_HANDLE_ERROR,
|
||||
"Invalid context handle.")
|
||||
|
||||
CG_ERROR_MACRO(17,
|
||||
CG_INVALID_PROGRAM_HANDLE_ERROR,
|
||||
"Invalid program handle.")
|
||||
|
||||
CG_ERROR_MACRO(18,
|
||||
CG_INVALID_PARAM_HANDLE_ERROR,
|
||||
"Invalid parameter handle.")
|
||||
|
||||
CG_ERROR_MACRO(19,
|
||||
CG_UNKNOWN_PROFILE_ERROR,
|
||||
"The specified profile is unknown.")
|
||||
|
||||
CG_ERROR_MACRO(20,
|
||||
CG_VAR_ARG_ERROR,
|
||||
"The variable arguments were specified incorrectly.")
|
||||
|
||||
CG_ERROR_MACRO(21,
|
||||
CG_INVALID_DIMENSION_ERROR,
|
||||
"The dimension value is invalid.")
|
||||
|
||||
CG_ERROR_MACRO(22,
|
||||
CG_ARRAY_PARAM_ERROR,
|
||||
"The parameter must be an array.")
|
||||
|
||||
CG_ERROR_MACRO(23,
|
||||
CG_OUT_OF_ARRAY_BOUNDS_ERROR,
|
||||
"Index into the array is out of bounds.")
|
||||
|
||||
CG_ERROR_MACRO(24,
|
||||
CG_CONFLICTING_TYPES_ERROR,
|
||||
"A type being added to the context conflicts with an "
|
||||
"existing type.")
|
||||
|
||||
CG_ERROR_MACRO(25,
|
||||
CG_CONFLICTING_PARAMETER_TYPES_ERROR,
|
||||
"The parameters being bound have conflicting types.")
|
||||
|
||||
CG_ERROR_MACRO(26,
|
||||
CG_PARAMETER_IS_NOT_SHARED_ERROR,
|
||||
"The parameter must be global.")
|
||||
|
||||
CG_ERROR_MACRO(27,
|
||||
CG_INVALID_PARAMETER_VARIABILITY_ERROR,
|
||||
"The parameter could not be changed to the given variability.")
|
||||
|
||||
CG_ERROR_MACRO(28,
|
||||
CG_CANNOT_DESTROY_PARAMETER_ERROR,
|
||||
"Cannot destroy the parameter. It is bound to other parameters "
|
||||
"or is not a root parameter.")
|
||||
|
||||
|
||||
CG_ERROR_MACRO(29,
|
||||
CG_NOT_ROOT_PARAMETER_ERROR,
|
||||
"The parameter is not a root parameter.")
|
||||
|
||||
CG_ERROR_MACRO(30,
|
||||
CG_PARAMETERS_DO_NOT_MATCH_ERROR,
|
||||
"The two parameters being bound do not match.")
|
||||
|
||||
CG_ERROR_MACRO(31,
|
||||
CG_IS_NOT_PROGRAM_PARAMETER_ERROR,
|
||||
"The parameter is not a program parameter.")
|
||||
|
||||
CG_ERROR_MACRO(32,
|
||||
CG_INVALID_PARAMETER_TYPE_ERROR,
|
||||
"The type of the parameter is invalid.")
|
||||
|
||||
CG_ERROR_MACRO(33,
|
||||
CG_PARAMETER_IS_NOT_RESIZABLE_ARRAY_ERROR,
|
||||
"The parameter must be a resizable array.")
|
||||
|
||||
CG_ERROR_MACRO(34,
|
||||
CG_INVALID_SIZE_ERROR,
|
||||
"The size value is invalid.")
|
||||
|
||||
CG_ERROR_MACRO(35,
|
||||
CG_BIND_CREATES_CYCLE_ERROR,
|
||||
"Cannot bind the given parameters. Binding will form a cycle.")
|
||||
|
||||
CG_ERROR_MACRO(36,
|
||||
CG_ARRAY_TYPES_DO_NOT_MATCH_ERROR,
|
||||
"Cannot bind the given parameters. Array types do not match.")
|
||||
|
||||
CG_ERROR_MACRO(37,
|
||||
CG_ARRAY_DIMENSIONS_DO_NOT_MATCH_ERROR,
|
||||
"Cannot bind the given parameters. "
|
||||
"Array dimensions do not match.")
|
||||
|
||||
CG_ERROR_MACRO(38,
|
||||
CG_ARRAY_HAS_WRONG_DIMENSION_ERROR,
|
||||
"The array is has the wrong dimension.")
|
||||
|
||||
CG_ERROR_MACRO(39,
|
||||
CG_TYPE_IS_NOT_DEFINED_IN_PROGRAM_ERROR,
|
||||
"Connecting the parameters failed because The type of the "
|
||||
"source parameter is not defined within the given program "
|
||||
"or does not match the type with the same name in the program.")
|
||||
|
||||
#undef CG_ERROR_MACRO
|
||||
|
||||
90
RenderDll/XRenderOGL/CG/cg_profiles.h
Normal file
90
RenderDll/XRenderOGL/CG/cg_profiles.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2002, NVIDIA Corporation.
|
||||
*
|
||||
*
|
||||
*
|
||||
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
|
||||
* of your agreement to the following terms, and your use, installation,
|
||||
* modification or redistribution of this NVIDIA software constitutes
|
||||
* acceptance of these terms. If you do not agree with these terms, please do
|
||||
* not use, install, modify or redistribute this NVIDIA software.
|
||||
*
|
||||
*
|
||||
*
|
||||
* In consideration of your agreement to abide by the following terms, and
|
||||
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
|
||||
* under NVIDIA<49>s copyrights in this original NVIDIA software (the "NVIDIA
|
||||
* Software"), to use, reproduce, modify and redistribute the NVIDIA
|
||||
* Software, with or without modifications, in source and/or binary forms;
|
||||
* provided that if you redistribute the NVIDIA Software, you must retain the
|
||||
* copyright notice of NVIDIA, this notice and the following text and
|
||||
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
|
||||
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
|
||||
* to endorse or promote products derived from the NVIDIA Software without
|
||||
* specific prior written permission from NVIDIA. Except as expressly stated
|
||||
* in this notice, no other rights or licenses express or implied, are granted
|
||||
* by NVIDIA herein, including but not limited to any patent rights that may be
|
||||
* infringed by your derivative works or by other works in which the NVIDIA
|
||||
* Software may be incorporated. No hardware is licensed hereunder.
|
||||
*
|
||||
*
|
||||
*
|
||||
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
||||
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
|
||||
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
|
||||
*
|
||||
*
|
||||
*
|
||||
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
||||
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
|
||||
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
|
||||
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
|
||||
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
|
||||
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following macro invocations define the supported CG profiles.
|
||||
*
|
||||
* The macros have the form :
|
||||
*
|
||||
* CG_PROFILE_MACRO(name, compiler_id, compiler_opt)
|
||||
*
|
||||
* name : The name of the profile. Used consistently with the API.
|
||||
* compiler_id : The identifier string for the profile used by the compiler.
|
||||
* compiler_id_caps : compiler_id in caps.
|
||||
* compiler_opt : The command-line switch used to force compilation into
|
||||
* the profile.
|
||||
* int_id : Integer enumerant associated with this bind location.
|
||||
* vertex_profile : Non-zero if this is a vertex profile, otherwise it
|
||||
* is considered to be a fragment profile.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#define CG_IN_PROFILES_INCLUDE
|
||||
|
||||
#include "Cg/cgGL_profiles.h"
|
||||
|
||||
|
||||
CG_PROFILE_MACRO(DX9Vertex11,vs_1_1,VS_1_1,"vs_1_1",6153,1)
|
||||
CG_PROFILE_MACRO(DX9Vertex20,vs_2_0,VS_2_0,"vs_2_0",6154,1)
|
||||
CG_PROFILE_MACRO(DX9Vertex2x,vs_2_x,VS_2_X,"vs_2_x",6155,1)
|
||||
CG_PROFILE_MACRO(DX9Vertex30,vs_3_0,VS_3_0,"vs_3_0",6156,1)
|
||||
|
||||
CG_PROFILE_MACRO(DX9Pixel11,ps_1_1,PS_1_1,"ps_1_1",6159,0)
|
||||
CG_PROFILE_MACRO(DX9Pixel12,ps_1_2,PS_1_2,"ps_1_2",6160,0)
|
||||
CG_PROFILE_MACRO(DX9Pixel13,ps_1_3,PS_1_3,"ps_1_3",6161,0)
|
||||
CG_PROFILE_MACRO(DX9Pixel20,ps_2_0,PS_2_0,"ps_2_0",6162,0)
|
||||
CG_PROFILE_MACRO(DX9Pixel2x,ps_2_x,PS_2_X,"ps_2_x",6163,0)
|
||||
CG_PROFILE_MACRO(DX9Pixel30,ps_3_0,PS_3_0,"ps_3_0",6164,0)
|
||||
|
||||
|
||||
#undef CG_PROFILE_MACRO
|
||||
#undef CG_IN_PROFILES_INCLUDE
|
||||
1011
RenderDll/XRenderOGL/GLCGPShader.cpp
Normal file
1011
RenderDll/XRenderOGL/GLCGPShader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
900
RenderDll/XRenderOGL/GLCGPShader.h
Normal file
900
RenderDll/XRenderOGL/GLCGPShader.h
Normal file
@@ -0,0 +1,900 @@
|
||||
/*=============================================================================
|
||||
GLCGPShader.h : OpenGL CG programs interface declaration.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef __GLCGPSHADER_H__
|
||||
#define __GLCGPSHADER_H__
|
||||
|
||||
#include "cg\cgGL.h"
|
||||
#include "nvparse/nvparse.h"
|
||||
|
||||
#define CG_FP_CACHE_VER 3.4
|
||||
|
||||
extern char *PS20toARBfp(const char *inName);
|
||||
extern char *PS20toNV30fp(const char *inName);
|
||||
|
||||
#ifdef WIN64
|
||||
#pragma warning( push ) //AMD Port
|
||||
#pragma warning( disable : 4267 )
|
||||
#endif
|
||||
|
||||
class CCGPShader_GL : public CPShader
|
||||
{
|
||||
SCGScript *m_DeclarationsScript;
|
||||
SCGScript *m_CoreScript;
|
||||
SCGScript *m_InputParmsScript;
|
||||
SCGScript *m_SubroutinesScript;
|
||||
|
||||
int m_CurInst;
|
||||
int m_dwFrame;
|
||||
struct SCacheInstance
|
||||
{
|
||||
int m_Mask;
|
||||
SShaderCache *m_pCache;
|
||||
SCacheInstance()
|
||||
{
|
||||
m_Mask = 0;
|
||||
m_pCache = NULL;
|
||||
}
|
||||
int Size()
|
||||
{
|
||||
int nSize = sizeof(*this);
|
||||
return nSize;
|
||||
}
|
||||
};
|
||||
struct SCGInstance
|
||||
{
|
||||
int m_Mask;
|
||||
int m_LightMask;
|
||||
CName m_PosScriptName;
|
||||
TArray<SCGParam4f> *m_ParamsNoObj;
|
||||
TArray<SCGParam4f> *m_ParamsObj;
|
||||
TArray<SCGMatrix> *m_MatrixObj;
|
||||
uint m_dwHandle;
|
||||
uint m_dwHandleExt;
|
||||
TArray<SCGBindConst> *m_BindConstants;
|
||||
TArray<SCGBind> *m_BindVars;
|
||||
int m_nCacheID;
|
||||
SCGInstance()
|
||||
{
|
||||
m_Mask = 0;
|
||||
m_LightMask = 0;
|
||||
m_dwHandle = m_dwHandleExt = 0;
|
||||
m_ParamsNoObj = NULL;
|
||||
m_ParamsObj = NULL;
|
||||
m_MatrixObj = NULL;
|
||||
m_BindConstants = NULL;
|
||||
m_BindVars = NULL;
|
||||
m_nCacheID = -1;
|
||||
}
|
||||
|
||||
int Size()
|
||||
{
|
||||
int nSize = sizeof(*this);
|
||||
if (m_ParamsNoObj)
|
||||
nSize += m_ParamsNoObj->GetMemoryUsage() + 12;
|
||||
if (m_ParamsObj)
|
||||
nSize += m_ParamsObj->GetMemoryUsage() + 12;
|
||||
if (m_MatrixObj)
|
||||
nSize += m_MatrixObj->GetMemoryUsage() + 12;
|
||||
if (m_BindConstants)
|
||||
nSize += m_BindConstants->GetMemoryUsage() + 12;
|
||||
if (m_BindVars)
|
||||
nSize += m_BindVars->GetMemoryUsage() + 12;
|
||||
|
||||
return nSize;
|
||||
}
|
||||
};
|
||||
TArray<SCGInstance> m_Insts;
|
||||
TArray<SCacheInstance> m_InstCache;
|
||||
TArray<SCGParam4f> m_ParamsNoObj;
|
||||
TArray<SCGParam4f> m_ParamsObj;
|
||||
|
||||
public:
|
||||
|
||||
virtual int Size()
|
||||
{
|
||||
int nSize = sizeof(*this);
|
||||
if (m_DeclarationsScript)
|
||||
nSize += m_DeclarationsScript->Size(false);
|
||||
if (m_CoreScript)
|
||||
nSize += m_CoreScript->Size(false);
|
||||
if (m_InputParmsScript)
|
||||
nSize += m_InputParmsScript->Size(false);
|
||||
if (m_SubroutinesScript)
|
||||
nSize += m_SubroutinesScript->Size(false);
|
||||
nSize += m_ParamsNoObj.GetMemoryUsage();
|
||||
nSize += m_ParamsObj.GetMemoryUsage();
|
||||
for (int i=0; i<m_Insts.GetSize(); i++)
|
||||
{
|
||||
if (i < m_Insts.Num())
|
||||
{
|
||||
SCGInstance *cgi = &m_Insts[i];
|
||||
nSize += cgi->Size();
|
||||
}
|
||||
else
|
||||
nSize += sizeof(SCGInstance);
|
||||
}
|
||||
return nSize;
|
||||
}
|
||||
int mfGetCacheInstanceID(int Mask, const char *name=NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<m_InstCache.Num(); i++)
|
||||
{
|
||||
if (m_InstCache[i].m_Mask == Mask)
|
||||
return i;
|
||||
}
|
||||
if (!name)
|
||||
return -1;
|
||||
int nNum = m_InstCache.Num();
|
||||
SCacheInstance ci;
|
||||
ci.m_pCache = gRenDev->m_cEF.OpenCacheFile(name, (float)CG_FP_CACHE_VER);
|
||||
ci.m_Mask = Mask;
|
||||
m_InstCache.AddElem(ci);
|
||||
|
||||
return nNum;
|
||||
}
|
||||
int mfGetCGInstanceID(int Type, int LightMask)
|
||||
{
|
||||
SCGInstance *cgi;
|
||||
if (m_CurInst >= 0 && m_Insts.Num() > m_CurInst)
|
||||
{
|
||||
cgi = &m_Insts[m_CurInst];
|
||||
if (cgi->m_Mask == Type && cgi->m_LightMask == LightMask)
|
||||
return m_CurInst;
|
||||
}
|
||||
m_dwFrame++;
|
||||
int i;
|
||||
for (i=0; i<m_Insts.Num(); i++)
|
||||
{
|
||||
cgi = &m_Insts[i];
|
||||
if (cgi->m_Mask == Type && cgi->m_LightMask == LightMask)
|
||||
{
|
||||
m_CurInst = i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
SCGInstance cg;
|
||||
cg.m_Mask = Type;
|
||||
cg.m_LightMask = LightMask;
|
||||
cg.m_dwHandle = NULL;
|
||||
cg.m_dwHandleExt = NULL;
|
||||
cg.m_ParamsNoObj = NULL;
|
||||
cg.m_ParamsObj = NULL;
|
||||
cg.m_BindConstants = NULL;
|
||||
cg.m_BindVars = NULL;
|
||||
cg.m_nCacheID = -1;
|
||||
|
||||
m_CurInst = m_Insts.Num();
|
||||
m_Insts.AddElem(cg);
|
||||
return m_CurInst;
|
||||
}
|
||||
|
||||
TArray<SCGParam4f> *mfGetParams(int Type)
|
||||
{
|
||||
if (!Type)
|
||||
return &m_ParamsNoObj;
|
||||
else
|
||||
return &m_ParamsObj;
|
||||
}
|
||||
|
||||
|
||||
CCGPShader_GL(CGprofile ProfType)
|
||||
{
|
||||
m_CGProfileType = ProfType;
|
||||
mfInit();
|
||||
}
|
||||
CCGPShader_GL();
|
||||
void mfSaveCGFile(const char *scr)
|
||||
{
|
||||
char name[1024];
|
||||
if (m_nMaskGen)
|
||||
sprintf(name, "%s(%x).cg", m_Name.c_str(), m_nMaskGen);
|
||||
else
|
||||
sprintf(name, "%s.cg", m_Name.c_str());
|
||||
FILE *fp = fopen(name, "w");
|
||||
fprintf(fp, scr);
|
||||
fclose (fp);
|
||||
}
|
||||
void mfInit()
|
||||
{
|
||||
#ifndef WIN64
|
||||
// NOTE: AMD64 port: find the 64-bit CG runtime
|
||||
if (!gcpOGL->m_CGContext)
|
||||
{
|
||||
gcpOGL->m_CGContext = cgCreateContext();
|
||||
assert(gcpOGL->m_CGContext != NULL);
|
||||
}
|
||||
#endif
|
||||
m_dwFrame = 1;
|
||||
m_CurInst = -1;
|
||||
m_CoreScript = NULL;
|
||||
m_InputParmsScript = NULL;
|
||||
m_SubroutinesScript = NULL;
|
||||
m_DeclarationsScript = NULL;
|
||||
}
|
||||
|
||||
void mfBind()
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
{
|
||||
if (m_Insts[m_CurInst].m_dwHandleExt > 0)
|
||||
{
|
||||
glCallList(m_Insts[m_CurInst].m_dwHandleExt);
|
||||
gRenDev->m_RP.m_PersFlags |= RBPF_TSNEEDSET;
|
||||
}
|
||||
else
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_TSNEEDSET;
|
||||
if (m_Insts[m_CurInst].m_dwHandle > 0)
|
||||
{
|
||||
glCallList(m_Insts[m_CurInst].m_dwHandle);
|
||||
if (m_Insts[m_CurInst].m_BindConstants)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindConstants->Num(); i++)
|
||||
{
|
||||
SCGBindConst *p = &m_Insts[m_CurInst].m_BindConstants->Get(i);
|
||||
int Reg = p->m_dwBind;
|
||||
int reg = (Reg & 0xffffff);
|
||||
int nComb = (Reg >> 28) - 1;
|
||||
if (reg >= 65536)
|
||||
reg -= 65536;
|
||||
assert (reg >= 0 && reg < 2);
|
||||
if (reg < 0 || reg >= 2)
|
||||
continue;
|
||||
int n = nComb*2+reg;
|
||||
if (m_CurParams[n][0] != p->m_Val[0] || m_CurParams[n][1] != p->m_Val[1] || m_CurParams[n][2] != p->m_Val[2] || m_CurParams[n][3] != p->m_Val[3])
|
||||
{
|
||||
m_CurParams[n][0] = p->m_Val[0];
|
||||
m_CurParams[n][1] = p->m_Val[1];
|
||||
m_CurParams[n][2] = p->m_Val[2];
|
||||
m_CurParams[n][3] = p->m_Val[3];
|
||||
if (Reg & 0xf0000000)
|
||||
glCombinerStageParameterfvNV(GL_COMBINER0_NV+nComb, reg+GL_CONSTANT_COLOR0_NV, p->m_Val);
|
||||
else
|
||||
glCombinerParameterfvNV(reg+GL_CONSTANT_COLOR0_NV, p->m_Val);
|
||||
}
|
||||
}
|
||||
}
|
||||
gRenDev->m_RP.m_PersFlags |= RBPF_PS1NEEDSET;
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_PS2NEEDSET;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBFP1)
|
||||
{
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_Insts[m_CurInst].m_dwHandle);
|
||||
if (m_Insts[m_CurInst].m_BindConstants)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindConstants->Num(); i++)
|
||||
{
|
||||
SCGBindConst *p = &m_Insts[m_CurInst].m_BindConstants->Get(i);
|
||||
int n = p->m_dwBind;
|
||||
if (m_CurParamsARB[n][0] != p->m_Val[0] || m_CurParamsARB[n][1] != p->m_Val[1] || m_CurParamsARB[n][2] != p->m_Val[2] || m_CurParamsARB[n][3] != p->m_Val[3])
|
||||
{
|
||||
m_CurParamsARB[n][0] = p->m_Val[0];
|
||||
m_CurParamsARB[n][1] = p->m_Val[1];
|
||||
m_CurParamsARB[n][2] = p->m_Val[2];
|
||||
m_CurParamsARB[n][3] = p->m_Val[3];
|
||||
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, p->m_dwBind, &p->m_Val[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
gRenDev->m_RP.m_PersFlags |= RBPF_PS2NEEDSET;
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_PS1NEEDSET;
|
||||
}
|
||||
}
|
||||
|
||||
void mfUnbind()
|
||||
{
|
||||
}
|
||||
|
||||
char *mfLoadCG(char *prog_text)
|
||||
{
|
||||
#ifndef WIN64
|
||||
CGprofile pr = (CGprofile)m_CGProfileType;
|
||||
|
||||
#if 0
|
||||
// Use HLSL compiler for PS_2_X profile since it generates more efficient code (and allmost bugs free)
|
||||
if (pr == CG_PROFILE_FP30 || pr == CG_PROFILE_ARBFP1)
|
||||
{
|
||||
char *Buf = sReplaceInText(prog_text, "pixout OUT", "float4 Color = (float4)0");
|
||||
char *Buf1 = sReplaceInText(Buf, "pixout main", "float4 main");
|
||||
remove("$$out.cg");
|
||||
if (Buf != Buf1)
|
||||
{
|
||||
if (Buf != prog_text)
|
||||
delete [] Buf;
|
||||
Buf = Buf1;
|
||||
}
|
||||
Buf1 = sReplaceInText(Buf, "return OUT", "return Color");
|
||||
if (Buf != Buf1)
|
||||
{
|
||||
if (Buf != prog_text)
|
||||
delete [] Buf;
|
||||
Buf = Buf1;
|
||||
}
|
||||
Buf1 = sReplaceInText(Buf, "OUT.Color", "Color");
|
||||
if (Buf != Buf1)
|
||||
{
|
||||
if (Buf != prog_text)
|
||||
delete [] Buf;
|
||||
Buf = Buf1;
|
||||
}
|
||||
|
||||
// make command for execution
|
||||
FILE *fp = fopen("$$in.cg", "w");
|
||||
if (!fp)
|
||||
return NULL;
|
||||
fputs(Buf, fp);
|
||||
fclose (fp);
|
||||
|
||||
char szCmdLine[512];
|
||||
sprintf(szCmdLine, "fxc.exe /T %s /Fc $$out.cg $$in.cg", pr == CG_PROFILE_FP30 ? "ps_2_a" : "ps_2_0");
|
||||
|
||||
STARTUPINFO si;
|
||||
ZeroMemory( &si, sizeof(si) );
|
||||
si.cb = sizeof(si);
|
||||
si.dwX = 100;
|
||||
si.dwY = 100;
|
||||
si.dwFlags = STARTF_USEPOSITION;
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory( &pi, sizeof(pi) );
|
||||
if( !CreateProcess( NULL, // No module name (use command line).
|
||||
szCmdLine, // Command line.
|
||||
NULL, // Process handle not inheritable.
|
||||
NULL, // Thread handle not inheritable.
|
||||
FALSE, // Set handle inheritance to FALSE.
|
||||
CREATE_NO_WINDOW, // No creation flags.
|
||||
NULL, // Use parent's environment block.
|
||||
NULL/*szFolderName*/, // Set starting directory.
|
||||
&si, // Pointer to STARTUPINFO structure.
|
||||
&pi ) // Pointer to PROCESS_INFORMATION structure.
|
||||
)
|
||||
{
|
||||
iLog->LogError("CreateProcess failed: %s", szCmdLine);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (WAIT_OBJECT_0 != WaitForSingleObject (pi.hProcess, 10000))
|
||||
iLog->LogWarning ("CG runtime takes forever to compile.. waiting.. (last error %d)", GetLastError());
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
char *pBuf;
|
||||
if (pr == CG_PROFILE_FP30)
|
||||
pBuf = PS20toNV30fp("$$out.cg");
|
||||
else
|
||||
pBuf = PS20toARBfp("$$out.cg");
|
||||
|
||||
if (Buf != prog_text)
|
||||
delete [] Buf;
|
||||
remove("$$in.cg");
|
||||
remove("$$out.cg");
|
||||
|
||||
return pBuf;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// Test adding source text to context
|
||||
const char *profileOpts[] =
|
||||
{
|
||||
"-DCGC=1",
|
||||
NULL,
|
||||
};
|
||||
cgGLSetOptimalOptions((CGprofile)m_CGProfileType);
|
||||
CGprogram cgPr = cgCreateProgram(gcpOGL->m_CGContext, CG_SOURCE, prog_text, (CGprofile)m_CGProfileType, "main", profileOpts);
|
||||
CGerror err = cgGetError();
|
||||
if (err != CG_NO_ERROR)
|
||||
{
|
||||
if ((m_Flags & PSFI_AUTOENUMTC) && m_CGProfileType == CG_PROFILE_FP20 && (gRenDev->GetFeatures() & RFT_HW_PS20))
|
||||
{
|
||||
#ifndef WIN64
|
||||
// NOTE: AMD64 port: find the 64-bit CG runtime
|
||||
m_CGProfileType = cgGLGetLatestProfile(CG_GL_FRAGMENT);
|
||||
#endif
|
||||
if (SUPPORTS_GL_ARB_vertex_program)
|
||||
m_CGProfileType = CG_PROFILE_ARBFP1;
|
||||
return mfLoadCG(prog_text);
|
||||
}
|
||||
Warning(0,0,"Couldn't create CG program '%s' (%s)", m_Name.c_str(), cgGetErrorString(err));
|
||||
mfSaveCGFile(prog_text);
|
||||
return NULL;
|
||||
}
|
||||
if (cgPr)
|
||||
{
|
||||
char *code = mfGetObjectCode(cgPr);
|
||||
cgDestroyProgram(cgPr);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
#else
|
||||
// make command for execution
|
||||
FILE *fp = fopen("$$in.cg", "w");
|
||||
if (!fp)
|
||||
return NULL;
|
||||
assert (*prog_text);
|
||||
fputs(prog_text, fp);
|
||||
fclose (fp);
|
||||
|
||||
char szCmdLine[512];
|
||||
sprintf(szCmdLine,
|
||||
"cgc.exe -profile %s -o $$out.cg $$in.cg",
|
||||
m_CGProfileType == CG_PROFILE_FP20 ? "fp20" : "arbfp1");
|
||||
|
||||
STARTUPINFO si;
|
||||
ZeroMemory( &si, sizeof(si) );
|
||||
si.cb = sizeof(si);
|
||||
si.dwX = 100;
|
||||
si.dwY = 100;
|
||||
si.dwFlags = STARTF_USEPOSITION;
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory( &pi, sizeof(pi) );
|
||||
if( !CreateProcess( NULL, // No module name (use command line).
|
||||
szCmdLine, // Command line.
|
||||
NULL, // Process handle not inheritable.
|
||||
NULL, // Thread handle not inheritable.
|
||||
FALSE, // Set handle inheritance to FALSE.
|
||||
CREATE_NO_WINDOW, // No creation flags.
|
||||
NULL, // Use parent's environment block.
|
||||
NULL/*szFolderName*/, // Set starting directory.
|
||||
&si, // Pointer to STARTUPINFO structure.
|
||||
&pi ) // Pointer to PROCESS_INFORMATION structure.
|
||||
)
|
||||
{
|
||||
iLog->LogError("CreateProcess failed: %s", szCmdLine);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (WAIT_OBJECT_0 != WaitForSingleObject (pi.hProcess, 10000))
|
||||
iLog->LogWarning ("CG runtime takes forever to compile.. waiting.. (last error %d)", GetLastError());
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
fp = fopen("$$out.cg", "rb");
|
||||
if (!fp)
|
||||
{
|
||||
Warning( 0,0,"CG compiler (cgc.exe) wasn't able to compile pixel shader '%s'", m_Name.c_str());
|
||||
mfSaveCGFile(prog_text);
|
||||
return NULL;
|
||||
}
|
||||
fseek(fp, 0, SEEK_END);
|
||||
int size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
if (size < 20)
|
||||
{
|
||||
Warning( 0,0,"CG compiler (cgc.exe) wasn't able to compile pixel shader '%s'", m_Name.c_str());
|
||||
mfSaveCGFile(prog_text);
|
||||
remove("$$in.cg");
|
||||
remove("$$out.cg");
|
||||
return NULL;
|
||||
}
|
||||
char *pBuf = new char[size+1];
|
||||
fread(pBuf, sizeof(char), size, fp);
|
||||
pBuf[size] = '\0';
|
||||
fclose(fp);
|
||||
remove("$$in.cg");
|
||||
remove("$$out.cg");
|
||||
|
||||
return pBuf;
|
||||
#endif
|
||||
}
|
||||
|
||||
void mfLoad(const char *prog_text)
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_ARBFP1)
|
||||
{
|
||||
glGenProgramsARB(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_Insts[m_CurInst].m_dwHandle);
|
||||
int size = strlen(prog_text);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, size, (const GLubyte *)prog_text);
|
||||
GLint errpos;
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errpos);
|
||||
if(errpos != -1)
|
||||
{
|
||||
const GLubyte *pError = glGetString(GL_PROGRAM_ERROR_STRING_ARB);
|
||||
iLog->Log("Warning: Fragment Program '%s' error (%s):\n", m_Name.c_str(), pError);
|
||||
int bgn = errpos - 10;
|
||||
bgn < 0 ? 0 : bgn;
|
||||
const char * c = (const char *)(prog_text + bgn);
|
||||
for(int i = 0; i < 30; i++)
|
||||
{
|
||||
if(bgn+i >= int(size-1))
|
||||
break;
|
||||
iLog->Log("%c", *c++);
|
||||
}
|
||||
iLog->Log("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_FP30)
|
||||
{
|
||||
glGenProgramsNV(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
glBindProgramNV(GL_FRAGMENT_PROGRAM_NV, m_Insts[m_CurInst].m_dwHandle);
|
||||
int size = strlen(prog_text);
|
||||
glLoadProgramNV(GL_FRAGMENT_PROGRAM_NV, m_Insts[m_CurInst].m_dwHandle, size, (const GLubyte *)prog_text);
|
||||
const GLubyte *pError = glGetString(GL_PROGRAM_ERROR_STRING_NV);
|
||||
if(pError && pError[0])
|
||||
iLog->Log("Error: %s", pError);
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
{
|
||||
const char *sStr = strstr(prog_text, "!!TS1.0");
|
||||
if (sStr)
|
||||
{
|
||||
char sLine[4][128];
|
||||
int n = 8;
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
int m = 0;
|
||||
while (sStr[n] != 0xa)
|
||||
{
|
||||
if (sStr[n] == '/' && sStr[n+1] == '/')
|
||||
break;
|
||||
sLine[i][m++] = sStr[n++];
|
||||
}
|
||||
if (sStr[n] == '/' && sStr[n+1] == '/')
|
||||
break;
|
||||
n++;
|
||||
sLine[i][m++] = 0;
|
||||
}
|
||||
int nS = i;
|
||||
bool bUseTS = false;
|
||||
for (i=0; i<nS; i++)
|
||||
{
|
||||
if (strcmp(sLine[i], "texture_2d();") && strcmp(sLine[i], "nop();") && strcmp(sLine[i], "texture_3d();") && strcmp(sLine[i], "texture_cube_map();") && strcmp(sLine[i], "texture_rectangle();"))
|
||||
{
|
||||
bUseTS = true;
|
||||
// Use projected env. bump mapping if it's supported
|
||||
if (gRenDev->GetFeatures() & RFT_HW_ENVBUMPPROJECTED)
|
||||
{
|
||||
if (!strncmp(sLine[i], "offset_rectangle", 16) || !strncmp(sLine[i], "offset_2d", 9))
|
||||
{
|
||||
// replace texture shader offset operation by projective one
|
||||
char sTemp[128];
|
||||
char *s = strchr(sLine[i], '(');
|
||||
if (s)
|
||||
{
|
||||
strcpy(sTemp, s);
|
||||
if (!strncmp(sLine[i], "offset_rectangle", 16))
|
||||
strcpy(sLine[i], "offset_projective_rectangle");
|
||||
else
|
||||
strcpy(sLine[i], "offset_projective_2d");
|
||||
strcat(sLine[i], sTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bUseTS)
|
||||
{
|
||||
char code[256];
|
||||
switch(nS)
|
||||
{
|
||||
case 1:
|
||||
sprintf(code, "!!TS1.0\n %s\n", sLine[0]);
|
||||
break;
|
||||
case 2:
|
||||
sprintf(code, "!!TS1.0\n %s\n %s\n", sLine[0], sLine[1]);
|
||||
break;
|
||||
case 3:
|
||||
sprintf(code, "!!TS1.0\n %s\n %s\n %s\n", sLine[0], sLine[1], sLine[2]);
|
||||
break;
|
||||
case 4:
|
||||
sprintf(code, "!!TS1.0\n %s\n %s\n %s\n %s\n", sLine[0], sLine[1], sLine[2], sLine[3]);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
uint listTS = glGenLists(1);
|
||||
glNewList(listTS, GL_COMPILE);
|
||||
nvparse(false, code);
|
||||
int n = 0;
|
||||
for (char * const * errors = nvparse_get_errors(); *errors; errors++)
|
||||
{
|
||||
n++;
|
||||
iLog->Log(*errors);
|
||||
}
|
||||
glEndList();
|
||||
if (!n)
|
||||
m_Insts[m_CurInst].m_dwHandleExt = listTS;
|
||||
}
|
||||
}
|
||||
|
||||
sStr = strstr(prog_text, "!!RC1.0");
|
||||
if (sStr)
|
||||
{
|
||||
uint listRC = glGenLists(1);
|
||||
glNewList(listRC, GL_COMPILE);
|
||||
nvparse(false, sStr);
|
||||
int n = 0;
|
||||
for (char * const * errors = nvparse_get_errors(); *errors; errors++)
|
||||
{
|
||||
n++;
|
||||
iLog->Log(*errors);
|
||||
}
|
||||
glEndList();
|
||||
if (!n)
|
||||
{
|
||||
m_Insts[m_CurInst].m_dwHandle = listRC;
|
||||
if (gParseConsts.Num())
|
||||
{
|
||||
m_Insts[m_CurInst].m_BindConstants = new TArray<SCGBindConst>;
|
||||
m_Insts[m_CurInst].m_BindConstants->Copy(gParseConsts);
|
||||
gParseConsts.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mfParameter(SCGBind *ParamBind, const float *vData, int nComps)
|
||||
{
|
||||
int i;
|
||||
if(!ParamBind)
|
||||
return;
|
||||
|
||||
if (!ParamBind->m_dwBind || ParamBind->m_dwFrameCreated != m_dwFrame)
|
||||
{
|
||||
ParamBind->m_dwFrameCreated = m_dwFrame;
|
||||
if (m_Insts[m_CurInst].m_BindVars)
|
||||
{
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
|
||||
{
|
||||
SCGBind *p = &m_Insts[m_CurInst].m_BindVars->Get(i);
|
||||
if (p->m_Name == ParamBind->m_Name)
|
||||
{
|
||||
assert(p->m_nComponents <= nComps);
|
||||
ParamBind->m_dwBind = (ParamBind->m_dwBind & 0x80000) | p->m_dwBind;
|
||||
if (!(ParamBind->m_dwBind & 0xffff))
|
||||
ParamBind->m_dwBind |= 0x10000;
|
||||
ParamBind->m_nBindComponents = p->m_nComponents;
|
||||
ParamBind->m_pNext = p->m_pNext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == m_Insts[m_CurInst].m_BindVars->Num())
|
||||
ParamBind->m_dwBind = -1;
|
||||
}
|
||||
else
|
||||
ParamBind->m_dwBind = -1;
|
||||
if (ParamBind->m_dwBind == -1 && CRenderer::CV_r_shaderssave >= 2)
|
||||
iLog->Log("Warning: couldn't find parameter %s for vertex shader %s (%x)", ParamBind->m_Name.c_str(), m_Name.c_str(), m_nMaskGen);
|
||||
}
|
||||
if ((int)ParamBind->m_dwBind == -1)
|
||||
return;
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
{
|
||||
SCGBind *pBind = ParamBind;
|
||||
while (pBind)
|
||||
{
|
||||
const float *v = vData;
|
||||
for (i=0; i<pBind->m_nBindComponents; i++)
|
||||
{
|
||||
int Reg = pBind->m_dwBind+i;
|
||||
int reg = (Reg & 0xf7ffff);
|
||||
int nComb = (Reg >> 28) - 1;
|
||||
if (reg == GL_OFFSET_TEXTURE_2D_MATRIX_NV)
|
||||
{
|
||||
float pr[4];
|
||||
pr[0] = v[0] * CRenderer::CV_r_embm;
|
||||
pr[1] = v[1] * CRenderer::CV_r_embm;
|
||||
pr[2] = v[2] * CRenderer::CV_r_embm;
|
||||
pr[3] = v[3] * CRenderer::CV_r_embm;
|
||||
if (CGLTexMan::m_TUState[nComb].m_Target == GL_TEXTURE_RECTANGLE_NV)
|
||||
{
|
||||
float fScrWidth = (float)gRenDev->GetWidth();
|
||||
float fScrHeight = (float)gRenDev->GetHeight();
|
||||
pr[0] *= fScrWidth;
|
||||
pr[1] *= fScrWidth;
|
||||
pr[2] *= fScrHeight;
|
||||
pr[3] *= fScrHeight;
|
||||
}
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB+nComb);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, reg, pr);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB+CTexMan::m_CurStage);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reg & 0x10000)
|
||||
reg = 0;
|
||||
assert (reg >= 0 && reg < 2);
|
||||
int n = nComb*2+reg;
|
||||
if (m_CurParams[n][0] != v[0] || m_CurParams[n][1] != v[1] || m_CurParams[n][2] != v[2] || m_CurParams[n][3] != v[3])
|
||||
{
|
||||
m_CurParams[n][0] = v[0];
|
||||
m_CurParams[n][1] = v[1];
|
||||
m_CurParams[n][2] = v[2];
|
||||
m_CurParams[n][3] = v[3];
|
||||
if (Reg & 0xf0000000)
|
||||
glCombinerStageParameterfvNV(GL_COMBINER0_NV+nComb, reg+GL_CONSTANT_COLOR0_NV, v);
|
||||
else
|
||||
glCombinerParameterfvNV(reg+GL_CONSTANT_COLOR0_NV, v);
|
||||
}
|
||||
}
|
||||
v += 4;
|
||||
}
|
||||
pBind = pBind->m_pNext;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<ParamBind->m_nBindComponents; i++)
|
||||
{
|
||||
int n = (ParamBind->m_dwBind+i) & ~0x10000;
|
||||
if (n & 0x80000)
|
||||
{
|
||||
n &= ~0x80000;
|
||||
float fScaleX = CRenderer::CV_r_embm * (float)gcpOGL->GetWidth();
|
||||
float fScaleY = CRenderer::CV_r_embm * (float)gcpOGL->GetHeight();
|
||||
float v[4];
|
||||
v[0] = vData[0] * fScaleX;
|
||||
v[1] = vData[1] * fScaleX;
|
||||
v[2] = vData[2] * fScaleY;
|
||||
v[3] = vData[3] * fScaleY;
|
||||
vData = v;
|
||||
}
|
||||
if (m_CurParamsARB[n][0] != vData[0] || m_CurParamsARB[n][1] != vData[1] || m_CurParamsARB[n][2] != vData[2] || m_CurParamsARB[n][3] != vData[3])
|
||||
{
|
||||
m_CurParamsARB[n][0] = vData[0];
|
||||
m_CurParamsARB[n][1] = vData[1];
|
||||
m_CurParamsARB[n][2] = vData[2];
|
||||
m_CurParamsARB[n][3] = vData[3];
|
||||
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, n, vData);
|
||||
}
|
||||
vData += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
void mfParameter4f(SCGBind *ParamBind, const float *v)
|
||||
{
|
||||
mfParameter(ParamBind, v, 1);
|
||||
}
|
||||
SCGBind *mfGetParameterBind(const char *Name)
|
||||
{
|
||||
CName nm = CName(Name, eFN_Add);
|
||||
if (!m_Insts[m_CurInst].m_BindVars)
|
||||
m_Insts[m_CurInst].m_BindVars = new TArray<SCGBind>;
|
||||
|
||||
int i;
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
|
||||
{
|
||||
if (nm == m_Insts[m_CurInst].m_BindVars->Get(i).m_Name)
|
||||
return &m_Insts[m_CurInst].m_BindVars->Get(i);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void mfParameter4f(const char *Name, const float *v)
|
||||
{
|
||||
SCGBind *pBind = mfGetParameterBind(Name);
|
||||
if (pBind)
|
||||
mfParameter4f(pBind, v);
|
||||
}
|
||||
|
||||
virtual void mfEnable()
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
{
|
||||
if (m_Insts[m_CurInst].m_dwHandleExt)
|
||||
{
|
||||
glEnable(GL_TEXTURE_SHADER_NV);
|
||||
gRenDev->m_RP.m_PersFlags |= RBPF_TSWASSET;
|
||||
}
|
||||
if (m_Insts[m_CurInst].m_dwHandle)
|
||||
{
|
||||
glEnable(GL_REGISTER_COMBINERS_NV);
|
||||
gRenDev->m_RP.m_PersFlags |= RBPF_PS1WASSET;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBFP1)
|
||||
{
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
gRenDev->m_RP.m_PersFlags |= RBPF_PS2WASSET;
|
||||
}
|
||||
}
|
||||
virtual void mfDisable()
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
{
|
||||
if (m_Insts[m_CurInst].m_dwHandleExt)
|
||||
{
|
||||
glDisable(GL_TEXTURE_SHADER_NV);
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_TSWASSET;
|
||||
}
|
||||
if (m_Insts[m_CurInst].m_dwHandle)
|
||||
{
|
||||
glDisable(GL_REGISTER_COMBINERS_NV);
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_PS1WASSET;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBFP1)
|
||||
{
|
||||
glDisable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_PS2WASSET;
|
||||
}
|
||||
}
|
||||
|
||||
void mfFree();
|
||||
|
||||
void mfDel()
|
||||
{
|
||||
if(m_Insts[m_CurInst].m_dwHandle && m_Insts[m_CurInst].m_dwHandle != -1)
|
||||
{
|
||||
if (m_Insts[m_CurInst].m_BindConstants)
|
||||
delete m_Insts[m_CurInst].m_BindConstants;
|
||||
if (m_Insts[m_CurInst].m_BindVars)
|
||||
delete m_Insts[m_CurInst].m_BindVars;
|
||||
if (m_Insts[m_CurInst].m_ParamsNoObj)
|
||||
delete m_Insts[m_CurInst].m_ParamsNoObj;
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
glDeleteLists(m_Insts[m_CurInst].m_dwHandle, 1);
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBFP1)
|
||||
glDeleteProgramsARB(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
m_Insts[m_CurInst].m_dwHandle = 0;
|
||||
}
|
||||
if(m_Insts[m_CurInst].m_dwHandleExt && m_Insts[m_CurInst].m_dwHandleExt != -1)
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_FP20)
|
||||
glDeleteLists(m_Insts[m_CurInst].m_dwHandleExt, 1);
|
||||
m_Insts[m_CurInst].m_dwHandleExt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void mfSetVariables(TArray<SCGParam4f>* Parms);
|
||||
|
||||
bool mfIsValid(int Num) const { return (m_Insts[m_CurInst].m_dwHandle != 0); }
|
||||
void mfGetSrcFileName(char *srcname, int nSize);
|
||||
void mfGetDstFileName(char *dstname, int nSize);
|
||||
|
||||
public:
|
||||
char *mfGenerateScriptPS();
|
||||
char *mfCreateAdditionalPS();
|
||||
void mfCompileParam4f(char *scr, SShader *ef, TArray<SCGParam4f> *Params);
|
||||
bool mfActivate();
|
||||
|
||||
public:
|
||||
virtual ~CCGPShader_GL();
|
||||
virtual void Release();
|
||||
virtual bool mfCompile(char *scr);
|
||||
virtual bool mfSet(bool bStat, SShaderPassHW *slw=NULL, int nFLags=0);
|
||||
virtual void mfSetVariables(bool bObj, TArray<SCGParam4f>* Vars);
|
||||
virtual void mfReset();
|
||||
virtual void mfPrecache();
|
||||
virtual bool mfIsCombiner() { return false; }
|
||||
virtual void mfGatherFXParameters(const char *buf, SShaderPassHW *pSHPass, std::vector<SFXParam>& Params, std::vector<SFXSampler>& Samplers, std::vector<SFXTexture>& Textures, SShader *ef) {};
|
||||
virtual void mfPostLoad() {};
|
||||
char *mfGetObjectCode(CGprogram cgPr)
|
||||
{
|
||||
const char *code = cgGetProgramString(cgPr, CG_COMPILED_PROGRAM);
|
||||
int size = strlen(code)+1;
|
||||
char *str = new char[size];
|
||||
cryMemcpy(str, code, size);
|
||||
|
||||
return str;
|
||||
}
|
||||
static vec4_t m_CurParams[32];
|
||||
static vec4_t m_CurParamsARB[32];
|
||||
};
|
||||
|
||||
#ifdef WIN64
|
||||
#pragma warning( pop ) //AMD Port
|
||||
#endif
|
||||
|
||||
#endif // __GLCGPSHADER_H__
|
||||
1896
RenderDll/XRenderOGL/GLCGVProgram.cpp
Normal file
1896
RenderDll/XRenderOGL/GLCGVProgram.cpp
Normal file
File diff suppressed because it is too large
Load Diff
918
RenderDll/XRenderOGL/GLCGVProgram.h
Normal file
918
RenderDll/XRenderOGL/GLCGVProgram.h
Normal file
@@ -0,0 +1,918 @@
|
||||
/*=============================================================================
|
||||
GLCGVProgram.h : OpenGL CG programs interface declaration.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef __GLCGVPROGRAM_H__
|
||||
#define __GLCGVPROGRAM_H__
|
||||
|
||||
#include "cg\cgGL.h"
|
||||
|
||||
#define CG_VP_CACHE_VER 3.4
|
||||
|
||||
#define VSCONST_0_025_05_1 28
|
||||
#define VSCONST_FOG 29
|
||||
|
||||
#define PSCONST_HDR_FOGCOLOR 31
|
||||
|
||||
class CCGVProgram_GL : public CVProgram
|
||||
{
|
||||
SCGScript *m_Script;
|
||||
SCGScript *m_PosScript;
|
||||
SCGScript *m_SubroutinesScript;
|
||||
SCGScript *m_DeclarationsScript;
|
||||
SCGScript *m_CoreScript;
|
||||
SCGScript *m_InputParmsScript;
|
||||
|
||||
struct SCGInstance
|
||||
{
|
||||
int m_Mask;
|
||||
CName m_PosScriptName;
|
||||
TArray<SCGParam4f> *m_ParamsNoObj;
|
||||
TArray<SCGParam4f> *m_ParamsObj;
|
||||
TArray<SCGMatrix> *m_MatrixObj;
|
||||
uint m_dwHandle;
|
||||
TArray<SCGBindConst> *m_BindConstants;
|
||||
TArray<SCGBind> *m_BindVars;
|
||||
SCGInstance()
|
||||
{
|
||||
m_dwHandle = 0;
|
||||
m_ParamsNoObj = NULL;
|
||||
m_ParamsObj = NULL;
|
||||
m_MatrixObj = NULL;
|
||||
m_BindConstants = NULL;
|
||||
m_BindVars = NULL;
|
||||
}
|
||||
|
||||
int Size()
|
||||
{
|
||||
int nSize = sizeof(*this);
|
||||
if (m_ParamsNoObj)
|
||||
nSize += m_ParamsNoObj->GetMemoryUsage() + 12;
|
||||
if (m_ParamsObj)
|
||||
nSize += m_ParamsObj->GetMemoryUsage() + 12;
|
||||
if (m_MatrixObj)
|
||||
nSize += m_MatrixObj->GetMemoryUsage() + 12;
|
||||
if (m_BindConstants)
|
||||
nSize += m_BindConstants->GetMemoryUsage() + 12;
|
||||
if (m_BindVars)
|
||||
nSize += m_BindVars->GetMemoryUsage() + 12;
|
||||
|
||||
return nSize;
|
||||
}
|
||||
};
|
||||
|
||||
int m_CurInst;
|
||||
TArray<SCGInstance> m_Insts;
|
||||
TArray<SCGParam4f> m_ParamsNoObj;
|
||||
TArray<SCGParam4f> m_Params_Inst;
|
||||
TArray<SCGParam4f> m_ParamsObj;
|
||||
TArray<SCGMatrix> m_MatrixObj;
|
||||
TArray<SArrayPointer *> m_Pointers;
|
||||
|
||||
int m_dwFrame;
|
||||
|
||||
void mfSetPointers(int nType);
|
||||
|
||||
public:
|
||||
|
||||
virtual int Size()
|
||||
{
|
||||
int nSize = sizeof(*this);
|
||||
if (m_Script)
|
||||
nSize += m_Script->Size(false);
|
||||
if (m_PosScript)
|
||||
nSize += m_PosScript->Size(false);
|
||||
if (m_DeclarationsScript)
|
||||
nSize += m_DeclarationsScript->Size(false);
|
||||
if (m_CoreScript)
|
||||
nSize += m_CoreScript->Size(false);
|
||||
if (m_SubroutinesScript)
|
||||
nSize += m_SubroutinesScript->Size(false);
|
||||
if (m_InputParmsScript)
|
||||
nSize += m_InputParmsScript->Size(false);
|
||||
nSize += m_ParamsNoObj.GetMemoryUsage();
|
||||
nSize += m_ParamsObj.GetMemoryUsage();
|
||||
nSize += m_MatrixObj.GetMemoryUsage();
|
||||
nSize += m_Pointers.GetMemoryUsage();
|
||||
for (int i=0; i<m_Insts.GetSize(); i++)
|
||||
{
|
||||
if (i < m_Insts.Num())
|
||||
{
|
||||
SCGInstance *cgi = &m_Insts[i];
|
||||
nSize += cgi->Size();
|
||||
}
|
||||
else
|
||||
nSize += sizeof(SCGInstance);
|
||||
}
|
||||
return nSize;
|
||||
}
|
||||
|
||||
TArray<SCGParam4f> *mfGetParams(int Type)
|
||||
{
|
||||
if (!Type)
|
||||
return &m_ParamsNoObj;
|
||||
else
|
||||
return &m_ParamsObj;
|
||||
}
|
||||
|
||||
|
||||
int mfGetCGInstanceID(int Type, CVProgram *pPosVP)
|
||||
{
|
||||
CCGVProgram_GL *pVP = (CCGVProgram_GL *)pPosVP;
|
||||
SCGInstance *cgi;
|
||||
if (m_CurInst >= 0 && m_Insts.Num() > m_CurInst)
|
||||
{
|
||||
cgi = &m_Insts[m_CurInst];
|
||||
if (cgi->m_Mask == Type)
|
||||
{
|
||||
if (!pVP || !pVP->m_PosScript || pVP->m_PosScript->m_Name == cgi->m_PosScriptName)
|
||||
return m_CurInst;
|
||||
}
|
||||
}
|
||||
int i;
|
||||
for (i=0; i<m_Insts.Num(); i++)
|
||||
{
|
||||
cgi = &m_Insts[i];
|
||||
if (cgi->m_Mask == Type && (!pVP || !pVP->m_PosScript || pVP->m_PosScript->m_Name == cgi->m_PosScriptName))
|
||||
{
|
||||
m_CurInst = i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
SCGInstance cg;
|
||||
cg.m_Mask = Type;
|
||||
cg.m_ParamsNoObj = NULL;
|
||||
cg.m_ParamsObj = NULL;
|
||||
cg.m_MatrixObj = NULL;
|
||||
cg.m_BindConstants = NULL;
|
||||
cg.m_BindVars = NULL;
|
||||
if (Type & VPVST_CLIPPLANES3)
|
||||
{
|
||||
if (!cg.m_ParamsNoObj)
|
||||
cg.m_ParamsNoObj = new TArray<SCGParam4f>;
|
||||
SCGParam4f pr;
|
||||
pr.m_nComponents = 1;
|
||||
pr.m_dwBind = 0;
|
||||
pr.m_Name = "ClipPlane";
|
||||
SParamComp_ClipPlane p;
|
||||
pr.m_Flags = PF_CANMERGED;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
}
|
||||
if (Type & VPVST_TCMASK)
|
||||
{
|
||||
if (!cg.m_ParamsNoObj)
|
||||
cg.m_ParamsNoObj = new TArray<SCGParam4f>;
|
||||
int nm = VPVST_TCM0;
|
||||
int ngol = VPVST_TCGOL0;
|
||||
int ngrm = VPVST_TCGRM0;
|
||||
int ngsm = VPVST_TCGSM0;
|
||||
int ngnm = VPVST_TCGNM0;
|
||||
for (int i=0; i<4; i++)
|
||||
{
|
||||
char str[128];
|
||||
if (Type & (ngol<<i))
|
||||
{
|
||||
SCGParam4f pr;
|
||||
pr.m_nComponents = 4;
|
||||
pr.m_dwBind = 0;
|
||||
sprintf(str, "MatrixTCG%d", i);
|
||||
pr.m_Name = str;
|
||||
SParamComp_MatrixTCG p;
|
||||
pr.m_Flags = PF_CANMERGED;
|
||||
p.m_Stage = i;
|
||||
p.m_Row = 0;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
p.m_Row = 1;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
p.m_Row = 2;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
p.m_Row = 3;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
}
|
||||
if (Type & ((ngrm|ngsm)<<i))
|
||||
{
|
||||
SCGParam4f pr;
|
||||
pr.m_nComponents = 1;
|
||||
pr.m_dwBind = 0;
|
||||
pr.m_Name = "CameraPos";
|
||||
SParamComp_OSCameraPos p;
|
||||
pr.m_Flags = PF_CANMERGED;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
if (!cg.m_MatrixObj)
|
||||
cg.m_MatrixObj = new TArray<SCGMatrix>;
|
||||
SCGMatrix m;
|
||||
m.m_eCGParamType = ECGP_Matr_View;
|
||||
m.m_Name = "ModelView";
|
||||
cg.m_MatrixObj->AddElem(m);
|
||||
m.m_eCGParamType = ECGP_Matr_View_IT;
|
||||
m.m_Name = "ModelViewIT";
|
||||
cg.m_MatrixObj->AddElem(m);
|
||||
}
|
||||
if (Type & (ngnm<<i))
|
||||
{
|
||||
if (!cg.m_MatrixObj)
|
||||
cg.m_MatrixObj = new TArray<SCGMatrix>;
|
||||
SCGMatrix m;
|
||||
m.m_eCGParamType = ECGP_Matr_View_IT;
|
||||
m.m_Name = "ModelViewIT";
|
||||
cg.m_MatrixObj->AddElem(m);
|
||||
}
|
||||
if (Type & (nm<<i))
|
||||
{
|
||||
SCGParam4f pr;
|
||||
pr.m_nComponents = 4;
|
||||
pr.m_dwBind = 0;
|
||||
sprintf(str, "MatrixTCM%d", i);
|
||||
pr.m_Name = str;
|
||||
SParamComp_MatrixTCM p;
|
||||
pr.m_Flags = PF_CANMERGED;
|
||||
p.m_Stage = i;
|
||||
|
||||
p.m_Row = 0;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
p.m_Row = 1;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
p.m_Row = 2;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
|
||||
p.m_Row = 3;
|
||||
pr.m_Comps[0] = SParamComp::mfAdd(&p);
|
||||
cg.m_ParamsNoObj->AddElem(pr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pVP && pVP->m_PosScript)
|
||||
{
|
||||
cg.m_PosScriptName = pVP->m_PosScript->m_Name;
|
||||
if (cg.m_PosScriptName != m_PosScript->m_Name && pVP->m_ParamsNoObj.Num())
|
||||
{
|
||||
if (!cg.m_ParamsNoObj)
|
||||
cg.m_ParamsNoObj = new TArray<SCGParam4f>;
|
||||
for (int i=0; i<pVP->m_ParamsNoObj.Num(); i++)
|
||||
{
|
||||
cg.m_ParamsNoObj->AddElem(pVP->m_ParamsNoObj[i]);
|
||||
cg.m_ParamsNoObj->Get(cg.m_ParamsNoObj->Num()-1).m_dwBind = 0;
|
||||
}
|
||||
cg.m_ParamsNoObj->Shrink();
|
||||
}
|
||||
if (cg.m_PosScriptName != m_PosScript->m_Name && pVP->m_ParamsObj.Num())
|
||||
{
|
||||
if (!cg.m_ParamsObj)
|
||||
cg.m_ParamsObj = new TArray<SCGParam4f>;
|
||||
for (int i=0; i<pVP->m_ParamsObj.Num(); i++)
|
||||
{
|
||||
cg.m_ParamsObj->AddElem(pVP->m_ParamsObj[i]);
|
||||
cg.m_ParamsObj->Get(cg.m_ParamsObj->Num()-1).m_dwBind = 0;
|
||||
}
|
||||
cg.m_ParamsObj->Shrink();
|
||||
}
|
||||
}
|
||||
if (cg.m_ParamsNoObj)
|
||||
{
|
||||
TArray<SCGParam4f> ObjP;
|
||||
gRenDev->m_cEF.mfCheckObjectDependParams(cg.m_ParamsNoObj, &ObjP);
|
||||
if (ObjP.Num())
|
||||
{
|
||||
cg.m_ParamsObj = new TArray<SCGParam4f>;
|
||||
cg.m_ParamsObj->Copy(ObjP);
|
||||
}
|
||||
}
|
||||
m_CurInst = m_Insts.Num();
|
||||
m_Insts.AddElem(cg);
|
||||
return m_CurInst;
|
||||
}
|
||||
|
||||
CCGVProgram_GL(CGprofile ProfType)
|
||||
{
|
||||
m_CGProfileType = ProfType;
|
||||
mfInit();
|
||||
}
|
||||
CCGVProgram_GL()
|
||||
{
|
||||
#ifndef WIN64
|
||||
// NOTE: AMD64 port: find the 64-bit CG runtime
|
||||
m_CGProfileType = cgGLGetLatestProfile(CG_GL_VERTEX);
|
||||
if (m_CGProfileType != CG_PROFILE_VP20 && SUPPORTS_GL_ARB_vertex_program)
|
||||
#endif
|
||||
m_CGProfileType = CG_PROFILE_ARBVP1;
|
||||
if (CGLRenderer::CV_gl_vsforce11 && SUPPORTS_GL_NV_vertex_program)
|
||||
m_CGProfileType = CG_PROFILE_VP20;
|
||||
mfInit();
|
||||
}
|
||||
void mfSaveCGFile(const char *scr)
|
||||
{
|
||||
char name[1024];
|
||||
if (m_nMaskGen)
|
||||
sprintf(name, "%s(%x).cg", m_Name.c_str(), m_nMaskGen);
|
||||
else
|
||||
sprintf(name, "%s.cg", m_Name.c_str());
|
||||
FILE *fp = fopen(name, "w");
|
||||
fprintf(fp, scr);
|
||||
fclose (fp);
|
||||
}
|
||||
void mfInit()
|
||||
{
|
||||
#ifndef WIN64
|
||||
// NOTE: AMD64 port: find the 64-bit CG runtime
|
||||
if (!gcpOGL->m_CGContext)
|
||||
{
|
||||
gcpOGL->m_CGContext = cgCreateContext();
|
||||
assert(gcpOGL->m_CGContext != NULL);
|
||||
//CGSetCompilerExe("cgc.exe");
|
||||
|
||||
//cgSetErrorCallback(mfErrorCallback);
|
||||
}
|
||||
#endif
|
||||
m_dwFrame = 1;
|
||||
m_CurInst = -1;
|
||||
m_Flags = 0;
|
||||
m_Script = NULL;
|
||||
m_CoreScript = NULL;
|
||||
m_InputParmsScript = NULL;
|
||||
m_PosScript = NULL;
|
||||
m_SubroutinesScript = NULL;
|
||||
m_DeclarationsScript = NULL;
|
||||
}
|
||||
|
||||
void mfBind()
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
{
|
||||
glBindProgramNV(GL_VERTEX_PROGRAM_NV, m_Insts[m_CurInst].m_dwHandle);
|
||||
if (m_Insts[m_CurInst].m_BindConstants)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindConstants->Num(); i++)
|
||||
{
|
||||
SCGBindConst *p = &m_Insts[m_CurInst].m_BindConstants->Get(i);
|
||||
int n = p->m_dwBind;
|
||||
if (m_CurParams[n][0] != p->m_Val[0] || m_CurParams[n][1] != p->m_Val[1] || m_CurParams[n][2] != p->m_Val[2] || m_CurParams[n][3] != p->m_Val[3])
|
||||
{
|
||||
m_CurParams[n][0] = p->m_Val[0];
|
||||
m_CurParams[n][1] = p->m_Val[1];
|
||||
m_CurParams[n][2] = p->m_Val[2];
|
||||
m_CurParams[n][3] = p->m_Val[3];
|
||||
glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, p->m_dwBind, &p->m_Val[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBVP1)
|
||||
{
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, m_Insts[m_CurInst].m_dwHandle);
|
||||
if (m_Insts[m_CurInst].m_BindConstants)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindConstants->Num(); i++)
|
||||
{
|
||||
SCGBindConst *p = &m_Insts[m_CurInst].m_BindConstants->Get(i);
|
||||
int n = p->m_dwBind;
|
||||
if (m_CurParams[n][0] != p->m_Val[0] || m_CurParams[n][1] != p->m_Val[1] || m_CurParams[n][2] != p->m_Val[2] || m_CurParams[n][3] != p->m_Val[3])
|
||||
{
|
||||
m_CurParams[n][0] = p->m_Val[0];
|
||||
m_CurParams[n][1] = p->m_Val[1];
|
||||
m_CurParams[n][2] = p->m_Val[2];
|
||||
m_CurParams[n][3] = p->m_Val[3];
|
||||
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, p->m_dwBind, &p->m_Val[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mfUnbind()
|
||||
{
|
||||
//cgError Ret = cgGLBindProgram(NULL);
|
||||
}
|
||||
|
||||
char *mfLoadCG(const char *prog_text)
|
||||
{
|
||||
#ifndef WIN64
|
||||
// TODO: AMD64 port: find 64-bit CG
|
||||
const char *profileOpts[] =
|
||||
{
|
||||
"-DCGC=1",
|
||||
NULL,
|
||||
};
|
||||
cgGLSetOptimalOptions((CGprofile)m_CGProfileType);
|
||||
CGprogram cgPr = cgCreateProgram(gcpOGL->m_CGContext, CG_SOURCE, prog_text, (CGprofile)m_CGProfileType, "main", profileOpts);
|
||||
CGerror err = cgGetError();
|
||||
if (err != CG_NO_ERROR)
|
||||
{
|
||||
if ((m_Flags & PSFI_AUTOENUMTC) && m_CGProfileType == CG_PROFILE_VP20 && (gRenDev->GetFeatures() & RFT_HW_PS20))
|
||||
{
|
||||
#ifndef WIN64
|
||||
// NOTE: AMD64 port: find the 64-bit CG runtime
|
||||
m_CGProfileType = cgGLGetLatestProfile(CG_GL_VERTEX);
|
||||
#endif
|
||||
if (SUPPORTS_GL_ARB_vertex_program)
|
||||
m_CGProfileType = CG_PROFILE_ARBVP1;
|
||||
return mfLoadCG(prog_text);
|
||||
}
|
||||
Warning(0,0,"Couldn't create CG program '%s' (%s)", m_Name.c_str(), cgGetErrorString(err));
|
||||
mfSaveCGFile(prog_text);
|
||||
return NULL;
|
||||
}
|
||||
if (!cgPr)
|
||||
{
|
||||
iLog->Log("Couldn't find function '%s' in CG pixel program '%s'", "main", m_Name.c_str());
|
||||
return NULL;
|
||||
}
|
||||
char *code = mfGetObjectCode(cgPr);
|
||||
cgDestroyProgram(cgPr);
|
||||
return code;
|
||||
#else
|
||||
// make command for execution
|
||||
FILE *fp = fopen("$$in.cg", "w");
|
||||
if (!fp)
|
||||
return NULL;
|
||||
assert (*prog_text);
|
||||
fputs(prog_text, fp);
|
||||
fclose (fp);
|
||||
|
||||
char szCmdLine[512];
|
||||
sprintf(szCmdLine,
|
||||
"cgc.exe -profile %s -o $$out.cg $$in.cg",
|
||||
m_CGProfileType == CG_PROFILE_VP20 ? "vp20" : "arbvp1");
|
||||
|
||||
STARTUPINFO si;
|
||||
ZeroMemory( &si, sizeof(si) );
|
||||
si.cb = sizeof(si);
|
||||
si.dwX = 100;
|
||||
si.dwY = 100;
|
||||
si.dwFlags = STARTF_USEPOSITION;
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory( &pi, sizeof(pi) );
|
||||
if( !CreateProcess( NULL, // No module name (use command line).
|
||||
szCmdLine, // Command line.
|
||||
NULL, // Process handle not inheritable.
|
||||
NULL, // Thread handle not inheritable.
|
||||
FALSE, // Set handle inheritance to FALSE.
|
||||
CREATE_NO_WINDOW, // No creation flags.
|
||||
NULL, // Use parent's environment block.
|
||||
NULL/*szFolderName*/, // Set starting directory.
|
||||
&si, // Pointer to STARTUPINFO structure.
|
||||
&pi ) // Pointer to PROCESS_INFORMATION structure.
|
||||
)
|
||||
{
|
||||
iLog->LogError("CreateProcess failed: %s", szCmdLine);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (WAIT_OBJECT_0 != WaitForSingleObject (pi.hProcess, 10000))
|
||||
iLog->LogWarning ("CG runtime takes forever to compile.. waiting.. (last error %d)", GetLastError());
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
fp = fopen("$$out.cg", "rb");
|
||||
if (!fp)
|
||||
{
|
||||
Warning( 0,0,"CG compiler (cgc.exe) wasn't able to compile vertex shader '%s'", m_Name.c_str());
|
||||
mfSaveCGFile(prog_text);
|
||||
return NULL;
|
||||
}
|
||||
fseek(fp, 0, SEEK_END);
|
||||
int size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
if (size < 20)
|
||||
{
|
||||
Warning( 0,0,"CG compiler (cgc.exe) wasn't able to compile vertex shader '%s'", m_Name.c_str());
|
||||
mfSaveCGFile(prog_text);
|
||||
remove("$$in.cg");
|
||||
remove("$$out.cg");
|
||||
return NULL;
|
||||
}
|
||||
char *pBuf = new char[size+1];
|
||||
fread(pBuf, sizeof(char), size, fp);
|
||||
pBuf[size] = '\0';
|
||||
fclose(fp);
|
||||
remove("$$in.cg");
|
||||
remove("$$out.cg");
|
||||
|
||||
return pBuf;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WIN64
|
||||
#pragma warning( push ) //AMD Port
|
||||
#pragma warning( disable : 4267 )
|
||||
#endif
|
||||
|
||||
void mfLoad(const char *prog_text)
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
{
|
||||
glGenProgramsNV(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
int size = strlen(prog_text);
|
||||
glLoadProgramNV(GL_VERTEX_PROGRAM_NV, m_Insts[m_CurInst].m_dwHandle, size, (const GLubyte *)prog_text);
|
||||
GLint errpos = -1;
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_NV, &errpos);
|
||||
if(errpos != -1)
|
||||
{
|
||||
iLog->Log("Warning: VProgram error:\n");
|
||||
int bgn = errpos - 10;
|
||||
bgn < 0 ? 0 : bgn;
|
||||
const char * c = (const char *)(prog_text + bgn);
|
||||
for(int i = 0; i < 30; i++)
|
||||
{
|
||||
if(bgn+i >= int(size-1))
|
||||
break;
|
||||
iLog->Log("%c", *c++);
|
||||
}
|
||||
iLog->Log("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBVP1)
|
||||
{
|
||||
glGenProgramsARB(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, m_Insts[m_CurInst].m_dwHandle);
|
||||
int size = strlen(prog_text);
|
||||
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, size, (const GLubyte *)prog_text);
|
||||
GLint errpos;
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errpos);
|
||||
if(errpos != -1)
|
||||
{
|
||||
iLog->Log("Warning: VProgram error:\n");
|
||||
int bgn = errpos - 10;
|
||||
bgn < 0 ? 0 : bgn;
|
||||
const char * c = (const char *)(prog_text + bgn);
|
||||
for(int i = 0; i < 30; i++)
|
||||
{
|
||||
if(bgn+i >= int(size-1))
|
||||
break;
|
||||
iLog->Log("%c", *c++);
|
||||
}
|
||||
iLog->Log("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mfParameter(SCGBind *ParamBind, const float *v, int nComps)
|
||||
{
|
||||
int i;
|
||||
if (!ParamBind)
|
||||
return;
|
||||
if (!ParamBind->m_dwBind || ParamBind->m_dwFrameCreated != m_dwFrame)
|
||||
{
|
||||
ParamBind->m_dwFrameCreated = m_dwFrame;
|
||||
if (m_Insts[m_CurInst].m_BindVars)
|
||||
{
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
|
||||
{
|
||||
SCGBind *p = &m_Insts[m_CurInst].m_BindVars->Get(i);
|
||||
if (p->m_Name == ParamBind->m_Name)
|
||||
{
|
||||
assert(p->m_nComponents <= nComps);
|
||||
ParamBind->m_dwBind = p->m_dwBind;
|
||||
ParamBind->m_nBindComponents = p->m_nComponents;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == m_Insts[m_CurInst].m_BindVars->Num())
|
||||
ParamBind->m_dwBind = -1;
|
||||
}
|
||||
else
|
||||
ParamBind->m_dwBind = -1;
|
||||
if (ParamBind->m_dwBind == -1 && CRenderer::CV_r_shaderssave >= 2)
|
||||
iLog->Log("Warning: couldn't find parameter %s for vertex shader %s (%x)", ParamBind->m_Name.c_str(), m_Name.c_str(), m_nMaskGen);
|
||||
}
|
||||
if ((int)ParamBind->m_dwBind == -1)
|
||||
return;
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
{
|
||||
for (i=0; i<ParamBind->m_nBindComponents; i++)
|
||||
{
|
||||
int n = ParamBind->m_dwBind+i;
|
||||
if (m_CurParams[n][0] != v[0] || m_CurParams[n][1] != v[1] || m_CurParams[n][2] != v[2] || m_CurParams[n][3] != v[3])
|
||||
{
|
||||
m_CurParams[n][0] = v[0];
|
||||
m_CurParams[n][1] = v[1];
|
||||
m_CurParams[n][2] = v[2];
|
||||
m_CurParams[n][3] = v[3];
|
||||
glProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, n, v);
|
||||
}
|
||||
v += 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<ParamBind->m_nBindComponents; i++)
|
||||
{
|
||||
int n = ParamBind->m_dwBind+i;
|
||||
if (m_CurParams[n][0] != v[0] || m_CurParams[n][1] != v[1] || m_CurParams[n][2] != v[2] || m_CurParams[n][3] != v[3])
|
||||
{
|
||||
m_CurParams[n][0] = v[0];
|
||||
m_CurParams[n][1] = v[1];
|
||||
m_CurParams[n][2] = v[2];
|
||||
m_CurParams[n][3] = v[3];
|
||||
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, n, v);
|
||||
}
|
||||
v += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
void mfParameter4f(SCGBind *ParamBind, const float *v)
|
||||
{
|
||||
mfParameter(ParamBind, v, 1);
|
||||
}
|
||||
SCGBind *mfGetParameterBind(const char *Name)
|
||||
{
|
||||
CName nm = CName(Name, eFN_Add);
|
||||
if (!m_Insts[m_CurInst].m_BindVars)
|
||||
m_Insts[m_CurInst].m_BindVars = new TArray<SCGBind>;
|
||||
|
||||
int i;
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
|
||||
{
|
||||
if (nm == m_Insts[m_CurInst].m_BindVars->Get(i).m_Name)
|
||||
return &m_Insts[m_CurInst].m_BindVars->Get(i);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void mfParameter4f(const char *Name, const float *v)
|
||||
{
|
||||
SCGBind *pBind = mfGetParameterBind(Name);
|
||||
if (pBind)
|
||||
mfParameter4f(pBind, v);
|
||||
}
|
||||
|
||||
void mfParameterStateMatrix(SCGMatrix *tm)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!tm->m_dwBind || tm->m_dwFrameCreated != m_dwFrame)
|
||||
{
|
||||
tm->m_dwFrameCreated = m_dwFrame;
|
||||
if (m_Insts[m_CurInst].m_BindVars)
|
||||
{
|
||||
for (i=0; i<m_Insts[m_CurInst].m_BindVars->Num(); i++)
|
||||
{
|
||||
SCGBind *p = &m_Insts[m_CurInst].m_BindVars->Get(i);
|
||||
if (p->m_Name == tm->m_Name)
|
||||
{
|
||||
assert(p->m_nComponents == 4);
|
||||
tm->m_dwBind = p->m_dwBind;
|
||||
if (tm->m_dwBind == 0)
|
||||
tm->m_dwBind = 65536;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == m_Insts[m_CurInst].m_BindVars->Num())
|
||||
tm->m_dwBind = -1;
|
||||
}
|
||||
else
|
||||
tm->m_dwBind = -1;
|
||||
}
|
||||
if (tm->m_dwBind == -1)
|
||||
return;
|
||||
|
||||
float *v = NULL;
|
||||
Matrix44 m;
|
||||
CGLRenderer *r = gcpOGL;
|
||||
switch(tm->m_eCGParamType)
|
||||
{
|
||||
case ECGP_Matr_ViewProj:
|
||||
if (!(r->m_RP.m_ObjFlags & FOB_TRANS_MASK))
|
||||
{
|
||||
if (r->m_RP.m_PersFlags & RBPF_WASWORLDSPACE)
|
||||
break;
|
||||
r->m_RP.m_PersFlags |= RBPF_WASWORLDSPACE;
|
||||
}
|
||||
else
|
||||
r->m_RP.m_PersFlags &= ~RBPF_WASWORLDSPACE;
|
||||
if (m_FrameObj == r->m_RP.m_FrameObject)
|
||||
return;
|
||||
m_FrameObj = r->m_RP.m_FrameObject;
|
||||
mathMatrixTranspose(m.GetData(), r->m_RP.m_pCurObject->GetVPMatrix().GetData(), g_CpuFlags);
|
||||
v = m.GetData();
|
||||
break;
|
||||
case ECGP_Matr_View_IT:
|
||||
mathMatrixInverse(m.GetData(), r->m_ViewMatrix.GetData(), g_CpuFlags);
|
||||
v = m.GetData();
|
||||
break;
|
||||
case ECGP_Matr_View:
|
||||
m = r->m_ViewMatrix;
|
||||
mathMatrixTranspose(m.GetData(), m.GetData(), g_CpuFlags);
|
||||
v = m.GetData();
|
||||
break;
|
||||
case ECGP_Matr_View_I:
|
||||
mathMatrixInverse(m.GetData(), r->m_ViewMatrix.GetData(), g_CpuFlags);
|
||||
mathMatrixTranspose(m.GetData(), m.GetData(), g_CpuFlags);
|
||||
v = m.GetData();
|
||||
break;
|
||||
case ECGP_Matr_View_T:
|
||||
v = r->m_ViewMatrix.GetData();
|
||||
break;
|
||||
default:
|
||||
iLog->Log("Unknown matrix state type %d int CG program '%s'", m_Name.c_str());
|
||||
assert(0);
|
||||
}
|
||||
if (v)
|
||||
{
|
||||
int n = (tm->m_dwBind == 65536) ? 0 : tm->m_dwBind;
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
{
|
||||
glProgramParameters4fvNV(GL_VERTEX_PROGRAM_NV, n, 4, v);
|
||||
if (n)
|
||||
memcpy(&m_CurParams[n][0], v, 4*4*sizeof(float));
|
||||
}
|
||||
else
|
||||
{
|
||||
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, n, v);
|
||||
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, n+1, v+4);
|
||||
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, n+2, v+8);
|
||||
glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, n+3, v+12);
|
||||
if (n)
|
||||
memcpy(&m_CurParams[n][0], v, 4*4*sizeof(float));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mfEnable()
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
glEnable(GL_VERTEX_PROGRAM_NV);
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBVP1)
|
||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||
}
|
||||
void mfDisable()
|
||||
{
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
glDisable(GL_VERTEX_PROGRAM_NV);
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBVP1)
|
||||
glDisable(GL_VERTEX_PROGRAM_ARB);
|
||||
gRenDev->m_RP.m_PersFlags &= ~RBPF_VSWASSET;
|
||||
}
|
||||
|
||||
void mfFree();
|
||||
|
||||
void mfDel()
|
||||
{
|
||||
if(m_Insts[m_CurInst].m_dwHandle >= 0)
|
||||
{
|
||||
if (m_Insts[m_CurInst].m_BindConstants)
|
||||
delete m_Insts[m_CurInst].m_BindConstants;
|
||||
if (m_Insts[m_CurInst].m_BindVars)
|
||||
delete m_Insts[m_CurInst].m_BindVars;
|
||||
if (m_Insts[m_CurInst].m_ParamsNoObj)
|
||||
delete m_Insts[m_CurInst].m_ParamsNoObj;
|
||||
if (m_Insts[m_CurInst].m_MatrixObj)
|
||||
delete m_Insts[m_CurInst].m_MatrixObj;
|
||||
if (m_CGProfileType == CG_PROFILE_VP20)
|
||||
glDeleteProgramsNV(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
else
|
||||
if (m_CGProfileType == CG_PROFILE_ARBVP1)
|
||||
glDeleteProgramsARB(1, &m_Insts[m_CurInst].m_dwHandle);
|
||||
}
|
||||
m_Insts[m_CurInst].m_dwHandle = 0;
|
||||
}
|
||||
|
||||
void mfSetVariables(TArray<SCGParam4f>* Parms);
|
||||
|
||||
bool mfIsValid(int Num) const { return (m_Insts[m_CurInst].m_dwHandle != 0); }
|
||||
void mfGetSrcFileName(char *srcname, int nSize);
|
||||
void mfGetDstFileName(char *dstname, int nSize);
|
||||
|
||||
public:
|
||||
SCGScript *mfGenerateScriptVP(CVProgram *pVP);
|
||||
char *mfGenerateTCScript(char *Script, int nt);
|
||||
char *mfCreateAdditionalVP(CVProgram *pPosVP);
|
||||
void mfCompileParam4f(char *scr, SShader *ef, TArray<SCGParam4f> *Params);
|
||||
void mfCompileParamStateMatrix(char *scr, SShader *ef, TArray<SCGMatrix> *Params);
|
||||
void mfCompileVertAttributes(char *scr, SShader *ef);
|
||||
bool mfActivate(CVProgram *pPosVP);
|
||||
|
||||
public:
|
||||
virtual ~CCGVProgram_GL();
|
||||
virtual void Release();
|
||||
virtual bool mfCompile(char *scr);
|
||||
virtual bool mfSet(bool bStat, SShaderPassHW *slw, int nSetPointers=1);
|
||||
virtual void mfSetVariables(bool bObj, TArray<SCGParam4f>* Vars);
|
||||
virtual void mfReset();
|
||||
virtual void mfPrecache();
|
||||
virtual bool mfHasPointer(ESrcPointer ePtr);
|
||||
virtual void mfGatherFXParameters(const char *buf, SShaderPassHW *pSHPass, std::vector<SFXParam>& Params, std::vector<SFXSampler>& Samplers, std::vector<SFXTexture>& Textures, SShader *ef) {};
|
||||
virtual void mfPostLoad() {};
|
||||
virtual int mfVertexFormat(bool &bUseTangents, bool &bUseLM) { return 0; }
|
||||
virtual void mfSetStateMatrices()
|
||||
{
|
||||
//PROFILE_FRAME(Shader_VShadersMatr);
|
||||
for (int i=0; i<m_MatrixObj.Num(); i++)
|
||||
{
|
||||
SCGMatrix *tm = &m_MatrixObj[i];
|
||||
mfParameterStateMatrix(tm);
|
||||
}
|
||||
if (m_Insts[m_CurInst].m_MatrixObj)
|
||||
{
|
||||
for (int i=0; i<m_Insts[m_CurInst].m_MatrixObj->Num(); i++)
|
||||
{
|
||||
SCGMatrix *tm = &m_Insts[m_CurInst].m_MatrixObj->Get(i);
|
||||
mfParameterStateMatrix(tm);
|
||||
}
|
||||
}
|
||||
}
|
||||
static void mfSetGlobalParams();
|
||||
static bool m_bCreateNoise;
|
||||
|
||||
char *mfGetObjectCode(CGprogram cgPr)
|
||||
{
|
||||
const char *code = cgGetProgramString(cgPr, CG_COMPILED_PROGRAM);
|
||||
int size = strlen(code)+1;
|
||||
char *str = new char[size];
|
||||
cryMemcpy(str, code, size);
|
||||
return str;
|
||||
}
|
||||
static SCGScript *mfAddNewScript(const char *Name, const char *Script)
|
||||
{
|
||||
int i;
|
||||
if (Name)
|
||||
{
|
||||
CName nm = CName(Name);
|
||||
if (nm.GetIndex())
|
||||
{
|
||||
for (i=0; i<m_CGScripts.Num(); i++)
|
||||
{
|
||||
SCGScript *scr = m_CGScripts[i];
|
||||
if (!scr || !scr->m_Name.GetIndex())
|
||||
continue;
|
||||
if (nm == scr->m_Name)
|
||||
{
|
||||
if (!Script || stricmp(Script, scr->m_Script) == 0)
|
||||
return scr;
|
||||
delete [] scr->m_Script;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Script)
|
||||
{
|
||||
if (Name)
|
||||
iLog->Log("Error: CCGVProgram_GL::mfAddNewScript: Couldn't find CG script for name '%s'", Name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SCGScript *scr = new SCGScript;
|
||||
if (Name)
|
||||
scr->m_Name = CName(Name, eFN_Add);
|
||||
|
||||
int len = strlen(Script)+1;
|
||||
scr->m_Script = new char[len];
|
||||
strcpy(scr->m_Script, Script);
|
||||
|
||||
if (Name)
|
||||
m_CGScripts.AddElem(scr);
|
||||
|
||||
return scr;
|
||||
}
|
||||
static void mfDeleteSharedScripts()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<m_CGScripts.Num(); i++)
|
||||
{
|
||||
SCGScript *scr = m_CGScripts[i];
|
||||
if (!scr)
|
||||
continue;
|
||||
SAFE_DELETE_ARRAY(scr->m_Script);
|
||||
delete scr;
|
||||
m_CGScripts[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static TArray<SCGScript *> m_CGScripts;
|
||||
static vec4_t m_CurParams[96];
|
||||
static vec4_t m_CurParamsARB[96];
|
||||
};
|
||||
|
||||
#ifdef WIN64
|
||||
#pragma warning( pop ) //AMD Port
|
||||
#endif
|
||||
|
||||
#endif // __GLCGVPROGRAMS_H__
|
||||
216
RenderDll/XRenderOGL/GLCubeMaps.h
Normal file
216
RenderDll/XRenderOGL/GLCubeMaps.h
Normal file
@@ -0,0 +1,216 @@
|
||||
#ifndef GLCUBEMAPS_H
|
||||
#define GLCUBEMAPS_H
|
||||
|
||||
struct SSingleLight
|
||||
{
|
||||
typedef GLfloat Type;
|
||||
int components;
|
||||
GLenum type;
|
||||
GLenum format;
|
||||
SSingleLight(float _power) :
|
||||
components(3), format(GL_RGB), type(GL_FLOAT), power(_power) {}
|
||||
|
||||
void operator() (const Vec3d& v, Type * t)
|
||||
{
|
||||
float z = v[2] > 0 ? v[2] : 0;
|
||||
z = (float)cry_powf(z, power);
|
||||
t[0] = z;
|
||||
t[1] = z;
|
||||
t[2] = z;
|
||||
}
|
||||
float power;
|
||||
};
|
||||
|
||||
struct SNormalizeVector
|
||||
{
|
||||
typedef GLfloat Type;
|
||||
int components;
|
||||
GLenum type;
|
||||
GLenum format;
|
||||
SNormalizeVector() : components(3), format(GL_RGB), type(GL_FLOAT) {}
|
||||
|
||||
void operator() (const Vec3d & v, Type * t)
|
||||
{
|
||||
Vec3d v2 = v;
|
||||
v2 *= .5;
|
||||
t[0] = v2[0] + .5f;
|
||||
t[1] = v2[1] + .5f;
|
||||
t[2] = v2[2] + .5f;
|
||||
}
|
||||
};
|
||||
|
||||
// make a cube map from a functor
|
||||
template <class FunctionOfDirection> void MakeCubeMap(FunctionOfDirection & f, GLenum internal_format, int size, bool bMips, STexPic *tp)
|
||||
{
|
||||
typedef typename FunctionOfDirection::Type Type;
|
||||
int components = f.components;
|
||||
GLenum type = f.type;
|
||||
GLenum format = f.format;
|
||||
Type * ip;
|
||||
|
||||
int level = 0;
|
||||
|
||||
tp->Unlink();
|
||||
tp->Link(&STexPic::m_Root);
|
||||
gRenDev->m_TexMan->AddToHash(tp->m_Bind, tp);
|
||||
tp->m_Width = size;
|
||||
tp->m_Height = size;
|
||||
|
||||
tp->m_nMips = 0;
|
||||
tp->m_Size = 0;
|
||||
while (true)
|
||||
{
|
||||
float offset = .5;
|
||||
float delta = 1;
|
||||
float halfsize = size/2.f;
|
||||
Vec3d v;
|
||||
Type * image = new Type[size*size*components];
|
||||
byte * pixels = new byte[size*size*components];
|
||||
tp->m_Size += size*size*components;
|
||||
// positive x image
|
||||
{
|
||||
ip = image;
|
||||
for(int j = 0; j < size; j++)
|
||||
{
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
v[2] = -(i*delta + offset - halfsize);
|
||||
v[1] = -(j*delta + offset - halfsize);
|
||||
v[0] = halfsize;
|
||||
v.Normalize();
|
||||
f(v, ip);
|
||||
pixels[3*(j*size+i) + 0] = (byte)(255.0f*ip[0]);
|
||||
pixels[3*(j*size+i) + 1] = (byte)(255.0f*ip[1]);
|
||||
pixels[3*(j*size+i) + 2] = (byte)(255.0f*ip[2]);
|
||||
ip += components;
|
||||
}
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT, level, internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
// negative x image
|
||||
{
|
||||
ip = image;
|
||||
for(int j = 0; j < size; j++)
|
||||
{
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
v[2] = (i*delta + offset - halfsize);
|
||||
v[1] = -(j*delta + offset - halfsize);
|
||||
v[0] = -halfsize;
|
||||
v.Normalize();
|
||||
f(v, ip);
|
||||
pixels[3*(j*size+i) + 0] = (byte)(255.0f*ip[0]);
|
||||
pixels[3*(j*size+i) + 1] = (byte)(255.0f*ip[1]);
|
||||
pixels[3*(j*size+i) + 2] = (byte)(255.0f*ip[2]);
|
||||
ip += components;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT, level, internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
|
||||
// positive y image
|
||||
{
|
||||
ip = image;
|
||||
for(int j = 0; j < size; j++)
|
||||
{
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
v[0] = (i*delta + offset - halfsize);
|
||||
v[2] = (j*delta + offset - halfsize);
|
||||
v[1] = halfsize;
|
||||
v.Normalize();
|
||||
f(v, ip);
|
||||
pixels[3*(j*size+i) + 0] = (byte)(255.0f*ip[0]);
|
||||
pixels[3*(j*size+i) + 1] = (byte)(255.0f*ip[1]);
|
||||
pixels[3*(j*size+i) + 2] = (byte)(255.0f*ip[2]);
|
||||
ip += components;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT, level, internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
// negative y image
|
||||
{
|
||||
ip = image;
|
||||
for(int j = 0; j < size; j++)
|
||||
{
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
v[0] = (i*delta + offset - halfsize);
|
||||
v[2] = -(j*delta + offset - halfsize);
|
||||
v[1] = -halfsize;
|
||||
v.Normalize();
|
||||
f(v, ip);
|
||||
pixels[3*(j*size+i) + 0] = (byte)(255.0f*ip[0]);
|
||||
pixels[3*(j*size+i) + 1] = (byte)(255.0f*ip[1]);
|
||||
pixels[3*(j*size+i) + 2] = (byte)(255.0f*ip[2]);
|
||||
ip += components;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT, level, internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
|
||||
// positive z image
|
||||
{
|
||||
ip = image;
|
||||
for(int j = 0; j < size; j++)
|
||||
{
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
v[0] = (i*delta + offset - halfsize);
|
||||
v[1] = -(j*delta + offset - halfsize);
|
||||
v[2] = halfsize;
|
||||
v.Normalize();
|
||||
f(v, ip);
|
||||
pixels[3*(j*size+i) + 0] = (byte)(255.0f*ip[0]);
|
||||
pixels[3*(j*size+i) + 1] = (byte)(255.0f*ip[1]);
|
||||
pixels[3*(j*size+i) + 2] = (byte)(255.0f*ip[2]);
|
||||
ip += components;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT, level, internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
// negative z image
|
||||
{
|
||||
ip = image;
|
||||
for(int j = 0; j < size; j++)
|
||||
{
|
||||
for(int i=0; i < size; i++)
|
||||
{
|
||||
v[0] = -(i*delta + offset - halfsize);
|
||||
v[1] = -(j*delta + offset - halfsize);
|
||||
v[2] = -halfsize;
|
||||
v.Normalize();
|
||||
f(v, ip);
|
||||
pixels[3*(j*size+i) + 0] = (byte)(255.0f*ip[0]);
|
||||
pixels[3*(j*size+i) + 1] = (byte)(255.0f*ip[1]);
|
||||
pixels[3*(j*size+i) + 2] = (byte)(255.0f*ip[2]);
|
||||
ip += components;
|
||||
}
|
||||
}
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT, level, internal_format, size, size, 0, format, GL_UNSIGNED_BYTE, pixels);
|
||||
}
|
||||
delete [] image;
|
||||
delete [] pixels;
|
||||
size >>= 1;
|
||||
level++;
|
||||
if (!bMips || !size)
|
||||
break;
|
||||
}
|
||||
tp->m_nMips = level;
|
||||
tp->m_Size *= 6;
|
||||
gRenDev->m_TexMan->m_StatsCurTexMem += tp->m_Size;
|
||||
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
if (bMips)
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
else
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
gRenDev->m_TexMan->CheckTexLimits(NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
188
RenderDll/XRenderOGL/GLFont.cpp
Normal file
188
RenderDll/XRenderOGL/GLFont.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/*=============================================================================
|
||||
GLFont.cpp : OpenGL specific font functions.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
* Modified by M<>rcio Martins
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
|
||||
#include "..\..\CryFont\FBitmap.h"
|
||||
|
||||
int CGLRenderer::FontCreateTexture(int Width, int Height, byte *pData, ETEX_Format eTF)
|
||||
{
|
||||
if (!pData)
|
||||
return -1;
|
||||
|
||||
char szName[128];
|
||||
sprintf(szName, "$AutoFont_%d", m_TexGenID++);
|
||||
|
||||
int iFlags = FT_HASALPHA | FT_NOREMOVE | FT_FONT | FT_NOSTREAM | FT_NOMIPS;
|
||||
STexPic *tp = m_TexMan->CreateTexture(szName, Width, Height, 1, iFlags, 0, pData, eTT_Base, -1.0f, -1.0f, 0, NULL, 0, eTF);
|
||||
|
||||
return tp->GetTextureID();
|
||||
}
|
||||
|
||||
bool CGLRenderer::FontUpdateTexture(int nTexId, int X, int Y, int USize, int VSize, byte *pData)
|
||||
{
|
||||
STexPic *tp = gRenDev->m_TexMan->m_Textures[nTexId-TX_FIRSTBIND];
|
||||
assert (tp && tp->m_Bind == nTexId);
|
||||
if (tp)
|
||||
{
|
||||
m_TexMan->UpdateTextureRegion(tp, pData, X, Y, USize, VSize);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CGLRenderer::FontUploadTexture(class CFBitmap* pBmp, ETEX_Format eTF)
|
||||
{
|
||||
if(!pBmp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int *pData = new unsigned int[pBmp->GetWidth() * pBmp->GetHeight()];
|
||||
|
||||
if (!pData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pBmp->Get32Bpp(&pData);
|
||||
|
||||
char szName[128];
|
||||
sprintf(szName, "$Auto_%d", m_TexGenID++);
|
||||
|
||||
int iFlags = FT_HASALPHA | FT_NOREMOVE | FT_FONT | FT_NOMIPS;
|
||||
STexPic *tp = m_TexMan->CreateTexture(szName, pBmp->GetWidth(), pBmp->GetHeight(), 1, iFlags, 0, (unsigned char *)pData, eTT_Base, -1.0f, -1.0f, 0, NULL, 0, eTF);
|
||||
//int size = pBmp->GetWidth() * pBmp->GetHeight() * 4;
|
||||
//tp->m_pData32 = new byte[size];
|
||||
//memcpy(tp->m_pData32, pBmp->GetData(), size);
|
||||
|
||||
SAFE_DELETE_ARRAY(pData);
|
||||
|
||||
pBmp->SetRenderData((void *)tp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGLRenderer::FontReleaseTexture(class CFBitmap *pBmp)
|
||||
{
|
||||
if(!pBmp)
|
||||
return;
|
||||
|
||||
STexPic *tp = (STexPic *)pBmp->GetRenderData();
|
||||
tp->Release(false);
|
||||
}
|
||||
|
||||
void CGLRenderer::FontSetTexture(class CFBitmap* pBmp, int nFilterMode)
|
||||
{
|
||||
// NOTE: we don't have mips for font texture
|
||||
if (pBmp)
|
||||
{
|
||||
STexPic *tp = (STexPic *)pBmp->GetRenderData();
|
||||
tp->Set();
|
||||
}
|
||||
switch(nFilterMode)
|
||||
{
|
||||
case FILTER_LINEAR:
|
||||
default:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
case FILTER_BILINEAR:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
case FILTER_TRILINEAR:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
}
|
||||
EF_SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
}
|
||||
|
||||
void CGLRenderer::FontSetTexture(int nTexId, int nFilterMode)
|
||||
{
|
||||
// NOTE: we don't have mips for font texture
|
||||
STexPic *tp = gRenDev->m_TexMan->m_Textures[nTexId-TX_FIRSTBIND];
|
||||
assert (tp && tp->m_Bind == nTexId);
|
||||
tp->Set();
|
||||
//tp->SaveTGA("Font.tga", 0);
|
||||
switch(nFilterMode)
|
||||
{
|
||||
case FILTER_LINEAR:
|
||||
default:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
case FILTER_BILINEAR:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
case FILTER_TRILINEAR:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
}
|
||||
//EF_SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
}
|
||||
|
||||
void CGLRenderer::FontSetRenderingState(unsigned long nVPWidth, unsigned long nVPHeight)
|
||||
{
|
||||
GLSetCull(eCULL_None);
|
||||
EnableTMU(true);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, m_width, m_height, 0.0, -1.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
m_RP.m_FlagsPerFlush = 0;
|
||||
|
||||
EF_SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST | GS_ALPHATEST_GREATER0);
|
||||
|
||||
EF_SetColorOp(eCO_REPLACE, eCO_MODULATE, eCA_Diffuse | (eCA_Diffuse<<3), DEF_TEXARG0);
|
||||
}
|
||||
|
||||
// match table with the blending modes
|
||||
static int nBlendMatchTable[] =
|
||||
{
|
||||
GL_ZERO,
|
||||
GL_ONE,
|
||||
GL_SRC_COLOR,
|
||||
GL_ONE_MINUS_SRC_COLOR,
|
||||
GL_SRC_ALPHA,
|
||||
GL_ONE_MINUS_SRC_ALPHA,
|
||||
GL_DST_ALPHA,
|
||||
GL_ONE_MINUS_DST_ALPHA,
|
||||
GL_DST_COLOR,
|
||||
GL_ONE_MINUS_DST_COLOR,
|
||||
};
|
||||
|
||||
void CGLRenderer::FontSetBlending(int blendSrc, int blendDest)
|
||||
{
|
||||
}
|
||||
|
||||
void CGLRenderer::FontRestoreRenderingState()
|
||||
{
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
EF_SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
|
||||
SetPolygonMode(m_polygon_mode);
|
||||
}
|
||||
|
||||
1631
RenderDll/XRenderOGL/GLFuncs.h
Normal file
1631
RenderDll/XRenderOGL/GLFuncs.h
Normal file
File diff suppressed because it is too large
Load Diff
219
RenderDll/XRenderOGL/GLHelper.cpp
Normal file
219
RenderDll/XRenderOGL/GLHelper.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
/*=============================================================================
|
||||
GLHelper.cpp : OpenGL some useful functions implementation.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include <Cry_Math.h>
|
||||
#include "GL_Renderer.h"
|
||||
|
||||
|
||||
|
||||
static float sIdentity[4][4] =
|
||||
{
|
||||
{1,0,0,0},
|
||||
{0,1,0,0},
|
||||
{0,0,1,0},
|
||||
{0,0,0,1}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Transform a point (column vector) by a 4x4 matrix. I.e. out = m * in
|
||||
* Input: m - the 4x4 matrix
|
||||
* in - the 4x1 vector
|
||||
* Output: out - the resulting 4x1 vector.
|
||||
*/
|
||||
static void transform_point(float out[4], const float m[16], const float in[4])
|
||||
{
|
||||
#define M(row,col) m[col*4+row]
|
||||
out[0] = M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
|
||||
out[1] = M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3];
|
||||
out[2] = M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3];
|
||||
out[3] = M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3];
|
||||
#undef M
|
||||
}
|
||||
|
||||
/* projection du point (objx,objy,obz) sur l'ecran (winx,winy,winz) */
|
||||
int SGLFuncs::gluProject(float objx, float objy, float objz, const float model[16], const float proj[16], const int viewport[4], float * winx, float * winy, float * winz)
|
||||
{
|
||||
/* matrice de transformation */
|
||||
float in[4], out[4];
|
||||
/* initilise la matrice et le vecteur a transformer */
|
||||
in[0] = objx;
|
||||
in[1] = objy;
|
||||
in[2] = objz;
|
||||
in[3] = 1.0;
|
||||
transform_point(out, model, in);
|
||||
transform_point(in, proj, out);
|
||||
/* d'ou le resultat normalise entre -1 et 1 */
|
||||
if (in[3] == 0.0)
|
||||
return FALSE;
|
||||
in[0] /= in[3];
|
||||
in[1] /= in[3];
|
||||
in[2] /= in[3];
|
||||
/* en coordonnees ecran */
|
||||
*winx = viewport[0] + (1 + in[0]) * viewport[2] / 2.0f;
|
||||
*winy = viewport[1] + (1 + in[1]) * viewport[3] / 2.0f;
|
||||
/* entre 0 et 1 suivant z */
|
||||
*winz = (1 + in[2]) / 2;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int SGLFuncs::gluUnProject(float winx, float winy, float winz, const float model[16], const float proj[16], const int viewport[4], float * objx, float * objy, float * objz)
|
||||
{
|
||||
/* matrice de transformation */
|
||||
float m[16], A[16];
|
||||
float in[4], out[4];
|
||||
/* transformation coordonnees normalisees entre -1 et 1 */
|
||||
in[0] = (winx - viewport[0]) * 2 / viewport[2] - 1.0f;
|
||||
in[1] = (winy - viewport[1]) * 2 / viewport[3] - 1.0f;
|
||||
in[2] = 2.0f * winz - 1.0f;
|
||||
in[3] = 1.0;
|
||||
/* calcul transformation inverse */
|
||||
mathMatrixMultiply(A, (float *)proj, (float *)model, g_CpuFlags);
|
||||
mathMatrixInverse(m, A, g_CpuFlags);
|
||||
/* d'ou les coordonnees objets */
|
||||
transform_point(out, m, in);
|
||||
if (out[3] == 0.0)
|
||||
return false;
|
||||
*objx = out[0] / out[3];
|
||||
*objy = out[1] / out[3];
|
||||
*objz = out[2] / out[3];
|
||||
return true;
|
||||
}
|
||||
|
||||
void SGLFuncs::gluLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz, float *m)
|
||||
{
|
||||
float x[3], y[3], z[3];
|
||||
float mag;
|
||||
/* Make rotation matrix */
|
||||
/* Z vector */
|
||||
z[0] = eyex - centerx;
|
||||
z[1] = eyey - centery;
|
||||
z[2] = eyez - centerz;
|
||||
mag = cry_sqrtf(z[0] * z[0] + z[1] * z[1] + z[2] * z[2]);
|
||||
if (mag)
|
||||
{ /* mpichler, 19950515 */
|
||||
z[0] /= mag;
|
||||
z[1] /= mag;
|
||||
z[2] /= mag;
|
||||
}
|
||||
/* Y vector */
|
||||
y[0] = upx;
|
||||
y[1] = upy;
|
||||
y[2] = upz;
|
||||
/* X vector = Y cross Z */
|
||||
x[0] = y[1] * z[2] - y[2] * z[1];
|
||||
x[1] = -y[0] * z[2] + y[2] * z[0];
|
||||
x[2] = y[0] * z[1] - y[1] * z[0];
|
||||
/* Recompute Y = Z cross X */
|
||||
y[0] = z[1] * x[2] - z[2] * x[1];
|
||||
y[1] = -z[0] * x[2] + z[2] * x[0];
|
||||
y[2] = z[0] * x[1] - z[1] * x[0];
|
||||
/* mpichler, 19950515 */
|
||||
/* cross product gives area of parallelogram, which is < 1.0 for
|
||||
* non-perpendicular unit-length vectors; so normalize x, y here
|
||||
*/
|
||||
mag = cry_sqrtf(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
|
||||
if (mag)
|
||||
{
|
||||
x[0] /= mag;
|
||||
x[1] /= mag;
|
||||
x[2] /= mag;
|
||||
}
|
||||
mag = cry_sqrtf(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]);
|
||||
if (mag)
|
||||
{
|
||||
y[0] /= mag;
|
||||
y[1] /= mag;
|
||||
y[2] /= mag;
|
||||
}
|
||||
#define M(row,col) m[col*4+row]
|
||||
M(0, 0) = x[0];
|
||||
M(0, 1) = x[1];
|
||||
M(0, 2) = x[2];
|
||||
M(0, 3) = 0;
|
||||
M(1, 0) = y[0];
|
||||
M(1, 1) = y[1];
|
||||
M(1, 2) = y[2];
|
||||
M(1, 3) = 0;
|
||||
M(2, 0) = z[0];
|
||||
M(2, 1) = z[1];
|
||||
M(2, 2) = z[2];
|
||||
M(2, 3) = 0;
|
||||
M(3, 0) = 0;
|
||||
M(3, 1) = 0;
|
||||
M(3, 2) = 0;
|
||||
M(3, 3) = 1;
|
||||
#undef M
|
||||
glTranslate(m, -eyex, -eyey, -eyez);
|
||||
}
|
||||
|
||||
void SGLFuncs::glTranslate(float *m, float x, float y, float z)
|
||||
{
|
||||
m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
||||
m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
||||
m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
||||
m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
|
||||
}
|
||||
|
||||
void SGLFuncs::glRotate(float *m, float angle, float x, float y, float z)
|
||||
{
|
||||
float mr[16];
|
||||
|
||||
/* This function contributed by Erich Boleyn (erich@uruk.org) */
|
||||
float mag, s, c;
|
||||
float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c;
|
||||
angle = ( angle * PI ) / 180.0f;
|
||||
s = cry_sinf( angle );
|
||||
c = cry_cosf( angle );
|
||||
mag = cry_sqrtf( x*x + y*y + z*z );
|
||||
if (mag <= 1.0e-4)
|
||||
{
|
||||
/* generate an identity matrix and return */
|
||||
memcpy(m, sIdentity, sizeof(float)*16);
|
||||
}
|
||||
else
|
||||
{
|
||||
x /= mag;
|
||||
y /= mag;
|
||||
z /= mag;
|
||||
#define M(row,col) mr[col*4+row]
|
||||
xx = x * x;
|
||||
yy = y * y;
|
||||
zz = z * z;
|
||||
xy = x * y;
|
||||
yz = y * z;
|
||||
zx = z * x;
|
||||
xs = x * s;
|
||||
ys = y * s;
|
||||
zs = z * s;
|
||||
one_c = 1.0F - c;
|
||||
M(0,0) = (one_c * xx) + c;
|
||||
M(0,1) = (one_c * xy) - zs;
|
||||
M(0,2) = (one_c * zx) + ys;
|
||||
M(0,3) = 0.0F;
|
||||
M(1,0) = (one_c * xy) + zs;
|
||||
M(1,1) = (one_c * yy) + c;
|
||||
M(1,2) = (one_c * yz) - xs;
|
||||
M(1,3) = 0.0F;
|
||||
M(2,0) = (one_c * zx) - ys;
|
||||
M(2,1) = (one_c * yz) + xs;
|
||||
M(2,2) = (one_c * zz) + c;
|
||||
M(2,3) = 0.0F;
|
||||
M(3,0) = 0.0F;
|
||||
M(3,1) = 0.0F;
|
||||
M(3,2) = 0.0F;
|
||||
M(3,3) = 1.0F;
|
||||
}
|
||||
mathMatrixMultiply(m, m, mr, g_CpuFlags);
|
||||
}
|
||||
|
||||
3718
RenderDll/XRenderOGL/GLLog.cpp
Normal file
3718
RenderDll/XRenderOGL/GLLog.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1262
RenderDll/XRenderOGL/GLObjSprites.cpp
Normal file
1262
RenderDll/XRenderOGL/GLObjSprites.cpp
Normal file
File diff suppressed because it is too large
Load Diff
245
RenderDll/XRenderOGL/GLPBuffer.cpp
Normal file
245
RenderDll/XRenderOGL/GLPBuffer.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/*=============================================================================
|
||||
GLPBuffer.cpp : implementation of the NVidia Pixel Buffers.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honich Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include "GLPBuffer.h"
|
||||
|
||||
|
||||
CPBuffer::CPBuffer( int w, int h, unsigned int mode ) : m_Width(w), m_Height(h), m_Mode(mode), m_MyDC(NULL), m_MyGLctx(NULL), m_Buffer(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CPBuffer::~CPBuffer()
|
||||
{
|
||||
if (m_Buffer)
|
||||
{
|
||||
pwglDeleteContext(m_MyGLctx);
|
||||
wglReleasePbufferDCARB(m_Buffer, m_MyDC);
|
||||
wglDestroyPbufferARB(m_Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the pbuffer was lost.
|
||||
// If it was lost, destroy it and then recreate it.
|
||||
void CPBuffer::mfHandleModeSwitch()
|
||||
{
|
||||
int lost = 0;
|
||||
|
||||
wglQueryPbufferARB(m_Buffer, WGL_PBUFFER_LOST_ARB, &lost);
|
||||
|
||||
if ( lost )
|
||||
{
|
||||
this->~CPBuffer();
|
||||
mfInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
// This function actually does the creation of the p-buffer.
|
||||
// It can only be called once a window has already been created.
|
||||
bool CPBuffer::mfInitialize(bool bShare)
|
||||
{
|
||||
HDC hdc = pwglGetCurrentDC();
|
||||
HGLRC hglrc = pwglGetCurrentContext();
|
||||
|
||||
// Query for a suitable pixel format based on the specified mode.
|
||||
int iattributes[2*MAX_ATTRIBS];
|
||||
float fattributes[2*MAX_ATTRIBS];
|
||||
int nfattribs = 0;
|
||||
int niattribs = 0;
|
||||
|
||||
// Attribute arrays must be "0" terminated - for simplicity, first
|
||||
// just zero-out the array entire, then fill from left to right.
|
||||
for ( int a = 0; a < 2*MAX_ATTRIBS; a++ )
|
||||
{
|
||||
iattributes[a] = 0;
|
||||
fattributes[a] = 0;
|
||||
}
|
||||
|
||||
// Since we are trying to create a pbuffer, the pixel format we
|
||||
// request (and subsequently use) must be "p-buffer capable".
|
||||
iattributes[2*niattribs ] = WGL_DRAW_TO_PBUFFER_ARB;
|
||||
iattributes[2*niattribs+1] = true;
|
||||
niattribs++;
|
||||
|
||||
if (m_Mode & FPB_DRAWTOTEXTURE)
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_BIND_TO_TEXTURE_RGB_ARB;
|
||||
iattributes[2*niattribs+1] = true;
|
||||
niattribs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_Mode & FPB_INDEX )
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_PIXEL_TYPE_ARB;
|
||||
iattributes[2*niattribs+1] = WGL_TYPE_COLORINDEX_ARB; // Yikes!
|
||||
niattribs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_PIXEL_TYPE_ARB;
|
||||
iattributes[2*niattribs+1] = WGL_TYPE_RGBA_ARB;
|
||||
niattribs++;
|
||||
}
|
||||
|
||||
if ( m_Mode & FPB_DOUBLE )
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_DOUBLE_BUFFER_ARB;
|
||||
iattributes[2*niattribs+1] = true;
|
||||
niattribs++;
|
||||
}
|
||||
|
||||
if ( m_Mode & FPB_DEPTH )
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_DEPTH_BITS_ARB;
|
||||
iattributes[2*niattribs+1] = 1;
|
||||
niattribs++;
|
||||
}
|
||||
|
||||
if ( m_Mode & FPB_STENCIL )
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_STENCIL_BITS_ARB;
|
||||
iattributes[2*niattribs+1] = 1;
|
||||
niattribs++;
|
||||
}
|
||||
|
||||
if ( m_Mode & FPB_ACCUM )
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_ACCUM_BITS_ARB;
|
||||
iattributes[2*niattribs+1] = 1;
|
||||
niattribs++;
|
||||
}
|
||||
|
||||
iattributes[2*niattribs ] = WGL_SUPPORT_OPENGL_ARB;
|
||||
iattributes[2*niattribs+1] = true;
|
||||
niattribs++;
|
||||
}
|
||||
|
||||
int format;
|
||||
int pformat[MAX_PFORMATS];
|
||||
unsigned int nformats;
|
||||
if ( !wglChoosePixelFormatARB( hdc, iattributes, fattributes, MAX_PFORMATS, pformat, &nformats ) )
|
||||
{
|
||||
iLog->Log("Warning: PBuffer creation error: Couldn't find a suitable pixel format.\n" );
|
||||
return false;
|
||||
}
|
||||
format = pformat[0];
|
||||
|
||||
// Create the p-buffer.
|
||||
iattributes[0] = 0;
|
||||
niattribs = 0;
|
||||
if (m_Mode & FPB_DRAWTOTEXTURE)
|
||||
{
|
||||
iattributes[2*niattribs ] = WGL_TEXTURE_FORMAT_ARB;
|
||||
iattributes[2*niattribs+1] = WGL_TEXTURE_RGBA_ARB;
|
||||
niattribs++;
|
||||
|
||||
iattributes[2*niattribs ] = WGL_TEXTURE_TARGET_ARB;
|
||||
iattributes[2*niattribs+1] = WGL_TEXTURE_2D_ARB;
|
||||
niattribs++;
|
||||
|
||||
iattributes[2*niattribs ] = WGL_MIPMAP_TEXTURE_ARB;
|
||||
iattributes[2*niattribs+1] = 0;
|
||||
niattribs++;
|
||||
|
||||
iattributes[2*niattribs ] = WGL_PBUFFER_LARGEST_ARB;
|
||||
iattributes[2*niattribs+1] = 0;
|
||||
niattribs++;
|
||||
|
||||
iattributes[2*niattribs ] = 0;
|
||||
}
|
||||
m_Buffer = wglCreatePbufferARB( hdc, format, m_Width, m_Height, iattributes );
|
||||
if ( !m_Buffer )
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
iLog->Log("Warning: PBuffer creation error: wglCreatePbufferARB() failed\n" );
|
||||
if ( err == ERROR_INVALID_PIXEL_FORMAT )
|
||||
{
|
||||
iLog->Log("Warning: ERROR_INVALID_PIXEL_FORMAT\n" );
|
||||
}
|
||||
else
|
||||
if ( err == ERROR_NO_SYSTEM_RESOURCES )
|
||||
{
|
||||
iLog->Log("Warning: ERROR_NO_SYSTEM_RESOURCES\n" );
|
||||
}
|
||||
else
|
||||
if ( err == ERROR_INVALID_DATA )
|
||||
{
|
||||
iLog->Log("Warning: ERROR_INVALID_DATA\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the device context.
|
||||
m_MyDC = wglGetPbufferDCARB( m_Buffer );
|
||||
if ( !m_MyDC )
|
||||
{
|
||||
iLog->Log("Warning: PBuffer creation error: wglGetPbufferDCARB() failed\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a gl context for the p-buffer.
|
||||
m_MyGLctx = pwglCreateContext( m_MyDC );
|
||||
if ( !m_MyGLctx )
|
||||
{
|
||||
iLog->Log("Warning: PBuffer creation error: wglCreateContext() failed\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( bShare )
|
||||
{
|
||||
if( !pwglShareLists(hglrc, m_MyGLctx) )
|
||||
{
|
||||
iLog->Log("Warning: PBuffer: wglShareLists() failed\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the actual width and height we were able to create.
|
||||
wglQueryPbufferARB( m_Buffer, WGL_PBUFFER_WIDTH_ARB, &m_Width );
|
||||
wglQueryPbufferARB( m_Buffer, WGL_PBUFFER_HEIGHT_ARB, &m_Height );
|
||||
|
||||
#ifdef _DEBUG
|
||||
iLog->Log("Created a %d x %d PBuffer\n", m_Width, m_Height );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPBuffer::mfMakeCurrent()
|
||||
{
|
||||
if ( !pwglMakeCurrent( m_MyDC, m_MyGLctx ) )
|
||||
{
|
||||
iLog->Log("Warning: CPBuffer::mfMakeCurrent() failed.\n" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPBuffer::mfMakeMainCurrent()
|
||||
{
|
||||
CGLRenderer *rd = gcpOGL;
|
||||
if ( !pwglMakeCurrent( rd->m_CurrContext->m_hDC, rd->m_CurrContext->m_hRC ) )
|
||||
{
|
||||
iLog->Log("Warning: CPBuffer::mfMakeMainCurrent() failed.\n" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CPBuffer::mfTextureBind()
|
||||
{
|
||||
return wglBindTexImageARB(m_Buffer, WGL_FRONT_LEFT_ARB);
|
||||
}
|
||||
|
||||
BOOL CPBuffer::mfReleaseFromTexture()
|
||||
{
|
||||
return wglReleaseTexImageARB(m_Buffer, WGL_FRONT_LEFT_ARB);
|
||||
}
|
||||
44
RenderDll/XRenderOGL/GLPBuffer.h
Normal file
44
RenderDll/XRenderOGL/GLPBuffer.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
GLPBuffer.h : OpenGL PBuffer interface declaration.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef PBUFFERS_H
|
||||
#define PBUFFERS_H
|
||||
|
||||
#define MAX_PFORMATS 256
|
||||
#define MAX_ATTRIBS 32
|
||||
|
||||
#define FPB_SINGLE 1
|
||||
#define FPB_INDEX 2
|
||||
#define FPB_DOUBLE 4
|
||||
#define FPB_DEPTH 8
|
||||
#define FPB_STENCIL 0x10
|
||||
#define FPB_ACCUM 0x20
|
||||
#define FPB_DRAWTOTEXTURE 0x40
|
||||
|
||||
class CPBuffer
|
||||
{
|
||||
private:
|
||||
HDC m_MyDC; // Handle to a device context.
|
||||
HGLRC m_MyGLctx; // Handle to a GL context.
|
||||
HPBUFFERARB m_Buffer; // Handle to a pbuffer.
|
||||
unsigned int m_Mode; // Flags indicating the type of pbuffer.
|
||||
public:
|
||||
int m_Width;
|
||||
int m_Height;
|
||||
CPBuffer( int width, int height, unsigned int mode );
|
||||
~CPBuffer();
|
||||
void mfHandleModeSwitch();
|
||||
bool mfMakeCurrent();
|
||||
bool mfMakeMainCurrent();
|
||||
BOOL mfTextureBind();
|
||||
BOOL mfReleaseFromTexture();
|
||||
bool mfInitialize(bool share = false);
|
||||
};
|
||||
|
||||
#endif
|
||||
971
RenderDll/XRenderOGL/GLREOcean.cpp
Normal file
971
RenderDll/XRenderOGL/GLREOcean.cpp
Normal file
@@ -0,0 +1,971 @@
|
||||
/*=============================================================================
|
||||
GLREOcean.cpp : implementation of the Ocean Rendering.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include "I3dengine.h"
|
||||
#include "../Common/NvTriStrip/NVTriStrip.h"
|
||||
#include "GLCGVProgram.h"
|
||||
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
|
||||
//=======================================================================
|
||||
|
||||
void CREOcean::mfReset()
|
||||
{
|
||||
}
|
||||
|
||||
void CREOcean::GenerateIndices(int nLodCode)
|
||||
{
|
||||
SPrimitiveGroup pg;
|
||||
TArray<ushort> Indicies;
|
||||
int size;
|
||||
|
||||
if (m_OceanIndicies[nLodCode])
|
||||
return;
|
||||
SOceanIndicies *oi = new SOceanIndicies;
|
||||
m_OceanIndicies[nLodCode] = oi;
|
||||
if (!(nLodCode & ~LOD_MASK))
|
||||
{
|
||||
int nL = nLodCode & LOD_MASK;
|
||||
pg.offsIndex = 0;
|
||||
pg.numIndices = m_pIndices[nL].Num();
|
||||
pg.numTris = pg.numIndices-2;
|
||||
pg.type = PT_STRIP;
|
||||
oi->m_Groups.AddElem(pg);
|
||||
oi->m_nInds = pg.numIndices;
|
||||
int size = pg.numIndices * sizeof(ushort);
|
||||
oi->m_pIndicies = new ushort[size];
|
||||
memcpy(oi->m_pIndicies, &m_pIndices[nL][0], size);
|
||||
return;
|
||||
}
|
||||
int nLod = nLodCode & LOD_MASK;
|
||||
int nl = 1<<nLod;
|
||||
int nGrid = (OCEANGRID+1);
|
||||
// set indices
|
||||
int iIndex = nGrid*nl+nl;
|
||||
int yStep = nGrid * nl;
|
||||
for(int a=nl; a<nGrid-1-nl; a+=nl)
|
||||
{
|
||||
for(int i=nl; i<nGrid-nl; i+=nl, iIndex+=nl)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + yStep);
|
||||
}
|
||||
|
||||
int iNextIndex = (a+nl) * nGrid + nl;
|
||||
|
||||
// connect two strips by inserting two degenerated triangles
|
||||
if(a < nGrid-1-nl*2)
|
||||
{
|
||||
Indicies.AddElem(iIndex + yStep - nl);
|
||||
Indicies.AddElem(iNextIndex);
|
||||
}
|
||||
iIndex = iNextIndex;
|
||||
}
|
||||
pg.numIndices = Indicies.Num();
|
||||
pg.numTris = pg.numIndices-2;
|
||||
pg.type = PT_STRIP;
|
||||
pg.offsIndex = 0;
|
||||
oi->m_Groups.AddElem(pg);
|
||||
|
||||
// Left
|
||||
pg.offsIndex = Indicies.Num();
|
||||
iIndex = nGrid*(nGrid-1);
|
||||
if (!(nLodCode & (1<<LOD_LEFTSHIFT)))
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex - nGrid * nl + nl);
|
||||
Indicies.AddElem(iIndex - nGrid * nl);
|
||||
iIndex = iIndex - nGrid * nl + nl;
|
||||
yStep = -(nGrid * nl) - nl;
|
||||
for(int i=nl; i<nGrid-nl; i+=nl, iIndex-=nGrid*nl)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + yStep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0; i<nGrid-nl; i+=nl*2)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex - (nGrid * nl) + nl);
|
||||
Indicies.AddElem(iIndex - nGrid * nl * 2);
|
||||
if (i < nGrid-nl-nl*2)
|
||||
Indicies.AddElem(iIndex - nGrid * nl * 2 + nl);
|
||||
iIndex -= nGrid * nl * 2;
|
||||
}
|
||||
}
|
||||
pg.numIndices = Indicies.Num()-pg.offsIndex;
|
||||
pg.numTris = pg.numIndices-2;
|
||||
oi->m_Groups.AddElem(pg);
|
||||
|
||||
// Bottom
|
||||
pg.offsIndex = Indicies.Num();
|
||||
iIndex = 0;
|
||||
if (!(nLodCode & (1<<LOD_BOTTOMSHIFT)))
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + nGrid*nl + nl);
|
||||
Indicies.AddElem(iIndex + nl);
|
||||
iIndex = iIndex + nGrid*nl + nl;
|
||||
yStep = -(nGrid * nl) + nl;
|
||||
for(int i=nl; i<nGrid-nl; i+=nl, iIndex+=nl)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + yStep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0; i<nGrid-nl; i+=nl*2)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + (nGrid * nl) + nl);
|
||||
Indicies.AddElem(iIndex + nl * 2);
|
||||
if (i < nGrid-nl-nl*2)
|
||||
Indicies.AddElem(iIndex + nGrid * nl + nl * 2);
|
||||
iIndex += nl * 2;
|
||||
}
|
||||
}
|
||||
pg.numIndices = Indicies.Num()-pg.offsIndex;
|
||||
pg.numTris = pg.numIndices-2;
|
||||
oi->m_Groups.AddElem(pg);
|
||||
|
||||
// Right
|
||||
pg.offsIndex = Indicies.Num();
|
||||
iIndex = nGrid-1;
|
||||
if (!(nLodCode & (1<<LOD_RIGHTSHIFT)))
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + nGrid * nl - nl);
|
||||
Indicies.AddElem(iIndex + nGrid * nl);
|
||||
iIndex = iIndex + nGrid * nl - nl;
|
||||
yStep = nGrid * nl + nl;
|
||||
for(int i=nl; i<nGrid-nl; i+=nl, iIndex+=nGrid*nl)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + yStep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0; i<nGrid-nl; i+=nl*2)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + (nGrid * nl) - nl);
|
||||
Indicies.AddElem(iIndex + nGrid * nl * 2);
|
||||
if (i < nGrid-nl-nl*2)
|
||||
Indicies.AddElem(iIndex + nGrid * nl * 2 - nl);
|
||||
iIndex += nGrid * nl * 2;
|
||||
}
|
||||
}
|
||||
pg.numIndices = Indicies.Num()-pg.offsIndex;
|
||||
pg.numTris = pg.numIndices-2;
|
||||
oi->m_Groups.AddElem(pg);
|
||||
|
||||
// Top
|
||||
pg.offsIndex = Indicies.Num();
|
||||
iIndex = nGrid*(nGrid-1)+nGrid-1;
|
||||
if (!(nLodCode & (1<<LOD_TOPSHIFT)))
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex - nGrid*nl - nl);
|
||||
Indicies.AddElem(iIndex - nl);
|
||||
iIndex = iIndex - nGrid*nl - nl;
|
||||
yStep = nGrid * nl - nl;
|
||||
for(int i=nl; i<nGrid-nl; i+=nl, iIndex-=nl)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex + yStep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0; i<nGrid-nl; i+=nl*2)
|
||||
{
|
||||
Indicies.AddElem(iIndex);
|
||||
Indicies.AddElem(iIndex - (nGrid * nl) - nl);
|
||||
Indicies.AddElem(iIndex - nl * 2);
|
||||
if (i < nGrid-nl-nl*2)
|
||||
Indicies.AddElem(iIndex - nGrid * nl - nl * 2);
|
||||
iIndex -= nl * 2;
|
||||
}
|
||||
}
|
||||
pg.numIndices = Indicies.Num()-pg.offsIndex;
|
||||
pg.numTris = pg.numIndices-2;
|
||||
oi->m_Groups.AddElem(pg);
|
||||
|
||||
size = Indicies.Num()*sizeof(ushort);
|
||||
oi->m_pIndicies = new ushort[size];
|
||||
oi->m_nInds = Indicies.Num();
|
||||
cryMemcpy(oi->m_pIndicies, &Indicies[0], size);
|
||||
}
|
||||
|
||||
|
||||
void CREOcean::UpdateTexture()
|
||||
{
|
||||
if (m_CustomTexBind[0]>0 && !CRenderer::CV_r_oceantexupdate)
|
||||
return;
|
||||
|
||||
CGLRenderer *r = gcpOGL;
|
||||
float data[OCEANGRID][OCEANGRID][2];
|
||||
double time0 = 0;
|
||||
ticks(time0);
|
||||
if (m_CustomTexBind[0] <= 0)
|
||||
{
|
||||
uint tnum = 0;
|
||||
glGenTextures(1, &tnum);
|
||||
assert(tnum<14000);
|
||||
m_CustomTexBind[0] = tnum;
|
||||
r->SetTexture(tnum, eTT_Base);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DSDT_NV, OCEANGRID, OCEANGRID, 0, GL_DSDT_NV, GL_FLOAT, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
r->SetTexture(0, eTT_Base);
|
||||
}
|
||||
for(unsigned int y=0; y<OCEANGRID; y++)
|
||||
{
|
||||
for( unsigned int x=0; x<OCEANGRID; x++)
|
||||
{
|
||||
data[y][x][0] = m_Normals[y][x].x;
|
||||
data[y][x][1] = m_Normals[y][x].y;
|
||||
//data[y][x][2] = (byte)QRound(m_Normals[y][x].z * 127.0f);
|
||||
}
|
||||
}
|
||||
r->SetTexture(m_CustomTexBind[0], eTT_Base);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, OCEANGRID, OCEANGRID, GL_DSDT_NV, GL_FLOAT, &data[0][0][0]);
|
||||
r->SetTexture(0, eTT_Base);
|
||||
|
||||
unticks(time0);
|
||||
m_RS.m_StatsTimeTexUpdate = (float)(time0*1000.0*g_SecondsPerCycle);
|
||||
}
|
||||
|
||||
void CREOcean::DrawOceanSector(SOceanIndicies *oi)
|
||||
{
|
||||
for (int i=0; i<oi->m_Groups.Num(); i++)
|
||||
{
|
||||
SPrimitiveGroup *g = &oi->m_Groups[i];
|
||||
switch (g->type)
|
||||
{
|
||||
case PT_STRIP:
|
||||
glDrawElements(GL_TRIANGLE_STRIP, g->numIndices, GL_UNSIGNED_SHORT, &oi->m_pIndicies[g->offsIndex]);
|
||||
break;
|
||||
|
||||
case PT_LIST:
|
||||
glDrawElements(GL_TRIANGLES, g->numIndices, GL_UNSIGNED_SHORT, &oi->m_pIndicies[g->offsIndex]);
|
||||
break;
|
||||
|
||||
case PT_FAN:
|
||||
glDrawElements(GL_TRIANGLE_FAN, g->numIndices, GL_UNSIGNED_SHORT, &oi->m_pIndicies[g->offsIndex]);
|
||||
break;
|
||||
}
|
||||
gRenDev->m_nPolygons += g->numTris;
|
||||
}
|
||||
}
|
||||
|
||||
static _inline int Compare(SOceanSector *& p1, SOceanSector *& p2)
|
||||
{
|
||||
if(p1->m_Flags > p2->m_Flags)
|
||||
return 1;
|
||||
else
|
||||
if(p1->m_Flags < p2->m_Flags)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static _inline float sCalcSplash(SSplash *spl, float fX, float fY)
|
||||
{
|
||||
CGLRenderer *r = gcpOGL;
|
||||
|
||||
float fDeltaTime = r->m_RP.m_RealTime - spl->m_fStartTime;
|
||||
float fScaleFactor = 1.0f / (r->m_RP.m_RealTime - spl->m_fLastTime + 1.0f);
|
||||
|
||||
float vDelt[2];
|
||||
|
||||
// Calculate 2D distance
|
||||
vDelt[0] = spl->m_Pos[0] - fX; vDelt[1] = spl->m_Pos[1] - fY;
|
||||
float fSqDist = vDelt[0]*vDelt[0] + vDelt[1]*vDelt[1];
|
||||
|
||||
// Inverse square root
|
||||
unsigned int *n1 = (unsigned int *)&fSqDist;
|
||||
unsigned int nn = 0x5f3759df - (*n1 >> 1);
|
||||
float *n2 = (float *)&nn;
|
||||
float fDistSplash = 1.0f / ((1.5f - (fSqDist * 0.5f) * *n2 * *n2) * *n2);
|
||||
|
||||
// Emulate sin waves
|
||||
float fDistFactor = fDeltaTime*10.0f - fDistSplash + 4.0f;
|
||||
fDistFactor = CLAMP(fDistFactor, 0.0f, 1.0f);
|
||||
float fRad = (fDistSplash - fDeltaTime*10) * 0.4f / 3.1416f * 1024.0f;
|
||||
float fSin = gRenDev->m_RP.m_tSinTable[QRound(fRad)&0x3ff] * fDistFactor;
|
||||
|
||||
return fSin * fScaleFactor * spl->m_fForce;
|
||||
}
|
||||
|
||||
float *CREOcean::mfFillAdditionalBuffer(SOceanSector *os, int nSplashes, SSplash *pSplashes[], int& nCurSize, int nLod, float fSize)
|
||||
{
|
||||
CGLRenderer *r = gcpOGL;
|
||||
int nSize = sizeof(struct_VERTEX_FORMAT_P3F_N_COL4UB_TEX2F) * r->m_RP.m_MaxVerts / sizeof(float);
|
||||
|
||||
float *pHM, *pTZ;
|
||||
|
||||
//int nFloats = (os->m_Flags & OSF_NEEDHEIGHTS) ? 1 : 0;
|
||||
//if (nSplashes)
|
||||
// nFloats++;
|
||||
int nFloats = 2;
|
||||
|
||||
if (gcpOGL->m_RP.m_NumFences)
|
||||
{
|
||||
if (nCurSize+(OCEANGRID+1)*(OCEANGRID+1)*nFloats >= nSize)
|
||||
{
|
||||
nCurSize = 0;
|
||||
//r->EF_SetFence(true);
|
||||
}
|
||||
pTZ = &r->m_RP.m_Ptr.VBPtr_0->x+nCurSize;
|
||||
nCurSize += (OCEANGRID+1)*(OCEANGRID+1)*nFloats;
|
||||
}
|
||||
else
|
||||
pTZ = &gcpOGL->m_RP.m_Ptr.VBPtr_0->x;
|
||||
pHM = pTZ;
|
||||
int nStep = 1<<nLod;
|
||||
if (!nSplashes)
|
||||
{
|
||||
int nIncr = nStep*nFloats;
|
||||
for (int ty=0; ty<OCEANGRID+1; ty+=nStep)
|
||||
{
|
||||
pTZ = &pHM[ty*(OCEANGRID+1)*nFloats];
|
||||
for (int tx=0; tx<OCEANGRID+1; tx+=nStep)
|
||||
{
|
||||
float fX = m_Pos[ty][tx][0]*fSize+os->x;
|
||||
float fY = m_Pos[ty][tx][1]*fSize+os->y;
|
||||
float fZ = GetHMap(fX, fY);
|
||||
pTZ[0] = fZ;
|
||||
pTZ += nIncr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!(os->m_Flags & OSF_NEEDHEIGHTS))
|
||||
{
|
||||
for (int ty=0; ty<OCEANGRID+1; ty+=nStep)
|
||||
{
|
||||
pTZ = &pHM[ty*(OCEANGRID+1)*nFloats];
|
||||
for (int tx=0; tx<OCEANGRID+1; tx+=nStep)
|
||||
{
|
||||
float fX = m_Pos[ty][tx][0]*fSize+os->x;
|
||||
float fY = m_Pos[ty][tx][1]*fSize+os->y;
|
||||
float fSplash = 0;
|
||||
for (int n=0; n<nSplashes; n++)
|
||||
{
|
||||
SSplash *spl = pSplashes[n];
|
||||
fSplash += sCalcSplash(spl, fX, fY);
|
||||
}
|
||||
pTZ[1] = fSplash;
|
||||
pTZ += nStep*2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int ty=0; ty<OCEANGRID+1; ty+=nStep)
|
||||
{
|
||||
pTZ = &pHM[ty*(OCEANGRID+1)*2];
|
||||
for (int tx=0; tx<OCEANGRID+1; tx+=nStep)
|
||||
{
|
||||
float fX = m_Pos[ty][tx][0]*fSize+os->x;
|
||||
float fY = m_Pos[ty][tx][1]*fSize+os->y;
|
||||
float fZ = GetHMap(fX, fY);
|
||||
pTZ[0] = fZ;
|
||||
float fSplash = 0;
|
||||
for (int n=0; n<nSplashes; n++)
|
||||
{
|
||||
SSplash *spl = pSplashes[n];
|
||||
fSplash += sCalcSplash(spl, fX, fY);
|
||||
}
|
||||
pTZ[1] = fSplash; // / (float)nSplashes;
|
||||
pTZ += nStep*2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pHM;
|
||||
}
|
||||
|
||||
void CREOcean::mfDrawOceanSectors()
|
||||
{
|
||||
float x, y;
|
||||
CGLRenderer *r = gcpOGL;
|
||||
CVertexBuffer *vb = m_pBuffer;
|
||||
int i;
|
||||
|
||||
m_RS.m_StatsNumRendOceanSectors = 0;
|
||||
|
||||
ushort *saveInds = r->m_RP.m_RendIndices;
|
||||
I3DEngine *eng = (I3DEngine *)iSystem->GetI3DEngine();
|
||||
float fMaxDist = eng->GetMaxViewDistance() / 1.0f;
|
||||
CCamera cam = r->GetCamera();
|
||||
Vec3d mins;
|
||||
Vec3d maxs;
|
||||
Vec3d cameraPos = cam.GetPos();
|
||||
float fCurX = (float)((int)cameraPos[0] & ~255) + 128.0f;
|
||||
float fCurY = (float)((int)cameraPos[1] & ~255) + 128.0f;
|
||||
|
||||
float fSize = (float)CRenderer::CV_r_oceansectorsize;
|
||||
float fHeightScale = (float)CRenderer::CV_r_oceanheightscale;
|
||||
if (fSize != m_fSectorSize)
|
||||
{
|
||||
m_fSectorSize = fSize;
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
m_OceanSectorsHash[i].Free();
|
||||
}
|
||||
}
|
||||
float fWaterLevel = eng->GetWaterLevel();
|
||||
CVProgram *vp = NULL;
|
||||
int nMaxSplashes = CLAMP(CRenderer::CV_r_oceanmaxsplashes, 0, 16);
|
||||
|
||||
//x = y = 0;
|
||||
//x = fCurX;
|
||||
//y = fCurY;
|
||||
m_VisOceanSectors.SetUse(0);
|
||||
int osNear = -1;
|
||||
int nMinLod = 65536;
|
||||
for (y=fCurY-fMaxDist; y<fCurY+fMaxDist; y+=fSize)
|
||||
{
|
||||
for (x=fCurX-fMaxDist; x<fCurX+fMaxDist; x+=fSize)
|
||||
{
|
||||
SOceanSector *os = GetSectorByPos(x, y);
|
||||
if (!(os->m_Flags & (OSF_FIRSTTIME | OSF_VISIBLE)))
|
||||
continue;
|
||||
mins.x = x+m_MinBound.x*fSize;
|
||||
mins.y = y+m_MinBound.y*fSize;
|
||||
mins.z = fWaterLevel+m_MinBound.z*fHeightScale;
|
||||
maxs.x = x+fSize+m_MaxBound.x*fSize;
|
||||
maxs.y = y+fSize+m_MaxBound.y*fSize;
|
||||
maxs.z = fWaterLevel+m_MaxBound.z*fHeightScale;
|
||||
int cull = cam.IsAABBVisible_hierarchical( AABB(mins,maxs) );
|
||||
if (cull != CULL_EXCLUSION)
|
||||
{
|
||||
Vec3d vCenter = (mins + maxs) * 0.5f;
|
||||
os->nLod = GetLOD(cameraPos, vCenter);
|
||||
if (os->nLod < nMinLod)
|
||||
{
|
||||
nMinLod = os->nLod;
|
||||
osNear = m_VisOceanSectors.Num();
|
||||
}
|
||||
os->m_Frame = gRenDev->m_cEF.m_Frame;
|
||||
os->m_Flags &= ~OSF_LODUPDATED;
|
||||
m_VisOceanSectors.AddElem(os);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_VisOceanSectors.Num())
|
||||
{
|
||||
LinkVisSectors(fSize);
|
||||
::Sort(&m_VisOceanSectors[0], m_VisOceanSectors.Num());
|
||||
}
|
||||
bool bCurNeedBuffer = false;
|
||||
int nSize = sizeof(struct_VERTEX_FORMAT_P3F_N_COL4UB_TEX2F) * r->m_RP.m_MaxVerts / sizeof(float);
|
||||
int nCurSize = 0;
|
||||
float *pHM, *pTZ;
|
||||
int nIndVP = CRenderer::CV_r_waterreflections ? 0 : 1;
|
||||
for (i=0; i<m_VisOceanSectors.Num(); i++)
|
||||
{
|
||||
SOceanSector *os = m_VisOceanSectors[i];
|
||||
//if ((int)os != 0xf3888a0)
|
||||
// continue;
|
||||
int nLod = os->nLod;
|
||||
bool bL = (nLod < GetSectorByPos(os->x-fSize, os->y)->nLod);
|
||||
bool bR = (nLod < GetSectorByPos(os->x+fSize, os->y)->nLod);
|
||||
bool bT = (nLod < GetSectorByPos(os->x, os->y+fSize)->nLod);
|
||||
bool bB = (nLod < GetSectorByPos(os->x, os->y-fSize)->nLod);
|
||||
int nLodCode = nLod + (bL<<LOD_LEFTSHIFT) + (bR<<LOD_RIGHTSHIFT) + (bT<<LOD_TOPSHIFT) + (bB<<LOD_BOTTOMSHIFT);
|
||||
if (!m_OceanIndicies[nLodCode])
|
||||
GenerateIndices(nLodCode);
|
||||
int nSplashes = 0;
|
||||
SSplash *pSplashes[16];
|
||||
int nS;
|
||||
for (nS=0; nS<r->m_RP.m_Splashes.Num(); nS++)
|
||||
{
|
||||
SSplash *spl = &r->m_RP.m_Splashes[nS];
|
||||
float fCurRadius = spl->m_fCurRadius;
|
||||
if (spl->m_Pos[0]-fCurRadius > os->x+fSize ||
|
||||
spl->m_Pos[1]-fCurRadius > os->y+fSize ||
|
||||
spl->m_Pos[0]+fCurRadius < os->x ||
|
||||
spl->m_Pos[1]+fCurRadius < os->y)
|
||||
continue;
|
||||
pSplashes[nSplashes++] = spl;
|
||||
if (nSplashes == nMaxSplashes)
|
||||
break;
|
||||
}
|
||||
if (os->m_Flags & OSF_FIRSTTIME)
|
||||
{
|
||||
if (gcpOGL->m_RP.m_NumFences)
|
||||
{
|
||||
if (nCurSize+(OCEANGRID+1)*(OCEANGRID+1) >= nSize)
|
||||
{
|
||||
nCurSize = 0;
|
||||
//r->EF_SetFence(true);
|
||||
}
|
||||
pTZ = &r->m_RP.m_Ptr.VBPtr_0->x+nCurSize;
|
||||
nCurSize += (OCEANGRID+1)*(OCEANGRID+1);
|
||||
}
|
||||
else
|
||||
pTZ = &gcpOGL->m_RP.m_Ptr.VBPtr_0->x;
|
||||
pHM = pTZ;
|
||||
|
||||
float fMinLevel = 99999.0f;
|
||||
bool bBlend = false;
|
||||
bool bNeedHeights = false;
|
||||
for (uint ty=0; ty<OCEANGRID+1; ty++)
|
||||
{
|
||||
for (uint tx=0; tx<OCEANGRID+1; tx++)
|
||||
{
|
||||
float fX = m_Pos[ty][tx][0]*fSize+os->x;
|
||||
float fY = m_Pos[ty][tx][1]*fSize+os->y;
|
||||
float fZ = GetHMap(fX, fY);
|
||||
pTZ[0] = fZ;
|
||||
pTZ += 2;
|
||||
fMinLevel = min(fMinLevel, fZ);
|
||||
if (!bBlend && fWaterLevel-fZ <= 1.0f)
|
||||
bBlend = true;
|
||||
if (fWaterLevel-fZ < 16.0f)
|
||||
bNeedHeights = true;
|
||||
}
|
||||
}
|
||||
os->m_Flags &= ~OSF_FIRSTTIME;
|
||||
if (fMinLevel <= fWaterLevel)
|
||||
os->m_Flags |= OSF_VISIBLE;
|
||||
//bNeedHeights = bBlend = false;
|
||||
if (bNeedHeights)
|
||||
os->m_Flags |= OSF_NEEDHEIGHTS;
|
||||
if (bBlend)
|
||||
{
|
||||
os->m_Flags |= OSF_BLEND;
|
||||
os->RenderState = GS_DEPTHWRITE | GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA;
|
||||
}
|
||||
else
|
||||
os->RenderState = GS_DEPTHWRITE;
|
||||
}
|
||||
else
|
||||
if ((os->m_Flags & OSF_NEEDHEIGHTS) || nSplashes)
|
||||
pHM = mfFillAdditionalBuffer(os, nSplashes, pSplashes, nCurSize, nLod, fSize);
|
||||
m_RS.m_StatsNumRendOceanSectors++;
|
||||
|
||||
r->EF_SetState(os->RenderState);
|
||||
int nVP = 0;
|
||||
if (os->m_Flags & OSF_NEEDHEIGHTS)
|
||||
nVP += OVP_HEIGHT;
|
||||
if (nSplashes)
|
||||
nVP++;
|
||||
|
||||
CVProgram *curVP = m_VPs[nVP];
|
||||
if (!curVP)
|
||||
continue;
|
||||
if (vp != curVP)
|
||||
{
|
||||
vp = curVP;
|
||||
vp->mfSet(true, NULL, 0);
|
||||
}
|
||||
int nFloats = (os->m_Flags & OSF_NEEDHEIGHTS) ? 1 : 0;
|
||||
if (nSplashes)
|
||||
nFloats++;
|
||||
if (nFloats)
|
||||
{
|
||||
if (glVertexAttribPointerNV)
|
||||
glVertexAttribPointerNV(1, 2, GL_FLOAT, sizeof(float)*2, pHM);
|
||||
if (!bCurNeedBuffer)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY1_NV);
|
||||
bCurNeedBuffer = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (bCurNeedBuffer)
|
||||
{
|
||||
glDisableClientState(GL_VERTEX_ATTRIB_ARRAY1_NV);
|
||||
bCurNeedBuffer = false;
|
||||
}
|
||||
float param[4];
|
||||
param[0] = os->x;
|
||||
param[1] = os->y;
|
||||
param[2] = 0;
|
||||
param[3] = 0;
|
||||
CCGVProgram_GL *vpGL = (CCGVProgram_GL *)vp;
|
||||
SCGBind *pBind = vpGL->mfGetParameterBind("PosOffset");
|
||||
if (pBind)
|
||||
vpGL->mfParameter4f(pBind, param);
|
||||
pBind = vpGL->mfGetParameterBind("PosScale");
|
||||
param[0] = fSize;
|
||||
param[1] = fSize;
|
||||
param[2] = fHeightScale;
|
||||
param[3] = 1;
|
||||
if (pBind)
|
||||
vpGL->mfParameter4f(pBind, param);
|
||||
|
||||
/*if (nSplashes)
|
||||
{
|
||||
static Vec3d sPos;
|
||||
static float sTime;
|
||||
sPos = Vec3d(306, 1942, 0);
|
||||
if ((GetAsyncKeyState(VK_NUMPAD1) & 0x8000))
|
||||
sTime = r->m_RP.m_RealTime;
|
||||
float fForce = 1.5f;
|
||||
cgBindIter *pBind = vpGL->mfGetParameterBind("Splash1");
|
||||
|
||||
if (pBind)
|
||||
{
|
||||
param[0] = sPos[0];
|
||||
param[1] = sPos[1];
|
||||
param[2] = sPos[2];
|
||||
param[3] = 0;
|
||||
vpGL->mfParameter4f(pBind, param);
|
||||
}
|
||||
pBind = vpGL->mfGetParameterBind("Time");
|
||||
if (pBind)
|
||||
{
|
||||
float fDeltaTime = r->m_RP.m_RealTime - sTime;
|
||||
float fScaleFactor = 1.0f / (r->m_RP.m_RealTime - sTime + 1.0f);
|
||||
param[0] = fForce * fScaleFactor;
|
||||
param[1] = 0;
|
||||
param[2] = -fDeltaTime*10;
|
||||
param[3] = fDeltaTime*10.0f;
|
||||
vpGL->mfParameter4f(pBind, param);
|
||||
}
|
||||
}*/
|
||||
|
||||
DrawOceanSector(m_OceanIndicies[nLodCode]);
|
||||
//if (bCurNeedBuffer && glSetFenceNV)
|
||||
// glSetFenceNV(r->m_RP.mBufs[r->m_RP.m_CurFence].mFence, GL_ALL_COMPLETED_NV);
|
||||
}
|
||||
if (bCurNeedBuffer)
|
||||
glDisableClientState(GL_VERTEX_ATTRIB_ARRAY1_NV);
|
||||
|
||||
if (glSetFenceNV)
|
||||
glSetFenceNV(m_pBuffer->m_fence, GL_ALL_COMPLETED_NV);
|
||||
m_pBuffer->m_bFenceSet = true;
|
||||
}
|
||||
|
||||
#define A(row,col) a[(col<<2)+row]
|
||||
#define B(row,col) b[(col<<2)+row]
|
||||
#define P(row,col) product[(col<<2)+row]
|
||||
static void matmul4( GLfloat *product, const GLfloat *a, const GLfloat *b )
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
float ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
|
||||
P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
|
||||
P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
|
||||
P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
|
||||
P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
|
||||
}
|
||||
}
|
||||
#undef A
|
||||
#undef B
|
||||
#undef P
|
||||
|
||||
static void transform_point(float out[4], const float m[16], const float in[4])
|
||||
{
|
||||
#define M(row,col) m[col*4+row]
|
||||
out[0] = M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3];
|
||||
out[1] = M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3];
|
||||
out[2] = M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3];
|
||||
out[3] = M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3];
|
||||
#undef M
|
||||
}
|
||||
|
||||
void CREOcean::mfDrawOceanScreenLod()
|
||||
{
|
||||
CGLRenderer *r = gcpOGL;
|
||||
int nScreenY = r->GetHeight();
|
||||
int nScreenX = r->GetWidth();
|
||||
|
||||
if(!nScreenY || !nScreenX)
|
||||
return;
|
||||
|
||||
float ProjectionMatrix[16];
|
||||
float ModelMatrix[16];
|
||||
int Viewport[4];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, ModelMatrix);
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, ProjectionMatrix);
|
||||
glGetIntegerv(GL_VIEWPORT, Viewport);
|
||||
float m[16], A[16];
|
||||
matmul4(A, ProjectionMatrix, ModelMatrix);
|
||||
QQinvertMatrixf(m, A);
|
||||
|
||||
|
||||
m_DWQVertices.Free();
|
||||
m_DWQIndices.Free();
|
||||
|
||||
int fParts = 25;
|
||||
|
||||
int nScreenXP = nScreenX/fParts;
|
||||
int nScreenYP = nScreenY/fParts;
|
||||
|
||||
if(!nScreenYP || !nScreenXP)
|
||||
return;
|
||||
|
||||
unsigned short nIdx = 0;
|
||||
int y_size = int(float(nScreenY)/(nScreenYP)+1.f);
|
||||
|
||||
const Vec3d vCamPos = r->GetCamera().GetPos();
|
||||
|
||||
I3DEngine *eng = (I3DEngine *)iSystem->GetI3DEngine();
|
||||
float fWaterLevel = eng->GetWaterLevel();
|
||||
|
||||
int nSize = 256;
|
||||
float fSize = (float)nSize;
|
||||
float fiSize = 1.0f / fSize;
|
||||
|
||||
bool bWaterVisible = false;
|
||||
|
||||
float *pBuf, *pBuf1;
|
||||
//if (r->m_RP.m_NumFences)
|
||||
//r->EF_SetFence(true);
|
||||
pBuf = &r->m_RP.m_Ptr.VBPtr_0->x;
|
||||
pBuf1 = pBuf;
|
||||
|
||||
float fScale = fSize / OCEANGRID;
|
||||
float fiScale = 1.0f / fScale;
|
||||
|
||||
for(int x=0; x<=nScreenX/(nScreenXP)*(nScreenXP); x+=int(nScreenXP))
|
||||
{
|
||||
for(int y=0; y<=nScreenY/(nScreenYP)*(nScreenYP); y+=int(nScreenYP))
|
||||
{
|
||||
Vec3d n, p;
|
||||
|
||||
n((float)x, (float)y, 0.0f);
|
||||
|
||||
float in[4], out[4];
|
||||
/* transformation coordonnees normalisees entre -1 et 1 */
|
||||
in[0] = (n.x - Viewport[0]) * 2 / Viewport[2] - 1.0f;
|
||||
in[1] = (n.y - Viewport[1]) * 2 / Viewport[3] - 1.0f;
|
||||
in[2] = 2.0f * n.z - 1.0f;
|
||||
in[3] = 1.0;
|
||||
|
||||
transform_point(out, m, in);
|
||||
if (out[3] == 0.0f)
|
||||
continue;
|
||||
p.x = out[0] / out[3];
|
||||
p.y = out[1] / out[3];
|
||||
p.z = out[2] / out[3];
|
||||
//r->UnProjectFromScreen(n.x, n.y, n.z, &p.x, &p.y, &p.z);
|
||||
|
||||
float z1 = vCamPos.z - p.z;
|
||||
float t;
|
||||
if(z1<0.0001f)
|
||||
z1=0.0001f;
|
||||
|
||||
{
|
||||
float z2 = vCamPos.z - fWaterLevel;
|
||||
t = z2/z1;
|
||||
if( t > 300*(vCamPos.z - fWaterLevel) )
|
||||
t = 300*(vCamPos.z - fWaterLevel);
|
||||
p = p - vCamPos;
|
||||
p = vCamPos + p*t;
|
||||
}
|
||||
|
||||
float fX = p.x * fiScale;
|
||||
float fY = p.y * fiScale;
|
||||
long nX = QInt(fX);
|
||||
long nY = QInt(fY);
|
||||
register float dx = fX - (float)nX;
|
||||
register float dy = fY - (float)nY;
|
||||
register float dix = 1.0f - dx;
|
||||
register float diy = 1.0f - dy;
|
||||
nX &= OCEANGRID-1;
|
||||
nY &= OCEANGRID-1;
|
||||
fX = (float)QInt(p.x * fiSize);
|
||||
fY = (float)QInt(p.y * fiSize);
|
||||
long nX1 = (nX+1);// & (OCEANGRID-1);
|
||||
long nY1 = (nY+1);// & (OCEANGRID-1);
|
||||
|
||||
register float d0, d1;
|
||||
Vec3d Pos, Nor;
|
||||
d0 = dix * m_Pos[nY][nX][0] + dx * m_Pos[nY][nX1][0];
|
||||
d1 = dix * m_Pos[nY1][nX][0] + dx * m_Pos[nY1][nX1][0];
|
||||
Pos.x = (diy * d0 + dy * d1) + fX;
|
||||
|
||||
d0 = dix * m_Pos[nY][nX][1] + dx * m_Pos[nY][nX1][1];
|
||||
d1 = dix * m_Pos[nY1][nX][1] + dx * m_Pos[nY1][nX1][1];
|
||||
Pos.y = (diy * d0 + dy * d1) + fY;
|
||||
|
||||
d0 = dix * m_HX[nY][nX] + dx * m_HX[nY][nX1];
|
||||
d1 = dix * m_HX[nY1][nX] + dx * m_HX[nY1][nX1];
|
||||
Pos.z = -(diy * d0 + dy * d1);
|
||||
|
||||
d0 = dix * m_Normals[nY][nX].x + dx * m_Normals[nY][nX1].x;
|
||||
d1 = dix * m_Normals[nY1][nX].x + dx * m_Normals[nY1][nX1].x;
|
||||
Nor.x = diy * d0 + dy * d1;
|
||||
|
||||
d0 = dix * m_Normals[nY][nX].y + dx * m_Normals[nY][nX1].y;
|
||||
d1 = dix * m_Normals[nY1][nX].y + dx * m_Normals[nY1][nX1].y;
|
||||
Nor.y = diy * d0 + dy * d1;
|
||||
|
||||
d0 = dix * m_Normals[nY][nX].z + dx * m_Normals[nY][nX1].z;
|
||||
d1 = dix * m_Normals[nY1][nX].z + dx * m_Normals[nY1][nX1].z;
|
||||
Nor.z = diy * d0 + dy * d1;
|
||||
|
||||
pBuf1[0] = Pos.x;
|
||||
pBuf1[1] = Pos.y;
|
||||
pBuf1[2] = Pos.z;
|
||||
|
||||
pBuf1[3] = Nor.x;
|
||||
pBuf1[4] = Nor.y;
|
||||
pBuf1[5] = Nor.z;
|
||||
|
||||
float fZ = GetHMap(Pos.x * fSize, Pos.y * fSize);
|
||||
pBuf1[6] = fZ;
|
||||
|
||||
if(fZ <= fWaterLevel)
|
||||
bWaterVisible = true;
|
||||
|
||||
pBuf1 += 7;
|
||||
|
||||
if(x<nScreenX/(nScreenXP)*(nScreenXP) && y<nScreenY/(nScreenYP)*(nScreenYP) && fabs(p.z-fWaterLevel)<1)
|
||||
{
|
||||
unsigned short nIdx2 = nIdx+y_size;
|
||||
|
||||
unsigned short _nIdx = nIdx+1;
|
||||
unsigned short _nIdx2 = (nIdx+y_size)+1;
|
||||
|
||||
m_DWQIndices.Add(_nIdx);
|
||||
m_DWQIndices.Add(nIdx);
|
||||
m_DWQIndices.Add(nIdx2);
|
||||
|
||||
m_DWQIndices.Add(_nIdx);
|
||||
m_DWQIndices.Add(nIdx2);
|
||||
m_DWQIndices.Add(_nIdx2);
|
||||
}
|
||||
|
||||
nIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
r->EF_SetState(GS_DEPTHWRITE | GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA);
|
||||
|
||||
glVertexAttribPointerNV(0, 3, GL_FLOAT, sizeof(float)*7, pBuf);
|
||||
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY0_NV);
|
||||
glVertexAttribPointerNV(2, 3, GL_FLOAT, sizeof(float)*7, pBuf+3);
|
||||
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY2_NV);
|
||||
glVertexAttribPointerNV(1, 1, GL_FLOAT, sizeof(float)*7, pBuf+6);
|
||||
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY1_NV);
|
||||
|
||||
CVProgram *vp = m_VPQ;
|
||||
if (!vp)
|
||||
return;
|
||||
if (vp)
|
||||
vp->mfSet(true, false);
|
||||
|
||||
glDrawElements(GL_TRIANGLES, m_DWQIndices.Num(), GL_UNSIGNED_SHORT, &m_DWQIndices[0]);
|
||||
|
||||
if (vp)
|
||||
vp->mfSet(false, false);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ATTRIB_ARRAY2_NV);
|
||||
glDisableClientState(GL_VERTEX_ATTRIB_ARRAY1_NV);
|
||||
glDisableClientState(GL_VERTEX_ATTRIB_ARRAY0_NV);
|
||||
}
|
||||
|
||||
bool CREOcean::mfDraw(SShader *ef, SShaderPass *sfm)
|
||||
{
|
||||
double time0 = 0;
|
||||
ticks(time0);
|
||||
|
||||
if (CRenderer::CV_r_oceanrendtype == 0)
|
||||
mfDrawOceanSectors();
|
||||
else
|
||||
mfDrawOceanScreenLod();
|
||||
unticks(time0);
|
||||
m_RS.m_StatsTimeRendOcean = (float)(time0*1000.0*g_SecondsPerCycle);
|
||||
|
||||
// gRenDev->PostLoad();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CREOcean::mfPreDraw(SShaderPass *sl)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
char BoxSides[0x40*8] = {
|
||||
0,0,0,0, 0,0,0,0, //00
|
||||
0,4,6,2, 0,0,0,4, //01
|
||||
7,5,1,3, 0,0,0,4, //02
|
||||
0,0,0,0, 0,0,0,0, //03
|
||||
0,1,5,4, 0,0,0,4, //04
|
||||
0,1,5,4, 6,2,0,6, //05
|
||||
7,5,4,0, 1,3,0,6, //06
|
||||
0,0,0,0, 0,0,0,0, //07
|
||||
7,3,2,6, 0,0,0,4, //08
|
||||
0,4,6,7, 3,2,0,6, //09
|
||||
7,5,1,3, 2,6,0,6, //0a
|
||||
0,0,0,0, 0,0,0,0, //0b
|
||||
0,0,0,0, 0,0,0,0, //0c
|
||||
0,0,0,0, 0,0,0,0, //0d
|
||||
0,0,0,0, 0,0,0,0, //0e
|
||||
0,0,0,0, 0,0,0,0, //0f
|
||||
0,2,3,1, 0,0,0,4, //10
|
||||
0,4,6,2, 3,1,0,6, //11
|
||||
7,5,1,0, 2,3,0,6, //12
|
||||
0,0,0,0, 0,0,0,0, //13
|
||||
0,2,3,1, 5,4,0,6, //14
|
||||
1,5,4,6, 2,3,0,6, //15
|
||||
7,5,4,0, 2,3,0,6, //16
|
||||
0,0,0,0, 0,0,0,0, //17
|
||||
0,2,6,7, 3,1,0,6, //18
|
||||
0,4,6,7, 3,1,0,6, //19
|
||||
7,5,1,0, 2,6,0,6, //1a
|
||||
0,0,0,0, 0,0,0,0, //1b
|
||||
0,0,0,0, 0,0,0,0, //1c
|
||||
0,0,0,0, 0,0,0,0, //1d
|
||||
0,0,0,0, 0,0,0,0, //1e
|
||||
0,0,0,0, 0,0,0,0, //1f
|
||||
7,6,4,5, 0,0,0,4, //20
|
||||
0,4,5,7, 6,2,0,6, //21
|
||||
7,6,4,5, 1,3,0,6, //22
|
||||
0,0,0,0, 0,0,0,0, //23
|
||||
7,6,4,0, 1,5,0,6, //24
|
||||
0,1,5,7, 6,2,0,6, //25
|
||||
7,6,4,0, 1,3,0,6, //26
|
||||
0,0,0,0, 0,0,0,0, //27
|
||||
7,3,2,6, 4,5,0,6, //28
|
||||
0,4,5,7, 3,2,0,6, //29
|
||||
6,4,5,1, 3,2,0,6, //2a
|
||||
0,0,0,0, 0,0,0,0, //2b
|
||||
0,0,0,0, 0,0,0,0, //2c
|
||||
0,0,0,0, 0,0,0,0, //2d
|
||||
0,0,0,0, 0,0,0,0, //2e
|
||||
0,0,0,0, 0,0,0,0, //2f
|
||||
0,0,0,0, 0,0,0,0, //30
|
||||
0,0,0,0, 0,0,0,0, //31
|
||||
0,0,0,0, 0,0,0,0, //32
|
||||
0,0,0,0, 0,0,0,0, //33
|
||||
0,0,0,0, 0,0,0,0, //34
|
||||
0,0,0,0, 0,0,0,0, //35
|
||||
0,0,0,0, 0,0,0,0, //36
|
||||
0,0,0,0, 0,0,0,0, //37
|
||||
0,0,0,0, 0,0,0,0, //38
|
||||
0,0,0,0, 0,0,0,0, //39
|
||||
0,0,0,0, 0,0,0,0, //3a
|
||||
0,0,0,0, 0,0,0,0, //3b
|
||||
0,0,0,0, 0,0,0,0, //3c
|
||||
0,0,0,0, 0,0,0,0, //3d
|
||||
0,0,0,0, 0,0,0,0, //3e
|
||||
0,0,0,0, 0,0,0,0, //3f
|
||||
};
|
||||
1536
RenderDll/XRenderOGL/GLRERender.cpp
Normal file
1536
RenderDll/XRenderOGL/GLRERender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
306
RenderDll/XRenderOGL/GLREShadowVolume.cpp
Normal file
306
RenderDll/XRenderOGL/GLREShadowVolume.cpp
Normal file
@@ -0,0 +1,306 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek RenderDLL source code
|
||||
//
|
||||
// File: GLREShadowVolume.cpp
|
||||
//
|
||||
// History:
|
||||
// -October 18,2001:Created by Marco Corbetta
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include "I3dengine.h" // USE_SHADOW_VERSION
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//TODO: Move into renderer header
|
||||
#include "..\..\Cry3DEngine\ShadowVolumeEdge.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
bool CRETriMeshShadow::mfDraw(SShader *ef, SShaderPass *sfm)
|
||||
{
|
||||
if(m_nCurrInst<0 || m_nCurrInst>=MAX_SV_INSTANCES)
|
||||
{
|
||||
iLog->Log("Warning: CRETriMeshShadow::mfDraw: m_nCurrInst not set");
|
||||
return false;
|
||||
}
|
||||
|
||||
// assert(m_arrLBuffers[m_nCurrInst].pVB);
|
||||
|
||||
CGLRenderer *rd = gcpOGL;
|
||||
CDLight *pDL = NULL;
|
||||
if (rd->m_RP.m_DynLMask)
|
||||
{
|
||||
for (int n=0; n<rd->m_RP.m_DLights[SRendItem::m_RecurseLevel].Num(); n++)
|
||||
{
|
||||
if (rd->m_RP.m_DynLMask & (1<<n))
|
||||
{
|
||||
pDL = rd->m_RP.m_DLights[SRendItem::m_RecurseLevel][n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pDL && pDL->m_sWidth && pDL->m_sHeight)
|
||||
rd->EF_Scissor(true, pDL->m_sX, pDL->m_sY, pDL->m_sWidth, pDL->m_sHeight);
|
||||
|
||||
//disable blending, alpha testing,
|
||||
//z-writing - use the z-fail stencil method
|
||||
CGLTexMan::BindNULL(0);
|
||||
rd->EF_SetColorOp(eCO_DISABLE, eCO_DISABLE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
|
||||
if (rd->CV_ind_VisualizeShadowVolumes)
|
||||
{
|
||||
glColor4f(1,1,1,1);
|
||||
rd->EF_SetState(GS_NODEPTHTEST | GS_STENCIL);
|
||||
}
|
||||
else
|
||||
rd->EF_SetState(GS_NOCOLMASK | GS_STENCIL);
|
||||
|
||||
if(m_arrLBuffers[m_nCurrInst].pVB && m_arrLBuffers[m_nCurrInst].pVB->m_pVertexBuffer)
|
||||
{
|
||||
if (SUPPORTS_GL_ATI_separate_stencil || SUPPORTS_GL_EXT_stencil_two_side)
|
||||
{
|
||||
// using 2-sided stencil
|
||||
rd->EF_SetStencilState(STENCOP_FAIL(FSS_STENCOP_KEEP) |
|
||||
STENCOP_ZFAIL(FSS_STENCOP_DECR_WRAP) |
|
||||
STENCOP_PASS(FSS_STENCOP_KEEP) |
|
||||
STENC_FUNC(FSS_STENCFUNC_ALWAYS) |
|
||||
STENCOP_CCW_FAIL(FSS_STENCOP_KEEP) |
|
||||
STENCOP_CCW_ZFAIL(FSS_STENCOP_INCR_WRAP) |
|
||||
STENCOP_CCW_PASS(FSS_STENCOP_KEEP) |
|
||||
STENC_CCW_FUNC(FSS_STENCFUNC_ALWAYS) |
|
||||
FSS_STENCIL_TWOSIDED,
|
||||
0, -1);
|
||||
|
||||
rd->GLSetCull(eCULL_None);
|
||||
|
||||
CVertexBuffer * pVB = m_arrLBuffers[m_nCurrInst].pVB->m_pVertexBuffer;
|
||||
SVertexStream *Indices = &m_arrLBuffers[m_nCurrInst].pVB->m_Indices;
|
||||
int nIndices;
|
||||
if (m_nRendIndices)
|
||||
nIndices = m_nRendIndices;
|
||||
else
|
||||
nIndices = Indices->m_nItems;
|
||||
|
||||
assert(nIndices);
|
||||
|
||||
rd->DrawBuffer(pVB, Indices, nIndices, 0, R_PRIMV_TRIANGLES);
|
||||
|
||||
rd->SetFenceCompleted(pVB); // set it explicitly since second DrawBuffer do not set it
|
||||
|
||||
gRenDev->m_nShadowVolumePolys += (nIndices/3);
|
||||
}
|
||||
else
|
||||
{
|
||||
rd->EF_SetStencilState(STENCOP_FAIL(FSS_STENCOP_KEEP) |
|
||||
STENCOP_ZFAIL(FSS_STENCOP_INCR) |
|
||||
STENCOP_PASS(FSS_STENCOP_KEEP) |
|
||||
STENC_FUNC(FSS_STENCFUNC_ALWAYS),
|
||||
0, -1);
|
||||
|
||||
rd->GLSetCull(eCULL_Front);
|
||||
|
||||
CVertexBuffer * pVB = m_arrLBuffers[m_nCurrInst].pVB->m_pVertexBuffer;
|
||||
SVertexStream *Indices = &m_arrLBuffers[m_nCurrInst].pVB->m_Indices;
|
||||
int nIndices;
|
||||
if (m_nRendIndices)
|
||||
nIndices = m_nRendIndices;
|
||||
else
|
||||
nIndices = Indices->m_nItems;
|
||||
|
||||
assert(nIndices);
|
||||
|
||||
rd->DrawBuffer(pVB, Indices, nIndices, 0, R_PRIMV_TRIANGLES);
|
||||
|
||||
rd->EF_SetStencilState(STENCOP_FAIL(FSS_STENCOP_KEEP) |
|
||||
STENCOP_ZFAIL(FSS_STENCOP_DECR) |
|
||||
STENCOP_PASS(FSS_STENCOP_KEEP) |
|
||||
STENC_FUNC(FSS_STENCFUNC_ALWAYS),
|
||||
0, -1);
|
||||
rd->GLSetCull(eCULL_Back);
|
||||
|
||||
rd->DrawBuffer(pVB, Indices, nIndices, 0, R_PRIMV_TRIANGLES);
|
||||
|
||||
rd->SetFenceCompleted(pVB); // set it explicitly since second DrawBuffer do not set it
|
||||
|
||||
gRenDev->m_nShadowVolumePolys += (nIndices*2/3);
|
||||
}
|
||||
}
|
||||
|
||||
m_nCurrInst = -1;
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
//TODO: BackFace culling
|
||||
//TODO: put into vertex buffer
|
||||
///////////////////////////////////////////////////////////////////
|
||||
bool CRETriMeshAdditionalShadow::mfDraw(SShader *ef, SShaderPass *sfm)
|
||||
{
|
||||
int k;
|
||||
|
||||
/*
|
||||
//cull front-facing
|
||||
glCullFace(GL_FRONT);
|
||||
|
||||
//first draw all back-facing and set z-buffer
|
||||
glColorMask(0,0,0,0);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
//glDisable(GL_CULL_FACE);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (k=0;k<m_nNumFaces;k++)
|
||||
{
|
||||
CObjFace *pFace=&m_pFacesList[k];
|
||||
if (!pFace->m_bLit)
|
||||
{
|
||||
glVertex3fv(&pFace->m_Vecs[0].x);
|
||||
glVertex3fv(&pFace->m_Vecs[1].x);
|
||||
glVertex3fv(&pFace->m_Vecs[2].x);
|
||||
}
|
||||
} //k
|
||||
glEnd();
|
||||
|
||||
|
||||
glColorMask(1,1,1,1);
|
||||
glDepthFunc(GL_EQUAL);
|
||||
//glDepthFunc(GL_LEQUAL);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ZERO,GL_SRC_COLOR);
|
||||
//glBlendFunc(GL_DST_COLOR,GL_ZERO);
|
||||
|
||||
//if (m_pTexture)
|
||||
if (0)
|
||||
{
|
||||
gRenDev->SetTexture(m_pTexture->m_Bind);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
CShadowVolEdge *pEdge;
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
for (k=0;k<m_nNumFaces;k++)
|
||||
{
|
||||
CObjFace *pFace=&m_pFacesList[k];
|
||||
if (pFace->m_bLit || (pFace->m_dwFlags&FLAG_BLACK_FACE))
|
||||
continue;
|
||||
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
//glTexCoord2f(pFace->m_fCoords[i][0],pFace->m_fCoords[i][1]);
|
||||
pEdge=pFace->m_pEdges[i];
|
||||
glColor3fv(&pFace->m_vColors[i].r);
|
||||
glVertex3fv(&pFace->m_Vecs[i].x);
|
||||
} //i
|
||||
} //k
|
||||
glEnd();
|
||||
|
||||
//return to previous state
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glColorMask(1,1,1,1);
|
||||
*//*
|
||||
|
||||
glDepthMask(0);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
//glEnable(GL_LINE_SMOOTH);
|
||||
//glLineWidth(8.0f);
|
||||
|
||||
//glPushMatrix();
|
||||
//glTranslatef(m_vOrigin.x,m_vOrigin.y,m_vOrigin.z);
|
||||
|
||||
//glDisable(GL_BLEND);
|
||||
glEnable(GL_BLEND);
|
||||
//glBlendFunc(GL_ZERO,GL_SRC_COLOR);
|
||||
glBlendFunc(GL_DST_COLOR,GL_ZERO);
|
||||
|
||||
float fDarkness=0.0f;
|
||||
|
||||
//glPolygonOffset(1.1f,4.0f);
|
||||
//glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for (k=0;k<m_nNumEdges;k++)
|
||||
{
|
||||
CShadowVolEdge *pEdge=&m_pShadowVolEdgesList[k];
|
||||
if ((!(pEdge->m_pAddEdge->m_dwFlags & FLAG_FALSE_EDGE_SILOHUETTE)) && (pEdge->m_pFace1->m_bLit!=pEdge->m_pFace2->m_bLit))
|
||||
{
|
||||
//glBegin(GL_LINE_LOOP);
|
||||
glColor3f(fDarkness,fDarkness,fDarkness);
|
||||
glVertex3fv(&pEdge->m_vecV0.x);
|
||||
glColor3f(1,1,1);
|
||||
glVertex3fv(&pEdge->m_pAddEdge->m_vExtrOut[0].x);
|
||||
glColor3f(1,1,1);
|
||||
glVertex3fv(&pEdge->m_pAddEdge->m_vExtrOut[1].x);
|
||||
glColor3f(fDarkness,fDarkness,fDarkness);
|
||||
glVertex3fv(&pEdge->m_vecV1.x);
|
||||
gRenDev->m_nPolygons += 2;
|
||||
//glEnd();
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
if (gRenDev->CV_ind_DrawBorderEdges)
|
||||
{
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
//glPolygonOffset(1.1f,4.0f);
|
||||
//glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
|
||||
glColor3f(fDarkness,fDarkness,fDarkness);
|
||||
//glColor3f(1,0,0);
|
||||
glBegin(GL_QUADS);
|
||||
for (k=0;k<m_nNumEdges;k++)
|
||||
{
|
||||
CShadowVolEdge *pEdge=&m_pShadowVolEdgesList[k];
|
||||
if ((!(pEdge->m_pAddEdge->m_dwFlags & FLAG_FALSE_EDGE_SILOHUETTE)) && (pEdge->m_pFace1->m_bLit!=pEdge->m_pFace2->m_bLit))
|
||||
{
|
||||
glColor3f(fDarkness,fDarkness,fDarkness);
|
||||
glVertex3fv(&pEdge->m_vecV0.x);
|
||||
glColor3f(1,1,1);
|
||||
glVertex3fv(&pEdge->m_pAddEdge->m_vExtrIn[0].x);
|
||||
glColor3f(1,1,1);
|
||||
glVertex3fv(&pEdge->m_pAddEdge->m_vExtrIn[1].x);
|
||||
glColor3f(fDarkness,fDarkness,fDarkness);
|
||||
glVertex3fv(&pEdge->m_vecV1.x);
|
||||
gRenDev->m_nPolygons += 2;
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
//glPopMatrix();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glLineWidth(1.0f);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glDepthMask(1);
|
||||
|
||||
return (true);
|
||||
}
|
||||
*/
|
||||
8054
RenderDll/XRenderOGL/GLRendPipeline.cpp
Normal file
8054
RenderDll/XRenderOGL/GLRendPipeline.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1753
RenderDll/XRenderOGL/GLScreenRender.cpp
Normal file
1753
RenderDll/XRenderOGL/GLScreenRender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1864
RenderDll/XRenderOGL/GLShaders.cpp
Normal file
1864
RenderDll/XRenderOGL/GLShaders.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2506
RenderDll/XRenderOGL/GLSystem.cpp
Normal file
2506
RenderDll/XRenderOGL/GLSystem.cpp
Normal file
File diff suppressed because it is too large
Load Diff
5949
RenderDll/XRenderOGL/GLTextures.cpp
Normal file
5949
RenderDll/XRenderOGL/GLTextures.cpp
Normal file
File diff suppressed because it is too large
Load Diff
267
RenderDll/XRenderOGL/GLTexturesStreaming.cpp
Normal file
267
RenderDll/XRenderOGL/GLTexturesStreaming.cpp
Normal file
@@ -0,0 +1,267 @@
|
||||
/*=============================================================================
|
||||
GLTexturesStreaming.cpp : OpenGL specific texture streaming technology.
|
||||
Copyright (c) 2001 Crytek Studios. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include "GLPBuffer.h"
|
||||
#include "I3dengine.h"
|
||||
|
||||
//===============================================================================
|
||||
|
||||
void STexPic::BuildMips()
|
||||
{
|
||||
if (!m_Mips[0])
|
||||
CreateMips();
|
||||
|
||||
glBindTexture(m_TargetType, m_Bind);
|
||||
if (m_eTT != eTT_Cubemap)
|
||||
{
|
||||
for (int i=0; i<m_nMips; i++)
|
||||
{
|
||||
int w, h;
|
||||
glGetTexLevelParameteriv(m_TargetType, i, GL_TEXTURE_WIDTH, &w);
|
||||
glGetTexLevelParameteriv(m_TargetType, i, GL_TEXTURE_HEIGHT, &h);
|
||||
assert (w && h);
|
||||
int tf = CGLTexMan::GetTexSrcFormat(m_ETF);
|
||||
int tfd = CGLTexMan::GetTexDstFormat(m_ETF);
|
||||
int size = CGLTexMan::TexSize(w, h, 1, tfd);
|
||||
SAFE_DELETE(m_Mips[0][i]);
|
||||
SMipmap *mp = new SMipmap(w, h, size);
|
||||
m_Mips[0][i] = mp;
|
||||
mp->m_bUploaded = true;
|
||||
if (m_ETF == eTF_DXT1 || m_ETF == eTF_DXT3 || m_ETF == eTF_DXT5)
|
||||
glGetCompressedTexImageARB(m_TargetType, i, &mp->DataArray[0]);
|
||||
else
|
||||
glGetTexImage(m_TargetType, i, tf, GL_UNSIGNED_BYTE, &mp->DataArray[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static const GLenum cubefaces[6] =
|
||||
{
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT,
|
||||
};
|
||||
STexPic *tp = this;
|
||||
for (int n=0; n<6; n++)
|
||||
{
|
||||
int tgt = cubefaces[n];
|
||||
for (int i=0; i<m_nMips; i++)
|
||||
{
|
||||
int w, h;
|
||||
glGetTexLevelParameteriv(tgt, i, GL_TEXTURE_WIDTH, &w);
|
||||
glGetTexLevelParameteriv(tgt, i, GL_TEXTURE_HEIGHT, &h);
|
||||
assert (w && h);
|
||||
int tf = CGLTexMan::GetTexSrcFormat(m_ETF);
|
||||
int tfd = CGLTexMan::GetTexDstFormat(m_ETF);
|
||||
int size = CGLTexMan::TexSize(w, h, 1, tfd);
|
||||
SAFE_DELETE(m_Mips[n][i]);
|
||||
SMipmap *mp = new SMipmap(w, h, size);
|
||||
m_Mips[n][i] = mp;
|
||||
mp->m_bUploaded = true;
|
||||
if (m_ETF == eTF_DXT1 || m_ETF == eTF_DXT3 || m_ETF == eTF_DXT5)
|
||||
glGetCompressedTexImageARB(tgt, i, &mp->DataArray[0]);
|
||||
else
|
||||
glGetTexImage(tgt, i, tf, GL_UNSIGNED_BYTE, &mp->DataArray[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool STexPic::UploadMips(int nStartMip, int nEndMip)
|
||||
{
|
||||
glBindTexture(m_TargetType, m_Bind);
|
||||
if (SUPPORTS_GL_SGIS_texture_lod/* && m_eTT != eTT_Cubemap*/)
|
||||
{
|
||||
glTexParameteri(m_TargetType, GL_TEXTURE_BASE_LEVEL_SGIS, nStartMip);
|
||||
//glTexParameteri(m_TargetType, GL_TEXTURE_MAX_LEVEL_SGIS, m_nMips-1);
|
||||
//glTexParameterf(m_TargetType, GL_TEXTURE_MIN_LOD_SGIS, (float)nStartMip);
|
||||
//glTexParameterf(m_TargetType, GL_TEXTURE_MAX_LOD_SGIS, (float)nEndMip);
|
||||
if (m_eTT != eTT_Cubemap)
|
||||
{
|
||||
int tfs = CGLTexMan::GetTexSrcFormat(m_ETF);
|
||||
int tfd = CGLTexMan::GetTexDstFormat(m_ETF);
|
||||
for (int i=nStartMip; i<=nEndMip; i++)
|
||||
{
|
||||
int nLod = i;
|
||||
SMipmap *mp = m_Mips[0][i];
|
||||
if (mp->m_bUploaded)
|
||||
continue;
|
||||
m_LoadedSize += m_pFileTexMips[i].m_Size;
|
||||
gRenDev->m_TexMan->m_StatsCurTexMem += m_pFileTexMips[i].m_Size;
|
||||
if (m_ETF == eTF_DXT1 || m_ETF == eTF_DXT3 || m_ETF == eTF_DXT5)
|
||||
{
|
||||
if (nLod && (!m_Mips[0][0] || !m_Mips[0][0]->m_bUploaded))
|
||||
glTexImage2D(m_TargetType, 0, tfd, m_Width, m_Height, 0, tfs, GL_UNSIGNED_BYTE, NULL);
|
||||
glCompressedTexImage2DARB(m_TargetType, nLod, tfd, mp->USize, mp->VSize, 0, mp->DataArray.Num(), &mp->DataArray[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nLod && (!m_Mips[0][0] || !m_Mips[0][0]->m_bUploaded))
|
||||
glTexImage2D(m_TargetType, 0, tfd, m_Width, m_Height, 0, tfs, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(m_TargetType, nLod, tfd, mp->USize, mp->VSize, 0, tfs, GL_UNSIGNED_BYTE, &mp->DataArray[0]);
|
||||
}
|
||||
mp->m_bUploaded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static const GLenum cubefaces[6] =
|
||||
{
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT,
|
||||
};
|
||||
for (int n=0; n<6; n++)
|
||||
{
|
||||
int tgt = cubefaces[n];
|
||||
int tfs = CGLTexMan::GetTexSrcFormat(m_ETF);
|
||||
int tfd = CGLTexMan::GetTexDstFormat(m_ETF);
|
||||
for (int i=nStartMip; i<=nEndMip; i++)
|
||||
{
|
||||
int nLod = i;
|
||||
SMipmap *mp = m_Mips[n][i];
|
||||
if (mp->m_bUploaded)
|
||||
continue;
|
||||
m_LoadedSize += m_pFileTexMips[i].m_Size;
|
||||
gRenDev->m_TexMan->m_StatsCurTexMem += m_pFileTexMips[i].m_Size;
|
||||
if (m_ETF == eTF_DXT1 || m_ETF == eTF_DXT3 || m_ETF == eTF_DXT5)
|
||||
{
|
||||
if (nLod && (!m_Mips[0][0] || !m_Mips[0][0]->m_bUploaded))
|
||||
glTexImage2D(tgt, 0, tfd, m_Width, m_Height, 0, tfs, GL_UNSIGNED_BYTE, NULL);
|
||||
glCompressedTexImage2DARB(tgt, nLod, tfd, mp->USize, mp->VSize, 0, mp->DataArray.Num(), &mp->DataArray[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nLod && (!m_Mips[0][0] || !m_Mips[0][0]->m_bUploaded))
|
||||
glTexImage2D(tgt, 0, tfd, m_Width, m_Height, 0, tfs, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(tgt, nLod, tfd, mp->USize, mp->VSize, 0, tfs, GL_UNSIGNED_BYTE, &mp->DataArray[0]);
|
||||
}
|
||||
mp->m_bUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_eTT != eTT_Cubemap)
|
||||
{
|
||||
int tfs = CGLTexMan::GetTexSrcFormat(m_ETF);
|
||||
int tfd = CGLTexMan::GetTexDstFormat(m_ETF);
|
||||
for (int i=nStartMip; i<=nEndMip; i++)
|
||||
{
|
||||
SMipmap *mp = m_Mips[0][i];
|
||||
if (mp->m_bUploaded)
|
||||
continue;
|
||||
int nLod = i-nStartMip;
|
||||
if (m_ETF == eTF_DXT1 || m_ETF == eTF_DXT3 || m_ETF == eTF_DXT5)
|
||||
glCompressedTexImage2DARB(m_TargetType, nLod, tfd, mp->USize, mp->VSize, 0, mp->DataArray.Num(), &mp->DataArray[0]);
|
||||
else
|
||||
glTexImage2D(m_TargetType, nLod, tfd, mp->USize, mp->VSize, 0, tfs, GL_UNSIGNED_BYTE, &mp->DataArray[0]);
|
||||
mp->m_bUploaded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static const GLenum cubefaces[6] =
|
||||
{
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT,
|
||||
};
|
||||
for (int n=0; n<6; n++)
|
||||
{
|
||||
int tgt = cubefaces[n];
|
||||
int tfs = CGLTexMan::GetTexSrcFormat(m_ETF);
|
||||
int tfd = CGLTexMan::GetTexDstFormat(m_ETF);
|
||||
for (int i=nStartMip; i<=nEndMip; i++)
|
||||
{
|
||||
SMipmap *mp = m_Mips[n][i];
|
||||
if (mp->m_bUploaded)
|
||||
continue;
|
||||
int nLod = i-nStartMip;
|
||||
if (m_ETF == eTF_DXT1 || m_ETF == eTF_DXT3 || m_ETF == eTF_DXT5)
|
||||
glCompressedTexImage2DARB(tgt, nLod, tfd, mp->USize, mp->VSize, 0, mp->DataArray.Num(), &mp->DataArray[0]);
|
||||
else
|
||||
glTexImage2D(tgt, nLod, tfd, mp->USize, mp->VSize, 0, tfs, GL_UNSIGNED_BYTE, &mp->DataArray[0]);
|
||||
mp->m_bUploaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SetFilter();
|
||||
SetWrapping();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void STexPic::RemoveFromPool()
|
||||
{
|
||||
if (!m_pPoolItem)
|
||||
return;
|
||||
STexPoolItem *pIT = m_pPoolItem;
|
||||
m_pPoolItem = NULL;
|
||||
pIT->m_pTex = NULL;
|
||||
m_LoadedSize = 0;
|
||||
}
|
||||
|
||||
void CTexMan::UnloadOldTextures(STexPic *pExclude)
|
||||
{
|
||||
if (!CRenderer::CV_r_texturesstreampoolsize)
|
||||
return;
|
||||
//ValidateTexSize();
|
||||
|
||||
STexPic *pTP = STexPic::m_Root.m_Prev;
|
||||
while (m_StatsCurTexMem >= CRenderer::CV_r_texturesstreampoolsize*1024*1024)
|
||||
{
|
||||
if (pTP == &STexPic::m_Root)
|
||||
{
|
||||
ICVar *var = iConsole->GetCVar("r_TexturesStreamPoolSize");
|
||||
var->Set(m_StatsCurTexMem/(1024*1024)+30);
|
||||
iLog->Log("WARNING: Texture pool was changed to %d Mb", CRenderer::CV_r_texturesstreampoolsize);
|
||||
return;
|
||||
}
|
||||
|
||||
STexPic *Next = pTP->m_Prev;
|
||||
if (pTP != pExclude)
|
||||
pTP->Unload();
|
||||
pTP = Next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void STexPic::PrecacheAsynchronously(float fDist, int Flags)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CTexMan::CheckTexLimits(STexPic *pExclude)
|
||||
{
|
||||
if (!(gRenDev->m_TexMan->m_Streamed & 1))
|
||||
return;
|
||||
if (CRenderer::CV_r_texturesstreampoolsize < 10)
|
||||
CRenderer::CV_r_texturesstreampoolsize = 10;
|
||||
|
||||
ValidateTexSize();
|
||||
|
||||
if (gRenDev->m_TexMan->m_StatsCurTexMem >= CRenderer::CV_r_texturesstreampoolsize*1024*1024)
|
||||
UnloadOldTextures(pExclude);
|
||||
}
|
||||
|
||||
|
||||
222
RenderDll/XRenderOGL/GLVPrograms.h
Normal file
222
RenderDll/XRenderOGL/GLVPrograms.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/*=============================================================================
|
||||
GLVPrograms.h : OpenGL vertex programming interface declaration.
|
||||
Copyright 1999 K&M. All Rights Reserved.
|
||||
|
||||
Revision history:
|
||||
* Created by Honitch Andrey
|
||||
|
||||
=============================================================================*/
|
||||
|
||||
#ifndef __GLVPROGRAMS_H__
|
||||
#define __GLVPROGRAMS_H__
|
||||
|
||||
#define VPF_TRACK_MATRIX 1
|
||||
|
||||
#define VPVST_FOGGLOBAL 1
|
||||
#define VPVST_CLIPPLANES 2
|
||||
#define VPVST_NOFOG 4
|
||||
|
||||
#define VPFI_NOFOG 1
|
||||
#define VPFI_UNIFIEDPOS 2
|
||||
#define VPFI_SUPPORTMULTVLIGHTS 4
|
||||
|
||||
class CVProgram_GLBase : public CVProgram
|
||||
{
|
||||
public:
|
||||
CVProgram_GLBase(GLenum tgt)
|
||||
{
|
||||
m_Target = tgt;
|
||||
for (int i=0; i<8; i++)
|
||||
{
|
||||
m_bValid[i] = false;
|
||||
m_Program[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~CVProgram_GLBase()
|
||||
{
|
||||
for (int i=0; i<8; i++)
|
||||
{
|
||||
mfDel(i);
|
||||
}
|
||||
}
|
||||
|
||||
void mfBind(int Num)
|
||||
{
|
||||
if(!m_bValid[Num])
|
||||
mfGen(Num);
|
||||
glBindProgramNV(m_Target, m_Program[Num]);
|
||||
}
|
||||
|
||||
void mfUnbind()
|
||||
{
|
||||
glBindProgramNV(m_Target, 0);
|
||||
}
|
||||
|
||||
void mfLoad(GLuint size, const GLubyte * prog_text, int Num)
|
||||
{
|
||||
if(!m_bValid[Num])
|
||||
mfGen(Num);
|
||||
glLoadProgramNV(m_Target, m_Program[Num], size, prog_text);
|
||||
GLint errpos;
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_NV, &errpos);
|
||||
if(errpos != -1)
|
||||
{
|
||||
iLog->Log("program error:\n");
|
||||
int bgn = errpos - 10;
|
||||
bgn < 0 ? 0 : bgn;
|
||||
const char * c = (const char *)(prog_text + bgn);
|
||||
for(int i = 0; i < 30; i++)
|
||||
{
|
||||
if(bgn+i >= int(size-1))
|
||||
break;
|
||||
iLog->Log("%c", *c++);
|
||||
}
|
||||
iLog->Log("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void mfLoad(GLuint size, const char * prog_text, int Num)
|
||||
{
|
||||
if(!m_bValid[Num])
|
||||
mfGen(Num);
|
||||
glLoadProgramNV(m_Target, m_Program[Num], size, (const GLubyte *) prog_text);
|
||||
GLint errpos;
|
||||
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_NV, &errpos);
|
||||
if(errpos != -1)
|
||||
{
|
||||
char name[128];
|
||||
sprintf(name, "%s.vps", m_Name);
|
||||
FILE *fp = fopen(name, "w");
|
||||
fprintf(fp, prog_text);
|
||||
fclose(fp);
|
||||
iLog->Log("program error: (see file '%s')\n", name);
|
||||
int bgn = errpos - 10;
|
||||
bgn < 0 ? 0 : bgn;
|
||||
const char * c = (const char *)(prog_text + bgn);
|
||||
for(int i = 0; i < 30; i++)
|
||||
{
|
||||
if(bgn+i >= int(size-1))
|
||||
break;
|
||||
iLog->Log("%c", *c++);
|
||||
}
|
||||
iLog->Log("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void mfLoad(const char * prog_text, int Num)
|
||||
{
|
||||
mfLoad(strlen(prog_text), prog_text, Num);
|
||||
}
|
||||
|
||||
// convenience methods
|
||||
void mfParameter(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
||||
{
|
||||
glProgramParameter4fNV(m_Target, index, x, y, z, w);
|
||||
}
|
||||
|
||||
void mfParameter(GLuint index, GLfloat * v)
|
||||
{
|
||||
glProgramParameter4fvNV(m_Target, index, v);
|
||||
}
|
||||
static void mfParameter(GLenum target, GLuint index, GLfloat * v)
|
||||
{
|
||||
glProgramParameter4fvNV(target, index, v);
|
||||
}
|
||||
void mfParameter3(GLuint index, const Vec3d& v)
|
||||
{
|
||||
GLfloat f[4];
|
||||
f[0] = v[0];
|
||||
f[1] = v[1];
|
||||
f[2] = v[2];
|
||||
f[3] = 1;
|
||||
glProgramParameter4fvNV(m_Target, index, f);
|
||||
}
|
||||
void mfParameter4(GLuint index, const vec4_t v)
|
||||
{
|
||||
glProgramParameter4fvNV(m_Target, index, v);
|
||||
}
|
||||
|
||||
void mfTrackMatrix(GLuint index, GLenum matrix, GLenum op)
|
||||
{
|
||||
glTrackMatrixNV(m_Target, index, matrix, op);
|
||||
}
|
||||
|
||||
void mfEnable() { glEnable(m_Target); }
|
||||
void mfDisable() { glDisable(m_Target); }
|
||||
|
||||
void mfDel(int Num)
|
||||
{
|
||||
if(m_bValid[Num])
|
||||
glDeleteProgramsNV(1, &m_Program[Num]);
|
||||
m_bValid[Num] = false;
|
||||
}
|
||||
|
||||
bool mfIsValid(int Num) const { return m_bValid[Num]; }
|
||||
|
||||
protected:
|
||||
|
||||
void mfGen(int Num)
|
||||
{
|
||||
glGenProgramsNV(1, &m_Program[Num]);
|
||||
m_bValid[Num] = true;
|
||||
}
|
||||
|
||||
bool m_bValid[8];
|
||||
GLenum m_Target;
|
||||
GLuint m_Program[8];
|
||||
};
|
||||
|
||||
struct STrackMatrix
|
||||
{
|
||||
GLuint m_Address;
|
||||
GLenum m_Matrix;
|
||||
GLenum m_Transform;
|
||||
};
|
||||
|
||||
|
||||
class CVProgram_GL : public CVProgram_GLBase
|
||||
{
|
||||
friend class CShader;
|
||||
|
||||
uint m_Flags;
|
||||
char *m_Script;
|
||||
TArray<STrackMatrix> m_TrackMatrix;
|
||||
TArray<SParam> m_Params;
|
||||
TArray<SArrayPointer *> m_Pointers;
|
||||
|
||||
void mfSetPointers(int nType);
|
||||
bool mfActivate(int Num);
|
||||
|
||||
public:
|
||||
char *mfCreateAdditionalVP(int Num);
|
||||
|
||||
CVProgram_GL() : CVProgram_GLBase(GL_VERTEX_PROGRAM_NV)
|
||||
{
|
||||
m_bCGType = false;
|
||||
m_Flags = 0;
|
||||
m_Script = NULL;
|
||||
}
|
||||
virtual int Size()
|
||||
{
|
||||
int nSize = sizeof(*this);
|
||||
if (m_Script)
|
||||
nSize += strlen(m_Script)+1;
|
||||
nSize += m_Params.GetSize() * sizeof(SParam);
|
||||
nSize += m_TrackMatrix.GetSize() * sizeof(STrackMatrix);
|
||||
nSize += m_Pointers.GetSize() * sizeof(SArrayPointer *);
|
||||
|
||||
return nSize;
|
||||
}
|
||||
|
||||
virtual ~CVProgram_GL();
|
||||
virtual bool mfCompile(char *scr, SShader *ef);
|
||||
virtual bool mfSet(bool bStat, int nSetPointers=1);
|
||||
virtual void mfSetVariables(TArray<SParam>* Vars);
|
||||
virtual void mfReset();
|
||||
virtual bool mfHasPointer(EPointer ePtr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // __GLVPROGRAMS_H__
|
||||
201
RenderDll/XRenderOGL/GL_Combiners.cpp
Normal file
201
RenderDll/XRenderOGL/GL_Combiners.cpp
Normal file
@@ -0,0 +1,201 @@
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
|
||||
#include "NVParse\nvparse.h"
|
||||
|
||||
void build_normalize_combiner_dlist()
|
||||
{
|
||||
glEnable(GL_REGISTER_COMBINERS_NV);
|
||||
|
||||
float specular [4]={1,0,0.0,1};
|
||||
glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,&specular[0]);
|
||||
|
||||
//float diffuse [4]={1,1,1,1};
|
||||
//glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,&diffuse[0]);
|
||||
|
||||
nvparse(false,
|
||||
|
||||
"!!RC1.0"
|
||||
/*
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=expand(col1).expand(col1);"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"discard=expand(col1);"
|
||||
"discard=half_bias(col1)*unsigned_invert(spare0);"
|
||||
"col1=sum();"
|
||||
"}"
|
||||
"}"
|
||||
*/
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=expand(tex2).expand(tex1);" // specular
|
||||
"spare1=expand(tex0).expand(tex1);" // diffuse
|
||||
"}"
|
||||
"}"
|
||||
|
||||
// specular exp
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=spare0*spare0;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=spare0*spare0;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=spare0*spare0;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=spare0*spare0;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=spare0*spare0;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
// attenuation
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare1=spare1*col0.a;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=spare0*col0.a;"
|
||||
"}"
|
||||
"}"
|
||||
|
||||
// summ result
|
||||
"final_product = const0 * spare1;\n"
|
||||
"out.rgb=spare0 + final_product;"
|
||||
"out.a=unsigned_invert(zero);"
|
||||
|
||||
);
|
||||
char*const*const szError=nvparse_get_errors();
|
||||
if(szError[0])
|
||||
iConsole->Exit(szError[0]);
|
||||
}
|
||||
/*
|
||||
void CGLRenderer::EnableBumpCombinersAdditive()
|
||||
{
|
||||
build_normalize_combiner_dlist();
|
||||
return;
|
||||
|
||||
//Makefunctionsfirst
|
||||
//GET_GL_PROC(PFNGLCOMBINERPARAMETERINVPROC,glCombinerParameteriNV);
|
||||
//GET_GL_PROC(PFNGLCOMBINERPARAMETERFVNVPROC,glCombinerParameterfvNV);
|
||||
//GET_GL_PROC(PFNGLCOMBINERINPUTNVPROC,glCombinerInputNV);
|
||||
//GET_GL_PROC(PFNGLCOMBINEROUTPUTNVPROC,glCombinerOutputNV);
|
||||
//GET_GL_PROC(PFNGLFINALCOMBINERINPUTNVPROC,glFinalCombinerInputNV);
|
||||
|
||||
//floatcon0[]={bright,bright,bright,bright};
|
||||
//floatcon1[]={ambient,ambient,ambient,1};
|
||||
|
||||
glEnable(GL_REGISTER_COMBINERS_NV);
|
||||
|
||||
//glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV,con0);
|
||||
//glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV,con1);
|
||||
|
||||
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV,1);
|
||||
|
||||
//Stage0:
|
||||
glCombinerInputNV(GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_A_NV,
|
||||
GL_TEXTURE0_ARB,GL_EXPAND_NORMAL_NV,GL_RGB);
|
||||
|
||||
glCombinerInputNV(GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_B_NV,
|
||||
GL_SECONDARY_COLOR_NV,GL_EXPAND_NORMAL_NV,GL_RGB);
|
||||
|
||||
glCombinerInputNV(GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_C_NV,
|
||||
GL_ZERO,GL_UNSIGNED_INVERT_NV,GL_RGB);
|
||||
|
||||
glCombinerInputNV(GL_COMBINER0_NV,GL_RGB,GL_VARIABLE_D_NV,
|
||||
GL_PRIMARY_COLOR_NV,GL_UNSIGNED_IDENTITY_NV,GL_ALPHA);
|
||||
|
||||
glCombinerOutputNV(GL_COMBINER0_NV,GL_RGB,
|
||||
GL_SPARE0_NV,GL_SPARE1_NV,GL_DISCARD_NV,
|
||||
GL_NONE,GL_NONE,GL_TRUE,GL_FALSE,GL_FALSE);
|
||||
|
||||
glCombinerOutputNV(GL_COMBINER1_NV,GL_RGB,
|
||||
GL_DISCARD_NV,GL_DISCARD_NV,GL_DISCARD_NV,
|
||||
GL_NONE,GL_NONE,GL_FALSE,GL_FALSE,GL_FALSE);
|
||||
|
||||
//Finalstage
|
||||
glFinalCombinerInputNV(GL_VARIABLE_A_NV,
|
||||
GL_E_TIMES_F_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
||||
glFinalCombinerInputNV(GL_VARIABLE_B_NV,
|
||||
GL_SPARE1_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
||||
glFinalCombinerInputNV(GL_VARIABLE_C_NV,
|
||||
GL_ZERO,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
||||
|
||||
glFinalCombinerInputNV(GL_VARIABLE_E_NV,
|
||||
GL_SPARE0_NV,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
||||
glFinalCombinerInputNV(GL_VARIABLE_F_NV,
|
||||
//GL_TEXTURE1_ARB,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
||||
GL_ZERO,GL_UNSIGNED_INVERT_NV,GL_RGB);
|
||||
glFinalCombinerInputNV(GL_VARIABLE_D_NV,
|
||||
GL_ZERO,GL_UNSIGNED_IDENTITY_NV,GL_RGB);
|
||||
}*/
|
||||
|
||||
//extern "C" char * state_to_rc10 ();
|
||||
|
||||
void CGLRenderer::ConfigCombinersForHardwareShadowPass(int withTexture,float*lightDimColor)
|
||||
{
|
||||
static int nList = 0;
|
||||
|
||||
CPShader::m_CurRC = 0;
|
||||
|
||||
if(nList)
|
||||
{
|
||||
glCallList(nList);
|
||||
return;
|
||||
}
|
||||
|
||||
nList = glGenLists(1);
|
||||
|
||||
glNewList(nList, GL_COMPILE);
|
||||
|
||||
nvparse(false,
|
||||
"!!RC1.0\n"
|
||||
"{"
|
||||
"rgb{"
|
||||
"spare0=unsigned_invert(zero);"
|
||||
"}"
|
||||
"alpha{"
|
||||
"spare0.a=unsigned_invert(tex0.b)*col0.a;"
|
||||
"}"
|
||||
"}"
|
||||
"out.rgb = unsigned_invert(col0.a) + tex0;\n"
|
||||
"out.a = spare0.a;\n"
|
||||
);
|
||||
|
||||
glEnable(GL_REGISTER_COMBINERS_NV);
|
||||
|
||||
glEndList();
|
||||
|
||||
int n = 0;
|
||||
|
||||
for (char * const * errors = nvparse_get_errors(); *errors; errors++)
|
||||
{
|
||||
n++;
|
||||
iLog->Log(*errors);
|
||||
}
|
||||
}
|
||||
353
RenderDll/XRenderOGL/GL_OutSpace.cpp
Normal file
353
RenderDll/XRenderOGL/GL_OutSpace.cpp
Normal file
@@ -0,0 +1,353 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include "I3dengine.h"
|
||||
|
||||
void CGLRenderer::PrepareOutSpaceTextures(CREOutSpace * pRE)
|
||||
{
|
||||
int arrnResult[2];
|
||||
ScanOutSpaceCube(pRE->m_TexID, iSystem->GetViewCamera().GetPos(), arrnResult);
|
||||
|
||||
// vPrevPos[arrnResult[0]] = iSystem->GetViewCamera().GetPos();
|
||||
//vPrevPos[arrnResult[1]] = iSystem->GetViewCamera().GetPos();
|
||||
|
||||
/*
|
||||
int nTempX, nTempY, nTempWidth, nTempHeight;
|
||||
int nTexSize = 512;
|
||||
gRenDev->GetViewport(&nTempX, &nTempY, &nTempWidth, &nTempHeight);
|
||||
gRenDev->SetViewport( 0, 0, nTexSize, nTexSize );
|
||||
|
||||
I3DEngine * pEngine = iSystem->GetI3DEngine();
|
||||
|
||||
CCamera prevCamera = gRenDev->GetCamera();
|
||||
CCamera tmp_cam = prevCamera;
|
||||
|
||||
tmp_cam.SetAngle(Vec3d(0,0,0));
|
||||
tmp_cam.Init(nTexSize, nTexSize);
|
||||
tmp_cam.Update();
|
||||
|
||||
iSystem->SetViewCamera(tmp_cam);
|
||||
gRenDev->SetCamera(tmp_cam);
|
||||
pEngine->SetCamera(tmp_cam,false);
|
||||
|
||||
pEngine->DrawLowDetail();
|
||||
|
||||
if(!pRE->m_TexID[0])
|
||||
glGenTextures(1,&(pRE->m_TexID[0]));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, pRE->m_TexID[0]);
|
||||
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
|
||||
glCopyTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGB,
|
||||
0, 0,
|
||||
nTexSize, nTexSize,
|
||||
0);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
|
||||
pEngine->SetCamera(prevCamera);
|
||||
iSystem->SetViewCamera(prevCamera);
|
||||
gRenDev->SetCamera(prevCamera);
|
||||
|
||||
gRenDev->SetViewport(nTempX, nTempY, nTempWidth, nTempHeight);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);*/
|
||||
}
|
||||
|
||||
void CGLRenderer::DrawOutSpaceSide( const float *angle, const Vec3d & Pos, int tex_size, int offsetX, int offsetY)
|
||||
{
|
||||
if (!iSystem)
|
||||
return;
|
||||
|
||||
CRenderer * renderer = gRenDev;
|
||||
CCamera tmp_camera = renderer->GetCamera();
|
||||
CCamera prevCamera = tmp_camera;
|
||||
|
||||
tmp_camera.Init(tex_size,tex_size);
|
||||
tmp_camera.SetPos(Pos);
|
||||
tmp_camera.SetAngle(Vec3d(angle[0], angle[1], angle[2]));
|
||||
tmp_camera.Update();
|
||||
|
||||
iSystem->SetViewCamera(tmp_camera);
|
||||
gRenDev->SetCamera(tmp_camera);
|
||||
|
||||
gRenDev->SetViewport(tex_size*offsetX, tex_size*offsetY, tex_size, tex_size);
|
||||
|
||||
I3DEngine *eng = (I3DEngine *)iSystem->GetIProcess();
|
||||
|
||||
eng->SetCamera(tmp_camera,false );
|
||||
|
||||
eng->DrawLowDetail(0);
|
||||
|
||||
iSystem->SetViewCamera(prevCamera);
|
||||
gRenDev->SetCamera(prevCamera);
|
||||
}
|
||||
|
||||
void CGLRenderer::ScanOutSpaceCube(uint & nTexID, const Vec3d & vPos, int * pResult)
|
||||
{
|
||||
// get normalized camera angle
|
||||
float fAngle = iSystem->GetViewCamera().GetAngles().z;
|
||||
while(fAngle>360)
|
||||
fAngle-=360;
|
||||
while(fAngle<0)
|
||||
fAngle+=360;
|
||||
|
||||
// get 2 visible sides
|
||||
int nSide = int(fAngle+45)/90;
|
||||
int nSide2 = int(fAngle+45+45)/90;
|
||||
if(nSide == nSide2)
|
||||
nSide2 = int(fAngle+45-45)/90;
|
||||
|
||||
// normalize
|
||||
if(nSide2<0)
|
||||
nSide2=3;
|
||||
if(nSide2>3)
|
||||
nSide2=0;
|
||||
|
||||
if(nSide<0)
|
||||
nSide=3;
|
||||
if(nSide>3)
|
||||
nSide=0;
|
||||
|
||||
static Vec3d vPrevPos[4];
|
||||
|
||||
// is images valid
|
||||
if (GetDistance(vPrevPos[nSide ],iSystem->GetViewCamera().GetPos())<1.0f &&
|
||||
GetDistance(vPrevPos[nSide2],iSystem->GetViewCamera().GetPos())<1.0f )
|
||||
return; // no need to update
|
||||
|
||||
iLog->Log("nSides = %d, %d",nSide,nSide2);
|
||||
|
||||
// now render 2 cubemap sides
|
||||
|
||||
CRenderer * renderer = gRenDev;
|
||||
int tex_size = 512;
|
||||
while(true)
|
||||
{
|
||||
if (tex_size>renderer->GetWidth() || tex_size>renderer->GetHeight())
|
||||
tex_size >>= 1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (tex_size <= 8)
|
||||
return;
|
||||
|
||||
static const GLenum OutSpaceCubeFaces[6] =
|
||||
{
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT,
|
||||
};
|
||||
|
||||
static const float sAngles[6][5] =
|
||||
{
|
||||
{ 0, 180, 0, 0, 0 },
|
||||
{ 0, 180, 90, 1, 0 },
|
||||
{ 0, 180, 180, 2, 0 },
|
||||
{ 0, 180, 270, 0, 1 },
|
||||
{ -90, 180, 0, 1, 1 },
|
||||
{ 90, 180, 0, 2, 1 }
|
||||
};
|
||||
|
||||
if(!nTexID)
|
||||
{ // create empty if not created
|
||||
glGenTextures(1,&nTexID);
|
||||
assert(nTexID<14000);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, nTexID);
|
||||
for(int n=0; n<6; n++)
|
||||
glTexImage2D(OutSpaceCubeFaces[n], 0, GL_RGB, tex_size, tex_size, 0, GL_RGB, GL_FLOAT, 0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, 0);
|
||||
}
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
int vX, vY, vWidth, vHeight;
|
||||
gRenDev->GetViewport(&vX, &vY, &vWidth, &vHeight);
|
||||
int bFog=0; // remember fog value
|
||||
glGetIntegerv(GL_FOG,&bFog);
|
||||
m_RP.m_bDrawToTexture = true;
|
||||
|
||||
DrawOutSpaceSide( &sAngles[nSide ][0], vPos, tex_size, 0, 0 );
|
||||
DrawOutSpaceSide( &sAngles[nSide2][0], vPos, tex_size, 1, 0 );
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, nTexID);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_WRAP_R,GL_CLAMP_TO_EDGE);
|
||||
/*
|
||||
int width = tex_size*3;
|
||||
int height = tex_size*2;
|
||||
byte *pic = new byte [width * height * 3];
|
||||
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, pic);
|
||||
CImage::SaveJPG(pic,FORMAT_24_BIT,width,height,"CubeEnv.jpg");
|
||||
delete [] pic;
|
||||
*/
|
||||
|
||||
glCopyTexSubImage2D(OutSpaceCubeFaces[nSide ], 0, 0, 0, (int)(tex_size*0), (int)(tex_size*0), tex_size, tex_size);
|
||||
glCopyTexSubImage2D(OutSpaceCubeFaces[nSide2], 0, 0, 0, (int)(tex_size*1), (int)(tex_size*0), tex_size, tex_size);
|
||||
|
||||
vPrevPos[nSide] = iSystem->GetViewCamera().GetPos();
|
||||
vPrevPos[nSide2] = iSystem->GetViewCamera().GetPos();
|
||||
|
||||
pResult[0] = nSide;
|
||||
pResult[1] = nSide2;
|
||||
|
||||
gRenDev->SetViewport(vX, vY, vWidth, vHeight);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
m_RP.m_bDrawToTexture = false;
|
||||
|
||||
if(bFog)
|
||||
glEnable(GL_FOG);
|
||||
}
|
||||
|
||||
bool CREOutSpace::mfDraw(SShader *ef, SShaderPass *sfm)
|
||||
{
|
||||
if(!m_TexID)
|
||||
return true;
|
||||
|
||||
gRenDev->ResetToDefault();
|
||||
gRenDev->SetEnviMode(R_MODE_MODULATE);
|
||||
gRenDev->EnableDepthTest(false);
|
||||
gRenDev->EnableDepthWrites(false);
|
||||
|
||||
int bFog=0; // remember fog value
|
||||
glGetIntegerv(GL_FOG,&bFog);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_EXT,m_TexID);
|
||||
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
|
||||
|
||||
float scale = 1.f/1;
|
||||
float eyePlaneS[] = { scale, 0, 0, 0 };
|
||||
float eyePlaneT[] = { 0, scale, 0, 0 };
|
||||
float eyePlaneR[] = { 0, 0, scale, 0 };
|
||||
|
||||
glTexGenfv(GL_S, GL_OBJECT_PLANE, eyePlaneS);
|
||||
glTexGenfv(GL_T, GL_OBJECT_PLANE, eyePlaneT);
|
||||
glTexGenfv(GL_R, GL_OBJECT_PLANE, eyePlaneR);
|
||||
|
||||
glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
|
||||
glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
|
||||
glTexGenf(GL_R,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
|
||||
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
glEnable(GL_TEXTURE_GEN_T);
|
||||
glEnable(GL_TEXTURE_GEN_R);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glRotatef(-90,1,0,0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
// glRotatef(-45,0,0,1);
|
||||
|
||||
float D = 8; // box size
|
||||
|
||||
{ // top
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F data[] =
|
||||
{
|
||||
D,-D, D, 1, 1.f-1,
|
||||
-D,-D, D, 0, 1.f-1,
|
||||
D, D, D, 1, 1.f-0,
|
||||
-D, D, D, 0, 1.f-0,
|
||||
};
|
||||
|
||||
// gRenDev->SetTexture(m_TexID[0]);
|
||||
// gRenDev->SetTexClampMode(true);
|
||||
gRenDev->DrawTriStrip(&(CVertexBuffer (data,VERTEX_FORMAT_P3F_TEX2F)),4);
|
||||
}
|
||||
|
||||
{ // s
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F data[] =
|
||||
{
|
||||
-D,-D, D, 1.0, 1.f-1.0,
|
||||
D,-D, D, 0.0, 1.f-1.0,
|
||||
-D,-D,-D, 1.0, 1.f-0.0,
|
||||
D,-D,-D, 0.0, 1.f-0.0,
|
||||
};
|
||||
|
||||
// gRenDev->SetTexture(m_TexID[0]);
|
||||
// gRenDev->SetTexClampMode(true);
|
||||
gRenDev->DrawTriStrip(&(CVertexBuffer (data,VERTEX_FORMAT_P3F_TEX2F)),4);
|
||||
}
|
||||
{ // e
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F data[] =
|
||||
{
|
||||
-D, D, D, 1.0, 1.f-0.0,
|
||||
-D,-D, D, 0.0, 1.f-0.0,
|
||||
-D, D,-D, 1.0, 1.f-0.0,
|
||||
-D,-D,-D, 0.0, 1.f-0.0,
|
||||
};
|
||||
|
||||
// gRenDev->SetTexture(m_TexID[0]);
|
||||
// gRenDev->SetTexClampMode(true);
|
||||
gRenDev->DrawTriStrip(&(CVertexBuffer (data,VERTEX_FORMAT_P3F_TEX2F)),4);
|
||||
}
|
||||
{ // n
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F data[] =
|
||||
{
|
||||
D, D, D, 1.0, 1.f-1.0,
|
||||
-D, D, D, 0.0, 1.f-1.0,
|
||||
D, D,-D, 1.0, 1.f-0.0,
|
||||
-D, D,-D, 0.0, 1.f-0.0,
|
||||
};
|
||||
|
||||
// gRenDev->SetTexture(m_TexID[0]);
|
||||
// gRenDev->SetTexClampMode(true);
|
||||
gRenDev->DrawTriStrip(&(CVertexBuffer (data,VERTEX_FORMAT_P3F_TEX2F)),4);
|
||||
}
|
||||
{ // w
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F data[] =
|
||||
{
|
||||
D,-D, D, 1.0, 1.f-0.0,
|
||||
D, D, D, 0.0, 1.f-0.0,
|
||||
D,-D,-D, 1.0, 1.f-0.0,
|
||||
D, D,-D, 0.0, 1.f-0.0,
|
||||
};
|
||||
|
||||
// gRenDev->SetTexture(m_TexID[0]);
|
||||
// gRenDev->SetTexClampMode(true);
|
||||
gRenDev->DrawTriStrip(&(CVertexBuffer (data,VERTEX_FORMAT_P3F_TEX2F)),4);
|
||||
}
|
||||
|
||||
{ // bottom
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F data[] =
|
||||
{
|
||||
D,-D, -D, 1, 1.f-1,
|
||||
-D,-D, -D, 0, 1.f-1,
|
||||
D, D, -D, 1, 1.f-0,
|
||||
-D, D, -D, 0, 1.f-0,
|
||||
};
|
||||
|
||||
// gRenDev->SetTexture(m_TexID[0]);
|
||||
// gRenDev->SetTexClampMode(true);
|
||||
gRenDev->DrawTriStrip(&(CVertexBuffer (data,VERTEX_FORMAT_P3F_TEX2F)),4);
|
||||
}
|
||||
|
||||
gRenDev->ResetToDefault();
|
||||
gRenDev->ResetTextureMatrix();
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_GEN_T);
|
||||
glDisable(GL_TEXTURE_GEN_R);
|
||||
glDisable(GL_TEXTURE_GEN_Q);
|
||||
glDisable(GL_TEXTURE_CUBE_MAP_EXT);
|
||||
|
||||
if(bFog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
3273
RenderDll/XRenderOGL/GL_Renderer.cpp
Normal file
3273
RenderDll/XRenderOGL/GL_Renderer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1557
RenderDll/XRenderOGL/GL_Renderer.h
Normal file
1557
RenderDll/XRenderOGL/GL_Renderer.h
Normal file
File diff suppressed because it is too large
Load Diff
922
RenderDll/XRenderOGL/GL_Shadows.cpp
Normal file
922
RenderDll/XRenderOGL/GL_Shadows.cpp
Normal file
@@ -0,0 +1,922 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek CryENGINE Source code
|
||||
//
|
||||
// File:GlRenderer.cpp
|
||||
// Description: Implementation of the OpenGL renderer API
|
||||
// shadow map calculations
|
||||
//
|
||||
// History:
|
||||
// -Jan 31,2001:Created by Vladimir Kajain
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include <IEntityRenderState.h>
|
||||
#include "../Common/shadow_renderer.h"
|
||||
#include "../Common/RendElements/CREScreenCommon.h"
|
||||
#include "GLCGVProgram.h"
|
||||
#include "GLCGPShader.h"
|
||||
|
||||
#include "I3dengine.h"
|
||||
|
||||
void WriteTGA8(byte *data8, int width, int height, char *filename);
|
||||
void BlurImage8(byte * pImage, int nSize, int nPassesNum);
|
||||
void MakePenumbraTextureFromDepthMap(byte * pDepthMapIn, int nSize, byte * pPenumbraMapOut);
|
||||
|
||||
void CGLRenderer::DrawAllShadowsOnTheScreen()
|
||||
{
|
||||
float width=800;
|
||||
float height=600;
|
||||
Set2DMode(true, (int)width, (int)height);
|
||||
|
||||
float fArrDim = max(4, sqrt(float(MAX_DYNAMIC_SHADOW_MAPS_COUNT)));
|
||||
float fPicDimX = width/fArrDim;
|
||||
float fPicDimY = height/fArrDim;
|
||||
int nShadowId=0;
|
||||
EF_SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
for(float x=0; nShadowId<MAX_DYNAMIC_SHADOW_MAPS_COUNT && x<width-10; x+=fPicDimX)
|
||||
for(float y=0; nShadowId<MAX_DYNAMIC_SHADOW_MAPS_COUNT && y<height-10; y+=fPicDimY)
|
||||
{
|
||||
ShadowMapTexInfo * pInf = &m_ShadowTexIDBuffer[nShadowId++];
|
||||
if(pInf->nTexId && pInf->pOwner)
|
||||
{
|
||||
STexPic *tp = (STexPic *)EF_GetTextureByID(pInf->nTexId);
|
||||
if (tp)
|
||||
{
|
||||
byte bSaveProj = tp->m_RefTex.bProjected;
|
||||
tp->m_RefTex.bProjected = 1;
|
||||
SetState( GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST );
|
||||
Draw2dImage(x, y, fPicDimX, fPicDimY, pInf->nTexId, 0,0,1,1,180);
|
||||
TextToScreen(x/width*100.f, y/height*100.f,
|
||||
"%8s", pInf->pOwner->GetName());
|
||||
tp->m_RefTex.bProjected = bSaveProj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set2DMode(false, m_width, m_height);
|
||||
}
|
||||
|
||||
void CGLRenderer::BlurImage(int nSizeX, int nSizeY, int nType, int nTexIdSrc, int nTexIdTmp)
|
||||
{
|
||||
if (nType == 1)
|
||||
{
|
||||
EF_SetState(GS_NODEPTHTEST);
|
||||
m_TexMan->SetTexture(nTexIdSrc, eTT_Base);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, nSizeX, nSizeY, 0);
|
||||
Set2DMode(true, 1, 1);
|
||||
|
||||
struct_VERTEX_FORMAT_P3F_TEX2F pScreenBlur[] =
|
||||
{
|
||||
Vec3(0, 1, 0), 0, 0,
|
||||
Vec3(0, 0, 0), 0, 1,
|
||||
Vec3(1, 1, 0), 1, 0,
|
||||
Vec3(1, 0, 0), 1, 1,
|
||||
};
|
||||
EF_SetColorOp(eCO_REPLACE, eCO_REPLACE, DEF_TEXARG0, DEF_TEXARG0);
|
||||
DrawTriStrip(&(CVertexBuffer (pScreenBlur,VERTEX_FORMAT_P3F_TEX2F)), 4);
|
||||
|
||||
EF_SetState(GS_NODEPTHTEST | GS_COLMASKONLYALPHA);
|
||||
|
||||
// set current vertex/fragment program
|
||||
CCGVProgram_GL *vpBlur=(CCGVProgram_GL *)m_RP.m_VPBlur;
|
||||
CCGPShader_GL *fpBlur=(CCGPShader_GL *)m_RP.m_RCBlur;
|
||||
if (vpBlur && fpBlur)
|
||||
{
|
||||
vpBlur->mfSet(true, 0);
|
||||
fpBlur->mfSet(true, 0);
|
||||
// setup texture offsets, for texture neighboors sampling
|
||||
float s1=1.0f/(float) nSizeX;
|
||||
float t1=1.0f/(float) nSizeY;
|
||||
float pfOffset0[]={ s1*0.5f, t1, 0.0f, 0.0f};
|
||||
float pfOffset1[]={ -s1, t1*0.5f, 0.0f, 0.0f};
|
||||
float pfOffset2[]={ -s1*0.5f, -t1, 0.0f, 0.0f};
|
||||
float pfOffset3[]={ s1, -t1*0.5f, 0.0f, 0.0f};
|
||||
EF_SelectTMU(0);
|
||||
m_TexMan->SetTexture(nTexIdSrc, eTT_Base);
|
||||
EF_SelectTMU(1);
|
||||
m_TexMan->SetTexture(nTexIdSrc, eTT_Base);
|
||||
EF_SelectTMU(2);
|
||||
m_TexMan->SetTexture(nTexIdSrc, eTT_Base);
|
||||
EF_SelectTMU(3);
|
||||
m_TexMan->SetTexture(nTexIdSrc, eTT_Base);
|
||||
vpBlur->mfParameter4f("Offset0", pfOffset0);
|
||||
vpBlur->mfParameter4f("Offset1", pfOffset1);
|
||||
vpBlur->mfParameter4f("Offset2", pfOffset2);
|
||||
vpBlur->mfParameter4f("Offset3", pfOffset3);
|
||||
int iBlurAmount = CV_r_shadowblur-1;
|
||||
EF_CommitPS();
|
||||
EF_CommitVS();
|
||||
for(int iBlurPasses=1; iBlurPasses<=iBlurAmount; iBlurPasses++)
|
||||
{
|
||||
// set texture coordinates scale (needed for rectangular textures in gl ..)
|
||||
float pfScale[]={ 1.0f, 1.0f, 1.0f, (float) iBlurPasses};
|
||||
vpBlur->mfParameter4f("vTexCoordScale", pfScale);
|
||||
|
||||
// set current rendertarget
|
||||
//pRenderer->m_pd3dDevice->SetRenderTarget( 0, pTexSurf);
|
||||
// render screen aligned quad...
|
||||
DrawTriStrip(&(CVertexBuffer (pScreenBlur,VERTEX_FORMAT_P3F_TEX2F)), 4);
|
||||
}
|
||||
vpBlur->mfSet(false, 0);
|
||||
fpBlur->mfSet(false, 0);
|
||||
EF_CommitPS();
|
||||
EF_CommitVS();
|
||||
EnableTMU(false);
|
||||
EF_SelectTMU(2);
|
||||
EnableTMU(false);
|
||||
EF_SelectTMU(1);
|
||||
EnableTMU(false);
|
||||
EF_SelectTMU(0);
|
||||
}
|
||||
Set2DMode(false, 1, 1);
|
||||
}
|
||||
else
|
||||
if (nType == 2)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CGLRenderer::OnEntityDeleted(IEntityRender * pEntityRender)
|
||||
{
|
||||
}
|
||||
|
||||
// render depth/shadow map into texture from light source position
|
||||
void CGLRenderer::PrepareDepthMap(ShadowMapFrustum * lof, bool make_new_tid)
|
||||
{
|
||||
PROFILE_FRAME(Prep_PrepareDepthMap);
|
||||
|
||||
if(!lof || !lof->pLs)
|
||||
return;
|
||||
|
||||
static int nCurTexIdSlot = 0;
|
||||
//lof->bUpdateRequested = true;
|
||||
|
||||
lof->nTexSize = max(lof->nTexSize, 32);
|
||||
if(lof->nTexIdSlot>=0)
|
||||
{
|
||||
if(m_ShadowTexIDBuffer[lof->nTexIdSlot].pOwner == lof->pOwner)
|
||||
{
|
||||
char * pName = 0;
|
||||
if(lof->pOwner)
|
||||
pName = (char*)lof->pOwner->GetName();
|
||||
if(m_ShadowTexIDBuffer[lof->nTexIdSlot].pOwnerGroup == lof->pOwnerGroup)
|
||||
if(m_ShadowTexIDBuffer[lof->nTexIdSlot].dwFlags == lof->dwFlags)
|
||||
if(lof->depth_tex_id && !lof->bUpdateRequested)
|
||||
{
|
||||
m_ShadowTexIDBuffer[lof->nTexIdSlot].nLastFrameID = GetFrameID();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nShadowTexSize = lof->nTexSize;
|
||||
lof->bUpdateRequested = false;
|
||||
//assert(lof->nTexSize);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Render objects into frame and Z buffers
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// remember fog value
|
||||
int bFog=0;
|
||||
glGetIntegerv(GL_FOG,&bFog);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
// glPush
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
// check extension
|
||||
bool bDepth = (m_Features & RFT_DEPTHMAPS) != 0;
|
||||
//if(!bSGIX_shadow && lof->shadow_type == EST_DEPTH_BUFFER)
|
||||
// return;
|
||||
|
||||
// normalize size
|
||||
while(nShadowTexSize>m_height || nShadowTexSize>m_width)
|
||||
nShadowTexSize/=2;
|
||||
|
||||
if (m_LogFile)
|
||||
Logv(SRendItem::m_RecurseLevel, " Really generating %dx%d shadow map for %s \n", nShadowTexSize, nShadowTexSize, lof->pOwner ? lof->pOwner->GetName() : "NoOwner");
|
||||
|
||||
// setup matrices
|
||||
int vX, vY, vWidth, vHeight;
|
||||
gRenDev->GetViewport(&vX, &vY, &vWidth, &vHeight);
|
||||
gRenDev->SetViewport(0, 0, nShadowTexSize, nShadowTexSize);
|
||||
|
||||
float lightFrustumMatrix[16];
|
||||
float lightViewMatrix[16];
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
makeProjectionMatrix(lof->FOV, lof->ProjRatio, lof->min_dist, lof->max_dist, lightFrustumMatrix);
|
||||
glLoadMatrixf(lightFrustumMatrix);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
SGLFuncs::gluLookAt( lof->pLs->vSrcPos.x, lof->pLs->vSrcPos.y, lof->pLs->vSrcPos.z,
|
||||
lof->target.x, lof->target.y, lof->target.z,
|
||||
0, 0, 1, lightViewMatrix);
|
||||
glLoadMatrixf(lightViewMatrix);
|
||||
//iLog->Log("Generate SM: From (%.3f,%.3f,%.3f) To (%.3f,%.3f,%.3f), FOV: %.3f, MinD: %.3f, MaxD: %.3f", lof->pLs->vSrcPos.x, lof->pLs->vSrcPos.y, lof->pLs->vSrcPos.z, lof->target.x, lof->target.y, lof->target.z, lof->FOV, lof->min_dist, lof->max_dist);
|
||||
|
||||
memcpy(lof->debugLightFrustumMatrix,lightFrustumMatrix,sizeof(lof->debugLightFrustumMatrix));
|
||||
memcpy(lof->debugLightViewMatrix, lightViewMatrix, sizeof(lof->debugLightViewMatrix));
|
||||
|
||||
// clear frame buffer
|
||||
CFColor col;
|
||||
if (!(m_Features & RFT_DEPTHMAPS) && (m_Features & RFT_SHADOWMAP_SELFSHADOW))
|
||||
col = CFColor(1,0.879f,0,0);
|
||||
else
|
||||
col = CFColor(0,0,0,0);
|
||||
EF_ClearBuffers(true, false, &col[0]);
|
||||
|
||||
// disable rendering of borders
|
||||
glScissor(1, 1, nShadowTexSize-2, nShadowTexSize-2);
|
||||
glEnable (GL_SCISSOR_TEST);
|
||||
|
||||
IShader * pStateShader = EF_LoadShader("StateNoCull", eSH_World);
|
||||
|
||||
// draw static objects (not entities)
|
||||
if(lof->pModelsList && lof->pModelsList->Count())
|
||||
{
|
||||
// cut underground geometry
|
||||
float plane[] = {0,0,1,0};
|
||||
|
||||
//if(!bDepth)
|
||||
// gRenDev->SetClipPlane(0,plane);
|
||||
|
||||
EF_StartEf();
|
||||
for(int m=0; m<lof->pModelsList->Count(); m++)
|
||||
{
|
||||
SRendParams rParms;
|
||||
rParms.pStateShader = pStateShader;
|
||||
if(!lof->m_fBending)
|
||||
rParms.nShaderTemplate = EFT_WHITESHADOW;
|
||||
|
||||
// set pos relative to entity 0
|
||||
if(lof->pEntityList && lof->pEntityList->Count())
|
||||
rParms.vPos -= (*lof->pEntityList)[0]->GetPos();
|
||||
rParms.dwFObjFlags |= FOB_TRANS_MASK;
|
||||
rParms.dwFObjFlags |= FOB_RENDER_INTO_SHADOWMAP;
|
||||
|
||||
rParms.fBending = lof->m_fBending;
|
||||
|
||||
(*lof->pModelsList)[m]->Render(rParms,Vec3(zero),0);
|
||||
}
|
||||
EF_EndEf3D(true);
|
||||
|
||||
gRenDev->SetClipPlane(0,NULL);
|
||||
}
|
||||
|
||||
// draw entities
|
||||
EF_StartEf();
|
||||
for(int m=0; lof->pEntityList && m_RP.m_pCurObject && m<lof->pEntityList->Count(); m++)
|
||||
{
|
||||
IEntityRender * pEnt = (*lof->pEntityList)[m];
|
||||
const char *name = pEnt->GetName();
|
||||
Vec3d vOffSetDir = GetNormalized( m_RP.m_pCurObject->GetTranslation() - lof->pLs->vSrcPos )*(0.1f+0.035f*(256.f/nShadowTexSize));
|
||||
IEntityRender * pEnt0 = (*lof->pEntityList)[0];
|
||||
SRendParams rParams;
|
||||
rParams.nShaderTemplate = bDepth ? EFT_WHITE : EFT_WHITESHADOW;
|
||||
rParams.pStateShader = pStateShader;
|
||||
rParams.vPos = vOffSetDir + (pEnt->GetPos() - lof->pOwner->GetPos());
|
||||
rParams.dwFObjFlags |= FOB_RENDER_INTO_SHADOWMAP;
|
||||
rParams.dwFObjFlags |= FOB_TRANS_MASK;
|
||||
pEnt->DrawEntity(rParams);
|
||||
}
|
||||
EF_EndEf3D(true);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Now make texture from frame buffer
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(make_new_tid)
|
||||
{ // new id for static objects
|
||||
glGenTextures(1,&lof->depth_tex_id);
|
||||
assert(lof->depth_tex_id<14000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// try to reuse slot if it was not modified
|
||||
if( lof->nTexIdSlot>=0 &&
|
||||
m_ShadowTexIDBuffer[lof->nTexIdSlot].nTexId == lof->depth_tex_id &&
|
||||
m_ShadowTexIDBuffer[lof->nTexIdSlot].nTexSize == nShadowTexSize &&
|
||||
m_ShadowTexIDBuffer[lof->nTexIdSlot].pOwner == lof->pOwner &&
|
||||
m_ShadowTexIDBuffer[lof->nTexIdSlot].pOwnerGroup == lof->pOwnerGroup &&
|
||||
m_ShadowTexIDBuffer[lof->nTexIdSlot].dwFlags == lof->dwFlags)
|
||||
{
|
||||
nCurTexIdSlot = lof->nTexIdSlot;
|
||||
}
|
||||
else
|
||||
{ // find oldest slot
|
||||
int nOldestSlot = -1;
|
||||
int nOldestFrameId = GetFrameID();
|
||||
for(int i=0; i<MAX_DYNAMIC_SHADOW_MAPS_COUNT; i++)
|
||||
{
|
||||
if(m_ShadowTexIDBuffer[i].nLastFrameID < nOldestFrameId && nShadowTexSize == m_ShadowTexIDBuffer[i].nTexSize)
|
||||
{
|
||||
nOldestFrameId = m_ShadowTexIDBuffer[i].nLastFrameID;
|
||||
nOldestSlot = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(nOldestSlot<0)
|
||||
nCurTexIdSlot++;
|
||||
else
|
||||
nCurTexIdSlot=nOldestSlot;
|
||||
|
||||
nCurTexIdSlot = nCurTexIdSlot;
|
||||
}
|
||||
|
||||
if(nCurTexIdSlot>=MAX_DYNAMIC_SHADOW_MAPS_COUNT)
|
||||
nCurTexIdSlot=0;
|
||||
|
||||
if(!m_ShadowTexIDBuffer[nCurTexIdSlot].nTexId)
|
||||
{
|
||||
glGenTextures(1,&m_ShadowTexIDBuffer[nCurTexIdSlot].nTexId);
|
||||
assert(m_ShadowTexIDBuffer[nCurTexIdSlot].nTexId<14000);
|
||||
make_new_tid = true;
|
||||
}
|
||||
if (m_ShadowTexIDBuffer[nCurTexIdSlot].nTexSize != nShadowTexSize)
|
||||
make_new_tid = true;
|
||||
|
||||
lof->nTexIdSlot = nCurTexIdSlot;
|
||||
lof->depth_tex_id = m_ShadowTexIDBuffer[nCurTexIdSlot].nTexId;
|
||||
|
||||
m_ShadowTexIDBuffer[nCurTexIdSlot].pOwner = lof->pOwner;
|
||||
m_ShadowTexIDBuffer[nCurTexIdSlot].pOwnerGroup = lof->pOwnerGroup;
|
||||
m_ShadowTexIDBuffer[nCurTexIdSlot].dwFlags = lof->dwFlags;
|
||||
m_ShadowTexIDBuffer[nCurTexIdSlot].nLastFrameID = GetFrameID();
|
||||
m_ShadowTexIDBuffer[nCurTexIdSlot].nTexSize = nShadowTexSize;
|
||||
}
|
||||
ShadowMapTexInfo *st = NULL;
|
||||
if (CV_r_shadowblur && !(m_Features & RFT_DEPTHMAPS))
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<m_TempShadowTextures.Num(); i++)
|
||||
{
|
||||
st = &m_TempShadowTextures[i];
|
||||
if (st->nTexSize == nShadowTexSize)
|
||||
break;
|
||||
}
|
||||
if (i == m_TempShadowTextures.Num())
|
||||
{
|
||||
ShadowMapTexInfo smt;
|
||||
smt.nTexId = 0;
|
||||
smt.nTexSize = nShadowTexSize;
|
||||
m_TempShadowTextures.AddElem(smt);
|
||||
}
|
||||
st = &m_TempShadowTextures[i];
|
||||
if (!st->nTexId)
|
||||
{
|
||||
glGenTextures(1,&st->nTexId);
|
||||
gRenDev->m_TexMan->SetTexture(st->nTexId, eTT_Base);
|
||||
}
|
||||
if (CV_r_shadowblur > 2 && !CRenderer::CV_r_nops20 && !st->nTexIdTemp)
|
||||
glGenTextures(1,&st->nTexIdTemp);
|
||||
int BlurType = CV_r_shadowblur-1;
|
||||
if (CV_r_shadowblur > 2 && CRenderer::CV_r_nops20)
|
||||
BlurType = 1;
|
||||
BlurImage(nShadowTexSize, nShadowTexSize, BlurType, st->nTexId, st->nTexIdTemp);
|
||||
}
|
||||
//assert(nShadowTexSize);
|
||||
//assert(lof->nTexSize);
|
||||
|
||||
static ICVar * pVar = iConsole->GetCVar("e_shadow_maps_debug");
|
||||
if (pVar && pVar->GetIVal()==1)
|
||||
{
|
||||
int width = nShadowTexSize;
|
||||
int height = nShadowTexSize;
|
||||
if (bDepth)
|
||||
{
|
||||
byte *pic = new byte [width * height];
|
||||
glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, pic);
|
||||
char buff[128];
|
||||
sprintf(buff, "ShadowMap%00d.tga", nCurTexIdSlot);
|
||||
WriteTGA8(pic,width,height,buff);
|
||||
delete [] pic;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte *pic = new byte [width * height * 4];
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pic);
|
||||
char buff[128];
|
||||
sprintf(buff, "ShadowMap%00d.tga", nCurTexIdSlot);
|
||||
::WriteTGA(pic,width,height,buff,32);
|
||||
delete [] pic;
|
||||
}
|
||||
}
|
||||
|
||||
gRenDev->m_TexMan->SetTexture(lof->depth_tex_id, eTT_Base);
|
||||
|
||||
// make texture of requested type
|
||||
if(bDepth)
|
||||
{
|
||||
glCopyTexImage2D( GL_TEXTURE_2D,
|
||||
0,
|
||||
bDepth ? (m_zbpp == 24 ? GL_DEPTH_COMPONENT24_SGIX : GL_DEPTH_COMPONENT16_SGIX) : GL_DEPTH_COMPONENT,
|
||||
0,
|
||||
0,
|
||||
nShadowTexSize,
|
||||
nShadowTexSize,
|
||||
0);
|
||||
}
|
||||
else if(lof->shadow_type == EST_PENUMBRA)
|
||||
{ // make penumbra texture
|
||||
int width = nShadowTexSize;
|
||||
int height = nShadowTexSize;
|
||||
byte * pDepthMap = new byte [width * height];
|
||||
glReadPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, pDepthMap);
|
||||
WriteTGA8(pDepthMap,width,height,"_DepthMap.tga");
|
||||
|
||||
byte * pPenumbra = new byte [width * height];
|
||||
assert(width==height);
|
||||
MakePenumbraTextureFromDepthMap(pDepthMap, width, pPenumbra);
|
||||
WriteTGA8(pPenumbra,width,height,"_Penumbra.tga");
|
||||
delete [] pDepthMap;
|
||||
|
||||
// make gl texture
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, width, width, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, pPenumbra);
|
||||
delete [] pPenumbra;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(1)//lof->dynamic)
|
||||
{ // entities
|
||||
if(make_new_tid)
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, nShadowTexSize, nShadowTexSize, 0);
|
||||
else
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, nShadowTexSize, nShadowTexSize);
|
||||
}
|
||||
else
|
||||
{ // static objects
|
||||
assert(nShadowTexSize<=512);
|
||||
byte *depth_map = new byte[512*512];
|
||||
glReadPixels(0, 0, nShadowTexSize, nShadowTexSize, GL_RED, GL_UNSIGNED_BYTE, depth_map);
|
||||
|
||||
for(int x=0; x<nShadowTexSize; x++)
|
||||
for(int y=0; y<nShadowTexSize; y++)
|
||||
{
|
||||
byte b;
|
||||
if(depth_map[x+y*nShadowTexSize] < 12) // we render normal object, not black
|
||||
b = 0;
|
||||
else
|
||||
b = 255;
|
||||
|
||||
// clear border
|
||||
if(x==0 || x==nShadowTexSize-1)
|
||||
if(y==0 || y==nShadowTexSize-1)
|
||||
b = 0;
|
||||
|
||||
depth_map[x+y*nShadowTexSize] = b;
|
||||
}
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_ALPHA_ARB,//GL_ALPHA,
|
||||
nShadowTexSize, nShadowTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, depth_map);
|
||||
|
||||
delete [] depth_map;
|
||||
}
|
||||
}
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
if(bDepth)
|
||||
{ // enable extension
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_SGIX, GL_TRUE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_OPERATOR_SGIX, GL_TEXTURE_LEQUAL_R_SGIX);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
gRenDev->SetViewport(vX, vY, vWidth, vHeight);
|
||||
gRenDev->SetScissor(0, 0, 0, 0);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
glClearColor(m_vClearColor.x,m_vClearColor.y,m_vClearColor.z,0);
|
||||
SetState(GS_DEPTHWRITE);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if(bFog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
if(lof->pPenumbra && lof->pPenumbra->bUpdateRequested)
|
||||
PrepareDepthMap(lof->pPenumbra, make_new_tid);
|
||||
}
|
||||
|
||||
void MakePenumbraTextureFromDepthMap(byte * pDepthMapIn, int nSize, byte * pPenumbraMapOut)
|
||||
{
|
||||
memcpy(pPenumbraMapOut,pDepthMapIn,nSize*nSize);
|
||||
|
||||
BlurImage8(pPenumbraMapOut, nSize, 3);
|
||||
|
||||
#define DATA_TMP(_x,_y) (pTemp[(_x)+nSize*(_y)])
|
||||
#define DATA(_x,_y) (pPenumbraMapOut[(_x)+nSize*(_y)])
|
||||
|
||||
{ // substract
|
||||
for(int x=0; x<nSize; x++)
|
||||
for(int y=0; y<nSize; y++)
|
||||
{
|
||||
float fVal = (float)DATA(x,y) - (float)pDepthMapIn[x+nSize*y];
|
||||
|
||||
fVal = (fVal*2.f) + 127.f;
|
||||
|
||||
DATA(x,y) = uchar( max(min(fVal,255),0) );
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(pDepthMapIn,pPenumbraMapOut,nSize*nSize);
|
||||
|
||||
{ // per fragment normalization
|
||||
int nRange = 1;
|
||||
for(int X=nRange; X<nSize-nRange; X++)
|
||||
for(int Y=nRange; Y<nSize-nRange; Y++)
|
||||
{
|
||||
// DATA(X,Y) = DATA(X,Y)>4 ? 255 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
{ // per fragment normalization
|
||||
int nRange = 8;
|
||||
for(int X=nRange; X<nSize-nRange-1; X++)
|
||||
for(int Y=nRange; Y<nSize-nRange-1; Y++)
|
||||
{
|
||||
float fMax = 0;
|
||||
for(int x=X-nRange; x<=X+nRange; x++)
|
||||
for(int y=Y-nRange; y<=Y+nRange; y++)
|
||||
{
|
||||
if(fMax < pDepthMapIn[x+nSize*y])
|
||||
fMax = pDepthMapIn[x+nSize*y];
|
||||
}
|
||||
|
||||
if(fMax)
|
||||
{
|
||||
float fValue = (float)pDepthMapIn[X+nSize*Y];
|
||||
float fNewValue = (fValue/fMax)*255.f;
|
||||
DATA(X,Y) = uchar( max(min(fNewValue,255),0) );
|
||||
}
|
||||
else
|
||||
{
|
||||
DATA(X,Y) = 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
#undef DATA
|
||||
#undef DATA_IN
|
||||
|
||||
// BlurImage8(pPenumbraMapOut, nSize, 1);
|
||||
}
|
||||
|
||||
inline void glShadowVertex(int x, int y)
|
||||
{
|
||||
glVertex3f((float)x, (float)y, iSystem->GetI3DEngine()->GetTerrainZ(x,y)+0.05f);//iTerrain->GetZSafe(x,y)/*+0.05f*/);
|
||||
}
|
||||
|
||||
void CGLRenderer::SetupShadowOnlyPass(int Num, ShadowMapFrustum * pFrustum, Vec3d * vShadowTrans, const float fShadowScale,
|
||||
Vec3d vObjTrans, float fObjScale, const Vec3d vObjAngles, Matrix44 * pObjMat)
|
||||
{
|
||||
if(!pFrustum)
|
||||
return;
|
||||
|
||||
float lightFrustumMatrix[16];
|
||||
float lightViewMatrix[16];
|
||||
|
||||
if(vShadowTrans)
|
||||
{ // make tmp matrix for this obj position if shadow frustum is not translated (translate original mats)
|
||||
// float fDist = (pFrustum->min_dist + pFrustum->max_dist)*0.5f;
|
||||
// float fRadius = (pFrustum->max_dist - pFrustum->min_dist)*0.5f*fShadowScale;
|
||||
makeProjectionMatrix(pFrustum->FOV*fShadowScale, pFrustum->ProjRatio, pFrustum->min_dist, pFrustum->max_dist, lightFrustumMatrix);
|
||||
|
||||
Vec3d mv_trans = *vShadowTrans; // - vObjTrans;
|
||||
float mat[16];
|
||||
|
||||
SGLFuncs::gluLookAt(
|
||||
pFrustum->pLs->vSrcPos.x+mv_trans.x,
|
||||
pFrustum->pLs->vSrcPos.y+mv_trans.y,
|
||||
pFrustum->pLs->vSrcPos.z+mv_trans.z,
|
||||
fShadowScale*pFrustum->target.x+mv_trans.x,
|
||||
fShadowScale*pFrustum->target.y+mv_trans.y,
|
||||
fShadowScale*pFrustum->target.z+mv_trans.z,
|
||||
0, 0, 1, mat );
|
||||
|
||||
if(pObjMat)
|
||||
mathMatrixMultiply(lightViewMatrix, mat, pObjMat->GetData(), g_CpuFlags);
|
||||
else
|
||||
{
|
||||
mathRotateZ(mat, vObjAngles.z, g_CpuFlags);
|
||||
mathRotateY(mat, vObjAngles.y, g_CpuFlags);
|
||||
mathRotateX(mat, vObjAngles.x, g_CpuFlags);
|
||||
mathScale(mat, Vec3d(fObjScale,fObjScale,fObjScale), g_CpuFlags);
|
||||
memcpy(lightViewMatrix, mat, sizeof(float)*16);
|
||||
}
|
||||
}
|
||||
|
||||
CGLTexMan::BindNULL(1);
|
||||
|
||||
gcpOGL->ConfigShadowTexgen(Num, 0, pFrustum, lightFrustumMatrix, lightViewMatrix);
|
||||
}
|
||||
|
||||
// Make 8-bit identity texture that maps (s)=(z) to [0,255]/255.
|
||||
int MakeShadowIdentityTexture()
|
||||
{
|
||||
uchar texmap[256];
|
||||
for (unsigned int i=0; i<256; i++)
|
||||
texmap[i] = i;
|
||||
|
||||
unsigned int tid;
|
||||
glGenTextures(1,&tid);
|
||||
assert(tid<14000);
|
||||
glBindTexture(GL_TEXTURE_1D, tid);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_INTENSITY8, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, texmap);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
return tid;
|
||||
}
|
||||
|
||||
// setup projection texgen
|
||||
void CGLRenderer::ConfigShadowTexgen(int Num, int rangeMap, ShadowMapFrustum * pFrustum, float * pLightFrustumMatrix, float * pLightViewMatrix)
|
||||
{
|
||||
float m1[16], m2[16], mtexSc[16];
|
||||
|
||||
if (rangeMap)
|
||||
{
|
||||
static int to_map_8bit = MakeShadowIdentityTexture();
|
||||
|
||||
float RSmatrix[16] =
|
||||
{
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0.5f, 128, 0, 0,
|
||||
0.5f, 128, 0, 1.0f
|
||||
};
|
||||
|
||||
if (Num >= 0)
|
||||
{
|
||||
m_RP.m_pRE->m_CustomTexBind[Num] = to_map_8bit;
|
||||
gRenDev->m_TexMan->SetTexture(to_map_8bit, eTT_Base);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_1D, to_map_8bit);
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
memcpy(mtexSc,RSmatrix,sizeof(m1));
|
||||
}
|
||||
else
|
||||
{
|
||||
float Smatrix[16] =
|
||||
{
|
||||
0.5f, 0, 0, 0,
|
||||
0, 0.5f, 0, 0,
|
||||
0, 0, 0.5f, 0,
|
||||
0.5f, 0.5f, 0.5f, 1.0f
|
||||
};
|
||||
|
||||
if (Num >= 0)
|
||||
{
|
||||
if(pFrustum->depth_tex_id<=0)
|
||||
iLog->Log("Warning: CGLRenderer::ConfigShadowTexgen: pFrustum->depth_tex_id not set");
|
||||
else
|
||||
{
|
||||
if (m_RP.m_pRE)
|
||||
{
|
||||
m_RP.m_pRE->m_CustomTexBind[Num] = pFrustum->depth_tex_id;
|
||||
m_RP.m_pRE->m_Color[Num] = pFrustum->fAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RP.m_RECustomTexBind[Num] = pFrustum->depth_tex_id;
|
||||
m_RP.m_REColor[Num] = pFrustum->fAlpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gRenDev->m_TexMan->SetTexture(pFrustum->depth_tex_id, eTT_Base);
|
||||
}
|
||||
|
||||
memcpy(mtexSc,Smatrix,sizeof(m1));
|
||||
}
|
||||
|
||||
mathMatrixMultiply(m2, pLightFrustumMatrix, pLightViewMatrix, g_CpuFlags);
|
||||
|
||||
if (Num >= 0)
|
||||
{
|
||||
Matrix44 *mt = &gRenDev->m_cEF.m_TempMatrices[Num][0];
|
||||
float *pf = mt->GetData();
|
||||
mathMatrixMultiply(m1, mtexSc, m2, g_CpuFlags);
|
||||
mathMatrixTranspose(pf, m1, g_CpuFlags);
|
||||
|
||||
if ((m_Features & RFT_SHADOWMAP_SELFSHADOW) && !(m_Features & RFT_DEPTHMAPS))
|
||||
{
|
||||
Matrix44 *mt = &gRenDev->m_cEF.m_TempMatrices[Num][7];
|
||||
float *pf = mt->GetData();
|
||||
mathMatrixTranspose(pf, m2, g_CpuFlags);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
//#include "nvparse/nvparse.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Render shadows on the object as first pass
|
||||
///////////////////////////////////////////////////////////////////
|
||||
/*bool CREShadowMap::mfDraw(SShader *ef, SShaderPass *sfm)
|
||||
{
|
||||
if(m_pShadowFrustum==0 && m_fAlpha == -1)
|
||||
{ // special case: draw all tree shadows
|
||||
iSystem->GetI3DEngine()->DrawTerrainShadowMaps();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(gRenDev->m_RP.m_pCurObject->m_Trans.GetDistance(Vec3d(512,512,100))>2000)
|
||||
return true;
|
||||
// iConsole->Exit("CREShadowMap::mfDraw");
|
||||
|
||||
if(gRenDev->m_RP.m_pCurObject->m_ObjFlags != FOB_USEMATRIX)
|
||||
gRenDev->MakeMatrix(gRenDev->m_RP.m_pCurObject->m_Trans, gRenDev->m_RP.m_pCurObject->m_Angs, Vec3d(1,1,1), &(gRenDev->m_RP.m_pCurObject->m_Matrix));
|
||||
|
||||
// draw shadow on the ground
|
||||
ShadowMapLightSource * pFrustum = (ShadowMapLightSource*)m_pShadowFrustum;
|
||||
if(pFrustum && pFrustum->m_LightFrustums.Count() && m_fAlpha>0)
|
||||
{
|
||||
// float alpha = gRenDev->m_RP.m_pCurObject->m_Trans.Distance(iSystem->GetViewCamera().GetPos());
|
||||
// alpha = 1 - alpha/32;
|
||||
if(m_fAlpha>0)
|
||||
{
|
||||
// restore world space
|
||||
Matrix mat(gRenDev->m_RP.m_pCurObject->m_Matrix);
|
||||
mat.Invert();
|
||||
gRenDev->PushMatrix();
|
||||
gRenDev->MultMatrix(&mat.m_values[0][0]);
|
||||
gRenDev->ResetToDefault();
|
||||
gRenDev->DrawShadowGrid(gRenDev->m_RP.m_pCurObject->m_Trans, gRenDev->m_RP.m_pCurObject->m_Scale,
|
||||
&pFrustum->m_LightFrustums[0], false, m_fAlpha, 0, 0);
|
||||
gRenDev->PopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
*/
|
||||
/* if(!m_pBuffer->m_pVertexBuffer || !gRenDev->m_RP.m_pCurObject->m_pShadowCasters)
|
||||
return true;
|
||||
|
||||
list2<ShadowMapLightSourceInstance> * lsources = (list2<ShadowMapLightSourceInstance>*)gRenDev->m_RP.m_pCurObject->m_pShadowCasters;
|
||||
|
||||
if(lsources->Count()==1)
|
||||
if((*lsources)[0].ls->m_LightFrustums.Count()==0)
|
||||
return true;
|
||||
|
||||
// restore world space
|
||||
Matrix mat(gRenDev->m_RP.m_pCurObject->m_Matrix);
|
||||
mat.Invert();
|
||||
gRenDev->PushMatrix();
|
||||
gRenDev->MultMatrix(&mat.m_values[0][0]);
|
||||
gRenDev->ResetToDefault();
|
||||
|
||||
// draw white
|
||||
gRenDev->ResetToDefault();
|
||||
gRenDev->EnableTMU(false);
|
||||
gRenDev->SetMaterialColor(1, 1, 1, 1);
|
||||
gRB.mStateIgnore |= (RBSI_ALPHAGEN | RBSI_RGBGEN);
|
||||
gRenDev->SetEnviMode(R_MODE_MODULATE);
|
||||
|
||||
gRenDev->PushMatrix();
|
||||
gRenDev->MultMatrix(gRenDev->m_RP.m_pCurObject->m_Matrix);
|
||||
|
||||
static int lid =0;
|
||||
if(!lid)
|
||||
{
|
||||
lid = glGenLists(1);
|
||||
glNewList(lid,GL_COMPILE);
|
||||
nvparse(
|
||||
"!!RC1.0"
|
||||
"out.rgb = col0;"
|
||||
"out.a = tex0.a;"
|
||||
);
|
||||
glEndList();
|
||||
}
|
||||
|
||||
glCallList(lid);
|
||||
|
||||
glEnable(GL_REGISTER_COMBINERS_NV);
|
||||
|
||||
char * const * const p = nvparse_get_errors();
|
||||
assert(!p[0]);
|
||||
|
||||
gRenDev->EnableAlphaTest(true);
|
||||
gRenDev->SetCullMode(R_CULL_NONE);
|
||||
gRenDev->EnableTMU(true);
|
||||
|
||||
gRB.mStateIgnore = 0;
|
||||
|
||||
for(int m=0; m<m_pBuffer->m_pMats->Count(); m++)
|
||||
{
|
||||
CMatInfo * pMat = &(*m_pBuffer->m_pMats)[m];
|
||||
if(pMat->nNumIndices && pMat->pShader)
|
||||
{
|
||||
SShader *ef = pMat->pShader->mfGetTemplate(-1);
|
||||
int bind = ef->m_Layers[0].m_MTLayers[0]->m_TexPic->m_Bind;
|
||||
|
||||
gRenDev->SetTexture(bind);
|
||||
|
||||
gRenDev->DrawBuffer(m_pBuffer->m_pVertexBuffer,
|
||||
&m_pBuffer->m_Indices[pMat->nFirstIndexId],
|
||||
pMat->nNumIndices,
|
||||
m_pBuffer->m_nPrimetiveType);
|
||||
}
|
||||
}
|
||||
|
||||
gRenDev->PopMatrix();
|
||||
|
||||
glDisable(GL_REGISTER_COMBINERS_NV);
|
||||
|
||||
// draw closest shadows
|
||||
for(int s=0; s<lsources->Count() && s<4; s++)
|
||||
if((*lsources)[s].ls->m_LightFrustums.Count())
|
||||
{
|
||||
gRenDev->ResetToDefault();
|
||||
gRenDev->SetCullMode(R_CULL_NONE);
|
||||
gRenDev->SetupShadowOnlyPass(&((*lsources)[s].ls->m_LightFrustums[0]), &((*lsources)[s].translation));
|
||||
|
||||
gRenDev->EnableBlend(true);
|
||||
gRenDev->SetEnviMode(R_MODE_MODULATE);
|
||||
gRenDev->SetBlendMode(R_BLEND_MODE__ZERO__ONE_MINUS_SRC_COLOR);
|
||||
gRenDev->SetDepthFunc(R_EQUAL);
|
||||
gRenDev->SetMaterialColor(1, 1, 1, 1);
|
||||
gRB.mStateIgnore |= (RBSI_ALPHAGEN | RBSI_RGBGEN);
|
||||
|
||||
gRenDev->PushMatrix();
|
||||
gRenDev->MultMatrix(gRenDev->m_RP.m_pCurObject->m_Matrix);
|
||||
gRenDev->DrawBuffer(m_pBuffer->m_pVertexBuffer, &m_pBuffer->m_Indices[0], m_pBuffer->m_Indices.Count(), m_pBuffer->m_nPrimetiveType);
|
||||
gRenDev->PopMatrix();
|
||||
|
||||
gRenDev->ResetToDefault();
|
||||
}
|
||||
|
||||
gRenDev->PopMatrix();
|
||||
|
||||
gRenDev->CheckError("CREShadowMap::mfDraw");
|
||||
|
||||
return true;*/
|
||||
/*}
|
||||
*/
|
||||
/*void CGLRenderer::ClearAlphaBuffer(float fAlphaValue)
|
||||
{
|
||||
glColorMask(0,0,0,1);
|
||||
glColor4f(fAlphaValue,fAlphaValue,fAlphaValue,fAlphaValue);
|
||||
|
||||
SelectTMU(1);
|
||||
EnableTMU(false);
|
||||
SelectTMU(0);
|
||||
EnableTMU(false);
|
||||
|
||||
int x1=0,x2=m_width,y1=0,y2=m_height;
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(x1, x2, y2, y1, -1.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2i(x1,y1);
|
||||
glVertex2i(x2,y1);
|
||||
glVertex2i(x2,y2);
|
||||
glVertex2i(x1,y2);
|
||||
glEnd();
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
EnableTMU(true);
|
||||
}
|
||||
*/
|
||||
142
RenderDll/XRenderOGL/GL_Textures.cpp
Normal file
142
RenderDll/XRenderOGL/GL_Textures.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Crytek CryENGINE Source code
|
||||
//
|
||||
// File:Gl_Textures.cpp
|
||||
// mostrly not used now
|
||||
//
|
||||
// History:
|
||||
// -Jan 31,2001:Created by Vladimir Kajalin
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
|
||||
#include "IStatObj.h"
|
||||
|
||||
void CGLRenderer::SetTexture(int tnum, ETexType Type)
|
||||
{
|
||||
m_TexMan->SetTexture(tnum, Type);
|
||||
}
|
||||
|
||||
void WriteTGA(byte *data, int width, int height, char *filename, int dest_bits_per_pixel);
|
||||
|
||||
uint CGLRenderer::Make3DSprite(int nTexSize, float fAngleStep, IStatObj * pStatObj)
|
||||
{
|
||||
char name[128];
|
||||
int flags = FT_HASALPHA;
|
||||
int flags2 = FT2_NODXT | FT2_DISCARDINCACHE;
|
||||
sprintf(name, "$Spr_%s", pStatObj->GetFileName());
|
||||
//STexPic *ti = m_TexMan->LoadFromCache(NULL, flags, flags2, name, pStatObj->GetFileName());
|
||||
//if (ti)
|
||||
// return ti->m_Bind;
|
||||
|
||||
int bFog=0; // remember fog value
|
||||
glGetIntegerv(GL_FOG,&bFog);
|
||||
glDisable(GL_FOG);
|
||||
|
||||
int nTexCount = int(360.f/fAngleStep);
|
||||
uchar * pMemBuffer = new uchar [nTexSize*nTexSize*nTexCount*4];
|
||||
|
||||
for(int i=0; i<nTexCount; i++)
|
||||
{
|
||||
// render object
|
||||
ClearColorBuffer(Vec3d(0.15f, 0.15f, 0.15f));
|
||||
ClearDepthBuffer();
|
||||
|
||||
glReadBuffer(GL_BACK);
|
||||
glDrawBuffer(GL_BACK);
|
||||
|
||||
// cals vertical/horisontal radiuses
|
||||
float dxh = (float)max( fabs(pStatObj->GetBoxMax().x), fabs(pStatObj->GetBoxMin().x));
|
||||
float dyh = (float)max( fabs(pStatObj->GetBoxMax().y), fabs(pStatObj->GetBoxMin().y));
|
||||
float fRadiusHors = (float)sqrt_tpl(dxh*dxh + dyh*dyh);//max(dxh,dyh);
|
||||
float fRadiusVert = (pStatObj->GetBoxMax().z-pStatObj->GetBoxMin().z)*0.5f;
|
||||
|
||||
float fDrawDist = fRadiusVert*25.f*8.f;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective( 0.58f, fRadiusHors/fRadiusVert, fDrawDist-fRadiusHors*2, fDrawDist+fRadiusHors*2);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glViewport(0, 0, nTexSize, nTexSize);
|
||||
glLoadIdentity();
|
||||
|
||||
Vec3d vCenter = (pStatObj->GetBoxMax()+pStatObj->GetBoxMin())*0.5f;
|
||||
|
||||
gluLookAt( 0,0,0, -1,0,0, 0,0,1 );
|
||||
|
||||
glColor4f(1,1,1,1);
|
||||
glPushMatrix();
|
||||
glTranslatef(-fDrawDist,0,0);
|
||||
glRotatef(fAngleStep*i, 0,0,1);
|
||||
glTranslatef(-vCenter.x,-vCenter.y,-vCenter.z);
|
||||
|
||||
ResetToDefault();
|
||||
EF_SetWorldColor(0.5,0.5,0.5);
|
||||
|
||||
EF_StartEf();
|
||||
SRendParams rParms;
|
||||
pStatObj->Render(rParms,Vec3(zero),0);
|
||||
EF_EndEf3D(true);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
// read into buffer and make texture
|
||||
assert(nTexSize<=1024);//just warning
|
||||
|
||||
glReadPixels(0, 0, nTexSize, nTexSize, GL_RGBA, GL_UNSIGNED_BYTE, &pMemBuffer[nTexSize*nTexSize*i*4]);
|
||||
|
||||
SetTextureAlphaChannelFromRGB(&pMemBuffer[nTexSize*nTexSize*i*4], nTexSize);
|
||||
/*
|
||||
{
|
||||
int width = 64;
|
||||
int height = 64;
|
||||
int imid=i;
|
||||
char buff[32]="";
|
||||
sprintf(buff, "sprite%d.tga", imid);
|
||||
imid++;
|
||||
for(int x=0; x<nTexSize*nTexSize*4; x+=4)
|
||||
{
|
||||
Exchange(pMemBuffer[x+0], pMemBuffer[x+2]);
|
||||
}
|
||||
|
||||
::WriteTGA(&pMemBuffer[nTexSize*nTexSize*i*4], width, height, buff, 32);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// make 3d texture
|
||||
/*glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
uint nTexId=0;
|
||||
glGenTextures(1,&nTexId);
|
||||
SetTexture3D(nTexId);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_3D_EXT, GL_TEXTURE_WRAP_R_EXT, GL_REPEAT);
|
||||
glTexImage3DEXT(GL_TEXTURE_3D_EXT, 0, GL_RGBA8, nTexSize, nTexSize, nTexCount, 0, GL_RGBA, GL_UNSIGNED_BYTE, pMemBuffer);*/
|
||||
|
||||
STexPic *tp = m_TexMan->CreateTexture(name, nTexSize, nTexSize, nTexCount, flags, flags2, pMemBuffer, eTT_3D, -1.0f, -1.0f, 0, NULL, 0, eTF_8888, pStatObj->GetFileName());
|
||||
|
||||
delete [] pMemBuffer;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
SetViewport();
|
||||
|
||||
m_TexMan->SetTexture(0, eTT_Base);
|
||||
|
||||
ResetToDefault();
|
||||
|
||||
if(bFog)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
return tp->m_Bind;
|
||||
}
|
||||
1373
RenderDll/XRenderOGL/GL_VertBuffer.cpp
Normal file
1373
RenderDll/XRenderOGL/GL_VertBuffer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
BIN
RenderDll/XRenderOGL/Libraries/CompressATI.lib
Normal file
BIN
RenderDll/XRenderOGL/Libraries/CompressATI.lib
Normal file
Binary file not shown.
BIN
RenderDll/XRenderOGL/Libraries/cg.lib
Normal file
BIN
RenderDll/XRenderOGL/Libraries/cg.lib
Normal file
Binary file not shown.
BIN
RenderDll/XRenderOGL/Libraries/cgGL.lib
Normal file
BIN
RenderDll/XRenderOGL/Libraries/cgGL.lib
Normal file
Binary file not shown.
BIN
RenderDll/XRenderOGL/Libraries/ijl15.lib
Normal file
BIN
RenderDll/XRenderOGL/Libraries/ijl15.lib
Normal file
Binary file not shown.
BIN
RenderDll/XRenderOGL/Libraries/nvDXTlib.lib
Normal file
BIN
RenderDll/XRenderOGL/Libraries/nvDXTlib.lib
Normal file
Binary file not shown.
BIN
RenderDll/XRenderOGL/Libraries/nvDXTlibMTDLL.lib
Normal file
BIN
RenderDll/XRenderOGL/Libraries/nvDXTlibMTDLL.lib
Normal file
Binary file not shown.
584
RenderDll/XRenderOGL/MyGlu.h
Normal file
584
RenderDll/XRenderOGL/MyGlu.h
Normal file
@@ -0,0 +1,584 @@
|
||||
/*++ BUILD Version: 0004 // Increment this if a change has global effects
|
||||
|
||||
Copyright (c) 1985-95, Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
glu.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Procedure declarations, constant definitions and macros for the OpenGL
|
||||
Utility Library.
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef __glu_h__
|
||||
#ifndef __GLU_H__
|
||||
|
||||
#define __glu_h__
|
||||
#define __GLU_H__
|
||||
|
||||
#include "Mygl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright 1991-1993, Silicon Graphics, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
|
||||
** the contents of this file may not be disclosed to third parties, copied or
|
||||
** duplicated in any form, in whole or in part, without the prior written
|
||||
** permission of Silicon Graphics, Inc.
|
||||
**
|
||||
** RESTRICTED RIGHTS LEGEND:
|
||||
** Use, duplication or disclosure by the Government is subject to restrictions
|
||||
** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
|
||||
** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
|
||||
** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
|
||||
** rights reserved under the Copyright Laws of the United States.
|
||||
*/
|
||||
|
||||
/*
|
||||
** Return the error string associated with a particular error code.
|
||||
** This will return 0 for an invalid error code.
|
||||
**
|
||||
** The generic function prototype that can be compiled for ANSI or Unicode
|
||||
** is defined as follows:
|
||||
**
|
||||
** LPCTSTR APIENTRY gluErrorStringWIN (GLenum errCode);
|
||||
*/
|
||||
#ifdef UNICODE
|
||||
#define gluErrorStringWIN(errCode) ((LPCSTR) gluErrorUnicodeStringEXT(errCode))
|
||||
#else
|
||||
#define gluErrorStringWIN(errCode) ((LPCWSTR) gluErrorString(errCode))
|
||||
#endif
|
||||
|
||||
const GLubyte* APIENTRY gluErrorString (
|
||||
GLenum errCode);
|
||||
|
||||
const wchar_t* APIENTRY gluErrorUnicodeStringEXT (
|
||||
GLenum errCode);
|
||||
|
||||
const GLubyte* APIENTRY gluGetString (
|
||||
GLenum name);
|
||||
|
||||
void APIENTRY gluOrtho2D (
|
||||
GLdouble left,
|
||||
GLdouble right,
|
||||
GLdouble bottom,
|
||||
GLdouble top);
|
||||
|
||||
void APIENTRY gluPerspective (
|
||||
GLdouble fovy,
|
||||
GLdouble aspect,
|
||||
GLdouble zNear,
|
||||
GLdouble zFar);
|
||||
|
||||
void APIENTRY gluPickMatrix (
|
||||
GLdouble x,
|
||||
GLdouble y,
|
||||
GLdouble width,
|
||||
GLdouble height,
|
||||
GLint viewport[4]);
|
||||
|
||||
void APIENTRY gluLookAt (
|
||||
GLdouble eyex,
|
||||
GLdouble eyey,
|
||||
GLdouble eyez,
|
||||
GLdouble centerx,
|
||||
GLdouble centery,
|
||||
GLdouble centerz,
|
||||
GLdouble upx,
|
||||
GLdouble upy,
|
||||
GLdouble upz);
|
||||
|
||||
int APIENTRY gluProject (
|
||||
GLdouble objx,
|
||||
GLdouble objy,
|
||||
GLdouble objz,
|
||||
const GLdouble modelMatrix[16],
|
||||
const GLdouble projMatrix[16],
|
||||
const GLint viewport[4],
|
||||
GLdouble *winx,
|
||||
GLdouble *winy,
|
||||
GLdouble *winz);
|
||||
|
||||
int APIENTRY gluUnProject (
|
||||
GLdouble winx,
|
||||
GLdouble winy,
|
||||
GLdouble winz,
|
||||
const GLdouble modelMatrix[16],
|
||||
const GLdouble projMatrix[16],
|
||||
const GLint viewport[4],
|
||||
GLdouble *objx,
|
||||
GLdouble *objy,
|
||||
GLdouble *objz);
|
||||
|
||||
|
||||
int APIENTRY gluScaleImage (
|
||||
GLenum format,
|
||||
GLint widthin,
|
||||
GLint heightin,
|
||||
GLenum typein,
|
||||
const void *datain,
|
||||
GLint widthout,
|
||||
GLint heightout,
|
||||
GLenum typeout,
|
||||
void *dataout);
|
||||
|
||||
|
||||
int APIENTRY gluBuild1DMipmaps (
|
||||
GLenum target,
|
||||
GLint components,
|
||||
GLint width,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const void *data);
|
||||
|
||||
int APIENTRY gluBuild2DMipmaps (
|
||||
GLenum target,
|
||||
GLint components,
|
||||
GLint width,
|
||||
GLint height,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const void *data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
class GLUnurbs;
|
||||
class GLUquadric;
|
||||
class GLUtesselator;
|
||||
|
||||
/* backwards compatibility: */
|
||||
typedef class GLUnurbs GLUnurbsObj;
|
||||
typedef class GLUquadric GLUquadricObj;
|
||||
typedef class GLUtesselator GLUtesselatorObj;
|
||||
typedef class GLUtesselator GLUtriangulatorObj;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct GLUnurbs GLUnurbs;
|
||||
typedef struct GLUquadric GLUquadric;
|
||||
typedef struct GLUtesselator GLUtesselator;
|
||||
|
||||
/* backwards compatibility: */
|
||||
typedef struct GLUnurbs GLUnurbsObj;
|
||||
typedef struct GLUquadric GLUquadricObj;
|
||||
typedef struct GLUtesselator GLUtesselatorObj;
|
||||
typedef struct GLUtesselator GLUtriangulatorObj;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
GLUquadric* APIENTRY gluNewQuadric (void);
|
||||
void APIENTRY gluDeleteQuadric (
|
||||
GLUquadric *state);
|
||||
|
||||
void APIENTRY gluQuadricNormals (
|
||||
GLUquadric *quadObject,
|
||||
GLenum normals);
|
||||
|
||||
void APIENTRY gluQuadricTexture (
|
||||
GLUquadric *quadObject,
|
||||
GLboolean textureCoords);
|
||||
|
||||
void APIENTRY gluQuadricOrientation (
|
||||
GLUquadric *quadObject,
|
||||
GLenum orientation);
|
||||
|
||||
void APIENTRY gluQuadricDrawStyle (
|
||||
GLUquadric *quadObject,
|
||||
GLenum drawStyle);
|
||||
|
||||
void APIENTRY gluCylinder (
|
||||
GLUquadric *qobj,
|
||||
GLdouble baseRadius,
|
||||
GLdouble topRadius,
|
||||
GLdouble height,
|
||||
GLint slices,
|
||||
GLint stacks);
|
||||
|
||||
void APIENTRY gluDisk (
|
||||
GLUquadric *qobj,
|
||||
GLdouble innerRadius,
|
||||
GLdouble outerRadius,
|
||||
GLint slices,
|
||||
GLint loops);
|
||||
|
||||
void APIENTRY gluPartialDisk (
|
||||
GLUquadric *qobj,
|
||||
GLdouble innerRadius,
|
||||
GLdouble outerRadius,
|
||||
GLint slices,
|
||||
GLint loops,
|
||||
GLdouble startAngle,
|
||||
GLdouble sweepAngle);
|
||||
|
||||
void APIENTRY gluSphere (
|
||||
GLUquadric *qobj,
|
||||
GLdouble radius,
|
||||
GLint slices,
|
||||
GLint stacks);
|
||||
|
||||
void APIENTRY gluQuadricCallback (
|
||||
GLUquadric *qobj,
|
||||
GLenum which,
|
||||
void (CALLBACK* fn)());
|
||||
|
||||
GLUtesselator* APIENTRY gluNewTess(
|
||||
void );
|
||||
|
||||
void APIENTRY gluDeleteTess(
|
||||
GLUtesselator *tess );
|
||||
|
||||
void APIENTRY gluTessBeginPolygon(
|
||||
GLUtesselator *tess,
|
||||
void *polygon_data );
|
||||
|
||||
void APIENTRY gluTessBeginContour(
|
||||
GLUtesselator *tess );
|
||||
|
||||
void APIENTRY gluTessVertex(
|
||||
GLUtesselator *tess,
|
||||
GLdouble coords[3],
|
||||
void *data );
|
||||
|
||||
void APIENTRY gluTessEndContour(
|
||||
GLUtesselator *tess );
|
||||
|
||||
void APIENTRY gluTessEndPolygon(
|
||||
GLUtesselator *tess );
|
||||
|
||||
void APIENTRY gluTessProperty(
|
||||
GLUtesselator *tess,
|
||||
GLenum which,
|
||||
GLdouble value );
|
||||
|
||||
void APIENTRY gluTessNormal(
|
||||
GLUtesselator *tess,
|
||||
GLdouble x,
|
||||
GLdouble y,
|
||||
GLdouble z );
|
||||
|
||||
void APIENTRY gluTessCallback(
|
||||
GLUtesselator *tess,
|
||||
GLenum which,
|
||||
void (CALLBACK *fn)());
|
||||
|
||||
void APIENTRY gluGetTessProperty(
|
||||
GLUtesselator *tess,
|
||||
GLenum which,
|
||||
GLdouble *value );
|
||||
|
||||
GLUnurbs* APIENTRY gluNewNurbsRenderer (void);
|
||||
|
||||
void APIENTRY gluDeleteNurbsRenderer (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluBeginSurface (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluBeginCurve (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluEndCurve (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluEndSurface (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluBeginTrim (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluEndTrim (
|
||||
GLUnurbs *nobj);
|
||||
|
||||
void APIENTRY gluPwlCurve (
|
||||
GLUnurbs *nobj,
|
||||
GLint count,
|
||||
GLfloat *array,
|
||||
GLint stride,
|
||||
GLenum type);
|
||||
|
||||
void APIENTRY gluNurbsCurve (
|
||||
GLUnurbs *nobj,
|
||||
GLint nknots,
|
||||
GLfloat *knot,
|
||||
GLint stride,
|
||||
GLfloat *ctlarray,
|
||||
GLint order,
|
||||
GLenum type);
|
||||
|
||||
void APIENTRY
|
||||
gluNurbsSurface(
|
||||
GLUnurbs *nobj,
|
||||
GLint sknot_count,
|
||||
float *sknot,
|
||||
GLint tknot_count,
|
||||
GLfloat *tknot,
|
||||
GLint s_stride,
|
||||
GLint t_stride,
|
||||
GLfloat *ctlarray,
|
||||
GLint sorder,
|
||||
GLint torder,
|
||||
GLenum type);
|
||||
|
||||
void APIENTRY
|
||||
gluLoadSamplingMatrices (
|
||||
GLUnurbs *nobj,
|
||||
const GLfloat modelMatrix[16],
|
||||
const GLfloat projMatrix[16],
|
||||
const GLint viewport[4] );
|
||||
|
||||
void APIENTRY
|
||||
gluNurbsProperty (
|
||||
GLUnurbs *nobj,
|
||||
GLenum property,
|
||||
GLfloat value );
|
||||
|
||||
void APIENTRY
|
||||
gluGetNurbsProperty (
|
||||
GLUnurbs *nobj,
|
||||
GLenum property,
|
||||
GLfloat *value );
|
||||
|
||||
void APIENTRY
|
||||
gluNurbsCallback (
|
||||
GLUnurbs *nobj,
|
||||
GLenum which,
|
||||
void (CALLBACK* fn)() );
|
||||
|
||||
|
||||
/**** Callback function prototypes ****/
|
||||
|
||||
/* gluQuadricCallback */
|
||||
typedef void (CALLBACK* GLUquadricErrorProc) (GLenum);
|
||||
|
||||
/* gluTessCallback */
|
||||
typedef void (CALLBACK* GLUtessBeginProc) (GLenum);
|
||||
typedef void (CALLBACK* GLUtessEdgeFlagProc) (GLboolean);
|
||||
typedef void (CALLBACK* GLUtessVertexProc) (void *);
|
||||
typedef void (CALLBACK* GLUtessEndProc) (void);
|
||||
typedef void (CALLBACK* GLUtessErrorProc) (GLenum);
|
||||
typedef void (CALLBACK* GLUtessCombineProc) (GLdouble[3],
|
||||
void*[4],
|
||||
GLfloat[4],
|
||||
void** );
|
||||
typedef void (CALLBACK* GLUtessBeginDataProc) (GLenum, void *);
|
||||
typedef void (CALLBACK* GLUtessEdgeFlagDataProc) (GLboolean, void *);
|
||||
typedef void (CALLBACK* GLUtessVertexDataProc) (void *, void *);
|
||||
typedef void (CALLBACK* GLUtessEndDataProc) (void *);
|
||||
typedef void (CALLBACK* GLUtessErrorDataProc) (GLenum, void *);
|
||||
typedef void (CALLBACK* GLUtessCombineDataProc) (GLdouble[3],
|
||||
void*[4],
|
||||
GLfloat[4],
|
||||
void**,
|
||||
void* );
|
||||
|
||||
/* gluNurbsCallback */
|
||||
typedef void (CALLBACK* GLUnurbsErrorProc) (GLenum);
|
||||
|
||||
|
||||
/**** Generic constants ****/
|
||||
|
||||
/* Version */
|
||||
#define GLU_VERSION_1_1 1
|
||||
#define GLU_VERSION_1_2 1
|
||||
|
||||
/* Errors: (return value 0 = no error) */
|
||||
#define GLU_INVALID_ENUM 100900
|
||||
#define GLU_INVALID_VALUE 100901
|
||||
#define GLU_OUT_OF_MEMORY 100902
|
||||
#define GLU_INCOMPATIBLE_GL_VERSION 100903
|
||||
|
||||
/* StringName */
|
||||
#define GLU_VERSION 100800
|
||||
#define GLU_EXTENSIONS 100801
|
||||
|
||||
/* Boolean */
|
||||
#define GLU_TRUE GL_TRUE
|
||||
#define GLU_FALSE GL_FALSE
|
||||
|
||||
|
||||
/**** Quadric constants ****/
|
||||
|
||||
/* QuadricNormal */
|
||||
#define GLU_SMOOTH 100000
|
||||
#define GLU_FLAT 100001
|
||||
#define GLU_NONE 100002
|
||||
|
||||
/* QuadricDrawStyle */
|
||||
#define GLU_POINT 100010
|
||||
#define GLU_LINE 100011
|
||||
#define GLU_FILL 100012
|
||||
#define GLU_SILHOUETTE 100013
|
||||
|
||||
/* QuadricOrientation */
|
||||
#define GLU_OUTSIDE 100020
|
||||
#define GLU_INSIDE 100021
|
||||
|
||||
/* Callback types: */
|
||||
/* GLU_ERROR 100103 */
|
||||
|
||||
|
||||
/**** Tesselation constants ****/
|
||||
|
||||
#define GLU_TESS_MAX_COORD 1.0e150
|
||||
|
||||
/* TessProperty */
|
||||
#define GLU_TESS_WINDING_RULE 100140
|
||||
#define GLU_TESS_BOUNDARY_ONLY 100141
|
||||
#define GLU_TESS_TOLERANCE 100142
|
||||
|
||||
/* TessWinding */
|
||||
#define GLU_TESS_WINDING_ODD 100130
|
||||
#define GLU_TESS_WINDING_NONZERO 100131
|
||||
#define GLU_TESS_WINDING_POSITIVE 100132
|
||||
#define GLU_TESS_WINDING_NEGATIVE 100133
|
||||
#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
|
||||
|
||||
/* TessCallback */
|
||||
#define GLU_TESS_BEGIN 100100 /* void (CALLBACK*)(GLenum type) */
|
||||
#define GLU_TESS_VERTEX 100101 /* void (CALLBACK*)(void *data) */
|
||||
#define GLU_TESS_END 100102 /* void (CALLBACK*)(void) */
|
||||
#define GLU_TESS_ERROR 100103 /* void (CALLBACK*)(GLenum errno) */
|
||||
#define GLU_TESS_EDGE_FLAG 100104 /* void (CALLBACK*)(GLboolean boundaryEdge) */
|
||||
#define GLU_TESS_COMBINE 100105 /* void (CALLBACK*)(GLdouble coords[3],
|
||||
void *data[4],
|
||||
GLfloat weight[4],
|
||||
void **dataOut) */
|
||||
#define GLU_TESS_BEGIN_DATA 100106 /* void (CALLBACK*)(GLenum type,
|
||||
void *polygon_data) */
|
||||
#define GLU_TESS_VERTEX_DATA 100107 /* void (CALLBACK*)(void *data,
|
||||
void *polygon_data) */
|
||||
#define GLU_TESS_END_DATA 100108 /* void (CALLBACK*)(void *polygon_data) */
|
||||
#define GLU_TESS_ERROR_DATA 100109 /* void (CALLBACK*)(GLenum errno,
|
||||
void *polygon_data) */
|
||||
#define GLU_TESS_EDGE_FLAG_DATA 100110 /* void (CALLBACK*)(GLboolean boundaryEdge,
|
||||
void *polygon_data) */
|
||||
#define GLU_TESS_COMBINE_DATA 100111 /* void (CALLBACK*)(GLdouble coords[3],
|
||||
void *data[4],
|
||||
GLfloat weight[4],
|
||||
void **dataOut,
|
||||
void *polygon_data) */
|
||||
|
||||
/* TessError */
|
||||
#define GLU_TESS_ERROR1 100151
|
||||
#define GLU_TESS_ERROR2 100152
|
||||
#define GLU_TESS_ERROR3 100153
|
||||
#define GLU_TESS_ERROR4 100154
|
||||
#define GLU_TESS_ERROR5 100155
|
||||
#define GLU_TESS_ERROR6 100156
|
||||
#define GLU_TESS_ERROR7 100157
|
||||
#define GLU_TESS_ERROR8 100158
|
||||
|
||||
#define GLU_TESS_MISSING_BEGIN_POLYGON GLU_TESS_ERROR1
|
||||
#define GLU_TESS_MISSING_BEGIN_CONTOUR GLU_TESS_ERROR2
|
||||
#define GLU_TESS_MISSING_END_POLYGON GLU_TESS_ERROR3
|
||||
#define GLU_TESS_MISSING_END_CONTOUR GLU_TESS_ERROR4
|
||||
#define GLU_TESS_COORD_TOO_LARGE GLU_TESS_ERROR5
|
||||
#define GLU_TESS_NEED_COMBINE_CALLBACK GLU_TESS_ERROR6
|
||||
|
||||
/**** NURBS constants ****/
|
||||
|
||||
/* NurbsProperty */
|
||||
#define GLU_AUTO_LOAD_MATRIX 100200
|
||||
#define GLU_CULLING 100201
|
||||
#define GLU_SAMPLING_TOLERANCE 100203
|
||||
#define GLU_DISPLAY_MODE 100204
|
||||
#define GLU_PARAMETRIC_TOLERANCE 100202
|
||||
#define GLU_SAMPLING_METHOD 100205
|
||||
#define GLU_U_STEP 100206
|
||||
#define GLU_V_STEP 100207
|
||||
|
||||
/* NurbsSampling */
|
||||
#define GLU_PATH_LENGTH 100215
|
||||
#define GLU_PARAMETRIC_ERROR 100216
|
||||
#define GLU_DOMAIN_DISTANCE 100217
|
||||
|
||||
|
||||
/* NurbsTrim */
|
||||
#define GLU_MAP1_TRIM_2 100210
|
||||
#define GLU_MAP1_TRIM_3 100211
|
||||
|
||||
/* NurbsDisplay */
|
||||
/* GLU_FILL 100012 */
|
||||
#define GLU_OUTLINE_POLYGON 100240
|
||||
#define GLU_OUTLINE_PATCH 100241
|
||||
|
||||
/* NurbsCallback */
|
||||
/* GLU_ERROR 100103 */
|
||||
|
||||
/* NurbsErrors */
|
||||
#define GLU_NURBS_ERROR1 100251
|
||||
#define GLU_NURBS_ERROR2 100252
|
||||
#define GLU_NURBS_ERROR3 100253
|
||||
#define GLU_NURBS_ERROR4 100254
|
||||
#define GLU_NURBS_ERROR5 100255
|
||||
#define GLU_NURBS_ERROR6 100256
|
||||
#define GLU_NURBS_ERROR7 100257
|
||||
#define GLU_NURBS_ERROR8 100258
|
||||
#define GLU_NURBS_ERROR9 100259
|
||||
#define GLU_NURBS_ERROR10 100260
|
||||
#define GLU_NURBS_ERROR11 100261
|
||||
#define GLU_NURBS_ERROR12 100262
|
||||
#define GLU_NURBS_ERROR13 100263
|
||||
#define GLU_NURBS_ERROR14 100264
|
||||
#define GLU_NURBS_ERROR15 100265
|
||||
#define GLU_NURBS_ERROR16 100266
|
||||
#define GLU_NURBS_ERROR17 100267
|
||||
#define GLU_NURBS_ERROR18 100268
|
||||
#define GLU_NURBS_ERROR19 100269
|
||||
#define GLU_NURBS_ERROR20 100270
|
||||
#define GLU_NURBS_ERROR21 100271
|
||||
#define GLU_NURBS_ERROR22 100272
|
||||
#define GLU_NURBS_ERROR23 100273
|
||||
#define GLU_NURBS_ERROR24 100274
|
||||
#define GLU_NURBS_ERROR25 100275
|
||||
#define GLU_NURBS_ERROR26 100276
|
||||
#define GLU_NURBS_ERROR27 100277
|
||||
#define GLU_NURBS_ERROR28 100278
|
||||
#define GLU_NURBS_ERROR29 100279
|
||||
#define GLU_NURBS_ERROR30 100280
|
||||
#define GLU_NURBS_ERROR31 100281
|
||||
#define GLU_NURBS_ERROR32 100282
|
||||
#define GLU_NURBS_ERROR33 100283
|
||||
#define GLU_NURBS_ERROR34 100284
|
||||
#define GLU_NURBS_ERROR35 100285
|
||||
#define GLU_NURBS_ERROR36 100286
|
||||
#define GLU_NURBS_ERROR37 100287
|
||||
|
||||
/**** Backwards compatibility for old tesselator ****/
|
||||
|
||||
void APIENTRY gluBeginPolygon( GLUtesselator *tess );
|
||||
|
||||
void APIENTRY gluNextContour( GLUtesselator *tess,
|
||||
GLenum type );
|
||||
|
||||
void APIENTRY gluEndPolygon( GLUtesselator *tess );
|
||||
|
||||
/* Contours types -- obsolete! */
|
||||
#define GLU_CW 100120
|
||||
#define GLU_CCW 100121
|
||||
#define GLU_INTERIOR 100122
|
||||
#define GLU_EXTERIOR 100123
|
||||
#define GLU_UNKNOWN 100124
|
||||
|
||||
/* Names without "TESS_" prefix */
|
||||
#define GLU_BEGIN GLU_TESS_BEGIN
|
||||
#define GLU_VERTEX GLU_TESS_VERTEX
|
||||
#define GLU_END GLU_TESS_END
|
||||
#define GLU_ERROR GLU_TESS_ERROR
|
||||
#define GLU_EDGE_FLAG GLU_TESS_EDGE_FLAG
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GLU_H__ */
|
||||
#endif /* __glu_h__ */
|
||||
1180
RenderDll/XRenderOGL/Mygl.h
Normal file
1180
RenderDll/XRenderOGL/Mygl.h
Normal file
File diff suppressed because it is too large
Load Diff
1816
RenderDll/XRenderOGL/NVParse/_ps1.0_lexer.cpp
Normal file
1816
RenderDll/XRenderOGL/NVParse/_ps1.0_lexer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1108
RenderDll/XRenderOGL/NVParse/_ps1.0_parser.cpp
Normal file
1108
RenderDll/XRenderOGL/NVParse/_ps1.0_parser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
21
RenderDll/XRenderOGL/NVParse/_ps1.0_parser.h
Normal file
21
RenderDll/XRenderOGL/NVParse/_ps1.0_parser.h
Normal file
@@ -0,0 +1,21 @@
|
||||
typedef union
|
||||
{
|
||||
int ival;
|
||||
float fval;
|
||||
|
||||
string * sval;
|
||||
constdef * cdef;
|
||||
std::vector<constdef> * consts;
|
||||
std::vector<string> * line;
|
||||
std::list<std::vector<string> > * lines;
|
||||
} YYSTYPE;
|
||||
#define HEADER 257
|
||||
#define NEWLINE 258
|
||||
#define NUMBER 259
|
||||
#define REG 260
|
||||
#define DEF 261
|
||||
#define ADDROP 262
|
||||
#define BLENDOP 263
|
||||
|
||||
|
||||
extern YYSTYPE ps10_lval;
|
||||
2442
RenderDll/XRenderOGL/NVParse/_rc1.0_lexer.cpp
Normal file
2442
RenderDll/XRenderOGL/NVParse/_rc1.0_lexer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1847
RenderDll/XRenderOGL/NVParse/_rc1.0_parser.cpp
Normal file
1847
RenderDll/XRenderOGL/NVParse/_rc1.0_parser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
54
RenderDll/XRenderOGL/NVParse/_rc1.0_parser.h
Normal file
54
RenderDll/XRenderOGL/NVParse/_rc1.0_parser.h
Normal file
@@ -0,0 +1,54 @@
|
||||
typedef union {
|
||||
int ival;
|
||||
float fval;
|
||||
RegisterEnum registerEnum;
|
||||
BiasScaleEnum biasScaleEnum;
|
||||
MappedRegisterStruct mappedRegisterStruct;
|
||||
ConstColorStruct constColorStruct;
|
||||
GeneralPortionStruct generalPortionStruct;
|
||||
GeneralFunctionStruct generalFunctionStruct;
|
||||
OpStruct opStruct;
|
||||
GeneralCombinerStruct generalCombinerStruct;
|
||||
GeneralCombinersStruct generalCombinersStruct;
|
||||
FinalProductStruct finalProductStruct;
|
||||
FinalRgbFunctionStruct finalRgbFunctionStruct;
|
||||
FinalAlphaFunctionStruct finalAlphaFunctionStruct;
|
||||
FinalCombinerStruct finalCombinerStruct;
|
||||
CombinersStruct combinersStruct;
|
||||
} YYSTYPE;
|
||||
#define regVariable 257
|
||||
#define constVariable 258
|
||||
#define color_sum 259
|
||||
#define final_product 260
|
||||
#define expandString 261
|
||||
#define halfBiasString 262
|
||||
#define unsignedString 263
|
||||
#define unsignedInvertString 264
|
||||
#define muxString 265
|
||||
#define sumString 266
|
||||
#define rgb_portion 267
|
||||
#define alpha_portion 268
|
||||
#define openParen 269
|
||||
#define closeParen 270
|
||||
#define openBracket 271
|
||||
#define closeBracket 272
|
||||
#define semicolon 273
|
||||
#define comma 274
|
||||
#define dot 275
|
||||
#define times 276
|
||||
#define minus 277
|
||||
#define equals 278
|
||||
#define plus 279
|
||||
#define bias_by_negative_one_half_scale_by_two 280
|
||||
#define bias_by_negative_one_half 281
|
||||
#define scale_by_one_half 282
|
||||
#define scale_by_two 283
|
||||
#define scale_by_four 284
|
||||
#define clamp_color_sum 285
|
||||
#define lerp 286
|
||||
#define fragment_rgb 287
|
||||
#define fragment_alpha 288
|
||||
#define floatValue 289
|
||||
|
||||
|
||||
extern YYSTYPE rc10_lval;
|
||||
2239
RenderDll/XRenderOGL/NVParse/_ts1.0_lexer.cpp
Normal file
2239
RenderDll/XRenderOGL/NVParse/_ts1.0_lexer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1449
RenderDll/XRenderOGL/NVParse/_ts1.0_parser.cpp
Normal file
1449
RenderDll/XRenderOGL/NVParse/_ts1.0_parser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
60
RenderDll/XRenderOGL/NVParse/_ts1.0_parser.h
Normal file
60
RenderDll/XRenderOGL/NVParse/_ts1.0_parser.h
Normal file
@@ -0,0 +1,60 @@
|
||||
typedef union {
|
||||
float fval;
|
||||
InstPtr inst;
|
||||
InstListPtr instList;
|
||||
MappedVariablePtr variable;
|
||||
} YYSTYPE;
|
||||
#define floatValue 257
|
||||
#define gequal 258
|
||||
#define less 259
|
||||
#define texVariable 260
|
||||
#define expandString 261
|
||||
#define openParen 262
|
||||
#define closeParen 263
|
||||
#define semicolon 264
|
||||
#define comma 265
|
||||
#define nop 266
|
||||
#define texture_1d 267
|
||||
#define texture_2d 268
|
||||
#define texture_rectangle 269
|
||||
#define texture_3d 270
|
||||
#define texture_cube_map 271
|
||||
#define cull_fragment 272
|
||||
#define pass_through 273
|
||||
#define offset_2d_scale 274
|
||||
#define offset_2d 275
|
||||
#define offset_rectangle_scale 276
|
||||
#define offset_rectangle 277
|
||||
#define offset_projective_2d_scale 278
|
||||
#define offset_projective_2d 279
|
||||
#define offset_projective_rectangle_scale 280
|
||||
#define offset_projective_rectangle 281
|
||||
#define dependent_ar 282
|
||||
#define dependent_gb 283
|
||||
#define dot_product_2d_1of2 284
|
||||
#define dot_product_2d_2of2 285
|
||||
#define dot_product_rectangle_1of2 286
|
||||
#define dot_product_rectangle_2of2 287
|
||||
#define dot_product_depth_replace_1of2 288
|
||||
#define dot_product_depth_replace_2of2 289
|
||||
#define dot_product_3d_1of3 290
|
||||
#define dot_product_3d_2of3 291
|
||||
#define dot_product_3d_3of3 292
|
||||
#define dot_product_cube_map_1of3 293
|
||||
#define dot_product_cube_map_2of3 294
|
||||
#define dot_product_cube_map_3of3 295
|
||||
#define dot_product_reflect_cube_map_eye_from_qs_1of3 296
|
||||
#define dot_product_reflect_cube_map_eye_from_qs_2of3 297
|
||||
#define dot_product_reflect_cube_map_eye_from_qs_3of3 298
|
||||
#define dot_product_reflect_cube_map_const_eye_1of3 299
|
||||
#define dot_product_reflect_cube_map_const_eye_2of3 300
|
||||
#define dot_product_reflect_cube_map_const_eye_3of3 301
|
||||
#define dot_product_cube_map_and_reflect_cube_map_eye_from_qs_1of3 302
|
||||
#define dot_product_cube_map_and_reflect_cube_map_eye_from_qs_2of3 303
|
||||
#define dot_product_cube_map_and_reflect_cube_map_eye_from_qs_3of3 304
|
||||
#define dot_product_cube_map_and_reflect_cube_map_const_eye_1of3 305
|
||||
#define dot_product_cube_map_and_reflect_cube_map_const_eye_2of3 306
|
||||
#define dot_product_cube_map_and_reflect_cube_map_const_eye_3of3 307
|
||||
|
||||
|
||||
extern YYSTYPE ts10_lval;
|
||||
4989
RenderDll/XRenderOGL/NVParse/_vs1.0_lexer.cpp
Normal file
4989
RenderDll/XRenderOGL/NVParse/_vs1.0_lexer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1442
RenderDll/XRenderOGL/NVParse/_vs1.0_parser.cpp
Normal file
1442
RenderDll/XRenderOGL/NVParse/_vs1.0_parser.cpp
Normal file
File diff suppressed because it is too large
Load Diff
46
RenderDll/XRenderOGL/NVParse/_vs1.0_parser.h
Normal file
46
RenderDll/XRenderOGL/NVParse/_vs1.0_parser.h
Normal file
@@ -0,0 +1,46 @@
|
||||
typedef union {
|
||||
int ival;
|
||||
unsigned int lval;
|
||||
float fval;
|
||||
char mask[4];
|
||||
char *comment;
|
||||
VS10Reg reg;
|
||||
VS10InstPtr inst;
|
||||
VS10InstListPtr instList;
|
||||
} YYSTYPE;
|
||||
#define VERTEX_SHADER 257
|
||||
#define ADD_INSTR 258
|
||||
#define DP3_INSTR 259
|
||||
#define DP4_INSTR 260
|
||||
#define DST_INSTR 261
|
||||
#define EXP_INSTR 262
|
||||
#define EXPP_INSTR 263
|
||||
#define FRC_INSTR 264
|
||||
#define LIT_INSTR 265
|
||||
#define LOG_INSTR 266
|
||||
#define LOGP_INSTR 267
|
||||
#define M3X2_INSTR 268
|
||||
#define M3X3_INSTR 269
|
||||
#define M3X4_INSTR 270
|
||||
#define M4X3_INSTR 271
|
||||
#define M4X4_INSTR 272
|
||||
#define MAD_INSTR 273
|
||||
#define MAX_INSTR 274
|
||||
#define MIN_INSTR 275
|
||||
#define MOV_INSTR 276
|
||||
#define MUL_INSTR 277
|
||||
#define NOP_INSTR 278
|
||||
#define RCP_INSTR 279
|
||||
#define RSQ_INSTR 280
|
||||
#define SGE_INSTR 281
|
||||
#define SLT_INSTR 282
|
||||
#define SUB_INSTR 283
|
||||
#define ILLEGAL 284
|
||||
#define UNKNOWN_STRING 285
|
||||
#define INTVAL 286
|
||||
#define REGISTER 287
|
||||
#define XYZW_MODIFIER 288
|
||||
#define COMMENT 289
|
||||
|
||||
|
||||
extern YYSTYPE vs10_lval;
|
||||
44
RenderDll/XRenderOGL/NVParse/macro.h
Normal file
44
RenderDll/XRenderOGL/NVParse/macro.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
typedef struct MACROTEXT {
|
||||
MACROTEXT *next;
|
||||
MACROTEXT *prev;
|
||||
char *macroText;
|
||||
} MACROTEXT;
|
||||
|
||||
typedef struct MACROENTRY
|
||||
{
|
||||
MACROENTRY *next;
|
||||
MACROENTRY *prev;
|
||||
char *macroName;
|
||||
MACROTEXT *firstMacroParms;
|
||||
MACROTEXT *lastMacroParms;
|
||||
MACROTEXT *firstMacroLines;
|
||||
MACROTEXT *lastMacroLines;
|
||||
unsigned int numParms;
|
||||
char *fileName;
|
||||
unsigned int lineNo;
|
||||
unsigned int nLines;
|
||||
bool bIsDefine;
|
||||
} MACROENTRY;
|
||||
|
||||
#define MAX_IFDEF_DEPTH 1024
|
||||
typedef struct IFDEFINFO
|
||||
{
|
||||
bool lastbProcessingIFDEF; // save off for if we were processing #ifdef
|
||||
bool lastbIFDEF; // wether ifdef was true or not
|
||||
bool lastbCompareDefine; // wether we compare #ifdef or #ifndef
|
||||
unsigned int lastIfDefStartLine; // where we started for this #ifdef
|
||||
} IFDEFINFO;
|
||||
|
||||
|
||||
typedef void (*MACROFUNCTIONPTR)(char *, unsigned int *, char **);
|
||||
|
||||
typedef struct MACROFUNCTIONS
|
||||
{
|
||||
char *name;
|
||||
MACROFUNCTIONPTR function;
|
||||
} MACROFUNCTIONS;
|
||||
158
RenderDll/XRenderOGL/NVParse/nvparse.cpp
Normal file
158
RenderDll/XRenderOGL/NVParse/nvparse.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
//void yyinit(char*);
|
||||
//int yyparse(void);
|
||||
|
||||
#include "rc1.0_general.h"
|
||||
|
||||
// RC1.0 -- register combiners 1.0 configuration
|
||||
bool rc10_init(char *);
|
||||
int rc10_parse();
|
||||
bool is_rc10(const char *);
|
||||
|
||||
// TS1.0 -- texture shader 1.0 configuration
|
||||
bool ts10_init(char *);
|
||||
int ts10_parse();
|
||||
bool is_ts10(const char *);
|
||||
|
||||
// VP1.0 -- vertex program
|
||||
bool vp10_init(char *);
|
||||
int vp10_parse();
|
||||
bool is_vp10(const char *);
|
||||
|
||||
// VSP1.0 -- vertex state program
|
||||
bool vsp10_init(char *);
|
||||
int vsp10_parse(int vspid);
|
||||
bool is_vsp10(const char *);
|
||||
|
||||
// VCP1.0 -- vertex constant program
|
||||
bool vcp10_init(char *);
|
||||
int vcp10_parse();
|
||||
bool is_vcp10(const char *);
|
||||
|
||||
// DX8 stuff
|
||||
|
||||
// PS1.0 -- DX8 Pixel Shader 1.0 configuration
|
||||
bool ps10_init(char *);
|
||||
int ps10_parse();
|
||||
bool is_ps10(const char *);
|
||||
|
||||
// VS1.0 -- DX8 Vertex Shader 1.0
|
||||
bool vs10_init(char *);
|
||||
int vs10_parse();
|
||||
bool is_vs10(const char *);
|
||||
void vs10_load_program();
|
||||
|
||||
nvparse_errors errors;
|
||||
int line_number;
|
||||
char * myin = 0;
|
||||
|
||||
TArray<SCGBindConst> gParseConsts;
|
||||
|
||||
void nvparse(bool bPerStage, const char * input_string, ...)
|
||||
{
|
||||
if (NULL == input_string)
|
||||
{
|
||||
errors.set("NULL string passed to nvparse");
|
||||
return;
|
||||
}
|
||||
|
||||
int len = strlen(input_string)+1;
|
||||
char * instring = new char [len];
|
||||
memcpy(instring, input_string, len);
|
||||
|
||||
// vertex constant program
|
||||
if(is_vcp10(instring))
|
||||
{
|
||||
if(vcp10_init(instring))
|
||||
{
|
||||
vcp10_parse();
|
||||
}
|
||||
}
|
||||
|
||||
// vertex state program
|
||||
else if(is_vsp10(instring))
|
||||
{
|
||||
if(vsp10_init(instring))
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, input_string);
|
||||
int vspid = va_arg(ap,int);
|
||||
va_end(ap);
|
||||
|
||||
vsp10_parse(vspid);
|
||||
}
|
||||
}
|
||||
|
||||
// vertex program
|
||||
else if(is_vp10(instring))
|
||||
{
|
||||
if(vp10_init(instring))
|
||||
{
|
||||
vp10_parse();
|
||||
}
|
||||
}
|
||||
|
||||
// register combiners (1 and 2)
|
||||
else if(is_rc10(instring))
|
||||
{
|
||||
if(rc10_init(instring))
|
||||
{
|
||||
gParseConsts.Free();
|
||||
rc10_parse();
|
||||
}
|
||||
}
|
||||
|
||||
// texture shader
|
||||
else if(is_ts10(instring))
|
||||
{
|
||||
if(ts10_init(instring))
|
||||
{
|
||||
ts10_parse();
|
||||
}
|
||||
}
|
||||
|
||||
// DX8 vertex shader
|
||||
else if ( is_vs10(instring) )
|
||||
{
|
||||
if(vs10_init(instring))
|
||||
{
|
||||
vs10_parse();
|
||||
vs10_load_program();
|
||||
}
|
||||
|
||||
}
|
||||
else if (is_ps10(instring))
|
||||
{
|
||||
if(ps10_init(instring))
|
||||
{
|
||||
ps10_parse();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errors.set("invalid string.\n \
|
||||
first characters must be: !!VP1.0 or !!VSP1.0 or !!RC1.0 or !!TS1.0\n \
|
||||
or it must be a valid DirectX 8.0 Vertex Shader");
|
||||
}
|
||||
delete [] instring;
|
||||
}
|
||||
|
||||
char * const * const nvparse_get_errors()
|
||||
{
|
||||
return errors.get_errors();
|
||||
}
|
||||
|
||||
char * const * const nvparse_print_errors(FILE * errfp)
|
||||
{
|
||||
for (char * const * ep = nvparse_get_errors(); *ep; ep++)
|
||||
{
|
||||
const char * errstr = *ep;
|
||||
fprintf(errfp, errstr);
|
||||
}
|
||||
return nvparse_get_errors();
|
||||
}
|
||||
17
RenderDll/XRenderOGL/NVParse/nvparse.h
Normal file
17
RenderDll/XRenderOGL/NVParse/nvparse.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef NVPARSE_H
|
||||
#define NVPARSE_H
|
||||
|
||||
#define NVPARSE 1
|
||||
|
||||
#include "nvparse_errors.h"
|
||||
#include "nvparse_externs.h"
|
||||
#include "../GL_Renderer.h"
|
||||
|
||||
void nvparse(bool m_bPerStage, const char * input_string, ...);
|
||||
char * const * const nvparse_get_errors();
|
||||
|
||||
extern TArray<SCGBindConst> gParseConsts;
|
||||
|
||||
//======================================================================
|
||||
|
||||
#endif
|
||||
56
RenderDll/XRenderOGL/NVParse/nvparse_errors.cpp
Normal file
56
RenderDll/XRenderOGL/NVParse/nvparse_errors.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
|
||||
nvparse_errors::nvparse_errors()
|
||||
{
|
||||
num_errors = 0;
|
||||
reset();
|
||||
}
|
||||
|
||||
nvparse_errors::~nvparse_errors()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void nvparse_errors::reset()
|
||||
{
|
||||
for(int i=0; i < num_errors; i++)
|
||||
free(elist[i]);//FIXME detail_nmap something is writing 0x2 to elist[1] blah!
|
||||
for(int j=0; j <= NVPARSE_MAX_ERRORS; j++)
|
||||
elist[j] = 0;
|
||||
num_errors = 0;
|
||||
}
|
||||
|
||||
extern char *gShObjectNotFound;
|
||||
|
||||
void nvparse_errors::set(const char * e)
|
||||
{
|
||||
if(num_errors < NVPARSE_MAX_ERRORS)
|
||||
{
|
||||
char buf[512];
|
||||
if (gShObjectNotFound)
|
||||
{
|
||||
sprintf(buf, "(%s) %s", gShObjectNotFound, e);
|
||||
elist[num_errors++] = Cry_strdup(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
elist[num_errors++] = Cry_strdup(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nvparse_errors::set(const char * e, int line_number)
|
||||
{
|
||||
char buff[256];
|
||||
sprintf(buff, "error on line %d: %s", line_number, e);
|
||||
if(num_errors < NVPARSE_MAX_ERRORS)
|
||||
elist[num_errors++] = Cry_strdup(buff);
|
||||
}
|
||||
|
||||
char * const * const nvparse_errors::get_errors()
|
||||
{
|
||||
return elist;
|
||||
}
|
||||
22
RenderDll/XRenderOGL/NVParse/nvparse_errors.h
Normal file
22
RenderDll/XRenderOGL/NVParse/nvparse_errors.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef _NVPARSE_ERRORS_H_
|
||||
#define _NVPARSE_ERRORS_H_
|
||||
|
||||
#pragma warning(disable:4786) // symbol size limitation
|
||||
#define NVPARSE_MAX_ERRORS 32
|
||||
class nvparse_errors
|
||||
{
|
||||
public:
|
||||
nvparse_errors();
|
||||
~nvparse_errors();
|
||||
|
||||
void reset();
|
||||
void set(const char * e);
|
||||
void set(const char * e, int line_number);
|
||||
char * const * const get_errors();
|
||||
inline int get_num_errors() { return num_errors; }
|
||||
private:
|
||||
char* elist [NVPARSE_MAX_ERRORS+1];
|
||||
int num_errors;
|
||||
};
|
||||
|
||||
#endif
|
||||
9
RenderDll/XRenderOGL/NVParse/nvparse_externs.h
Normal file
9
RenderDll/XRenderOGL/NVParse/nvparse_externs.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef NVPARSE_EXTERNS_H
|
||||
#define NVPARSE_EXTERNS_H
|
||||
|
||||
extern nvparse_errors errors;
|
||||
extern int line_number;
|
||||
extern char * myin;
|
||||
|
||||
|
||||
#endif
|
||||
743
RenderDll/XRenderOGL/NVParse/ps1.0_program.cpp
Normal file
743
RenderDll/XRenderOGL/NVParse/ps1.0_program.cpp
Normal file
@@ -0,0 +1,743 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include "ps1.0_program.h"
|
||||
|
||||
|
||||
//using namespace std;
|
||||
using namespace ps10;
|
||||
|
||||
|
||||
#define DBG_MESG(msg, line) errors.set(msg, line)
|
||||
//#define DBG_MESG(msg, line)
|
||||
|
||||
namespace
|
||||
{
|
||||
struct set_constants
|
||||
{
|
||||
void operator() (constdef c)
|
||||
{
|
||||
if(c.reg[0] != 'c' && c.reg.size() != 2)
|
||||
DBG_MESG("def line must use constant registers", 0);
|
||||
int reg = c.reg[1] - '0';
|
||||
GLenum stage = GL_COMBINER0_NV + (reg / 2);
|
||||
GLenum cclr = GL_CONSTANT_COLOR0_NV + (reg % 2);
|
||||
|
||||
GLfloat cval[4];
|
||||
cval[0] = c.r;
|
||||
cval[0] = c.g;
|
||||
cval[0] = c.b;
|
||||
cval[0] = c.a;
|
||||
glCombinerStageParameterfvNV(stage, cclr, cval);
|
||||
}
|
||||
};
|
||||
|
||||
GLenum get_tex_target()
|
||||
{
|
||||
if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
|
||||
return GL_TEXTURE_CUBE_MAP_ARB;
|
||||
if(glIsEnabled(GL_TEXTURE_3D))
|
||||
return GL_TEXTURE_3D;
|
||||
if(glIsEnabled(GL_TEXTURE_RECTANGLE_NV))
|
||||
return GL_TEXTURE_RECTANGLE_NV;
|
||||
if(glIsEnabled(GL_TEXTURE_2D))
|
||||
return GL_TEXTURE_2D;
|
||||
if(glIsEnabled(GL_TEXTURE_1D))
|
||||
return GL_TEXTURE_1D;
|
||||
|
||||
//otherwise make the op none...
|
||||
return GL_NONE;
|
||||
}
|
||||
|
||||
|
||||
struct set_texture_shaders
|
||||
{
|
||||
set_texture_shaders(std::vector<constdef> * cdef)
|
||||
{
|
||||
for(stage = 0; stage < 4; stage++)
|
||||
{
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
|
||||
}
|
||||
stage = 0;
|
||||
c = cdef;
|
||||
}
|
||||
|
||||
void operator() (std::vector<string> & instr)
|
||||
{
|
||||
if(stage > 3)
|
||||
return;
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + stage);
|
||||
|
||||
string op = instr[0];
|
||||
if(op == "tex")
|
||||
{
|
||||
if(instr.size() != 2)
|
||||
fprintf(stderr,"incorrect \"tex\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, get_tex_target());
|
||||
}
|
||||
else if(op == "texbem")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texbem\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV);
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texbem\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texbeml")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texbeml\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV);
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texbeml\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texcoord")
|
||||
{
|
||||
if(instr.size() != 2)
|
||||
fprintf(stderr,"incorrect \"texcoord\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_PASS_THROUGH_NV);
|
||||
}
|
||||
else if(op == "texkill")
|
||||
{
|
||||
if(instr.size() != 2)
|
||||
fprintf(stderr,"incorrect \"texkill\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_CULL_FRAGMENT_NV);
|
||||
}
|
||||
else if(op == "texm3x2pad")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x2pad\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
if(instr[2].find("_bx2") != string::npos)
|
||||
{
|
||||
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
}
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x2pad\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texm3x2tex")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x2tex\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV);
|
||||
if(instr[2].find("_bx2") != string::npos)
|
||||
{
|
||||
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
}
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x2tex\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texm3x3pad")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3pad\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
if(instr[2].find("_bx2") != string::npos)
|
||||
{
|
||||
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
}
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3pad\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texm3x3tex")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV);
|
||||
|
||||
if(instr[2].find("_bx2") != string::npos)
|
||||
{
|
||||
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
}
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texm3x3spec")
|
||||
{
|
||||
if(instr.size() != 4 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3spec\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
|
||||
if(! c)
|
||||
return;
|
||||
constdef cd;
|
||||
for(int i = c->size()-1; i >= 0; i--)
|
||||
{
|
||||
cd = (*c)[i];
|
||||
if(cd.reg == "c0")
|
||||
break;
|
||||
}
|
||||
|
||||
if(cd.reg != string("c0") || instr[3] != string("c0"))
|
||||
return;
|
||||
GLfloat eye[4];
|
||||
eye[0] = cd.r;
|
||||
eye[1] = cd.g;
|
||||
eye[2] = cd.b;
|
||||
eye[3] = cd.a;
|
||||
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_CONST_EYE_NV, eye);
|
||||
|
||||
if(instr[2].find("_bx2") != string::npos)
|
||||
{
|
||||
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
}
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texm3x3vspec")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3vspec\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV);
|
||||
|
||||
if(instr[2].find("_bx2") != string::npos)
|
||||
{
|
||||
instr[2].erase(instr[2].begin() + instr[2].find("_bx2"), instr[2].end());
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
}
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texm3x3tex\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texreg2ar")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texreg2ar\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_AR_TEXTURE_2D_NV);
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texreg2ar\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
else if(op == "texreg2gb")
|
||||
{
|
||||
if(instr.size() != 3 || stage == 0)
|
||||
fprintf(stderr,"incorrect \"texreg2gb\" instruction, stage %d...\n", stage);
|
||||
reg2stage[instr[1]] = stage;
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV);
|
||||
if(reg2stage.count(instr[2]) == 0)
|
||||
fprintf(stderr,"incorrect \"texreg2gb\" instruction, stage %d...\n", stage);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + reg2stage[instr[2]]);
|
||||
}
|
||||
stage++;
|
||||
}
|
||||
|
||||
std::map<string, int> reg2stage;
|
||||
int stage;
|
||||
std::vector<constdef> * c;
|
||||
};
|
||||
|
||||
GLenum reg_enum(string s)
|
||||
{
|
||||
if(s == "c0")
|
||||
return GL_CONSTANT_COLOR0_NV;
|
||||
else if(s == "c1")
|
||||
return GL_CONSTANT_COLOR1_NV;
|
||||
else if(s == "c2")
|
||||
return GL_CONSTANT_COLOR0_NV;
|
||||
else if(s == "c3")
|
||||
return GL_CONSTANT_COLOR1_NV;
|
||||
else if(s == "c4")
|
||||
return GL_CONSTANT_COLOR0_NV;
|
||||
else if(s == "c5")
|
||||
return GL_CONSTANT_COLOR1_NV;
|
||||
else if(s == "c6")
|
||||
return GL_CONSTANT_COLOR0_NV;
|
||||
else if(s == "c7")
|
||||
return GL_CONSTANT_COLOR1_NV;
|
||||
else if(s == "t0")
|
||||
return GL_TEXTURE0_ARB;
|
||||
else if(s == "t1")
|
||||
return GL_TEXTURE1_ARB;
|
||||
else if(s == "t2")
|
||||
return GL_TEXTURE2_ARB;
|
||||
else if(s == "t3")
|
||||
return GL_TEXTURE3_ARB;
|
||||
else if(s == "v0")
|
||||
return GL_PRIMARY_COLOR_NV;
|
||||
else if(s == "v1")
|
||||
return GL_SECONDARY_COLOR_NV;
|
||||
else if(s == "r0")
|
||||
return GL_SPARE0_NV;
|
||||
else if(s == "r1")
|
||||
return GL_SPARE1_NV;
|
||||
else // ??
|
||||
return GL_DISCARD_NV;
|
||||
}
|
||||
|
||||
struct src
|
||||
{
|
||||
src(string s)
|
||||
{
|
||||
init(s);
|
||||
}
|
||||
|
||||
|
||||
void init(string s)
|
||||
{
|
||||
arg = s;
|
||||
comp = GL_RGB;
|
||||
map = GL_SIGNED_IDENTITY_NV;
|
||||
|
||||
int offset;
|
||||
if((offset = s.find(".a")) != string::npos)
|
||||
{
|
||||
comp = GL_ALPHA;
|
||||
s.erase(offset, offset+2);
|
||||
}
|
||||
|
||||
bool negate = false;
|
||||
|
||||
if(s[0] == '1')
|
||||
{
|
||||
s.erase(0, 1);
|
||||
while(s[0] == ' ')
|
||||
s.erase(0,1);
|
||||
if(s[0] == '-')
|
||||
s.erase(0,1);
|
||||
while(s[0] == ' ')
|
||||
s.erase(0,1);
|
||||
map = GL_UNSIGNED_INVERT_NV;
|
||||
}
|
||||
else if(s[0] == '-')
|
||||
{
|
||||
s.erase(0, 1);
|
||||
while(s[0] == ' ')
|
||||
s.erase(0,1);
|
||||
negate = true;
|
||||
map = GL_UNSIGNED_INVERT_NV;
|
||||
}
|
||||
|
||||
bool half_bias = false;
|
||||
bool expand = false;
|
||||
if(s.find("_bias") != string::npos)
|
||||
{
|
||||
s.erase(s.find("_bias"), 5);
|
||||
half_bias = true;
|
||||
}
|
||||
else if(s.find("_bx2") != string::npos)
|
||||
{
|
||||
s.erase(s.find("_bx2"), 4);
|
||||
expand = true;
|
||||
}
|
||||
|
||||
if(expand)
|
||||
{
|
||||
if(negate)
|
||||
map = GL_EXPAND_NEGATE_NV;
|
||||
else
|
||||
map = GL_EXPAND_NORMAL_NV;
|
||||
}
|
||||
else if(half_bias)
|
||||
{
|
||||
if(negate)
|
||||
map = GL_HALF_BIAS_NEGATE_NV;
|
||||
else
|
||||
map = GL_HALF_BIAS_NORMAL_NV;
|
||||
}
|
||||
reg = reg_enum(s);
|
||||
}
|
||||
|
||||
string arg;
|
||||
GLenum reg;
|
||||
GLenum map;
|
||||
GLenum comp;
|
||||
};
|
||||
|
||||
|
||||
struct set_register_combiners
|
||||
{
|
||||
set_register_combiners()
|
||||
{
|
||||
combiner = 0;
|
||||
}
|
||||
|
||||
void operator() (std::vector<string> & instr)
|
||||
{
|
||||
string op;
|
||||
GLenum scale;
|
||||
bool op_sat = false;
|
||||
op = instr[0];
|
||||
int offset;
|
||||
if((offset = op.find("_x2")) != string::npos)
|
||||
{
|
||||
scale = GL_SCALE_BY_TWO_NV;
|
||||
op.erase(op.begin()+offset, op.begin()+offset+3);
|
||||
}
|
||||
else if((offset = op.find("_x4")) != string::npos)
|
||||
{
|
||||
scale = GL_SCALE_BY_FOUR_NV;
|
||||
op.erase(op.begin()+offset, op.begin()+offset+3);
|
||||
}
|
||||
else if((offset = op.find("_d2")) != string::npos)
|
||||
{
|
||||
scale = GL_SCALE_BY_ONE_HALF_NV;
|
||||
op.erase(op.begin()+offset, op.begin()+offset+3);
|
||||
}
|
||||
|
||||
if((offset = op.find("_sat")) != string::npos)
|
||||
{
|
||||
// need to actually use this...
|
||||
op_sat = true;
|
||||
op.erase(op.begin()+offset, op.begin()+offset+4);
|
||||
}
|
||||
|
||||
string dst = instr[1];
|
||||
int mask = GL_RGBA;
|
||||
if((offset = dst.find(".rgba")) != string::npos)
|
||||
{
|
||||
dst.erase(offset, offset + 5);
|
||||
}
|
||||
else if((offset = dst.find(".rgb")) != string::npos)
|
||||
{
|
||||
dst.erase(offset, offset + 4);
|
||||
mask = GL_RGB;
|
||||
}
|
||||
else if((offset = dst.find(".a")) != string::npos)
|
||||
{
|
||||
dst.erase(offset, offset + 2);
|
||||
mask = GL_ALPHA;
|
||||
}
|
||||
|
||||
GLenum dreg = reg_enum(dst);
|
||||
GLenum C = GL_COMBINER0_NV + combiner;
|
||||
|
||||
if(op == "add" || op == "sub")
|
||||
{
|
||||
src a(instr[2]);
|
||||
src b(instr[3]);
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, b.reg, b.map, b.comp);
|
||||
if(op == "add")
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||
else
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_EXPAND_NORMAL_NV, GL_RGB);
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, b.reg, b.map, GL_ALPHA);
|
||||
if(op == "add")
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
else
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, GL_ZERO, GL_EXPAND_NORMAL_NV, GL_ALPHA);
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else if(op == "cnd")
|
||||
{
|
||||
src a(instr[3]);
|
||||
src b(instr[4]);
|
||||
if(instr[2] != string("r0.a"))
|
||||
{} // bad
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, b.reg, b.map, b.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, b.reg, b.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else if(op == "dp3")
|
||||
{
|
||||
src a(instr[2]);
|
||||
src b(instr[3]);
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
|
||||
glCombinerOutputNV(C, GL_RGB, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ooh.. what to do here?
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
// todo -- make next ref to dst.a actually ref dst.b since combiners can't write dp3 to the alpha channel
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else if(op == "lrp")
|
||||
{
|
||||
src a(instr[2]);
|
||||
src b(instr[3]);
|
||||
src c(instr[4]);
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, GL_UNSIGNED_IDENTITY_NV, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, a.reg, GL_UNSIGNED_INVERT_NV, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, c.reg, c.map, c.comp);
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, b.reg, b.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, a.reg, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, c.reg, c.map, GL_ALPHA);
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else if(op == "mad")
|
||||
{
|
||||
src a(instr[2]);
|
||||
src b(instr[3]);
|
||||
src c(instr[4]);
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_C_NV, b.reg, b.map, b.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_D_NV, c.reg, c.map, c.comp);
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_C_NV, b.reg, b.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_D_NV, c.reg, c.map, GL_ALPHA);
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, dreg, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else if(op == "mov")
|
||||
{
|
||||
src a(instr[2]);
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
|
||||
glCombinerOutputNV(C, GL_RGB, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
|
||||
glCombinerOutputNV(C, GL_ALPHA, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
else if(op == "mul")
|
||||
{
|
||||
src a(instr[2]);
|
||||
src b(instr[3]);
|
||||
if(mask == GL_RGBA || mask == GL_RGB)
|
||||
{
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_A_NV, a.reg, a.map, a.comp);
|
||||
glCombinerInputNV(C, GL_RGB, GL_VARIABLE_B_NV, b.reg, b.map, b.comp);
|
||||
glCombinerOutputNV(C, GL_RGB, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
|
||||
if(mask == GL_RGBA || mask == GL_ALPHA)
|
||||
{
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_A_NV, a.reg, a.map, GL_ALPHA);
|
||||
glCombinerInputNV(C, GL_ALPHA, GL_VARIABLE_B_NV, b.reg, b.map, GL_ALPHA);
|
||||
glCombinerOutputNV(C, GL_ALPHA, dreg, GL_DISCARD_NV, GL_DISCARD_NV, scale, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
glCombinerOutputNV(C, GL_ALPHA, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE,
|
||||
GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int combiner;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ps10::invoke(std::vector<constdef> * c,
|
||||
std::list<std::vector<string> > * a,
|
||||
std::list<std::vector<string> > * b)
|
||||
{
|
||||
glEnable(GL_PER_STAGE_CONSTANTS_NV); // should we require apps to do this?
|
||||
if(c)
|
||||
std::for_each(c->begin(), c->end(), set_constants());
|
||||
if(a)
|
||||
std::for_each(a->begin(), a->end(), set_texture_shaders(c));
|
||||
if(b)
|
||||
std::for_each(b->begin(), b->end(), set_register_combiners());
|
||||
}
|
||||
|
||||
// simple identification - just look for magic substring
|
||||
// -- easy to break...
|
||||
bool is_ps10(const char * s)
|
||||
{
|
||||
if(strstr(s, "ps.1.0"))
|
||||
return true;
|
||||
if(strstr(s, "Ps.1.0"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ps10::init_extensions()
|
||||
{
|
||||
// register combiners
|
||||
static bool rcinit = false;
|
||||
if(rcinit == false)
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_register_combiners)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_register_combiners\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rcinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
// register combiners 2
|
||||
static bool rc2init = false;
|
||||
if(rc2init == false)
|
||||
{
|
||||
if( !SUPPORTS_GL_NV_register_combiners2)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_register_combiners2\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc2init = true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool tsinit = 0;
|
||||
if (tsinit == false )
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_texture_shader || !SUPPORTS_GL_ARB_multitexture)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_texture_shader\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tsinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
21
RenderDll/XRenderOGL/NVParse/ps1.0_program.h
Normal file
21
RenderDll/XRenderOGL/NVParse/ps1.0_program.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _PS10_PROGRAM_H
|
||||
#define _PS10_PROGRAM_H
|
||||
|
||||
namespace ps10
|
||||
{
|
||||
|
||||
struct constdef
|
||||
{
|
||||
string reg;
|
||||
float r,g,b,a;
|
||||
};
|
||||
|
||||
|
||||
void invoke(std::vector<constdef> * c,
|
||||
std::list<std::vector<string> > * a,
|
||||
std::list<std::vector<string> > * b);
|
||||
|
||||
bool init_extensions();
|
||||
}
|
||||
|
||||
#endif
|
||||
56
RenderDll/XRenderOGL/NVParse/rc1.0_combiners.cpp
Normal file
56
RenderDll/XRenderOGL/NVParse/rc1.0_combiners.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
|
||||
#include "rc1.0_combiners.h"
|
||||
|
||||
void CombinersStruct::Validate()
|
||||
{
|
||||
if (2 == numConsts &&
|
||||
cc[0].reg.bits.name == cc[1].reg.bits.name)
|
||||
errors.set("global constant set twice");
|
||||
|
||||
generals.Validate(numConsts, &cc[0]);
|
||||
|
||||
final.Validate();
|
||||
}
|
||||
|
||||
void CombinersStruct::Invoke()
|
||||
{
|
||||
for (int i = 0; i < numConsts; i++)
|
||||
glCombinerParameterfvNV(cc[i].reg.bits.name, &(cc[i].v[0]));
|
||||
|
||||
generals.Invoke();
|
||||
|
||||
final.Invoke();
|
||||
}
|
||||
|
||||
bool is_rc10(const char * s)
|
||||
{
|
||||
return ! strncmp(s, "!!RC1.0", 7);
|
||||
}
|
||||
|
||||
|
||||
bool rc10_init_more()
|
||||
{
|
||||
bool rcinit = false;
|
||||
if(rcinit == false)
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_register_combiners && !SUPPORTS_GL_ATI_fragment_shader)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_register_combiners or GL_ATI_fragment_shader\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rcinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool rc2init = true;
|
||||
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
24
RenderDll/XRenderOGL/NVParse/rc1.0_combiners.h
Normal file
24
RenderDll/XRenderOGL/NVParse/rc1.0_combiners.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _RC10_COMBINERS_H
|
||||
#define _RC10_COMBINERS_H
|
||||
|
||||
#include "rc1.0_general.h"
|
||||
#include "rc1.0_final.h"
|
||||
|
||||
class CombinersStruct {
|
||||
public:
|
||||
void Init(GeneralCombinersStruct _gcs, FinalCombinerStruct _fc, ConstColorStruct _cc0, ConstColorStruct _cc1)
|
||||
{ generals = _gcs; final = _fc; cc[0] = _cc0; cc[1] = _cc1; numConsts = 2;}
|
||||
void Init(GeneralCombinersStruct _gcs, FinalCombinerStruct _fc, ConstColorStruct _cc0)
|
||||
{ generals = _gcs; final = _fc; cc[0] = _cc0; numConsts = 1;}
|
||||
void Init(GeneralCombinersStruct _gcs, FinalCombinerStruct _fc)
|
||||
{ generals = _gcs; final = _fc; numConsts = 0;}
|
||||
void Validate();
|
||||
void Invoke();
|
||||
private:
|
||||
GeneralCombinersStruct generals;
|
||||
FinalCombinerStruct final;
|
||||
ConstColorStruct cc[2];
|
||||
int numConsts;
|
||||
};
|
||||
|
||||
#endif
|
||||
159
RenderDll/XRenderOGL/NVParse/rc1.0_final.cpp
Normal file
159
RenderDll/XRenderOGL/NVParse/rc1.0_final.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include "rc1.0_final.h"
|
||||
#include "rc1.0_general.h"
|
||||
|
||||
void FinalRgbFunctionStruct::ZeroOut()
|
||||
{
|
||||
RegisterEnum zero;
|
||||
zero.word = RCP_ZERO;
|
||||
a.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
b.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
c.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
d.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
}
|
||||
|
||||
void FinalAlphaFunctionStruct::ZeroOut()
|
||||
{
|
||||
RegisterEnum zero;
|
||||
zero.word = RCP_ZERO;
|
||||
g.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
}
|
||||
|
||||
void FinalProductStruct::ZeroOut()
|
||||
{
|
||||
RegisterEnum zero;
|
||||
zero.word = RCP_ZERO;
|
||||
e.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
f.Init(zero, GL_UNSIGNED_IDENTITY_NV);
|
||||
}
|
||||
void FinalCombinerStruct::Validate()
|
||||
{
|
||||
if (hasProduct &&
|
||||
(GL_E_TIMES_F_NV == product.e.reg.bits.name ||
|
||||
GL_SPARE0_PLUS_SECONDARY_COLOR_NV == product.e.reg.bits.name ||
|
||||
GL_DISCARD_NV == product.e.reg.bits.name ||
|
||||
GL_E_TIMES_F_NV == product.f.reg.bits.name ||
|
||||
GL_SPARE0_PLUS_SECONDARY_COLOR_NV == product.f.reg.bits.name ||
|
||||
GL_DISCARD_NV == product.f.reg.bits.name))
|
||||
errors.set("invalid input register for final_product");
|
||||
|
||||
if (hasProduct &&
|
||||
(RCP_BLUE == product.e.reg.bits.channel ||
|
||||
RCP_BLUE == product.f.reg.bits.channel))
|
||||
errors.set("blue register used in final_product");
|
||||
|
||||
if (GL_E_TIMES_F_NV == alpha.g.reg.bits.name ||
|
||||
GL_SPARE0_PLUS_SECONDARY_COLOR_NV == alpha.g.reg.bits.name ||
|
||||
GL_DISCARD_NV == alpha.g.reg.bits.name)
|
||||
errors.set("invalid input register for final alpha");
|
||||
|
||||
if (RCP_RGB == alpha.g.reg.bits.channel)
|
||||
errors.set("rgb register used in final alpha");
|
||||
|
||||
if (GL_SPARE0_PLUS_SECONDARY_COLOR_NV == rgb.a.reg.bits.name &&
|
||||
GL_SPARE0_PLUS_SECONDARY_COLOR_NV != rgb.b.reg.bits.name &&
|
||||
GL_ZERO == rgb.c.reg.bits.name && GL_UNSIGNED_IDENTITY_NV == rgb.c.map)
|
||||
{
|
||||
MappedRegisterStruct temp;
|
||||
temp = rgb.a;
|
||||
rgb.a = rgb.b;
|
||||
rgb.b = temp;
|
||||
}
|
||||
|
||||
if (GL_SPARE0_PLUS_SECONDARY_COLOR_NV == rgb.a.reg.bits.name &&
|
||||
GL_ZERO == rgb.b.reg.bits.name && GL_UNSIGNED_INVERT_NV == rgb.b.map &&
|
||||
GL_ZERO == rgb.c.reg.bits.name && GL_UNSIGNED_IDENTITY_NV == rgb.c.map &&
|
||||
GL_SPARE0_PLUS_SECONDARY_COLOR_NV != rgb.d.reg.bits.name)
|
||||
{
|
||||
MappedRegisterStruct temp;
|
||||
temp = rgb.a;
|
||||
rgb.a = rgb.d;
|
||||
rgb.d = temp;
|
||||
}
|
||||
|
||||
if (GL_SPARE0_PLUS_SECONDARY_COLOR_NV == rgb.a.reg.bits.name ||
|
||||
GL_DISCARD_NV == rgb.a.reg.bits.name ||
|
||||
GL_DISCARD_NV == rgb.b.reg.bits.name ||
|
||||
GL_DISCARD_NV == rgb.c.reg.bits.name ||
|
||||
GL_DISCARD_NV == rgb.d.reg.bits.name)
|
||||
errors.set("invalid input register for final rgb");
|
||||
|
||||
if (RCP_BLUE == rgb.a.reg.bits.channel ||
|
||||
RCP_BLUE == rgb.b.reg.bits.channel ||
|
||||
RCP_BLUE == rgb.c.reg.bits.channel ||
|
||||
RCP_BLUE == rgb.d.reg.bits.channel)
|
||||
errors.set("blue register used in final rgb");
|
||||
|
||||
if ((GL_E_TIMES_F_NV == rgb.a.reg.bits.name ||
|
||||
GL_E_TIMES_F_NV == rgb.b.reg.bits.name ||
|
||||
GL_E_TIMES_F_NV == rgb.c.reg.bits.name ||
|
||||
GL_E_TIMES_F_NV == rgb.d.reg.bits.name) && !hasProduct)
|
||||
errors.set("final_product used but not set");
|
||||
|
||||
if (RCP_NONE == rgb.a.reg.bits.channel)
|
||||
rgb.a.reg.bits.channel = RCP_RGB;
|
||||
if (RCP_NONE == rgb.b.reg.bits.channel)
|
||||
rgb.b.reg.bits.channel = RCP_RGB;
|
||||
if (RCP_NONE == rgb.c.reg.bits.channel)
|
||||
rgb.c.reg.bits.channel = RCP_RGB;
|
||||
if (RCP_NONE == rgb.d.reg.bits.channel)
|
||||
rgb.d.reg.bits.channel = RCP_RGB;
|
||||
if (RCP_NONE == product.e.reg.bits.channel)
|
||||
product.e.reg.bits.channel = RCP_RGB;
|
||||
if (RCP_NONE == product.f.reg.bits.channel)
|
||||
product.f.reg.bits.channel = RCP_RGB;
|
||||
if (RCP_NONE == alpha.g.reg.bits.channel)
|
||||
alpha.g.reg.bits.channel = RCP_ALPHA;
|
||||
}
|
||||
|
||||
void FinalCombinerStruct::Invoke()
|
||||
{
|
||||
if(clamp)
|
||||
glCombinerParameteriNV(GL_COLOR_SUM_CLAMP_NV, GL_TRUE);
|
||||
else
|
||||
glCombinerParameteriNV(GL_COLOR_SUM_CLAMP_NV, GL_FALSE);
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_A_NV,
|
||||
rgb.a.reg.bits.name,
|
||||
rgb.a.map,
|
||||
MAP_CHANNEL(rgb.a.reg.bits.channel));
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_B_NV,
|
||||
rgb.b.reg.bits.name,
|
||||
rgb.b.map,
|
||||
MAP_CHANNEL(rgb.b.reg.bits.channel));
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_C_NV,
|
||||
rgb.c.reg.bits.name,
|
||||
rgb.c.map,
|
||||
MAP_CHANNEL(rgb.c.reg.bits.channel));
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_D_NV,
|
||||
rgb.d.reg.bits.name,
|
||||
rgb.d.map,
|
||||
MAP_CHANNEL(rgb.d.reg.bits.channel));
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_E_NV,
|
||||
product.e.reg.bits.name,
|
||||
product.e.map,
|
||||
MAP_CHANNEL(product.e.reg.bits.channel));
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_F_NV,
|
||||
product.f.reg.bits.name,
|
||||
product.f.map,
|
||||
MAP_CHANNEL(product.f.reg.bits.channel));
|
||||
|
||||
glFinalCombinerInputNV(
|
||||
GL_VARIABLE_G_NV,
|
||||
alpha.g.reg.bits.name,
|
||||
alpha.g.map,
|
||||
MAP_CHANNEL(alpha.g.reg.bits.channel));
|
||||
}
|
||||
48
RenderDll/XRenderOGL/NVParse/rc1.0_final.h
Normal file
48
RenderDll/XRenderOGL/NVParse/rc1.0_final.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _RC10_FINAL_H
|
||||
#define _RC10_FINAL_H
|
||||
|
||||
#include "rc1.0_register.h"
|
||||
|
||||
class FinalAlphaFunctionStruct {
|
||||
public:
|
||||
void Init(MappedRegisterStruct _g) { g = _g; }
|
||||
void ZeroOut();
|
||||
MappedRegisterStruct g;
|
||||
};
|
||||
|
||||
class FinalRgbFunctionStruct {
|
||||
public:
|
||||
void Init(MappedRegisterStruct _a, MappedRegisterStruct _b, MappedRegisterStruct _c, MappedRegisterStruct _d)
|
||||
{ a = _a; b = _b; c = _c; d = _d; }
|
||||
void ZeroOut();
|
||||
MappedRegisterStruct a;
|
||||
MappedRegisterStruct b;
|
||||
MappedRegisterStruct c;
|
||||
MappedRegisterStruct d;
|
||||
};
|
||||
|
||||
class FinalProductStruct {
|
||||
public:
|
||||
void Init(MappedRegisterStruct _e, MappedRegisterStruct _f) { e = _e; f = _f; }
|
||||
void ZeroOut();
|
||||
MappedRegisterStruct e;
|
||||
MappedRegisterStruct f;
|
||||
};
|
||||
|
||||
class FinalCombinerStruct {
|
||||
public:
|
||||
void Init(FinalRgbFunctionStruct _rgb, FinalAlphaFunctionStruct _alpha, int _clamp, FinalProductStruct _product)
|
||||
{ rgb = _rgb; alpha = _alpha; clamp = _clamp; product = _product; hasProduct = true;}
|
||||
void Init(FinalRgbFunctionStruct _rgb, FinalAlphaFunctionStruct _alpha, int _clamp)
|
||||
{ rgb = _rgb; alpha = _alpha; clamp = _clamp; hasProduct = false; product.ZeroOut();}
|
||||
|
||||
int hasProduct;
|
||||
FinalProductStruct product;
|
||||
int clamp;
|
||||
FinalRgbFunctionStruct rgb;
|
||||
FinalAlphaFunctionStruct alpha;
|
||||
void Validate();
|
||||
void Invoke();
|
||||
};
|
||||
|
||||
#endif
|
||||
334
RenderDll/XRenderOGL/NVParse/rc1.0_general.cpp
Normal file
334
RenderDll/XRenderOGL/NVParse/rc1.0_general.cpp
Normal file
@@ -0,0 +1,334 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include "rc1.0_general.h"
|
||||
|
||||
void GeneralCombinersStruct::Validate(int numConsts, ConstColorStruct *pcc)
|
||||
{
|
||||
GLint maxGCs;
|
||||
if (SUPPORTS_GL_ATI_fragment_shader)
|
||||
maxGCs = 8;
|
||||
else
|
||||
glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &maxGCs);
|
||||
if (num > maxGCs)
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
sprintf(buffer, "%d general combiners specified, only %d supported", num, maxGCs);
|
||||
errors.set(buffer);
|
||||
num = maxGCs;
|
||||
}
|
||||
|
||||
if (0 == num) {
|
||||
// Setup a "fake" general combiner 0
|
||||
general[0].ZeroOut();
|
||||
num = 1;
|
||||
}
|
||||
|
||||
localConsts = 0;
|
||||
int i;
|
||||
for (i = 0; i < num; i++)
|
||||
localConsts += general[i].numConsts;
|
||||
|
||||
if (localConsts > 0)
|
||||
if (NULL == glCombinerStageParameterfvNV)
|
||||
errors.set("local constant(s) specified, but not supported -- ignored");
|
||||
else
|
||||
for (i = 0; i < num; i++)
|
||||
general[i].SetUnusedLocalConsts(numConsts, pcc);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
general[i].Validate(i);
|
||||
|
||||
|
||||
for (; i < maxGCs; i++)
|
||||
general[i].ZeroOut();
|
||||
}
|
||||
|
||||
void GeneralCombinersStruct::Invoke()
|
||||
{
|
||||
if (SUPPORTS_GL_NV_register_combiners)
|
||||
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, num);
|
||||
int i;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
general[i].Invoke(i);
|
||||
}
|
||||
|
||||
/*if (NULL != glCombinerStageParameterfvNV)
|
||||
{
|
||||
if (localConsts > 0)
|
||||
glEnable(GL_PER_STAGE_CONSTANTS_NV);
|
||||
else
|
||||
glDisable(GL_PER_STAGE_CONSTANTS_NV);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
void GeneralCombinerStruct::ZeroOut()
|
||||
{
|
||||
numPortions = 2;
|
||||
numConsts = 0;
|
||||
|
||||
portion[0].ZeroOut();
|
||||
portion[0].designator = RCP_RGB;
|
||||
portion[1].ZeroOut();
|
||||
portion[1].designator = RCP_ALPHA;
|
||||
}
|
||||
|
||||
|
||||
void GeneralCombinerStruct::SetUnusedLocalConsts(int numGlobalConsts, ConstColorStruct *globalCCs)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < numGlobalConsts; i++)
|
||||
{
|
||||
bool constUsed = false;
|
||||
int j;
|
||||
for (j = 0; j < numConsts; j++)
|
||||
constUsed |= (cc[j].reg.bits.name == globalCCs[i].reg.bits.name);
|
||||
if (!constUsed)
|
||||
cc[numConsts++] = globalCCs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GeneralCombinerStruct::Validate(int stage)
|
||||
{
|
||||
if (2 == numConsts &&
|
||||
cc[0].reg.bits.name == cc[1].reg.bits.name)
|
||||
errors.set("local constant set twice");
|
||||
|
||||
switch (numPortions)
|
||||
{
|
||||
case 0:
|
||||
portion[0].designator = RCP_RGB;
|
||||
// Fallthru
|
||||
case 1:
|
||||
portion[1].designator = ((RCP_RGB == portion[0].designator) ? RCP_ALPHA : RCP_RGB);
|
||||
// Fallthru
|
||||
case 2:
|
||||
if (portion[0].designator == portion[1].designator)
|
||||
errors.set("portion declared twice");
|
||||
break;
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < numPortions; i++)
|
||||
portion[i].Validate(stage);
|
||||
|
||||
for (; i < 2; i++)
|
||||
portion[i].ZeroOut();
|
||||
|
||||
}
|
||||
|
||||
void GeneralCombinerStruct::Invoke(int stage)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (NULL != glCombinerStageParameterfvNV)
|
||||
{
|
||||
for (i = 0; i < numConsts; i++)
|
||||
{
|
||||
SCGBindConst cg;
|
||||
cg.m_nBindComponents = 1;
|
||||
cg.m_Val[0] = cc[i].v[0];
|
||||
cg.m_Val[1] = cc[i].v[1];
|
||||
cg.m_Val[2] = cc[i].v[2];
|
||||
cg.m_Val[3] = cc[i].v[3];
|
||||
int nReg = cc[i].reg.bits.name - GL_CONSTANT_COLOR0_NV;
|
||||
cg.m_dwBind = nReg + ((stage+1)<<28);
|
||||
gParseConsts.AddElem(cg);
|
||||
//glCombinerStageParameterfvNV(GL_COMBINER0_NV + stage, cc[i].reg.bits.name, &(cc[i].v[0]));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
portion[i].Invoke(stage);
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralPortionStruct::Validate(int stage)
|
||||
{
|
||||
gf.Validate(stage, designator);
|
||||
}
|
||||
|
||||
void GeneralPortionStruct::Invoke(int stage)
|
||||
{
|
||||
gf.Invoke(stage, designator, bs);
|
||||
}
|
||||
|
||||
void GeneralPortionStruct::ZeroOut()
|
||||
{
|
||||
gf.ZeroOut();
|
||||
bs.word = RCP_SCALE_BY_ONE;
|
||||
}
|
||||
|
||||
void GeneralFunctionStruct::ZeroOut()
|
||||
{
|
||||
// Create mapped registers for zero and discard
|
||||
MappedRegisterStruct unsignedZero;
|
||||
RegisterEnum zero;
|
||||
zero.word = RCP_ZERO;
|
||||
unsignedZero.Init(zero);
|
||||
|
||||
MappedRegisterStruct unsignedDiscard;
|
||||
RegisterEnum discard;
|
||||
discard.word = RCP_DISCARD;
|
||||
unsignedDiscard.Init(discard);
|
||||
|
||||
numOps = 3;
|
||||
|
||||
op[0].op = RCP_MUL;
|
||||
op[0].reg[0] = unsignedDiscard;
|
||||
op[0].reg[1] = unsignedZero;
|
||||
op[0].reg[2] = unsignedZero;
|
||||
|
||||
op[1].op = RCP_MUL;
|
||||
op[1].reg[0] = unsignedDiscard;
|
||||
op[1].reg[1] = unsignedZero;
|
||||
op[1].reg[2] = unsignedZero;
|
||||
|
||||
op[2].op = RCP_SUM;
|
||||
op[2].reg[0] = unsignedDiscard;
|
||||
|
||||
}
|
||||
|
||||
void GeneralFunctionStruct::Validate(int stage, int portion)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < numOps; i++)
|
||||
op[i].Validate(stage, portion);
|
||||
// Check if multiple ops are writing to same register (and it's not DISCARD)
|
||||
if (numOps > 1 &&
|
||||
op[0].reg[0].reg.bits.name == op[1].reg[0].reg.bits.name &&
|
||||
GL_DISCARD_NV != op[0].reg[0].reg.bits.name)
|
||||
errors.set("writing to same register twice");
|
||||
if (numOps > 2 &&
|
||||
(op[0].reg[0].reg.bits.name == op[2].reg[0].reg.bits.name ||
|
||||
op[1].reg[0].reg.bits.name == op[2].reg[0].reg.bits.name) &&
|
||||
GL_DISCARD_NV != op[2].reg[0].reg.bits.name)
|
||||
errors.set("writing to same register twice");
|
||||
|
||||
// Set unused outputs to discard, unused inputs to zero/unsigned_identity
|
||||
if (numOps < 2) {
|
||||
// Set C input to zero
|
||||
op[1].reg[1].reg.bits.name = GL_ZERO;
|
||||
op[1].reg[1].map = GL_UNSIGNED_IDENTITY_NV;
|
||||
op[1].reg[1].reg.bits.channel = portion;
|
||||
|
||||
// Set D input to zero
|
||||
op[1].reg[2].reg.bits.name = GL_ZERO;
|
||||
op[1].reg[2].map = GL_UNSIGNED_IDENTITY_NV;
|
||||
op[1].reg[2].reg.bits.channel = portion;
|
||||
|
||||
// Discard CD output
|
||||
op[1].op = false;
|
||||
op[1].reg[0].reg.bits.name = GL_DISCARD_NV;
|
||||
}
|
||||
|
||||
if (numOps < 3) {
|
||||
// Discard muxSum output
|
||||
op[2].reg[0].reg.bits.name = GL_DISCARD_NV;
|
||||
op[2].op = RCP_SUM;
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralFunctionStruct::Invoke(int stage, int portion, BiasScaleEnum bs)
|
||||
{
|
||||
GLenum portionEnum = (RCP_RGB == portion) ? GL_RGB : GL_ALPHA;
|
||||
|
||||
int chan = op[0].reg[1].reg.bits.channel;
|
||||
if (chan == RCP_NONE)
|
||||
chan = portion;
|
||||
glCombinerInputNV(GL_COMBINER0_NV + stage,
|
||||
portionEnum,
|
||||
GL_VARIABLE_A_NV,
|
||||
op[0].reg[1].reg.bits.name,
|
||||
op[0].reg[1].map,
|
||||
MAP_CHANNEL(chan));
|
||||
|
||||
chan = op[0].reg[2].reg.bits.channel;
|
||||
if (chan == RCP_NONE)
|
||||
chan = portion;
|
||||
glCombinerInputNV(GL_COMBINER0_NV + stage,
|
||||
portionEnum,
|
||||
GL_VARIABLE_B_NV,
|
||||
op[0].reg[2].reg.bits.name,
|
||||
op[0].reg[2].map,
|
||||
MAP_CHANNEL(chan));
|
||||
|
||||
chan = op[1].reg[1].reg.bits.channel;
|
||||
if (chan == RCP_NONE)
|
||||
chan = portion;
|
||||
glCombinerInputNV(GL_COMBINER0_NV + stage,
|
||||
portionEnum,
|
||||
GL_VARIABLE_C_NV,
|
||||
op[1].reg[1].reg.bits.name,
|
||||
op[1].reg[1].map,
|
||||
MAP_CHANNEL(chan));
|
||||
|
||||
chan = op[1].reg[2].reg.bits.channel;
|
||||
if (chan == RCP_NONE)
|
||||
chan = portion;
|
||||
glCombinerInputNV(GL_COMBINER0_NV + stage,
|
||||
portionEnum,
|
||||
GL_VARIABLE_D_NV,
|
||||
op[1].reg[2].reg.bits.name,
|
||||
op[1].reg[2].map,
|
||||
MAP_CHANNEL(chan));
|
||||
|
||||
glCombinerOutputNV(GL_COMBINER0_NV + stage,
|
||||
portionEnum,
|
||||
op[0].reg[0].reg.bits.name,
|
||||
op[1].reg[0].reg.bits.name,
|
||||
op[2].reg[0].reg.bits.name,
|
||||
bs.bits.scale,
|
||||
bs.bits.bias,
|
||||
op[0].op,
|
||||
op[1].op,
|
||||
(op[2].op == RCP_MUX) ? true : false);
|
||||
}
|
||||
|
||||
// This helper function assigns a channel to an undesignated input register
|
||||
static void ConvertRegister(RegisterEnum& reg, int portion)
|
||||
{
|
||||
if (RCP_NONE == reg.bits.channel) {
|
||||
reg.bits.channel = portion;
|
||||
if (GL_FOG == reg.bits.name && RCP_ALPHA == portion)
|
||||
// Special case where fog alpha is final only, but RGB is not
|
||||
reg.bits.finalOnly = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpStruct::Validate(int stage, int portion)
|
||||
{
|
||||
int args = 1;
|
||||
|
||||
if (RCP_DOT == op || RCP_MUL == op)
|
||||
args = 3;
|
||||
else
|
||||
args = 1;
|
||||
|
||||
if (reg[0].reg.bits.readOnly)
|
||||
errors.set("writing to a read-only register");
|
||||
|
||||
if (RCP_ALPHA == portion &&
|
||||
RCP_DOT == op)
|
||||
errors.set("dot used in alpha portion");
|
||||
int i;
|
||||
for (i = 0; i < args; i++) {
|
||||
ConvertRegister(reg[i].reg, portion);
|
||||
if (reg[i].reg.bits.finalOnly)
|
||||
errors.set("final register used in general combiner");
|
||||
if (RCP_RGB == portion &&
|
||||
RCP_BLUE == reg[i].reg.bits.channel)
|
||||
errors.set("blue register usedin rgb portion");
|
||||
if (RCP_ALPHA == portion &&
|
||||
RCP_RGB == reg[i].reg.bits.channel)
|
||||
errors.set("rgb register used in alpha portion");
|
||||
if (i > 0 &&
|
||||
GL_DISCARD_NV == reg[i].reg.bits.name)
|
||||
errors.set("reading from discard");
|
||||
}
|
||||
}
|
||||
107
RenderDll/XRenderOGL/NVParse/rc1.0_general.h
Normal file
107
RenderDll/XRenderOGL/NVParse/rc1.0_general.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef _RC10_GENERAL_H
|
||||
#define _RC10_GENERAL_H
|
||||
|
||||
#include "rc1.0_register.h"
|
||||
#include "nvparse_errors.h"
|
||||
#include "nvparse_externs.h"
|
||||
|
||||
enum {
|
||||
RCP_MUL = 0,
|
||||
RCP_DOT,
|
||||
RCP_MUX,
|
||||
RCP_SUM
|
||||
};
|
||||
|
||||
class ConstColorStruct {
|
||||
public:
|
||||
void Init(RegisterEnum _reg, float _v0, float _v1, float _v2, float _v3)
|
||||
{ reg = _reg; v[0] = _v0; v[1] = _v1; v[2] = _v2; v[3] = _v3; }
|
||||
RegisterEnum reg;
|
||||
float v[4];
|
||||
};
|
||||
|
||||
class OpStruct {
|
||||
public:
|
||||
void Init(int _op, RegisterEnum _reg0, MappedRegisterStruct _reg1, MappedRegisterStruct _reg2)
|
||||
{ op = _op; reg[0].reg = _reg0; reg[1] = _reg1; reg[2] = _reg2; }
|
||||
void Init(int _op, RegisterEnum _reg0)
|
||||
{ op = _op; reg[0].reg = _reg0; }
|
||||
int op;
|
||||
MappedRegisterStruct reg[3];
|
||||
void Validate(int stage, int portion);
|
||||
};
|
||||
|
||||
class GeneralFunctionStruct {
|
||||
public:
|
||||
void Init(OpStruct _op0, OpStruct _op1, OpStruct _op2) { op[0] = _op0; op[1] = _op1; op[2] = _op2; numOps = 3; }
|
||||
void Init(OpStruct _op0, OpStruct _op1) { op[0] = _op0; op[1] = _op1; numOps = 2; }
|
||||
void Init(OpStruct _op0) { op[0] = _op0; numOps = 1; }
|
||||
void Validate(int stage, int portion);
|
||||
void Invoke(int stage, int portion, BiasScaleEnum bs);
|
||||
void ZeroOut();
|
||||
int numOps;
|
||||
OpStruct op[3];
|
||||
};
|
||||
|
||||
|
||||
class GeneralPortionStruct {
|
||||
public:
|
||||
void Init(int _designator, GeneralFunctionStruct _gf, BiasScaleEnum _bs)
|
||||
{ designator = _designator; gf = _gf; bs = _bs; }
|
||||
|
||||
void Validate(int stage);
|
||||
void Invoke(int stage);
|
||||
void ZeroOut();
|
||||
int designator;
|
||||
GeneralFunctionStruct gf;
|
||||
BiasScaleEnum bs;
|
||||
};
|
||||
|
||||
class GeneralCombinerStruct {
|
||||
public:
|
||||
void Init(GeneralPortionStruct _portion0, GeneralPortionStruct _portion1, ConstColorStruct _cc0, ConstColorStruct _cc1)
|
||||
{ portion[0] = _portion0; portion[1] = _portion1; numPortions = 2; cc[0] = _cc0; cc[1] = _cc1; numConsts = 2; }
|
||||
void Init(GeneralPortionStruct _portion0, GeneralPortionStruct _portion1, ConstColorStruct _cc0)
|
||||
{ portion[0] = _portion0; portion[1] = _portion1; numPortions = 2; cc[0] = _cc0; numConsts = 1; }
|
||||
void Init(GeneralPortionStruct _portion0, GeneralPortionStruct _portion1)
|
||||
{ portion[0] = _portion0; portion[1] = _portion1; numPortions = 2; numConsts = 0; }
|
||||
|
||||
void Init(GeneralPortionStruct _portion0, ConstColorStruct _cc0, ConstColorStruct _cc1)
|
||||
{ portion[0] = _portion0; numPortions = 1; cc[0] = _cc0; cc[1] = _cc1; numConsts = 2; }
|
||||
void Init(GeneralPortionStruct _portion0, ConstColorStruct _cc0)
|
||||
{ portion[0] = _portion0; numPortions = 1; cc[0] = _cc0; numConsts = 1; }
|
||||
void Init(GeneralPortionStruct _portion0)
|
||||
{ portion[0] = _portion0; numPortions = 1; numConsts = 0; }
|
||||
|
||||
void Validate(int stage);
|
||||
void SetUnusedLocalConsts(int numGlobalConsts, ConstColorStruct *globalCCs);
|
||||
void Invoke(int stage);
|
||||
void ZeroOut();
|
||||
GeneralPortionStruct portion[2];
|
||||
int numPortions;
|
||||
ConstColorStruct cc[2];
|
||||
int numConsts;
|
||||
};
|
||||
|
||||
class GeneralCombinersStruct {
|
||||
public:
|
||||
void Init() {num = 0;}
|
||||
void Init(GeneralCombinerStruct _gc) { num = 1; general[0] = _gc; }
|
||||
GeneralCombinersStruct& operator+=(GeneralCombinerStruct& _gc)
|
||||
{
|
||||
if (num < RCP_NUM_GENERAL_COMBINERS)
|
||||
general[num++] = _gc;
|
||||
else
|
||||
errors.set("Too many general combiners.");
|
||||
return *this;
|
||||
}
|
||||
void Validate(int numConsts, ConstColorStruct *cc);
|
||||
void Invoke();
|
||||
GeneralCombinerStruct general[RCP_NUM_GENERAL_COMBINERS];
|
||||
int num;
|
||||
private:
|
||||
int localConsts;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
206
RenderDll/XRenderOGL/NVParse/rc1.0_register.h
Normal file
206
RenderDll/XRenderOGL/NVParse/rc1.0_register.h
Normal file
@@ -0,0 +1,206 @@
|
||||
#ifndef _RC10_REGISTER_H
|
||||
#define _RC10_REGISTER_H
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# define BYTE_ORDER !BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define RCP_NUM_GENERAL_COMBINERS 8
|
||||
|
||||
#define RCP_RGB 0
|
||||
#define RCP_ALPHA 1
|
||||
#define RCP_BLUE 2
|
||||
#define RCP_NONE 3
|
||||
|
||||
typedef union _RegisterEnum {
|
||||
struct {
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
unsigned int name :16; // OpenGL enum for register
|
||||
unsigned int channel : 2; // RCP_RGB, RCP_ALPHA, etc
|
||||
unsigned int readOnly : 1; // true or false
|
||||
unsigned int finalOnly : 1; // true or false
|
||||
unsigned int unused :12;
|
||||
#else
|
||||
unsigned int unused :12;
|
||||
unsigned int finalOnly : 1; // true or false
|
||||
unsigned int readOnly : 1; // true or false
|
||||
unsigned int channel : 2; // RCP_RGB, RCP_ALPHA, RCP_BLUE, RCP_NONE
|
||||
unsigned int name :16; // OpenGL enum for register
|
||||
#endif
|
||||
} bits;
|
||||
unsigned int word;
|
||||
} RegisterEnum;
|
||||
// No need for writeOnly flag, since DISCARD is the only register in that category
|
||||
|
||||
// WARNING: Don't monkey with the above structure or this macro
|
||||
// unless you're absolutely sure of what you're doing!
|
||||
// This constant allocation makes validation *much* cleaner.
|
||||
#define RCP_SET_REGISTER_ENUM(name, channel, readonly, finalonly) \
|
||||
((finalonly << 19) | (readonly << 18) | (channel << 16) | name)
|
||||
|
||||
#define RCP_FOG_RGB RCP_SET_REGISTER_ENUM(GL_FOG, RCP_RGB, 1, 0)
|
||||
#define RCP_FOG_ALPHA RCP_SET_REGISTER_ENUM(GL_FOG, RCP_ALPHA, 1, 1)
|
||||
#define RCP_FOG_BLUE RCP_SET_REGISTER_ENUM(GL_FOG, RCP_BLUE, 1, 0)
|
||||
#define RCP_FOG RCP_SET_REGISTER_ENUM(GL_FOG, RCP_NONE, 1, 0)
|
||||
#define RCP_PRIMARY_COLOR_RGB RCP_SET_REGISTER_ENUM(GL_PRIMARY_COLOR_NV, RCP_RGB, 0, 0)
|
||||
#define RCP_PRIMARY_COLOR_ALPHA RCP_SET_REGISTER_ENUM(GL_PRIMARY_COLOR_NV, RCP_ALPHA, 0, 0)
|
||||
#define RCP_PRIMARY_COLOR_BLUE RCP_SET_REGISTER_ENUM(GL_PRIMARY_COLOR_NV, RCP_BLUE, 0, 0)
|
||||
#define RCP_PRIMARY_COLOR RCP_SET_REGISTER_ENUM(GL_PRIMARY_COLOR_NV, RCP_NONE, 0, 0)
|
||||
#define RCP_SECONDARY_COLOR_RGB RCP_SET_REGISTER_ENUM(GL_SECONDARY_COLOR_NV, RCP_RGB, 0, 0)
|
||||
#define RCP_SECONDARY_COLOR_ALPHA RCP_SET_REGISTER_ENUM(GL_SECONDARY_COLOR_NV, RCP_ALPHA, 0, 0)
|
||||
#define RCP_SECONDARY_COLOR_BLUE RCP_SET_REGISTER_ENUM(GL_SECONDARY_COLOR_NV, RCP_BLUE, 0, 0)
|
||||
#define RCP_SECONDARY_COLOR RCP_SET_REGISTER_ENUM(GL_SECONDARY_COLOR_NV, RCP_NONE, 0, 0)
|
||||
#define RCP_SPARE0_RGB RCP_SET_REGISTER_ENUM(GL_SPARE0_NV, RCP_RGB, 0, 0)
|
||||
#define RCP_SPARE0_ALPHA RCP_SET_REGISTER_ENUM(GL_SPARE0_NV, RCP_ALPHA, 0, 0)
|
||||
#define RCP_SPARE0_BLUE RCP_SET_REGISTER_ENUM(GL_SPARE0_NV, RCP_BLUE, 0, 0)
|
||||
#define RCP_SPARE0 RCP_SET_REGISTER_ENUM(GL_SPARE0_NV, RCP_NONE, 0, 0)
|
||||
#define RCP_SPARE1_RGB RCP_SET_REGISTER_ENUM(GL_SPARE1_NV, RCP_RGB, 0, 0)
|
||||
#define RCP_SPARE1_ALPHA RCP_SET_REGISTER_ENUM(GL_SPARE1_NV, RCP_ALPHA, 0, 0)
|
||||
#define RCP_SPARE1_BLUE RCP_SET_REGISTER_ENUM(GL_SPARE1_NV, RCP_BLUE, 0, 0)
|
||||
#define RCP_SPARE1 RCP_SET_REGISTER_ENUM(GL_SPARE1_NV, RCP_NONE, 0, 0)
|
||||
#define RCP_TEXTURE0_RGB RCP_SET_REGISTER_ENUM(GL_TEXTURE0_ARB, RCP_RGB, 0, 0)
|
||||
#define RCP_TEXTURE0_ALPHA RCP_SET_REGISTER_ENUM(GL_TEXTURE0_ARB, RCP_ALPHA, 0, 0)
|
||||
#define RCP_TEXTURE0_BLUE RCP_SET_REGISTER_ENUM(GL_TEXTURE0_ARB, RCP_BLUE, 0, 0)
|
||||
#define RCP_TEXTURE0 RCP_SET_REGISTER_ENUM(GL_TEXTURE0_ARB, RCP_NONE, 0, 0)
|
||||
#define RCP_TEXTURE1_RGB RCP_SET_REGISTER_ENUM(GL_TEXTURE1_ARB, RCP_RGB, 0, 0)
|
||||
#define RCP_TEXTURE1_ALPHA RCP_SET_REGISTER_ENUM(GL_TEXTURE1_ARB, RCP_ALPHA, 0, 0)
|
||||
#define RCP_TEXTURE1_BLUE RCP_SET_REGISTER_ENUM(GL_TEXTURE1_ARB, RCP_BLUE, 0, 0)
|
||||
#define RCP_TEXTURE1 RCP_SET_REGISTER_ENUM(GL_TEXTURE1_ARB, RCP_NONE, 0, 0)
|
||||
#define RCP_TEXTURE2_RGB RCP_SET_REGISTER_ENUM(GL_TEXTURE2_ARB, RCP_RGB, 0, 0)
|
||||
#define RCP_TEXTURE2_ALPHA RCP_SET_REGISTER_ENUM(GL_TEXTURE2_ARB, RCP_ALPHA, 0, 0)
|
||||
#define RCP_TEXTURE2_BLUE RCP_SET_REGISTER_ENUM(GL_TEXTURE2_ARB, RCP_BLUE, 0, 0)
|
||||
#define RCP_TEXTURE2 RCP_SET_REGISTER_ENUM(GL_TEXTURE2_ARB, RCP_NONE, 0, 0)
|
||||
#define RCP_TEXTURE3_RGB RCP_SET_REGISTER_ENUM(GL_TEXTURE3_ARB, RCP_RGB, 0, 0)
|
||||
#define RCP_TEXTURE3_ALPHA RCP_SET_REGISTER_ENUM(GL_TEXTURE3_ARB, RCP_ALPHA, 0, 0)
|
||||
#define RCP_TEXTURE3_BLUE RCP_SET_REGISTER_ENUM(GL_TEXTURE3_ARB, RCP_BLUE, 0, 0)
|
||||
#define RCP_TEXTURE3 RCP_SET_REGISTER_ENUM(GL_TEXTURE3_ARB, RCP_NONE, 0, 0)
|
||||
#define RCP_CONST_COLOR0_RGB RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR0_NV, RCP_RGB, 1, 0)
|
||||
#define RCP_CONST_COLOR0_ALPHA RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR0_NV, RCP_ALPHA, 1, 0)
|
||||
#define RCP_CONST_COLOR0_BLUE RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR0_NV, RCP_BLUE, 1, 0)
|
||||
#define RCP_CONST_COLOR0 RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR0_NV, RCP_NONE, 1, 0)
|
||||
#define RCP_CONST_COLOR1_RGB RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR1_NV, RCP_RGB, 1, 0)
|
||||
#define RCP_CONST_COLOR1_ALPHA RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR1_NV, RCP_ALPHA, 1, 0)
|
||||
#define RCP_CONST_COLOR1_BLUE RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR1_NV, RCP_BLUE, 1, 0)
|
||||
#define RCP_CONST_COLOR1 RCP_SET_REGISTER_ENUM(GL_CONSTANT_COLOR1_NV, RCP_NONE, 1, 0)
|
||||
#define RCP_ZERO_RGB RCP_SET_REGISTER_ENUM(GL_ZERO, RCP_RGB, 1, 0)
|
||||
#define RCP_ZERO_ALPHA RCP_SET_REGISTER_ENUM(GL_ZERO, RCP_ALPHA, 1, 0)
|
||||
#define RCP_ZERO_BLUE RCP_SET_REGISTER_ENUM(GL_ZERO, RCP_BLUE, 1, 0)
|
||||
#define RCP_ZERO RCP_SET_REGISTER_ENUM(GL_ZERO, RCP_NONE, 1, 0)
|
||||
#define RCP_ONE_RGB RCP_SET_REGISTER_ENUM(GL_ONE, RCP_RGB, 1, 0)
|
||||
#define RCP_ONE_ALPHA RCP_SET_REGISTER_ENUM(GL_ONE, RCP_ALPHA, 1, 0)
|
||||
#define RCP_ONE_BLUE RCP_SET_REGISTER_ENUM(GL_ONE, RCP_BLUE, 1, 0)
|
||||
#define RCP_ONE RCP_SET_REGISTER_ENUM(GL_ONE, RCP_NONE, 1, 0)
|
||||
#define RCP_DISCARD RCP_SET_REGISTER_ENUM(GL_DISCARD_NV, RCP_NONE, 0, 0)
|
||||
#define RCP_FINAL_PRODUCT RCP_SET_REGISTER_ENUM(GL_E_TIMES_F_NV, RCP_NONE, 1, 1)
|
||||
#define RCP_COLOR_SUM RCP_SET_REGISTER_ENUM(GL_SPARE0_PLUS_SECONDARY_COLOR_NV, RCP_NONE, 1, 1)
|
||||
|
||||
#define MAP_CHANNEL(channel) ((RCP_RGB == (channel)) ? GL_RGB : (RCP_ALPHA == (channel) ? GL_ALPHA : GL_BLUE))
|
||||
|
||||
typedef union _BiasScaleEnum {
|
||||
struct {
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
unsigned int bias :16; // OpenGL enum for bias
|
||||
unsigned int scale :16; // OpenGL enum for scale
|
||||
#else
|
||||
unsigned int scale :16; // OpenGL enum for scale
|
||||
unsigned int bias :16; // OpenGL enum for bias
|
||||
#endif
|
||||
} bits;
|
||||
unsigned int word;
|
||||
} BiasScaleEnum;
|
||||
|
||||
// WARNING: Don't monkey with the above structure or this macro
|
||||
// unless you're absolutely sure of what you're doing!
|
||||
// This constant allocation makes validation *much* cleaner.
|
||||
#define RCP_SET_BIAS_SCALE_ENUM(bias, scale) ((scale << 16) | bias)
|
||||
|
||||
#define RCP_BIAS_BY_NEGATIVE_ONE_HALF_SCALE_BY_TWO RCP_SET_BIAS_SCALE_ENUM(GL_BIAS_BY_NEGATIVE_ONE_HALF_NV, GL_SCALE_BY_TWO_NV)
|
||||
#define RCP_BIAS_BY_NEGATIVE_ONE_HALF RCP_SET_BIAS_SCALE_ENUM(GL_BIAS_BY_NEGATIVE_ONE_HALF_NV, GL_NONE)
|
||||
#define RCP_SCALE_BY_ONE_HALF RCP_SET_BIAS_SCALE_ENUM(GL_NONE, GL_SCALE_BY_ONE_HALF_NV)
|
||||
#define RCP_SCALE_BY_ONE RCP_SET_BIAS_SCALE_ENUM(GL_NONE, GL_NONE)
|
||||
#define RCP_SCALE_BY_TWO RCP_SET_BIAS_SCALE_ENUM(GL_NONE, GL_SCALE_BY_TWO_NV)
|
||||
#define RCP_SCALE_BY_FOUR RCP_SET_BIAS_SCALE_ENUM(GL_NONE, GL_SCALE_BY_FOUR_NV)
|
||||
|
||||
class MappedRegisterStruct {
|
||||
public:
|
||||
void Init(RegisterEnum _reg, int _map = GL_UNSIGNED_IDENTITY_NV)
|
||||
{
|
||||
if (RCP_ONE == _reg.bits.name) {
|
||||
_reg.bits.name = RCP_ZERO;
|
||||
switch (_map) {
|
||||
case GL_UNSIGNED_IDENTITY_NV:
|
||||
_map = GL_UNSIGNED_INVERT_NV;
|
||||
break;
|
||||
case GL_UNSIGNED_INVERT_NV:
|
||||
_map = GL_UNSIGNED_IDENTITY_NV;
|
||||
break;
|
||||
case GL_EXPAND_NORMAL_NV:
|
||||
_map = GL_UNSIGNED_INVERT_NV;
|
||||
break;
|
||||
case GL_EXPAND_NEGATE_NV:
|
||||
_map = GL_EXPAND_NORMAL_NV;
|
||||
break;
|
||||
case GL_HALF_BIAS_NORMAL_NV:
|
||||
_map = GL_HALF_BIAS_NEGATE_NV;
|
||||
break;
|
||||
case GL_HALF_BIAS_NEGATE_NV:
|
||||
_map = GL_HALF_BIAS_NORMAL_NV;
|
||||
break;
|
||||
case GL_SIGNED_IDENTITY_NV:
|
||||
_map = GL_UNSIGNED_INVERT_NV;
|
||||
break;
|
||||
case GL_SIGNED_NEGATE_NV:
|
||||
_map = GL_EXPAND_NORMAL_NV;
|
||||
break;
|
||||
}
|
||||
}
|
||||
map = _map;
|
||||
reg = _reg;
|
||||
}
|
||||
int map;
|
||||
RegisterEnum reg;
|
||||
};
|
||||
|
||||
#ifdef TEST_BIT_FIELDS
|
||||
|
||||
class RegisterEnumTest {
|
||||
public:
|
||||
RegisterEnumTest()
|
||||
{
|
||||
RegisterEnum reg;
|
||||
bool error = false;
|
||||
|
||||
if (sizeof(reg.bits) != sizeof(reg.word))
|
||||
error = true;
|
||||
|
||||
reg.word = 0; reg.bits.name = 0xFFFF;
|
||||
if (RCP_SET_REGISTER_ENUM(0xFFFF, 0, 0, 0) != reg.word)
|
||||
error = true;
|
||||
|
||||
reg.word = 0; reg.bits.channel = 3;
|
||||
if (RCP_SET_REGISTER_ENUM(0, 3, 0, 0) != reg.word)
|
||||
error = true;
|
||||
|
||||
reg.word = 0; reg.bits.readOnly = true;
|
||||
if (RCP_SET_REGISTER_ENUM(0, 0, 1, 0) != reg.word)
|
||||
error = true;
|
||||
|
||||
reg.word = 0; reg.bits.finalOnly = true;
|
||||
if (RCP_SET_REGISTER_ENUM(0, 0, 0, 1) != reg.word)
|
||||
error = true;
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "ERROR: Bit Fields were not compiled correctly in " __FILE__ "!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static RegisterEnumTest registerEnumTest;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
311
RenderDll/XRenderOGL/NVParse/ts1.0_inst.cpp
Normal file
311
RenderDll/XRenderOGL/NVParse/ts1.0_inst.cpp
Normal file
@@ -0,0 +1,311 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include "ts1.0_inst.h"
|
||||
|
||||
Inst::Inst(int inst, float arg0, float arg1, float arg2, float arg3, float arg4, float arg5, float arg6)
|
||||
{
|
||||
opcode.word = inst;
|
||||
expand = 0;
|
||||
args[0] = arg0;
|
||||
args[1] = arg1;
|
||||
args[2] = arg2;
|
||||
args[3] = arg3;
|
||||
args[4] = arg4;
|
||||
args[5] = arg5;
|
||||
args[6] = arg6;
|
||||
}
|
||||
|
||||
Inst::Inst(int inst, MappedVariablePtr arg0, float arg1, float arg2, float arg3, float arg4, float arg5, float arg6)
|
||||
{
|
||||
opcode.word = inst;
|
||||
expand = arg0->expand;
|
||||
args[0] = arg0->var;
|
||||
args[1] = arg1;
|
||||
args[2] = arg2;
|
||||
args[3] = arg3;
|
||||
args[4] = arg4;
|
||||
args[5] = arg5;
|
||||
args[6] = arg6;
|
||||
}
|
||||
|
||||
void Inst::Invoke()
|
||||
{
|
||||
switch(opcode.word) {
|
||||
case TSP_NOP:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
|
||||
break;
|
||||
case TSP_TEXTURE_1D:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_1D);
|
||||
break;
|
||||
case TSP_TEXTURE_2D:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);
|
||||
break;
|
||||
case TSP_TEXTURE_RECTANGLE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_RECTANGLE_NV);
|
||||
break;
|
||||
case TSP_TEXTURE_3D:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D);
|
||||
break;
|
||||
case TSP_TEXTURE_CUBE_MAP:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB);
|
||||
break;
|
||||
case TSP_CULL_FRAGMENT:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_CULL_FRAGMENT_NV);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_CULL_MODES_NV, &args[0]);
|
||||
break;
|
||||
case TSP_PASS_THROUGH:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_PASS_THROUGH_NV);
|
||||
break;
|
||||
case TSP_OFFSET_2D_SCALE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_SCALE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_SCALE_NV, args[5]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_BIAS_NV, args[6]);
|
||||
break;
|
||||
case TSP_OFFSET_PROJECTIVE_2D_SCALE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_SCALE_NV, args[5]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_BIAS_NV, args[6]);
|
||||
break;
|
||||
case TSP_OFFSET_2D:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_2D_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
break;
|
||||
case TSP_OFFSET_PROJECTIVE_2D:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
break;
|
||||
case TSP_OFFSET_RECTANGLE_SCALE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_SCALE_NV, args[5]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_BIAS_NV, args[6]);
|
||||
break;
|
||||
case TSP_OFFSET_PROJECTIVE_RECTANGLE_SCALE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_SCALE_NV, args[5]);
|
||||
glTexEnvf(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_BIAS_NV, args[6]);
|
||||
break;
|
||||
case TSP_OFFSET_RECTANGLE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_TEXTURE_RECTANGLE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
break;
|
||||
case TSP_OFFSET_PROJECTIVE_RECTANGLE:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, &args[1]);
|
||||
break;
|
||||
case TSP_DEPENDENT_AR:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_AR_TEXTURE_2D_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DEPENDENT_GB:
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DEPENDENT_GB_TEXTURE_2D_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_2D_1_OF_2:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_2D_2_OF_2:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_RECTANGLE_1_OF_2:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_RECTANGLE_2_OF_2:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_DEPTH_REPLACE_1_OF_2:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_DEPTH_REPLACE_2_OF_2:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_DEPTH_REPLACE_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_3D_1_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_3D_2_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_3D_3_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_1_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_2_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_3_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_CONST_EYE_NV, &args[1]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
break;
|
||||
case TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3:
|
||||
if (expand)
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_EXPAND_NORMAL_NV);
|
||||
else
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV, GL_UNSIGNED_IDENTITY_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV);
|
||||
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + (int)args[0]);
|
||||
glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_CONST_EYE_NV, &args[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
146
RenderDll/XRenderOGL/NVParse/ts1.0_inst.h
Normal file
146
RenderDll/XRenderOGL/NVParse/ts1.0_inst.h
Normal file
@@ -0,0 +1,146 @@
|
||||
#ifndef _INST_H
|
||||
#define _INST_H
|
||||
|
||||
#define TSP_MAX_ARGS 7
|
||||
#define TSP_NUM_TEXTURE_UNITS 4
|
||||
|
||||
#ifdef _WIN32
|
||||
# define BYTE_ORDER !BIG_ENDIAN
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef union _InstructionEnum {
|
||||
struct {
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
unsigned int instruction :10; // instruction id
|
||||
unsigned int stage : 4; // stage number
|
||||
unsigned int dependent : 1; // dependent operation
|
||||
unsigned int noOutput : 1; // no RGBA output
|
||||
#else
|
||||
unsigned int noOutput : 1;
|
||||
unsigned int dependent : 1;
|
||||
unsigned int stage : 4;
|
||||
unsigned int instruction :10;
|
||||
#endif
|
||||
} bits;
|
||||
unsigned int word;
|
||||
} InstructionEnum;
|
||||
|
||||
// WARNING: Don't monkey with the above structure or this macro
|
||||
// unless you're absolutely sure of what you're doing!
|
||||
// This constant allocation makes validation *much* cleaner.
|
||||
#define TSP_SET_INSTRUCTION_ENUM(inst, st, dep, noout) \
|
||||
((noout << 15) | (dep << 14) | (st << 10) | inst)
|
||||
|
||||
#define TSP_NOP TSP_SET_INSTRUCTION_ENUM(0, 0, 0, 1)
|
||||
#define TSP_TEXTURE_1D TSP_SET_INSTRUCTION_ENUM(1, 0, 0, 0)
|
||||
#define TSP_TEXTURE_2D TSP_SET_INSTRUCTION_ENUM(2, 0, 0, 0)
|
||||
#define TSP_TEXTURE_RECTANGLE TSP_SET_INSTRUCTION_ENUM(3, 0, 0, 0)
|
||||
#define TSP_TEXTURE_3D TSP_SET_INSTRUCTION_ENUM(4, 0, 0, 0)
|
||||
#define TSP_TEXTURE_CUBE_MAP TSP_SET_INSTRUCTION_ENUM(5, 0, 0, 0)
|
||||
#define TSP_CULL_FRAGMENT TSP_SET_INSTRUCTION_ENUM(6, 0, 0, 1)
|
||||
#define TSP_PASS_THROUGH TSP_SET_INSTRUCTION_ENUM(7, 0, 0, 0)
|
||||
#define TSP_DEPENDENT_AR TSP_SET_INSTRUCTION_ENUM(8, 0, 1, 0)
|
||||
#define TSP_DEPENDENT_GB TSP_SET_INSTRUCTION_ENUM(9, 0, 1, 0)
|
||||
#define TSP_OFFSET_2D TSP_SET_INSTRUCTION_ENUM(10, 0, 1, 0)
|
||||
#define TSP_OFFSET_2D_SCALE TSP_SET_INSTRUCTION_ENUM(11, 0, 1, 0)
|
||||
#define TSP_OFFSET_RECTANGLE TSP_SET_INSTRUCTION_ENUM(12, 0, 1, 0)
|
||||
#define TSP_OFFSET_RECTANGLE_SCALE TSP_SET_INSTRUCTION_ENUM(13, 0, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_2D_1_OF_2 TSP_SET_INSTRUCTION_ENUM(14, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_2D_2_OF_2 TSP_SET_INSTRUCTION_ENUM(14, 1, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_RECTANGLE_1_OF_2 TSP_SET_INSTRUCTION_ENUM(15, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_RECTANGLE_2_OF_2 TSP_SET_INSTRUCTION_ENUM(15, 1, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_DEPTH_REPLACE_1_OF_2 TSP_SET_INSTRUCTION_ENUM(16, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_DEPTH_REPLACE_2_OF_2 TSP_SET_INSTRUCTION_ENUM(16, 1, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_3D_1_OF_3 TSP_SET_INSTRUCTION_ENUM(17, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_3D_2_OF_3 TSP_SET_INSTRUCTION_ENUM(17, 1, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_3D_3_OF_3 TSP_SET_INSTRUCTION_ENUM(17, 2, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_1_OF_3 TSP_SET_INSTRUCTION_ENUM(18, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_2_OF_3 TSP_SET_INSTRUCTION_ENUM(18, 1, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_3_OF_3 TSP_SET_INSTRUCTION_ENUM(18, 2, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3 TSP_SET_INSTRUCTION_ENUM(19, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3 TSP_SET_INSTRUCTION_ENUM(19, 1, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3 TSP_SET_INSTRUCTION_ENUM(19, 2, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3 TSP_SET_INSTRUCTION_ENUM(20, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3 TSP_SET_INSTRUCTION_ENUM(20, 1, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3 TSP_SET_INSTRUCTION_ENUM(20, 2, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_1_OF_3 TSP_SET_INSTRUCTION_ENUM(21, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_2_OF_3 TSP_SET_INSTRUCTION_ENUM(21, 1, 1, 0)
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_EYE_FROM_QS_3_OF_3 TSP_SET_INSTRUCTION_ENUM(21, 2, 1, 0)
|
||||
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_1_OF_3 TSP_SET_INSTRUCTION_ENUM(22, 0, 1, 1)
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_2_OF_3 TSP_SET_INSTRUCTION_ENUM(22, 1, 1, 0)
|
||||
#define TSP_DOT_PRODUCT_CUBE_MAP_AND_REFLECT_CUBE_MAP_CONST_EYE_3_OF_3 TSP_SET_INSTRUCTION_ENUM(22, 2, 1, 0)
|
||||
|
||||
#define TSP_OFFSET_PROJECTIVE_2D TSP_SET_INSTRUCTION_ENUM(23, 0, 1, 0)
|
||||
#define TSP_OFFSET_PROJECTIVE_2D_SCALE TSP_SET_INSTRUCTION_ENUM(24, 0, 1, 0)
|
||||
#define TSP_OFFSET_PROJECTIVE_RECTANGLE TSP_SET_INSTRUCTION_ENUM(25, 0, 1, 0)
|
||||
#define TSP_OFFSET_PROJECTIVE_RECTANGLE_SCALE TSP_SET_INSTRUCTION_ENUM(26, 0, 1, 0)
|
||||
|
||||
typedef struct _MappedVariable {
|
||||
float var;
|
||||
int expand;
|
||||
} MappedVariable, *MappedVariablePtr;
|
||||
|
||||
typedef class Inst {
|
||||
public:
|
||||
Inst(int inst, float arg0 = 0., float arg1 = 0., float arg2 = 0., float arg3 = 0., float arg4 = 0., float arg5 = 0., float arg6 = 0.);
|
||||
Inst(int inst, MappedVariablePtr arg0, float arg1 = 0., float arg2 = 0., float arg3 = 0., float arg4 = 0., float arg5 = 0., float arg6 = 0.);
|
||||
void Invoke();
|
||||
InstructionEnum opcode;
|
||||
float args[TSP_MAX_ARGS];
|
||||
private:
|
||||
int expand;
|
||||
} *InstPtr;
|
||||
|
||||
#ifdef TEST_BIT_FIELDS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class InstructionEnumTest {
|
||||
public:
|
||||
InstructionEnumTest()
|
||||
{
|
||||
InstructionEnum inst;
|
||||
bool error = false;
|
||||
|
||||
if (sizeof(inst.bits) != sizeof(inst.word))
|
||||
error = true;
|
||||
|
||||
inst.word = 0; inst.bits.instruction = 0x3FF;
|
||||
if (TSP_SET_INSTRUCTION_ENUM(0x3FF, 0, 0, 0) != inst.word)
|
||||
error = true;
|
||||
|
||||
inst.word = 0; inst.bits.stage = 0x0F;
|
||||
if (TSP_SET_INSTRUCTION_ENUM(0, 0x0F, 0, 0) != inst.word)
|
||||
error = true;
|
||||
|
||||
inst.word = 0; inst.bits.dependent = true;
|
||||
if (TSP_SET_INSTRUCTION_ENUM(0, 0, 1, 0) != inst.word)
|
||||
error = true;
|
||||
|
||||
inst.word = 0; inst.bits.noOutput = true;
|
||||
if (TSP_SET_INSTRUCTION_ENUM(0, 0, 0, 1) != inst.word)
|
||||
error = true;
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "ERROR: Bit Fields were not compiled correctly in " __FILE__ "!\n");
|
||||
_asm {int 3}
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static InstructionEnumTest instructionEnumTest;
|
||||
|
||||
#endif /* TEST_BIT_FIELDS */
|
||||
|
||||
#endif
|
||||
103
RenderDll/XRenderOGL/NVParse/ts1.0_inst_list.cpp
Normal file
103
RenderDll/XRenderOGL/NVParse/ts1.0_inst_list.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include "ts1.0_inst_list.h"
|
||||
|
||||
|
||||
const int instListInc = 4;
|
||||
|
||||
InstList::InstList()
|
||||
{
|
||||
size = 0;
|
||||
max = instListInc;
|
||||
list = (InstPtr)malloc(sizeof(Inst) * max);
|
||||
}
|
||||
|
||||
InstList::~InstList()
|
||||
{
|
||||
free(list);
|
||||
}
|
||||
|
||||
int InstList::Size()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
InstList& InstList::operator+=(InstPtr t)
|
||||
{
|
||||
if (size == max) {
|
||||
/* Extend list size by instListInc amount */
|
||||
max += instListInc;
|
||||
list = (InstPtr)realloc(list, sizeof(Inst) * max);
|
||||
}
|
||||
list[size++] = *t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void InstList::Invoke()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < size; i++) {
|
||||
// set active texture
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + i);
|
||||
list[i].Invoke();
|
||||
}
|
||||
// Reset active texture to unit 0
|
||||
// Could do a glGet to figure out what the initial active texunit was,
|
||||
// and reset to that, but the glGet would not behave well within
|
||||
// a display list...
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
|
||||
void InstList::Validate()
|
||||
{
|
||||
if (size > TSP_NUM_TEXTURE_UNITS)
|
||||
errors.set("too many instructions");
|
||||
int i;
|
||||
for (i = 0; i < size; i++) {
|
||||
int stage = list[i].opcode.bits.stage;
|
||||
if (stage > i)
|
||||
errors.set("prior stage missing");
|
||||
if (list[i].opcode.bits.instruction != list[i - stage].opcode.bits.instruction)
|
||||
errors.set("stage mismatch");
|
||||
if (list[i].opcode.bits.dependent) {
|
||||
int previousTexture = (int)list[i].args[0];
|
||||
if (previousTexture >= i - stage)
|
||||
errors.set("invalid texture reference");
|
||||
if (list[previousTexture].opcode.bits.noOutput)
|
||||
errors.set("no output on referenced texture");
|
||||
}
|
||||
}
|
||||
|
||||
// Assign remaining undesignated texture units to nop
|
||||
for (; i < TSP_NUM_TEXTURE_UNITS; i++) {
|
||||
InstPtr nopInst = new Inst(TSP_NOP);
|
||||
*this += nopInst;
|
||||
delete nopInst;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_ts10(const char * s)
|
||||
{
|
||||
return ! strncmp(s, "!!TS1.0", 7);
|
||||
}
|
||||
|
||||
bool ts10_init_more()
|
||||
{
|
||||
static bool tsinit = false;
|
||||
if (tsinit == false )
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_texture_shader || !SUPPORTS_GL_ARB_multitexture)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_texture_shader\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tsinit = true;
|
||||
}
|
||||
}
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
return true;
|
||||
}
|
||||
20
RenderDll/XRenderOGL/NVParse/ts1.0_inst_list.h
Normal file
20
RenderDll/XRenderOGL/NVParse/ts1.0_inst_list.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _InstList_h
|
||||
#define _InstList_h
|
||||
|
||||
#include "ts1.0_inst.h"
|
||||
|
||||
typedef class InstList {
|
||||
public:
|
||||
InstList();
|
||||
~InstList();
|
||||
int Size();
|
||||
InstList& operator+=(InstPtr t);
|
||||
void Validate();
|
||||
void Invoke();
|
||||
private:
|
||||
InstPtr list;
|
||||
int size;
|
||||
int max;
|
||||
} *InstListPtr;
|
||||
|
||||
#endif
|
||||
5
RenderDll/XRenderOGL/NVParse/unistd.h
Normal file
5
RenderDll/XRenderOGL/NVParse/unistd.h
Normal file
@@ -0,0 +1,5 @@
|
||||
// to make flex and vc++ play nice together
|
||||
#ifndef _WIN32
|
||||
#error
|
||||
//this thing was getting me for hours! "why can't I close the bloody file!"
|
||||
#endif
|
||||
341
RenderDll/XRenderOGL/NVParse/vcp1.0_impl.cpp
Normal file
341
RenderDll/XRenderOGL/NVParse/vcp1.0_impl.cpp
Normal file
@@ -0,0 +1,341 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void ParseVertexProgramConstants( GLenum target, char *instring);
|
||||
GLuint LookupTrackMatrix(char *matrixName);
|
||||
GLuint LookupTrackMatrixTransform(char *matrixTransformName);
|
||||
}
|
||||
|
||||
bool is_vcp10(const char * s)
|
||||
{
|
||||
return ! strncmp(s, "!!VCP1.0", 8);
|
||||
}
|
||||
|
||||
bool vcp10_init(char * s)
|
||||
{
|
||||
static int vpinit = 0;
|
||||
|
||||
if (vpinit == 0 )
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_vertex_program)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_vertex_program");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vpinit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
|
||||
myin = s;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int vcp10_parse()
|
||||
{
|
||||
// parse the constant declarations, setting their values in the GL.
|
||||
ParseVertexProgramConstants( GL_VERTEX_PROGRAM_NV, myin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : ParseVertexProgramConstants |
|
||||
//| Description: Parse and set VP1.0 constant memory based on const |
|
||||
//| directives. |
|
||||
//| |
|
||||
//| Format : constXX = (x, y, z, w); # where XXX is an integer 0-95. |
|
||||
//| : constXX = TRACK(matrix, transform); # track a matrix |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void ParseVertexProgramConstants(GLenum target, char *instring)
|
||||
{
|
||||
// don't overwrite the original string.
|
||||
char *tmpstring = new char[strlen(instring)+1];
|
||||
strcpy(tmpstring, instring);
|
||||
|
||||
char lineSeparator[] = "\n";
|
||||
char wordSeparator[] = " \t";
|
||||
char error[256];
|
||||
char dummy[256];
|
||||
char *token;
|
||||
|
||||
//iterate over the lines in the string
|
||||
token = strtok(tmpstring, lineSeparator);
|
||||
|
||||
// we assume the first line is the "!!VP1.0 line".
|
||||
if (token != NULL)
|
||||
{
|
||||
token = strtok(NULL, lineSeparator);
|
||||
}
|
||||
|
||||
int iLineCount = 1; // skip first line
|
||||
|
||||
while (token != NULL)
|
||||
{
|
||||
iLineCount++;
|
||||
|
||||
// if the first non-whitespace character is a #, this is a comment. Skip.
|
||||
if (!sscanf(token, " #%s", dummy))
|
||||
{ // not a comment. Is it a constant?
|
||||
|
||||
// strip whitespace from the beginning of the string
|
||||
int i;
|
||||
for (i = 0; i < (int)strlen(token) && isspace(token[i]); i++);
|
||||
token += i;
|
||||
|
||||
if (strlen(token) > 0 && // this is not a blank line and
|
||||
!strnicmp(token, "c[", 2)) // the first word is of the form "c[xx]", so its a constant.
|
||||
{
|
||||
int iConstID;
|
||||
int iNumValuesAssigned;
|
||||
char c[6];
|
||||
|
||||
iNumValuesAssigned = sscanf(token, " %c [ %d ] = %s ", &c[0], &iConstID, dummy);
|
||||
|
||||
if (3 != iNumValuesAssigned || toupper(c[0]) != 'C')
|
||||
{ // error in constant directive.
|
||||
sprintf(error, "error at line %d \n\"%s\"\n", iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else if (!strnicmp(dummy, "track", 5))
|
||||
{ // this is a TrackMatrix directive
|
||||
char matrixName[256], matrixTransformName[256];
|
||||
|
||||
// the series of %c's are to make sure "track(" doesn't get glommed onto the matrixName
|
||||
iNumValuesAssigned = sscanf(token,
|
||||
" %c [ %d ] = %c%c%c%c%c ( %s %s ) ;",
|
||||
&c[0], &iConstID, &c[1], &c[2], &c[3], &c[4], &c[5],
|
||||
matrixName, matrixTransformName);
|
||||
|
||||
if (iNumValuesAssigned < 8)
|
||||
{
|
||||
sprintf(error, "error at line %d \n\"%s\"\n", iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *buffer;
|
||||
if (9 == iNumValuesAssigned)
|
||||
{
|
||||
// just need to remove any junk from the matrix names and IDs.
|
||||
if (buffer = strstr(matrixName, ","))
|
||||
buffer[0] = 0;
|
||||
|
||||
if (buffer = strstr(matrixTransformName, ")"))
|
||||
buffer[0] = 0;
|
||||
}
|
||||
else // 8 == iNumValuesAssigned
|
||||
{
|
||||
// have to split the two names, since they both were put into the matrixName
|
||||
if (buffer = strstr(matrixName, ","))
|
||||
{
|
||||
strcpy(matrixTransformName, buffer + 1);
|
||||
buffer[0] = 0;
|
||||
// get rid of paren at end of transform name, if it is there
|
||||
if (buffer = strstr(matrixTransformName, ")"))
|
||||
{
|
||||
buffer[0] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(error, "error at line %d \n\"%s\"\n", iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
}
|
||||
|
||||
// constant ID must be modulo 4.
|
||||
if (0 != (iConstID % 4))
|
||||
{
|
||||
sprintf(error,
|
||||
"error at line %d \n\"%s\"\n\tglTrackMatrixNV address must be modulo 4\n",
|
||||
iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else if (iConstID < 0 || iConstID > 95)
|
||||
{
|
||||
sprintf(error,
|
||||
"error at line %d \n\"%s\"\n\tConstant address out of range\n",
|
||||
iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
// get the enum values for the specified matrices
|
||||
GLuint iMatrixID = LookupTrackMatrix(matrixName);
|
||||
GLuint iTransformID = LookupTrackMatrixTransform(matrixTransformName);
|
||||
|
||||
if (0 == iMatrixID)
|
||||
{
|
||||
sprintf(error,
|
||||
"error at line %d \n\"%s\"\n\tInvalid Matrix parameter in glTrackMatrixNV.\n",
|
||||
iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else if (0 == iTransformID)
|
||||
{
|
||||
sprintf(error,
|
||||
"error at line %d \n\"%s\"\n\tInvalid Transform parameter in glTrackMatrixNV\n",
|
||||
iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
// untrack any currently tracked matrix
|
||||
glTrackMatrixNV(target, iConstID, GL_NONE, GL_IDENTITY_NV);
|
||||
|
||||
// tell GL the matrix to track
|
||||
glTrackMatrixNV(target, iConstID, iMatrixID, iTransformID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else // this is a constant directive
|
||||
{
|
||||
float xyzw[4] = {0, 0, 0, 0};
|
||||
iNumValuesAssigned = sscanf(token,
|
||||
" %c [ %d ] = ( %f , %f , %f , %f ) ; ",
|
||||
&c, &iConstID, xyzw, xyzw + 1, xyzw + 2, xyzw + 3);
|
||||
|
||||
if (6 != iNumValuesAssigned)
|
||||
{ // error in constant directive.
|
||||
sprintf(error, "error at line %d \n\"%s\"\n", iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else if (iConstID < 0 || iConstID > 95)
|
||||
{
|
||||
sprintf(error,
|
||||
"error at line %d \n\"%s\"\n\tConstant address out of range\n",
|
||||
iLineCount, token);
|
||||
errors.set(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always set the closest matrix location to tracking NONE to avoid errors!
|
||||
glTrackMatrixNV(target, iConstID - (iConstID % 4), GL_NONE, GL_IDENTITY_NV);
|
||||
|
||||
// tell GL the constant values
|
||||
glProgramParameter4fvNV(target, iConstID, xyzw);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get the next line
|
||||
token = strtok(NULL, lineSeparator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct MatrixLookupEntry
|
||||
{
|
||||
string name;
|
||||
GLuint ID;
|
||||
};
|
||||
|
||||
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : LookupTrackMatrix |
|
||||
//| Description: Returns the enumerated matrix name given a valid string |
|
||||
//| or 0 if an unknown matrix is requested. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
GLuint LookupTrackMatrix(char *matrixName)
|
||||
{
|
||||
static bool bFirstTime = true;
|
||||
static int iNumEntries = 14;
|
||||
static MatrixLookupEntry* matrixLookupTable = new MatrixLookupEntry[iNumEntries];
|
||||
|
||||
if (bFirstTime) // build the lookup table
|
||||
{
|
||||
matrixLookupTable[0].name = "GL_NONE";
|
||||
matrixLookupTable[0].ID = GL_NONE;
|
||||
matrixLookupTable[1].name = "GL_MODELVIEW";
|
||||
matrixLookupTable[1].ID = GL_MODELVIEW;
|
||||
matrixLookupTable[2].name = "GL_PROJECTION";
|
||||
matrixLookupTable[2].ID = GL_PROJECTION;
|
||||
matrixLookupTable[3].name = "GL_TEXTURE";
|
||||
matrixLookupTable[3].ID = GL_TEXTURE;
|
||||
matrixLookupTable[4].name = "GL_COLOR";
|
||||
matrixLookupTable[4].ID = GL_COLOR;
|
||||
matrixLookupTable[5].name = "GL_MODELVIEW_PROJECTION_NV";
|
||||
matrixLookupTable[5].ID = GL_MODELVIEW_PROJECTION_NV;
|
||||
matrixLookupTable[6].name = "GL_MATRIX0_NV";
|
||||
matrixLookupTable[6].ID = GL_MATRIX0_NV;
|
||||
matrixLookupTable[7].name = "GL_MATRIX1_NV";
|
||||
matrixLookupTable[7].ID = GL_MATRIX1_NV;
|
||||
matrixLookupTable[8].name = "GL_MATRIX2_NV";
|
||||
matrixLookupTable[8].ID = GL_MATRIX2_NV;
|
||||
matrixLookupTable[9].name = "GL_MATRIX3_NV";
|
||||
matrixLookupTable[9].ID = GL_MATRIX3_NV;
|
||||
matrixLookupTable[10].name = "GL_MATRIX4_NV";
|
||||
matrixLookupTable[10].ID = GL_MATRIX4_NV;
|
||||
matrixLookupTable[11].name = "GL_MATRIX5_NV";
|
||||
matrixLookupTable[11].ID = GL_MATRIX5_NV;
|
||||
matrixLookupTable[12].name = "GL_MATRIX6_NV";
|
||||
matrixLookupTable[12].ID = GL_MATRIX6_NV;
|
||||
matrixLookupTable[13].name = "GL_MATRIX7_NV";
|
||||
matrixLookupTable[13].ID = GL_MATRIX7_NV;
|
||||
bFirstTime = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iNumEntries; i++)
|
||||
{
|
||||
if (!strcmp(matrixName, matrixLookupTable[i].name.c_str()))
|
||||
{
|
||||
|
||||
return matrixLookupTable[i].ID;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : LookupTrackMatrixTransform |
|
||||
//| Description: Returns the enumerated matrix transform name given a valid |
|
||||
//| string name or 0 if an unknown transform is requested. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
GLuint LookupTrackMatrixTransform(char *matrixTransformName)
|
||||
{
|
||||
static bool bFirstTime = true;
|
||||
static int iNumEntries = 4;
|
||||
static MatrixLookupEntry* transformLookupTable = new MatrixLookupEntry[iNumEntries];
|
||||
|
||||
if (bFirstTime)
|
||||
{
|
||||
transformLookupTable[0].name = "GL_IDENTITY_NV";
|
||||
transformLookupTable[0].ID = GL_IDENTITY_NV;
|
||||
transformLookupTable[1].name = "GL_INVERSE_NV";
|
||||
transformLookupTable[1].ID = GL_INVERSE_NV;
|
||||
transformLookupTable[2].name = "GL_TRANSPOSE_NV";
|
||||
transformLookupTable[2].ID = GL_TRANSPOSE_NV;
|
||||
transformLookupTable[3].name = "GL_INVERSE_TRANSPOSE_NV";
|
||||
transformLookupTable[3].ID = GL_INVERSE_TRANSPOSE_NV;
|
||||
bFirstTime = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < iNumEntries; i++)
|
||||
{
|
||||
if (!strcmp( matrixTransformName, transformLookupTable[i].name.c_str()))
|
||||
{
|
||||
return transformLookupTable[i].ID;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
163
RenderDll/XRenderOGL/NVParse/vp1.0_impl.cpp
Normal file
163
RenderDll/XRenderOGL/NVParse/vp1.0_impl.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
//using namespace std;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void LoadProgram( GLenum target, GLuint id, char *instring );
|
||||
void StrToUpper(char * string);
|
||||
int vpid;
|
||||
}
|
||||
|
||||
|
||||
bool is_vp10(const char * s)
|
||||
{
|
||||
return ! strncmp(s, "!!VP1.0", 7);
|
||||
}
|
||||
|
||||
bool vp10_init(char * s)
|
||||
{
|
||||
static bool vpinit = false;
|
||||
if (vpinit == false )
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_vertex_program)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_vertex_program");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vpinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
myin = s;
|
||||
|
||||
glGetIntegerv( GL_VERTEX_PROGRAM_BINDING_NV, &vpid );
|
||||
|
||||
if ( vpid == 0 )
|
||||
{
|
||||
char str[128];
|
||||
sprintf( str, "No vertex program id bound for nvparse() invocation. Bound id = %d\n", vpid );
|
||||
errors.set( str );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int vp10_parse()
|
||||
{
|
||||
LoadProgram( GL_VERTEX_PROGRAM_NV, vpid, myin );
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : LoadProgram |
|
||||
//| Description: Load a program into GL, and report any errors encountered. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void LoadProgram( GLenum target, GLuint id, char *instring )
|
||||
{
|
||||
GLint errPos;
|
||||
GLenum errCode;
|
||||
const GLubyte *errString;
|
||||
|
||||
int len = strlen(instring);
|
||||
glLoadProgramNV( target, id, len, (const GLubyte *) instring );
|
||||
if ( (errCode = glGetError()) != GL_NO_ERROR )
|
||||
{
|
||||
errString = gluErrorString( errCode );
|
||||
|
||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
|
||||
|
||||
int nlines = 1;
|
||||
int nchar = 1;
|
||||
int i;
|
||||
for ( i = 0; i < errPos; i++ )
|
||||
{
|
||||
if ( instring[i] == '\n' )
|
||||
{
|
||||
nlines++;
|
||||
nchar = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nchar++;
|
||||
}
|
||||
}
|
||||
int start;
|
||||
int end;
|
||||
int flag = ((instring[errPos]==';') | (instring[errPos-1]==';')) ? 1 : 0;
|
||||
for ( i = errPos; i >= 0; i-- )
|
||||
{
|
||||
start = i;
|
||||
if ( flag && (start >= errPos-1) )
|
||||
continue;
|
||||
if ( instring[i] == ';' )
|
||||
{
|
||||
if ( !flag )
|
||||
{
|
||||
start = i+1;
|
||||
if ( instring[start] == '\n' )
|
||||
start++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( i = errPos; i < len; i++ )
|
||||
{
|
||||
end = i;
|
||||
if ( instring[i] == ';' && end > start)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( errPos - start > 30 )
|
||||
{
|
||||
start = errPos - 30;
|
||||
}
|
||||
if ( end - errPos > 30 )
|
||||
{
|
||||
end = errPos + 30;
|
||||
}
|
||||
|
||||
char substring[96];
|
||||
memset( substring, 0, 96 );
|
||||
strncpy( substring, &(instring[start]), end-start+1 );
|
||||
char str[256];
|
||||
//sprintf( str, "error at line %d character %d\n \"%s\"\n", nlines, nchar, substring );
|
||||
sprintf( str, "error at line %d character %d\n\"%s\"\n", nlines, nchar, substring );
|
||||
int width = errPos-start;
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
strcat( str, " " );
|
||||
}
|
||||
strcat( str, "|\n" );
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
strcat( str, " " );
|
||||
}
|
||||
strcat( str, "^\n" );
|
||||
|
||||
errors.set( str );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : StrToUpper |
|
||||
//| Description: Converts all lowercase chars in a string to uppercase. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void StrToUpper(char *string)
|
||||
{
|
||||
for (unsigned int i = 0; i < strlen(string); i++)
|
||||
string[i] = toupper(string[i]);
|
||||
}
|
||||
|
||||
}
|
||||
1437
RenderDll/XRenderOGL/NVParse/vs1.0_inst.cpp
Normal file
1437
RenderDll/XRenderOGL/NVParse/vs1.0_inst.cpp
Normal file
File diff suppressed because it is too large
Load Diff
89
RenderDll/XRenderOGL/NVParse/vs1.0_inst.h
Normal file
89
RenderDll/XRenderOGL/NVParse/vs1.0_inst.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef _VS10INST_H
|
||||
#define _VS10INST_H
|
||||
|
||||
#define VS10_ADD 1
|
||||
#define VS10_DP3 2
|
||||
#define VS10_DP4 3
|
||||
#define VS10_DST 4
|
||||
#define VS10_EXP 5
|
||||
#define VS10_EXPP 6
|
||||
#define VS10_FRC 7
|
||||
#define VS10_LIT 8
|
||||
#define VS10_LOG 9
|
||||
#define VS10_LOGP 10
|
||||
#define VS10_M3X2 11
|
||||
#define VS10_M3X3 12
|
||||
#define VS10_M3X4 13
|
||||
#define VS10_M4X3 14
|
||||
#define VS10_M4X4 15
|
||||
#define VS10_MAD 16
|
||||
#define VS10_MAX 17
|
||||
#define VS10_MIN 18
|
||||
#define VS10_MOV 19
|
||||
#define VS10_MUL 20
|
||||
#define VS10_NOP 21
|
||||
#define VS10_RCP 22
|
||||
#define VS10_RSQ 23
|
||||
#define VS10_SGE 24
|
||||
#define VS10_SLT 25
|
||||
#define VS10_SUB 26
|
||||
#define VS10_COMMENT 27
|
||||
#define VS10_HEADER 28
|
||||
|
||||
#define TYPE_TEMPORARY_REG 1
|
||||
#define TYPE_VERTEX_ATTRIB_REG 2
|
||||
#define TYPE_ADDRESS_REG 3
|
||||
#define TYPE_CONSTANT_MEM_REG 4
|
||||
#define TYPE_CONSTANT_A0_REG 5
|
||||
#define TYPE_CONSTANT_A0_OFFSET_REG 6
|
||||
#define TYPE_POSITION_RESULT_REG 7
|
||||
#define TYPE_COLOR_RESULT_REG 8
|
||||
#define TYPE_TEXTURE_RESULT_REG 9
|
||||
#define TYPE_FOG_RESULT_REG 10
|
||||
#define TYPE_POINTS_RESULT_REG 11
|
||||
|
||||
class VS10Reg {
|
||||
public:
|
||||
// VS10Reg();
|
||||
// VS10Reg(const VS10Reg &r);
|
||||
// VS10Reg& operator=(const VS10Reg &r);
|
||||
void Init();
|
||||
void Translate();
|
||||
int type;
|
||||
int index;
|
||||
int sign;
|
||||
char mask[4];
|
||||
|
||||
int ValidateIndex();
|
||||
};
|
||||
|
||||
typedef class VS10Inst {
|
||||
public:
|
||||
~VS10Inst();
|
||||
VS10Inst();
|
||||
VS10Inst(int currline);
|
||||
VS10Inst(const VS10Inst &inst);
|
||||
VS10Inst& operator=(const VS10Inst &inst);
|
||||
VS10Inst(int currline, int inst);
|
||||
VS10Inst(int currline, int inst, char *cmt);
|
||||
VS10Inst(int currline, int inst, VS10Reg dreg, VS10Reg src0);
|
||||
VS10Inst(int currline, int inst, VS10Reg dreg, VS10Reg src0, VS10Reg src1);
|
||||
VS10Inst(int currline, int inst, VS10Reg dreg, VS10Reg src0, VS10Reg src1, VS10Reg src2);
|
||||
void Validate( int &vsflag );
|
||||
int Translate();
|
||||
VS10Reg dst;
|
||||
VS10Reg src[3];
|
||||
private:
|
||||
int line;
|
||||
int instid;
|
||||
char *comment;
|
||||
void ValidateRegIndices();
|
||||
void ValidateDestMask();
|
||||
void ValidateSrcMasks();
|
||||
void ValidateDestWritable();
|
||||
void ValidateSrcReadable();
|
||||
void ValidateReadPorts();
|
||||
|
||||
} *VS10InstPtr;
|
||||
|
||||
#endif
|
||||
297
RenderDll/XRenderOGL/NVParse/vs1.0_inst_list.cpp
Normal file
297
RenderDll/XRenderOGL/NVParse/vs1.0_inst_list.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
#include "vs1.0_inst_list.h"
|
||||
|
||||
extern string vs10_transstring;
|
||||
|
||||
#define MAX_NUM_INSTRUCTIONS 128
|
||||
#define INSTRUCTION_LIST_INC 128
|
||||
|
||||
VS10InstList::VS10InstList()
|
||||
{
|
||||
size = 0;
|
||||
max = INSTRUCTION_LIST_INC;
|
||||
list = new VS10Inst[max];
|
||||
}
|
||||
|
||||
VS10InstList::~VS10InstList()
|
||||
{
|
||||
delete [] list;
|
||||
}
|
||||
|
||||
int VS10InstList::Size()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
VS10InstList& VS10InstList::operator+=(VS10InstPtr t)
|
||||
{
|
||||
if (size == max) {
|
||||
// Extend list size by increment amount.
|
||||
VS10InstPtr newlist;
|
||||
max += INSTRUCTION_LIST_INC;
|
||||
newlist = new VS10Inst[max];
|
||||
for ( int i = 0; i < size; i++ )
|
||||
newlist[i] = list[i];
|
||||
delete [] list;
|
||||
list = newlist;
|
||||
}
|
||||
list[size++] = *t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void VS10InstList::Translate()
|
||||
{
|
||||
int ntranslated = 0;
|
||||
|
||||
vs10_transstring.append( "!!VP1.0\n" );
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
ntranslated += list[i].Translate();
|
||||
}
|
||||
vs10_transstring.append( "END\n" );
|
||||
|
||||
if ( ntranslated > 128 )
|
||||
{
|
||||
char str[256];
|
||||
sprintf( str, "Vertex Shader had more than 128 instructions. (Converted to: %d)\n", ntranslated );
|
||||
errors.set( str );
|
||||
}
|
||||
//fprintf( stderr, "Converted vertex shader to vertex program with %d instructions.\n\n", ntranslated );
|
||||
}
|
||||
|
||||
void VS10InstList::Validate()
|
||||
{
|
||||
int vsflag = 0;
|
||||
for ( int i = 0; i < size; i++ )
|
||||
{
|
||||
list[i].Validate( vsflag );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void LoadProgram( GLenum target, GLuint id, char *instring );
|
||||
void StrToUpper(char * string);
|
||||
int vpid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool is_vs10(const char *s)
|
||||
{
|
||||
int len;
|
||||
char *temp;
|
||||
bool vshader_flag;
|
||||
|
||||
temp = NULL;
|
||||
len = strlen(s);
|
||||
if ( len > 0 )
|
||||
temp = new char [len+1];
|
||||
for ( int k = 0; k < len; k++ )
|
||||
{
|
||||
temp[k] = (char) tolower( (char) s[k] );
|
||||
}
|
||||
if ( len == 0 )
|
||||
vshader_flag = false;
|
||||
else
|
||||
{
|
||||
vshader_flag = ( NULL != strstr(temp, "vs.1.0") );
|
||||
delete [] temp;
|
||||
}
|
||||
return vshader_flag;
|
||||
}
|
||||
|
||||
bool vs10_init_more()
|
||||
{
|
||||
static bool vpinit = false;
|
||||
if (vpinit == false )
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_vertex_program)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_vertex_program");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vpinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
glGetIntegerv( GL_VERTEX_PROGRAM_BINDING_NV, &vpid );
|
||||
|
||||
if ( vpid == 0 )
|
||||
{
|
||||
char str[128];
|
||||
sprintf( str, "No vertex program id bound for nvparse() invocation. Bound id = %d\n", vpid );
|
||||
errors.set( str );
|
||||
return false;
|
||||
}
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
vs10_transstring = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
void vs10_load_program()
|
||||
{
|
||||
// Only load the program if no errors occurred.
|
||||
if ( errors.get_num_errors() == 0 )
|
||||
LoadProgram( GL_VERTEX_PROGRAM_NV, vpid, (char *) vs10_transstring.c_str() );
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : LoadProgram |
|
||||
//| Description: Load a program into GL, and report any errors encountered. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void LoadProgram( GLenum target, GLuint id, char *instring )
|
||||
{
|
||||
GLint errPos;
|
||||
GLenum errCode;
|
||||
const GLubyte *errString;
|
||||
|
||||
int len = strlen(instring);
|
||||
glLoadProgramNV( target, id, len, (const GLubyte *) instring );
|
||||
if ( (errCode = glGetError()) != GL_NO_ERROR )
|
||||
{
|
||||
errString = gluErrorString( errCode );
|
||||
|
||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
|
||||
|
||||
int nlines = 1;
|
||||
int nchar = 1;
|
||||
int i;
|
||||
for ( i = 0; i < errPos; i++ )
|
||||
{
|
||||
if ( instring[i] == '\n' )
|
||||
{
|
||||
nlines++;
|
||||
nchar = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nchar++;
|
||||
}
|
||||
}
|
||||
int start;
|
||||
int end;
|
||||
int flag = ((instring[errPos]==';') | (instring[errPos-1]==';')) ? 1 : 0;
|
||||
for ( i = errPos; i >= 0; i-- )
|
||||
{
|
||||
start = i;
|
||||
if ( flag && (start >= errPos-1) )
|
||||
continue;
|
||||
if ( instring[i] == ';' )
|
||||
{
|
||||
if ( !flag )
|
||||
{
|
||||
start = i+1;
|
||||
if ( instring[start] == '\n' )
|
||||
start++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( i = errPos; i < len; i++ )
|
||||
{
|
||||
end = i;
|
||||
if ( instring[i] == ';' && end > start)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( errPos - start > 30 )
|
||||
{
|
||||
start = errPos - 30;
|
||||
}
|
||||
if ( end - errPos > 30 )
|
||||
{
|
||||
end = errPos + 30;
|
||||
}
|
||||
|
||||
char substring[96];
|
||||
memset( substring, 0, 96 );
|
||||
strncpy( substring, &(instring[start]), end-start+1 );
|
||||
char str[256];
|
||||
//sprintf( str, "error at line %d character %d\n \"%s\"\n", nlines, nchar, substring );
|
||||
sprintf( str, "error at line %d character %d\n\"%s\"\n", nlines, nchar, substring );
|
||||
int width = errPos-start;
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
strcat( str, " " );
|
||||
}
|
||||
strcat( str, "|\n" );
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
strcat( str, " " );
|
||||
}
|
||||
strcat( str, "^\n" );
|
||||
|
||||
errors.set( str );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : StrToUpper |
|
||||
//| Description: Converts all lowercase chars in a string to uppercase. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void StrToUpper(char *string)
|
||||
{
|
||||
for (unsigned int i = 0; i < strlen(string); i++)
|
||||
string[i] = toupper(string[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
else if ( is_vs10(instring) )
|
||||
{
|
||||
if (vpinit == 0 )
|
||||
{
|
||||
if(! glh_init_extensions("GL_NV_vertex_program"))
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_vertex_program");
|
||||
free(instring);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
vpinit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( glGetError() != GL_NO_ERROR )
|
||||
{
|
||||
errors.set( "Previous GL_ERROR prior to vertex shader parsing.\n" );
|
||||
}
|
||||
|
||||
int vpid;
|
||||
glGetIntegerv( GL_VERTEX_PROGRAM_BINDING_NV, &vpid );
|
||||
|
||||
if ( vpid == 0 )
|
||||
{
|
||||
char str[128];
|
||||
sprintf( str, "No vertex program id bound for nvparse() invocation. Bound id = %d\n", vpid );
|
||||
errors.set( str );
|
||||
}
|
||||
else
|
||||
{
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
vs10_init(instring);
|
||||
vs10_transstring = "";
|
||||
vs10_parse();
|
||||
//fprintf( stderr, "Converted text:\n%s\n\n\n", vs10_transstring.c_str() );
|
||||
LoadProgram( GL_VERTEX_PROGRAM_NV, vpid, (char *) vs10_transstring.c_str() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
25
RenderDll/XRenderOGL/NVParse/vs1.0_inst_list.h
Normal file
25
RenderDll/XRenderOGL/NVParse/vs1.0_inst_list.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _VS10_H
|
||||
#define _VS10_H
|
||||
|
||||
#define WRITEMASK_X 0x01
|
||||
#define WRITEMASK_Y 0x02
|
||||
#define WRITEMASK_Z 0x04
|
||||
#define WRITEMASK_W 0x08
|
||||
|
||||
#include "vs1.0_inst.h"
|
||||
|
||||
typedef class VS10InstList {
|
||||
public:
|
||||
VS10InstList();
|
||||
~VS10InstList();
|
||||
int Size();
|
||||
VS10InstList& operator+=(VS10InstPtr t);
|
||||
void Validate();
|
||||
void Translate();
|
||||
private:
|
||||
VS10InstPtr list;
|
||||
int size;
|
||||
int max;
|
||||
} *VS10InstListPtr;
|
||||
|
||||
#endif
|
||||
152
RenderDll/XRenderOGL/NVParse/vsp1.0_impl.cpp
Normal file
152
RenderDll/XRenderOGL/NVParse/vsp1.0_impl.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "nvparse.h"
|
||||
|
||||
//using namespace std;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
void LoadProgram( GLenum target, GLuint id, char *instring );
|
||||
void StrToUpper(char * string);
|
||||
}
|
||||
|
||||
|
||||
bool is_vsp10(const char * s)
|
||||
{
|
||||
return ! strncmp(s, "!!VSP1.0", 8);
|
||||
}
|
||||
|
||||
bool vsp10_init(char * s)
|
||||
{
|
||||
static bool vpinit = false;
|
||||
if (vpinit == false )
|
||||
{
|
||||
if(!SUPPORTS_GL_NV_vertex_program)
|
||||
{
|
||||
errors.set("unable to initialize GL_NV_vertex_program");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vpinit = true;
|
||||
}
|
||||
}
|
||||
|
||||
errors.reset();
|
||||
line_number = 1;
|
||||
myin = s;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int vsp10_parse(int vpsid)
|
||||
{
|
||||
LoadProgram( GL_VERTEX_STATE_PROGRAM_NV, vpsid, myin );
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : LoadProgram |
|
||||
//| Description: Load a program into GL, and report any errors encountered. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void LoadProgram( GLenum target, GLuint id, char *instring )
|
||||
{
|
||||
GLint errPos;
|
||||
GLenum errCode;
|
||||
const GLubyte *errString;
|
||||
|
||||
int len = strlen(instring);
|
||||
glLoadProgramNV( target, id, len, (const GLubyte *) instring );
|
||||
if ( (errCode = glGetError()) != GL_NO_ERROR )
|
||||
{
|
||||
errString = gluErrorString( errCode );
|
||||
|
||||
glGetIntegerv( GL_PROGRAM_ERROR_POSITION_NV, &errPos );
|
||||
|
||||
int nlines = 1;
|
||||
int nchar = 1;
|
||||
int i;
|
||||
for ( i = 0; i < errPos; i++ )
|
||||
{
|
||||
if ( instring[i] == '\n' )
|
||||
{
|
||||
nlines++;
|
||||
nchar = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nchar++;
|
||||
}
|
||||
}
|
||||
int start;
|
||||
int end;
|
||||
int flag = ((instring[errPos]==';') | (instring[errPos-1]==';')) ? 1 : 0;
|
||||
for ( i = errPos; i >= 0; i-- )
|
||||
{
|
||||
start = i;
|
||||
if ( flag && (start >= errPos-1) )
|
||||
continue;
|
||||
if ( instring[i] == ';' )
|
||||
{
|
||||
if ( !flag )
|
||||
{
|
||||
start = i+1;
|
||||
if ( instring[start] == '\n' )
|
||||
start++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( i = errPos; i < len; i++ )
|
||||
{
|
||||
end = i;
|
||||
if ( instring[i] == ';' && end > start)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( errPos - start > 30 )
|
||||
{
|
||||
start = errPos - 30;
|
||||
}
|
||||
if ( end - errPos > 30 )
|
||||
{
|
||||
end = errPos + 30;
|
||||
}
|
||||
|
||||
char substring[96];
|
||||
memset( substring, 0, 96 );
|
||||
strncpy( substring, &(instring[start]), end-start+1 );
|
||||
char str[256];
|
||||
//sprintf( str, "error at line %d character %d\n \"%s\"\n", nlines, nchar, substring );
|
||||
sprintf( str, "error at line %d character %d\n\"%s\"\n", nlines, nchar, substring );
|
||||
int width = errPos-start;
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
strcat( str, " " );
|
||||
}
|
||||
strcat( str, "|\n" );
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
strcat( str, " " );
|
||||
}
|
||||
strcat( str, "^\n" );
|
||||
|
||||
errors.set( str );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//.----------------------------------------------------------------------------.
|
||||
//| Function : StrToUpper |
|
||||
//| Description: Converts all lowercase chars in a string to uppercase. |
|
||||
//.----------------------------------------------------------------------------.
|
||||
void StrToUpper(char *string)
|
||||
{
|
||||
for (unsigned int i = 0; i < strlen(string); i++)
|
||||
string[i] = toupper(string[i]);
|
||||
}
|
||||
|
||||
}
|
||||
1231
RenderDll/XRenderOGL/XRenderOGL.vcproj
Normal file
1231
RenderDll/XRenderOGL/XRenderOGL.vcproj
Normal file
File diff suppressed because it is too large
Load Diff
10
RenderDll/XRenderOGL/XRenderOGL.vcproj.vspscc
Normal file
10
RenderDll/XRenderOGL/XRenderOGL.vcproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = "file:F:\\Crytek\\RenderDll\\XRenderOGL\\XRenderOGL.vcproj"
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
|
||||
}
|
||||
464
RenderDll/XRenderOGL/state_to_nvparse_text.cpp
Normal file
464
RenderDll/XRenderOGL/state_to_nvparse_text.cpp
Normal file
@@ -0,0 +1,464 @@
|
||||
#include "RenderPCH.h"
|
||||
#include "GL_Renderer.h"
|
||||
#include "state_to_nvparse_text.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
//using namespace std;
|
||||
|
||||
// register combiners
|
||||
namespace
|
||||
{
|
||||
struct portion_state
|
||||
{
|
||||
GLint portion;
|
||||
GLint input[4];
|
||||
GLint mapping[4];
|
||||
GLint compusg[4];
|
||||
GLint output[3];
|
||||
GLint opselect[3];
|
||||
GLint bias;
|
||||
GLint scale;
|
||||
};
|
||||
|
||||
|
||||
bool nvrc1_supported;
|
||||
bool nvrc2_enabled;
|
||||
GLfloat c0[4], c1[4];
|
||||
|
||||
bool same_color( const GLfloat * rgba1, const GLfloat * rgba2)
|
||||
{
|
||||
if( rgba1[0] == rgba2[0] &&
|
||||
rgba1[1] == rgba2[1] &&
|
||||
rgba1[2] == rgba2[2] &&
|
||||
rgba1[3] == rgba2[3])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
portion_state get_portion(GLenum combiner, GLenum portion)
|
||||
{
|
||||
GLenum v[4] = { GL_VARIABLE_A_NV, GL_VARIABLE_B_NV, GL_VARIABLE_C_NV, GL_VARIABLE_D_NV };
|
||||
portion_state p;
|
||||
p.portion = portion;
|
||||
|
||||
for(int i=0; i < 4; i++)
|
||||
{
|
||||
glGetCombinerInputParameterivNV(combiner, portion, v[i], GL_COMBINER_INPUT_NV, & p.input[i]);
|
||||
glGetCombinerInputParameterivNV(combiner, portion, v[i], GL_COMBINER_MAPPING_NV, & p.mapping[i]);
|
||||
glGetCombinerInputParameterivNV(combiner, portion, v[i], GL_COMBINER_COMPONENT_USAGE_NV, & p.compusg[i]);
|
||||
}
|
||||
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_AB_OUTPUT_NV, & p.output[0]);
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_CD_OUTPUT_NV, & p.output[1]);
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_SUM_OUTPUT_NV, & p.output[2]);
|
||||
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_AB_DOT_PRODUCT_NV, & p.opselect[0]);
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_CD_DOT_PRODUCT_NV, & p.opselect[1]);
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_MUX_SUM_NV, & p.opselect[2]);
|
||||
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_BIAS_NV, & p.bias);
|
||||
glGetCombinerOutputParameterivNV(combiner, portion, GL_COMBINER_SCALE_NV, & p.scale);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
string register_name(GLenum reg)
|
||||
{
|
||||
switch (reg)
|
||||
{
|
||||
case GL_CONSTANT_COLOR0_NV:
|
||||
return "const0";
|
||||
case GL_CONSTANT_COLOR1_NV:
|
||||
return "const1";
|
||||
case GL_FOG_COLOR:
|
||||
return "fog";
|
||||
case GL_PRIMARY_COLOR_NV:
|
||||
return "col0";
|
||||
case GL_SECONDARY_COLOR_NV:
|
||||
return "col1";
|
||||
case GL_TEXTURE0_ARB:
|
||||
return "tex0";
|
||||
case GL_TEXTURE1_ARB:
|
||||
return "tex1";
|
||||
case GL_TEXTURE2_ARB:
|
||||
return "tex2";
|
||||
case GL_TEXTURE3_ARB:
|
||||
return "tex3";
|
||||
case GL_SPARE0_NV:
|
||||
return "spare0";
|
||||
case GL_SPARE1_NV:
|
||||
return "spare1";
|
||||
case GL_ZERO:
|
||||
return "zero";
|
||||
case GL_DISCARD_NV:
|
||||
return "discard";
|
||||
case GL_E_TIMES_F_NV:
|
||||
return "final_product";
|
||||
case GL_SPARE0_PLUS_SECONDARY_COLOR_NV:
|
||||
return "color_sum";
|
||||
default:
|
||||
return "unknown_register";
|
||||
}
|
||||
}
|
||||
|
||||
void get_mapping(GLenum mapping, string & mapping_prefix, string & mapping_suffix)
|
||||
{
|
||||
switch (mapping)
|
||||
{
|
||||
case GL_SIGNED_IDENTITY_NV:
|
||||
mapping_prefix = "";
|
||||
mapping_suffix = "";
|
||||
break;
|
||||
case GL_SIGNED_NEGATE_NV:
|
||||
mapping_prefix = "-";
|
||||
mapping_suffix = "";
|
||||
break;
|
||||
case GL_EXPAND_NORMAL_NV:
|
||||
mapping_prefix = "expand(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
case GL_EXPAND_NEGATE_NV:
|
||||
mapping_prefix = "-expand(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
case GL_HALF_BIAS_NORMAL_NV:
|
||||
mapping_prefix = "half_bias(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
case GL_HALF_BIAS_NEGATE_NV:
|
||||
mapping_prefix = "-half_bias(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
case GL_UNSIGNED_IDENTITY_NV:
|
||||
mapping_prefix = "unsigned(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
case GL_UNSIGNED_INVERT_NV:
|
||||
mapping_prefix = "unsigned_invert(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
default:
|
||||
mapping_prefix = "unknown_mapping(";
|
||||
mapping_suffix = ")";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string operand_string(GLenum reg, GLenum mapping, GLenum compusg, GLenum portion)
|
||||
{
|
||||
string rname = register_name(reg);
|
||||
string cu;
|
||||
if(compusg != portion)
|
||||
{
|
||||
if(compusg == GL_RGB)
|
||||
cu = ".rgb";
|
||||
if(compusg == GL_ALPHA)
|
||||
cu = ".a";
|
||||
if(compusg == GL_BLUE)
|
||||
cu = ".b";
|
||||
}
|
||||
string mapping_prefix, mapping_suffix;
|
||||
get_mapping(mapping, mapping_prefix, mapping_suffix);
|
||||
string op = mapping_prefix + rname + cu + mapping_suffix;
|
||||
return op;
|
||||
}
|
||||
|
||||
string general_combiner_portion(GLenum combiner, GLenum portion)
|
||||
{
|
||||
portion_state p = get_portion(combiner, portion);
|
||||
string s;
|
||||
|
||||
// if unused portion return empty string
|
||||
if( p.output[0] == GL_DISCARD_NV &&
|
||||
p.output[1] == GL_DISCARD_NV &&
|
||||
p.output[2] == GL_DISCARD_NV)
|
||||
return s;
|
||||
|
||||
if(portion == GL_RGB) s += " rgb {\n";
|
||||
else s += " alpha {\n";
|
||||
|
||||
// do the AB and CD expressions
|
||||
for(int i=0; i < 2; i++)
|
||||
{
|
||||
if(p.output[i] != GL_DISCARD_NV || p.output[2] != GL_DISCARD_NV)
|
||||
{
|
||||
s += " ";
|
||||
s += register_name(p.output[i]);
|
||||
s += " = ";
|
||||
// handle the arg * 1 simplification:
|
||||
if( (p.input[2*i ] == GL_ZERO && p.mapping[2*i ] == GL_UNSIGNED_INVERT_NV) &&
|
||||
(p.input[2*i+1] != GL_ZERO) )
|
||||
{
|
||||
s += operand_string(p.input[2*i+1], p.mapping[2*i+1], p.compusg[2*i+1], portion);
|
||||
}
|
||||
else if( (p.input[2*i+1] == GL_ZERO && p.mapping[2*i+1] == GL_UNSIGNED_INVERT_NV) &&
|
||||
(p.input[2*i ] != GL_ZERO) )
|
||||
{
|
||||
s += operand_string(p.input[2*i], p.mapping[2*i], p.compusg[2*i], portion);
|
||||
}
|
||||
else
|
||||
{
|
||||
s += operand_string(p.input[2*i], p.mapping[2*i], p.compusg[2*i], portion);
|
||||
if(p.opselect[i] == GL_TRUE)
|
||||
s += " . ";
|
||||
else
|
||||
s += " * ";
|
||||
s += operand_string(p.input[2*i+1], p.mapping[2*i+1], p.compusg[2*i+1], portion);
|
||||
}
|
||||
s += ";\n";
|
||||
}
|
||||
}
|
||||
if(p.output[2] != GL_DISCARD_NV)
|
||||
{
|
||||
s += " ";
|
||||
s += register_name(p.output[2]);
|
||||
s += " = ";
|
||||
if(p.opselect[2] == GL_TRUE)
|
||||
s += "mux();\n";
|
||||
else
|
||||
s += "sum();\n";
|
||||
}
|
||||
|
||||
if(p.bias == GL_NONE && p.scale == GL_SCALE_BY_ONE_HALF_NV)
|
||||
s += " scale_by_one_half();\n";
|
||||
else if(p.bias == GL_NONE && p.scale == GL_SCALE_BY_TWO_NV)
|
||||
s += " scale_by_one_two();\n";
|
||||
else if(p.bias == GL_NONE && p.scale == GL_SCALE_BY_FOUR_NV)
|
||||
s += " scale_by_one_four();\n";
|
||||
else if(p.bias == GL_BIAS_BY_NEGATIVE_ONE_HALF_NV && p.scale == GL_NONE)
|
||||
s += " bias_by_negative_one_half();\n";
|
||||
else if(p.bias == GL_BIAS_BY_NEGATIVE_ONE_HALF_NV && p.scale == GL_SCALE_BY_TWO_NV)
|
||||
s += " bias_by_negative_one_half_scale_by_two();\n";
|
||||
|
||||
|
||||
s += " }\n";
|
||||
return s;
|
||||
}
|
||||
|
||||
string general_combiner(GLenum combiner)
|
||||
{
|
||||
string s;
|
||||
s += general_combiner_portion(combiner, GL_RGB);
|
||||
s += general_combiner_portion(combiner, GL_ALPHA);
|
||||
// if unused combiner return empty string
|
||||
if(s.size() == 0)
|
||||
return "";
|
||||
string cc;
|
||||
if(nvrc2_enabled)
|
||||
{
|
||||
GLfloat sc0[4], sc1[4];
|
||||
glGetCombinerStageParameterfvNV(combiner, GL_CONSTANT_COLOR0_NV, sc0);
|
||||
glGetCombinerStageParameterfvNV(combiner, GL_CONSTANT_COLOR1_NV, sc1);
|
||||
if(! same_color(c0, sc0))
|
||||
{
|
||||
char buf[80];
|
||||
sprintf(buf, " const0 = (%f, %f, %f, %f);\n", sc0[0], sc0[1], sc0[2], sc0[3]);
|
||||
cc += buf;
|
||||
}
|
||||
if(! same_color(c1, sc1))
|
||||
{
|
||||
char buf[80];
|
||||
sprintf(buf, " const1 = (%f, %f, %f, %f);\n", sc1[0], sc1[1], sc1[2], sc1[3]);
|
||||
cc += buf;
|
||||
}
|
||||
}
|
||||
|
||||
return "{\n" + cc + s + "}\n";
|
||||
}
|
||||
|
||||
struct final_combiner_state
|
||||
{
|
||||
GLint input[7];
|
||||
GLint mapping[7];
|
||||
GLint compusg[7];
|
||||
bool clamp_color_sum;
|
||||
};
|
||||
|
||||
final_combiner_state get_final_combiner_state()
|
||||
{
|
||||
GLenum v[7] = { GL_VARIABLE_A_NV, GL_VARIABLE_B_NV, GL_VARIABLE_C_NV,
|
||||
GL_VARIABLE_D_NV, GL_VARIABLE_E_NV, GL_VARIABLE_F_NV,
|
||||
GL_VARIABLE_G_NV };
|
||||
final_combiner_state fc;
|
||||
|
||||
for(int i=0; i < 7; i++)
|
||||
{
|
||||
glGetFinalCombinerInputParameterivNV(v[i], GL_COMBINER_INPUT_NV, & fc.input[i]);
|
||||
glGetFinalCombinerInputParameterivNV(v[i], GL_COMBINER_MAPPING_NV, & fc.mapping[i]);
|
||||
glGetFinalCombinerInputParameterivNV(v[i], GL_COMBINER_COMPONENT_USAGE_NV, & fc.compusg[i]);
|
||||
}
|
||||
GLboolean clamp_color_sum = GL_FALSE;
|
||||
glGetBooleanv(GL_COLOR_SUM_CLAMP_NV, & clamp_color_sum);
|
||||
fc.clamp_color_sum = (clamp_color_sum == GL_TRUE);
|
||||
return fc;
|
||||
}
|
||||
|
||||
bool is_zero(const final_combiner_state & fc, int i)
|
||||
{
|
||||
if(fc.input[i] == GL_ZERO && fc.mapping[i] == GL_UNSIGNED_IDENTITY_NV)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
string final_operand_string(GLenum reg, GLenum mapping, GLenum compusg, GLenum portion)
|
||||
{
|
||||
string rname = register_name(reg);
|
||||
string cu;
|
||||
if(compusg != portion)
|
||||
{
|
||||
if(compusg == GL_RGB)
|
||||
cu = ".rgb";
|
||||
if(compusg == GL_ALPHA)
|
||||
cu = ".a";
|
||||
if(compusg == GL_BLUE)
|
||||
cu = ".b";
|
||||
}
|
||||
string mapping_prefix, mapping_suffix;
|
||||
if(mapping == GL_UNSIGNED_INVERT_NV)
|
||||
{
|
||||
mapping_prefix = "unsigned_invert(";
|
||||
mapping_suffix = ")";
|
||||
}
|
||||
string op = mapping_prefix + rname + cu + mapping_suffix;
|
||||
return op;
|
||||
}
|
||||
|
||||
string final_combiner()
|
||||
{
|
||||
final_combiner_state fc = get_final_combiner_state();
|
||||
string final_product;
|
||||
|
||||
if( fc.input[0] == GL_E_TIMES_F_NV ||
|
||||
fc.input[1] == GL_E_TIMES_F_NV ||
|
||||
fc.input[2] == GL_E_TIMES_F_NV ||
|
||||
fc.input[3] == GL_E_TIMES_F_NV )
|
||||
{
|
||||
final_product += "final_product = ";
|
||||
final_product += final_operand_string(fc.input[4], fc.mapping[4], fc.compusg[4], GL_RGB);
|
||||
final_product += " * ";
|
||||
final_product += final_operand_string(fc.input[5], fc.mapping[5], fc.compusg[5], GL_RGB);
|
||||
final_product += ";\n";
|
||||
}
|
||||
string clamp_color_sum;
|
||||
if(fc.clamp_color_sum &&
|
||||
(fc.input[1] == GL_SPARE0_PLUS_SECONDARY_COLOR_NV ||
|
||||
fc.input[2] == GL_SPARE0_PLUS_SECONDARY_COLOR_NV ||
|
||||
fc.input[3] == GL_SPARE0_PLUS_SECONDARY_COLOR_NV )
|
||||
)
|
||||
clamp_color_sum = "clamp_color_sum();\n";
|
||||
|
||||
string out_rgb;
|
||||
if(is_zero(fc, 0) && ! is_zero(fc, 3)) // output == d;
|
||||
{
|
||||
out_rgb = "out.rgb = ";
|
||||
out_rgb += final_operand_string(fc.input[3], fc.mapping[3], fc.compusg[3], GL_RGB);
|
||||
out_rgb += ";\n";
|
||||
}
|
||||
else if(! is_zero(fc, 0) && ! is_zero(fc, 1) && ! is_zero(fc, 2)) // lerp
|
||||
{
|
||||
out_rgb = "out.rgb = lerp(";
|
||||
out_rgb += final_operand_string(fc.input[0], fc.mapping[0], fc.compusg[0], GL_RGB);
|
||||
out_rgb += ", ";
|
||||
out_rgb += final_operand_string(fc.input[1], fc.mapping[1], fc.compusg[1], GL_RGB);
|
||||
out_rgb += ", ";
|
||||
out_rgb += final_operand_string(fc.input[2], fc.mapping[2], fc.compusg[2], GL_RGB);
|
||||
out_rgb += ")";
|
||||
if(! is_zero(fc,3))
|
||||
{
|
||||
out_rgb += " + ";
|
||||
out_rgb += final_operand_string(fc.input[3], fc.mapping[3], fc.compusg[3], GL_RGB);
|
||||
}
|
||||
out_rgb += ";\n";
|
||||
}
|
||||
else if(! is_zero(fc, 0) && ! is_zero(fc, 1)) // mul or mad
|
||||
{
|
||||
out_rgb = "out.rgb = ";
|
||||
out_rgb += final_operand_string(fc.input[0], fc.mapping[0], fc.compusg[0], GL_RGB);
|
||||
out_rgb += " * ";
|
||||
out_rgb += final_operand_string(fc.input[1], fc.mapping[1], fc.compusg[1], GL_RGB);
|
||||
if(! is_zero(fc,3))
|
||||
{
|
||||
out_rgb += " + ";
|
||||
out_rgb += final_operand_string(fc.input[3], fc.mapping[3], fc.compusg[3], GL_RGB);
|
||||
}
|
||||
out_rgb += ";\n";
|
||||
}
|
||||
else if(! is_zero(fc, 0) && is_zero(fc, 1) && ! is_zero(fc,2)) // odd case of mul or mad
|
||||
{
|
||||
// invert the mapping for A since the combiner setup is (1-A)C
|
||||
// but we can only express AB with nvparse
|
||||
if(fc.mapping[0] == GL_UNSIGNED_IDENTITY_NV)
|
||||
fc.mapping[0] = GL_UNSIGNED_INVERT_NV;
|
||||
else
|
||||
fc.mapping[0] = GL_UNSIGNED_IDENTITY_NV;
|
||||
|
||||
out_rgb = "out.rgb = ";
|
||||
out_rgb += final_operand_string(fc.input[0], fc.mapping[0], fc.compusg[0], GL_RGB);
|
||||
out_rgb += " * ";
|
||||
out_rgb += final_operand_string(fc.input[2], fc.mapping[2], fc.compusg[2], GL_RGB);
|
||||
if(! is_zero(fc,3))
|
||||
{
|
||||
out_rgb += " + ";
|
||||
out_rgb += final_operand_string(fc.input[3], fc.mapping[3], fc.compusg[3], GL_RGB);
|
||||
}
|
||||
out_rgb += ";\n";
|
||||
}
|
||||
|
||||
string out_a;
|
||||
if( ! is_zero(fc, 6) )
|
||||
{
|
||||
out_a = "out.a = ";
|
||||
out_a += final_operand_string(fc.input[6], fc.mapping[6], fc.compusg[6], GL_ALPHA);
|
||||
out_a += ";\n";
|
||||
}
|
||||
|
||||
return final_product + clamp_color_sum + out_rgb + out_a;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern "C" char * state_to_rc10 ()
|
||||
{
|
||||
nvrc1_supported = false; // required
|
||||
nvrc2_enabled = false; // optional
|
||||
|
||||
if(SUPPORTS_GL_NV_register_combiners)
|
||||
nvrc1_supported = true;
|
||||
if(SUPPORTS_GL_NV_register_combiners2)
|
||||
{
|
||||
if(glIsEnabled(GL_PER_STAGE_CONSTANTS_NV))
|
||||
nvrc2_enabled = true;
|
||||
}
|
||||
|
||||
if(nvrc1_supported == false)
|
||||
return 0;
|
||||
|
||||
GLenum combiner[8] = {GL_COMBINER0_NV, GL_COMBINER1_NV, GL_COMBINER2_NV, GL_COMBINER3_NV,
|
||||
GL_COMBINER4_NV, GL_COMBINER5_NV, GL_COMBINER6_NV, GL_COMBINER7_NV };
|
||||
string state;
|
||||
|
||||
state += "!!RC1.0\n";
|
||||
|
||||
glGetFloatv(GL_CONSTANT_COLOR0_NV, c0);
|
||||
glGetFloatv(GL_CONSTANT_COLOR1_NV, c1);
|
||||
|
||||
char buf[80];
|
||||
sprintf(buf, "const0 = (%f, %f, %f, %f);\n", c0[0], c0[1], c0[2], c0[3]);
|
||||
state += buf;
|
||||
sprintf(buf, "const1 = (%f, %f, %f, %f);\n", c1[0], c1[1], c1[2], c1[3]);
|
||||
state += buf;
|
||||
|
||||
GLint num_combiners;
|
||||
glGetIntegerv(GL_NUM_GENERAL_COMBINERS_NV, &num_combiners);
|
||||
for(int i = 0; i < num_combiners; i++)
|
||||
state += general_combiner(combiner[i]);
|
||||
|
||||
state += final_combiner();
|
||||
|
||||
return strdup(state.c_str());
|
||||
}
|
||||
|
||||
|
||||
16
RenderDll/XRenderOGL/state_to_nvparse_text.h
Normal file
16
RenderDll/XRenderOGL/state_to_nvparse_text.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef STATE_TO_NVPARSE_TEXT_H
|
||||
#define STATE_TO_NVPARSE_TEXT_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char * state_to_rc10 ();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user