From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02433.html | 21892 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 21892 insertions(+) create mode 100644 docs/doxygen/nel/a02433.html (limited to 'docs/doxygen/nel/a02433.html') diff --git a/docs/doxygen/nel/a02433.html b/docs/doxygen/nel/a02433.html new file mode 100644 index 00000000..00cf3b21 --- /dev/null +++ b/docs/doxygen/nel/a02433.html @@ -0,0 +1,21892 @@ + + +NeL: NL3D::CDriverGL class Reference + + + +
+

NL3D::CDriverGL Class Reference

#include <driver_opengl.h> +

+

Inheritance diagram for NL3D::CDriverGL: +

+ +NL3D::IDriver +NLMISC::CRefCount + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

EXTVertexShader specifics.

enum  EEVSVariants {
+  EVSSecondaryColorVariant = 0, +EVSFogCoordsVariant = 1, +EVSSkinWeightVariant = 2, +EVSPaletteSkinVariant = 3, +
+  EVSNumVariants +
+ }
bool setupEXTVertexShader (const CVPParser::TProgram &program, GLuint id, uint variants[EVSNumVariants], uint16 &usedInputRegisters)
GLuint _EVSColorHandle
GLuint _EVSConstantHandle
GLuint _EVSNormalHandle
GLuint _EVSPositionHandle
GLuint _EVSTexHandle [8]
const uint _EVSNumConstant = 97

Vertex program interface

enum  TMatrix { ModelView = 0, +Projection, +ModelViewProjection, +NumMatrix + }
enum  TTransform {
+  Identity = 0, +Inverse, +Transpose, +InverseTranspose, +
+  NumTransform +
+ }
virtual void setConstantMatrix (uint index, TMatrix matrix, TTransform transform)=0

Prec settings, for optimisation.

enum  CTexEnvSpecial {
+  TexEnvSpecialDisabled = 0, +TexEnvSpecialLightMap, +TexEnvSpecialSpecularStage1, +TexEnvSpecialSpecularStage1NoText, +
+  TexEnvSpecialPPLStage0, +TexEnvSpecialPPLStage2, +TexEnvSpecialCloudStage0, +TexEnvSpecialCloudStage1 +
+ }
void resetTextureShaders ()
void setTextureShaders (const uint8 *addressingModes, const NLMISC::CSmartPtr< ITexture > *textures)
CMaterial_CurrentMaterial
CMaterial::TShader _CurrentMaterialSupportedShader
GLenum _CurrentTexAddrMode [IDRV_MAT_MAXTEXTURES]
CMaterial::CTexEnv _CurrentTexEnv [IDRV_MAT_MAXTEXTURES]
CTexEnvSpecial _CurrentTexEnvSpecial [IDRV_MAT_MAXTEXTURES]
ITexture_CurrentTexture [IDRV_MAT_MAXTEXTURES]
CTextureDrvInfosGL_CurrentTextureInfoGL [IDRV_MAT_MAXTEXTURES]
CDriverGLStates _DriverGLStates
uint32 _MaterialAllTextureTouchedFlag
bool _NVTextureShaderEnabled
bool _StageSupportEMBM [IDRV_MAT_MAXTEXTURES]

Per pixel lighting

typedef NLMISC::CSmartPtr<
+ CTextureCube
TSPTextureCube
typedef std::vector< TSPTextureCubeTTexCubeVect
sint beginPPLMultiPass ()
sint beginPPLNoSpecMultiPass ()
void endPPLMultiPass ()
void endPPLNoSpecMultiPass ()
CTextureCubegetDiffuseCubeMap ()
CTextureCubegetSpecularCubeMap (uint exp)
 get (and if necessary, build) a cube map used for specular lighting. The range for exponent is limited, and only the best fit is used

void setupPPLNoSpecPass (uint pass)
void setupPPLPass (uint pass)
TTexCubeVect _SpecularTextureCubes

Profiling

void appendVBHardLockProfile (NLMISC::TTicks time, IVertexBufferHard *vb)
uint computeMipMapMemoryUsage (uint w, uint h, GLint glfmt) const
uint32 _AllocatedTextureMemory
uint _CurVBHardLockCount
uint32 _NbSetupMaterialCall
uint32 _NbSetupModelMatrixCall
uint _NumVBHardProfileFrame
CPrimitiveProfile _PrimitiveProfileIn
CPrimitiveProfile _PrimitiveProfileOut
bool _SumTextureMemoryUsed
std::set< CTextureDrvInfosGL * > _TextureUsed
std::vector< CVBHardProfile_VBHardProfiles
bool _VBHardProfiling

Lightmap.

sint beginLightMapMultiPass ()
void computeLightMapInfos (const CMaterial &mat)
void endLightMapMultiPass ()
void resetLightMapVertexSetup ()
void setupLightMapPass (uint pass)
bool _LastVertexSetupIsLightMap
CMaterial::CTexEnv _LightMapLastStageEnv
std::vector< uint_LightMapLUT
sint8 _LightMapUVMap [IDRV_MAT_MAXTEXTURES]
uint _NLightMapPass
uint _NLightMapPerPass
uint _NLightMaps
 Temp Variables computed in beginLightMapMultiPass(). Reused in setupLightMapPass().


Specular.

sint beginSpecularMultiPass ()
void endSpecularMultiPass ()
void setupSpecularBegin ()
void setupSpecularEnd ()
void setupSpecularPass (uint pass)
bool _SpecularBatchOn

[NOHEADER]

void checkForPerPixelLightingSupport ()
float _PPLExponent
NLMISC::CRGBA _PPLightDiffuseColor
NLMISC::CRGBA _PPLightSpecularColor
bool _SupportPerPixelShader
bool _SupportPerPixelShaderNoSpec

[NOHEADER]

void deleteARBFragmentPrograms ()
void deleteFragmentShaders ()
void initFragmentShaders ()
void setupWaterPassARB (const CMaterial &mat)
void setupWaterPassNV20 (const CMaterial &mat)
void setupWaterPassR200 (const CMaterial &mat)
GLuint ARBWaterShader [4]
GLuint ATIWaterShaderHandle
GLuint ATIWaterShaderHandleNoDiffuseMap

VertexBufferHard

void fenceOnCurVBHardIfNeeded (IVertexBufferHardGL *newVBHard)
void resetVertexArrayRange ()
IVertexArrayRange_AGPVertexArrayRange
IVertexArrayRange_CurrentVertexArrayRange
IVertexBufferHardGL_CurrentVertexBufferHard
uint32 _MaxVerticesByVBHard
void * _NVCurrentVARPtr
uint32 _NVCurrentVARSize
bool _SlowUnlockVBHard
bool _SupportVBHard
CPtrSet< IVertexBufferHardGL_VertexBufferHardSet
IVertexArrayRange_VRAMVertexArrayRange
class CVertexArrayRangeATI
class CVertexArrayRangeMapObjectATI
class CVertexArrayRangeNVidia
class CVertexBufferHardGLATI
class CVertexBufferHardGLMapObjectATI
class CVertexBufferHardGLNVidia

Caustics shaders

NLMISC::CSmartPtr< CTextureCube_CausticCubeMap
void initCausticCubeMap ()

Public Types

enum  { MaxLight = 8 + }
enum  TMatrixCount { MaxModelMatrix = 16 + }
enum  TMessageBoxIcon {
+  noIcon = 0, +handIcon, +questionIcon, +exclamationIcon, +
+  asteriskIcon, +warningIcon, +errorIcon, +informationIcon, +
+  stopIcon, +iconCount +
+ }
enum  TMessageBoxId {
+  okId = 0, +yesId, +noId, +abortId, +
+  retryId, +cancelId, +ignoreId, +idCount +
+ }
enum  TMessageBoxType {
+  okType = 0, +okCancelType, +yesNoType, +abortRetryIgnoreType, +
+  yesNoCancelType, +retryCancelType, +typeCount +
+ }
enum  TPolygonMode { Filled = 0, +Line, +Point + }
enum  TVBHardType { VBHardAGP = 0, +VBHardVRAM, +CountVBHard + }

Public Member Functions

virtual bool activate ()
 Before rendering via a driver in a thread, must activate() (per thread).

virtual bool activeVertexBuffer (CVertexBuffer &VB, uint first, uint end)
virtual bool activeVertexBuffer (CVertexBuffer &VB)
virtual void activeVertexBufferHard (IVertexBufferHard *VB)
 CDriverGL ()
virtual bool clear2D (CRGBA rgba)
virtual bool clearZBuffer (float zval=1)
virtual void copyFrameBufferToTexture (ITexture *tex, uint32 level, uint32 offsetx, uint32 offsety, uint32 x, uint32 y, uint32 width, uint32 height)
virtual IVertexBufferHardcreateVertexBufferHard (uint16 vertexFormat, const uint8 *typeArray, uint32 numVertices, TVBHardType vbType, const uint8 *uvRouting)=0
virtual IVertexBufferHardcreateVertexBufferHard (uint16 vertexFormat, const uint8 *typeArray, uint32 numVertices, IDriver::TVBHardType vbType, const uint8 *uvRouting)
virtual void deleteVertexBufferHard (IVertexBufferHard *VB)
virtual void disableHardwareTextureShader ()
virtual void disableHardwareVertexArrayAGP ()
virtual void disableHardwareVertexProgram ()
void disableUserTextureMatrix ()
 disable all texture matrix

virtual void enableLight (uint8 num, bool enable=true)
virtual NLMISC::IKeyboardDeviceenableLowLevelKeyboard (bool enable)
virtual NLMISC::IMouseDeviceenableLowLevelMouse (bool enable, bool exclusive)
void enableUsedTextureMemorySum (bool enable)
virtual void endProfileVBHardLock (std::vector< std::string > &result)
virtual void endSpecularBatch ()
virtual ModeList enumModes ()
virtual bool fillBuffer (CBitmap &bitmap)
virtual void forceDXTCCompression (bool dxtcComp)
virtual void forceNormalize (bool normalize)
virtual void forceTextureResize (uint divisor)
virtual uint32 getAvailableVertexAGPMemory ()
virtual uint32 getAvailableVertexVRAMMemory ()
virtual uint8 getBitPerPixel ()
 Return the depth of the driver after init().

virtual void getBuffer (CBitmap &bitmap)
virtual void getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect)
virtual void * getDisplay ()
virtual uint getDoubleClickDelay (bool hardwareMouse)
virtual const char * getDriverInformation ()
virtual NLMISC::IEventEmittergetEventEmitter ()
uint32 getHwnd ()
virtual uint32 getImplementationVersion () const
virtual NLMISC::IInputDeviceManagergetLowLevelInputDeviceManager ()
virtual uint getMaxLight () const
virtual uint getMaxVerticesByVertexBufferHard () const
virtual bool getModes (std::vector< GfxMode > &modes)
virtual sint getNbTextureStages () const
 Get the number of texture stage avaliable, for multitexturing (Normal material shaders). Valid only after setDisplay().

TPolygonMode getPolygonMode ()
const sintgetRefCount () const
virtual uint getSwapVBLInterval ()
 get the number of VBL wait when a swapBuffers() is issued. 0 means no synchronisation to the VBL

virtual uint getTextureHandle (const ITexture &tex)
uint32 getUsedTextureMemory () const
virtual const char * getVideocardInformation ()
virtual CMatrix getViewMatrix () const
virtual void getViewport (CViewport &viewport)
virtual void getWindowPos (uint32 &x, uint32 &y)
 Get the position of the window always (0,0) in fullscreen.

virtual emptyProc getWindowProc ()
virtual void getWindowSize (uint32 &width, uint32 &height)
 Get the width and the height of the window.

virtual void getZBuffer (std::vector< float > &zbuffer)
virtual void getZBufferPart (std::vector< float > &zbuffer, NLMISC::CRect &rect)
virtual bool init (uint windowIcon=0)
virtual bool initVertexArrayRange (uint agpMem, uint vramMem)
bool invalidateShareTexture (ITexture &)
virtual bool isActive ()
 Return true if driver is still active. Return false else. If he user close the window, must return false.

virtual bool isForceNormalize () const
virtual bool isTextureExist (const ITexture &tex)
virtual void mapTextureStageToUV (uint stage, uint uv)
virtual void multiplyModelMatrix (const CMatrix &mtx)
virtual uint32 profileAllocatedTextureMemory ()
virtual void profileRenderedPrimitives (CPrimitiveProfile &pIn, CPrimitiveProfile &pOut)
virtual uint32 profileSetupedMaterials () const
virtual uint32 profileSetupedModelMatrix () const
virtual void profileVBHardAllocation (std::vector< std::string > &result)
virtual bool release ()
 Deriver should calls IDriver::release() first, to destroy all driver components (textures, shaders, VBuffers).

virtual bool render (CPrimitiveBlock &PB, CMaterial &Mat)
virtual void renderOrientedQuads (CMaterial &mat, uint32 startIndex, uint32 numQuads)
virtual void renderPoints (CMaterial &Mat, uint32 numPoints)
virtual void renderQuads (CMaterial &Mat, uint32 startIndex, uint32 numQuads)
virtual void renderSimpleTriangles (uint32 *tri, uint32 ntris)
virtual void renderTriangles (CMaterial &Mat, uint32 *tri, uint32 ntris)
virtual void setAmbientColor (CRGBA color)
virtual void setCapture (bool b)
virtual void setColorMask (bool bRed, bool bGreen, bool bBlue, bool bAlpha)
 Set the color mask filter through where the operation done will pass.

virtual bool setDisplay (void *wnd, const GfxMode &mode, bool show) throw (EBadDisplay)
virtual void setFrustum (float left, float right, float bottom, float top, float znear, float zfar, bool perspective=true)
virtual void setLight (uint8 num, const CLight &light)
virtual bool setMode (const GfxMode &mode)
virtual void setMousePos (float x, float y)
 x and y must be between 0.0 and 1.0

virtual void setPerPixelLightingLight (CRGBA diffuse, CRGBA specular, float shininess)
virtual void setPolygonMode (TPolygonMode mode)
virtual void setSwapVBLInterval (uint interval)
void setTextureEnvFunction (uint stage, CMaterial &mat)
 Setup texture env functions. Used by setupMaterial.

virtual bool setupMaterial (CMaterial &mat)
 For objects with caustics, setup the first texture (which actually is the one from the material).

virtual void setupModelMatrix (const CMatrix &mtx)
virtual void setupScissor (const class CScissor &scissor)
virtual bool setupTexture (ITexture &tex)
virtual bool setupTextureEx (ITexture &tex, bool bUpload, bool &bAllUploaded, bool bMustRecreateSharedTexture=false)
void setupUserTextureMatrix (uint numStages, CMaterial &mat)
 setup the texture matrix for a given number of stages (starting from 0)

virtual void setupViewMatrix (const CMatrix &mtx)
virtual void setupViewMatrixEx (const CMatrix &mtx, const CVector &cameraPos)
virtual void setupViewport (const class CViewport &viewport)
virtual void showCursor (bool b)
 show cursor if b is true, or hide it if b is false

virtual bool slowUnlockVertexBufferHard () const
virtual void startProfileVBHardLock ()
virtual void startSpecularBatch ()
virtual bool supportCloudRenderSinglePass () const
virtual bool supportPerPixelLighting (bool specular) const
virtual bool supportVertexBufferHard () const
virtual bool swapBuffers ()
 Swap the back and front buffers.

virtual void swapTextureHandle (ITexture &tex0, ITexture &tex1)
virtual TMessageBoxId systemMessageBox (const char *message, const char *title, TMessageBoxType type=okType, TMessageBoxIcon icon=noIcon)
virtual bool uploadTexture (ITexture &tex, NLMISC::CRect &rect, uint8 nNumMipMap)
virtual bool uploadTextureCube (ITexture &tex, NLMISC::CRect &rect, uint8 nNumMipMap, uint8 nNumFace)
virtual ~CDriverGL ()
Material multipass.
virtual sint beginMaterialMultiPass ()
 init multipass for _CurrentMaterial. return number of pass required to render this material.

virtual void endMaterialMultiPass ()
 end multipass for this material.

virtual void setupMaterialPass (uint pass)
 active the ith pass of this material.

Fog support.
virtual void enableFog (bool enable)
virtual bool fogEnabled ()
virtual CRGBA getFogColor () const
virtual float getFogEnd () const
virtual float getFogStart () const
 Get.

virtual void setupFog (float start, float end, CRGBA color)
 setup fog parameters. fog must enabled to see result. start and end are in [0,1] range.

Misc
virtual void enablePolygonSmoothing (bool smooth)
virtual void finish ()
virtual NLMISC::CRGBA getBlendConstantColor () const
virtual bool isPolygonSmoothingEnabled () const
 see enablePolygonSmoothing()

virtual void setBlendConstantColor (NLMISC::CRGBA col)
virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties)
virtual bool supportBlendConstantColor () const
EMBM support
virtual bool isEMBMSupportedAtStage (uint stage) const
virtual void setEMBMMatrix (const uint stage, const float mat[4])
virtual bool supportEMBM () const
texture addressing modes
virtual bool isTextureAddrModeSupported (CMaterial::TTexAddressingMode mode) const
 test wether a texture addressing mode is supported

virtual bool isWaterShaderSupported () const
 test wether a texture addressing mode is supported

virtual void setMatrix2DForTextureOffsetAddrMode (const uint stage, const float mat[4])
virtual bool supportTextureShaders () const
 test wether the device supports some form of texture shader. (could be limited to DX6 EMBM for example)


Static Public Member Functions

void getTextureShareName (const ITexture &tex, std::string &output)

Data Fields

sint crefs
CPtrInfo * pinfo

Static Public Attributes

const uint32 InterfaceVersion = 0x4e
 Version of the driver interface. To increment when the interface change.

CPtrInfo NullPtrInfo

Protected Member Functions

void removeShaderPtr (ItShaderPtrList shaderIt)
void removeTextureDrvInfoPtr (ItTexDrvInfoPtrMap texDrvInfoIt)
void removeTextureDrvSharePtr (ItTexDrvSharePtrList texDrvShareIt)
void removeVBDrvInfoPtr (ItVBDrvInfoPtrList vbDrvInfoIt)
 remove ptr from the lists in the driver.

void removeVtxPrgDrvInfoPtr (ItVtxPrgDrvInfoPtrList vtxPrgDrvInfoIt)

Protected Attributes

TPolygonMode _PolygonMode
TShaderPtrList _Shaders
CSynchronized< TTexDrvInfoPtrMap_SyncTexDrvInfos
TTexDrvSharePtrList _TexDrvShares
TVBDrvInfoPtrList _VBDrvInfos
TVtxPrgDrvInfoPtrList _VtxPrgDrvInfos

Private Types


Private Member Functions

void activateTexEnvColor (uint stage, NLMISC::CRGBA col)
void activateTexEnvColor (uint stage, const CMaterial::CTexEnv &env)
void activateTexEnvMode (uint stage, const CMaterial::CTexEnv &env)
bool activateTexture (uint stage, ITexture *tex)
void cleanLightSetup ()
bool clipRect (NLMISC::CRect &rect)
void doRefreshRenderSetup ()
void enableGlNormalize (bool normalize)
 Test/activate normalisation of normal.

void enableNVTextureShader (bool enabled)
 nv texture shaders. Should be used only if this caps is present!

void forceActivateTexEnvColor (uint stage, const CMaterial::CTexEnv &env)
void forceActivateTexEnvColor (uint stage, NLMISC::CRGBA col)
void forceActivateTexEnvMode (uint stage, const CMaterial::CTexEnv &env)
GLint getGlTextureFormat (ITexture &tex, bool &compressed)
void initEMBM ()
sint inlGetNumTextStages () const
 Same as getNbTextureStages(), but faster because inline, and not virtual!!

bool isVertexProgramEnabled () const
void refreshProjMatrixFromGL ()
void refreshRenderSetup ()
void retrieveATIDriverVersion ()
void setupGlArrays (CVertexBufferInfo &vb)
 setup GL arrays, with a vb info.

void setupGlArraysForEXTVertexShader (CVertexBufferInfo &vb)
void setupGlArraysForNVVertexProgram (CVertexBufferInfo &vb)
void setupGlArraysStd (CVertexBufferInfo &vb)
 Tools fct used by setupGLArrays.

void setupUVPtr (uint stage, CVertexBufferInfo &VB, uint uvId)
 setup a texture stage with an UV from VB.

bool setupVertexBuffer (CVertexBuffer &VB)
void toggleGlArraysForEXTVertexShader ()
void toggleGlArraysForNVVertexProgram ()
void verifyNVTextureShaderConfig ()
Vertex program implementation
bool activeEXTVertexShader (CVertexProgram *program)
bool activeNVVertexProgram (CVertexProgram *program)
Vertex program interface
bool activeVertexProgram (CVertexProgram *program)
void enableVertexProgramDoubleSidedColor (bool doubleSided)
bool isVertexProgramEmulated () const
bool isVertexProgramSupported () const
void setConstant (uint index, uint num, const double *src)
 setup several 4 double csts taken from the given tab

void setConstant (uint index, uint num, const float *src)
 setup several 4 float csts taken from the given tab

void setConstant (uint indexStart, const NLMISC::CVectorD &value)
void setConstant (uint indexStart, const NLMISC::CVector &value)
void setConstant (uint index, double, double, double, double)
void setConstant (uint index, float, float, float, float)
void setConstantMatrix (uint index, IDriver::TMatrix matrix, IDriver::TTransform transform)
bool supportVertexProgramDoubleSidedColor () const
 Check if the driver support double sided colors vertex programs.

Cloud Shader
sint beginCloudMultiPass ()
void endCloudMultiPass ()
void setupCloudPass (uint pass)
Material multipass.
sint beginMultiPass ()
 init multipass for _CurrentMaterial. return number of pass required to render this material.

void endMultiPass ()
 end multipass for this material.

void setupPass (uint pass)
 active the ith pass of this material.

Water
sint beginWaterMultiPass ()
void endWaterMultiPass ()
void setupWaterPass (uint pass)
CMaterial::TShader getSupportedShader (CMaterial::TShader shader)
 test wether the given shader is supported, and gives back a supported shader


Private Attributes

uint _ATIDriverVersion
bool _ATIFogRangeFixed
NLMISC::CRGBA _CurrentBlendConstantColor
GLfloat _CurrentFogColor [4]
bool _CurrentGlNormalize
CViewport _CurrViewport
uint8 _Depth
bool _FogEnabled
float _FogEnd
float _FogStart
bool _ForceDXTCCompression
bool _ForceNormalize
uint _ForceTextureResizePower
 Divisor for textureResize (power).

bool _FullScreen
NLMISC::CMatrix _GLProjMat
bool _Initialized
bool _LastSetupGLArrayVertexProgram
NLMISC::CRefPtr< CVertexProgram_LastSetuppedVP
CVertexBufferInfo _LastVB
 LastVB for UV setup.

bool _LightDirty [MaxLight]
bool _LightEnable [MaxLight]
uint _LightMode [MaxLight]
bool _LightSetupDirty
uint _MaxDriverLight
CMatrix _ModelViewMatrix
bool _ModelViewMatrixDirty
bool _OffScreen
float _OODeltaZ
bool _PolygonSmooth
bool _ProjMatDirty
CVector _PZBCameraPos
bool _RenderSetupDirty
CMatrix _SpecularTexMtx
NLMISC::CMatrix _UserTexMat [IDRV_MAT_MAXTEXTURES]
uint _UserTexMatEnabled
CMatrix _UserViewMtx
bool _VertexProgramEnabled
CMatrix _ViewMtx
CVector _WorldLightDirection [MaxLight]
CVector _WorldLightPos [MaxLight]
Driver Caps.
CGlExtensions _Extensions

Static Private Attributes

const uint GLMatrix [IDriver::NumMatrix]
const uint GLTransform [IDriver::NumTransform]
const uint GLType [CVertexBuffer::NumType]
const uint GLVertexAttribIndex [CVertexBuffer::NumValue]
const uint NumCoordinatesType [CVertexBuffer::NumType]
const uint32 ReleaseVersion = 0xa

Friends

struct CPtrInfo
class CTextureDrvInfosGL
class CTextureDrvShare
class CVertexProgamDrvInfosGL
class IShader
class ITextureDrvInfos
class IVBDrvInfos
class IVertexProgramDrvInfos
+

Member Typedef Documentation

+

+ + + + +
+ + +
typedef NLMISC::CSmartPtr<CTextureCube> NL3D::CDriverGL::TSPTextureCube [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 812 of file driver_opengl.h.

+

+ + + + +
+ + +
typedef std::vector<TSPTextureCube> NL3D::CDriverGL::TTexCubeVect [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 813 of file driver_opengl.h.

+


Member Enumeration Documentation

+

+ + + + +
+ + +
anonymous enum +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + +
MaxLight  +
+
+ +

+Definition at line 202 of file driver_opengl.h. +

+

00202 { MaxLight=8 };
+
+

+ + + + +
+ + +
enum NL3D::CDriverGL::CTexEnvSpecial [private] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + + + + + +
TexEnvSpecialDisabled  +
TexEnvSpecialLightMap  +
TexEnvSpecialSpecularStage1  +
TexEnvSpecialSpecularStage1NoText  +
TexEnvSpecialPPLStage0  +
TexEnvSpecialPPLStage2  +
TexEnvSpecialCloudStage0  +
TexEnvSpecialCloudStage1  +
+
+ +

+Definition at line 641 of file driver_opengl.h. +

+Referenced by setupSpecularPass(). +

+

+

+ + + + +
+ + +
enum NL3D::CDriverGL::EEVSVariants +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + + +
EVSSecondaryColorVariant  +
EVSFogCoordsVariant  +
EVSSkinWeightVariant  +
EVSPaletteSkinVariant  +
EVSNumVariants  +
+
+ +

+Definition at line 1031 of file driver_opengl.h. +

+

+

+ + + + +
+ + +
enum NL3D::IDriver::TMatrix [inherited] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + +
ModelView  +
Projection  +
ModelViewProjection  +
NumMatrix  +
+
+ +

+Definition at line 825 of file driver.h. +

+

00826         {
+00827                 ModelView= 0,
+00828                 Projection,
+00829                 ModelViewProjection,
+00830                 NumMatrix
+00831         };
+
+

+ + + + +
+ + +
enum NL3D::IDriver::TMatrixCount [inherited] +
+
+ + + + + +
+   + + +

+Driver Max matrix count. Kept for backward compatibility. Suppose any Hardware VertexProgram can handle only 16 matrix

Enumeration values:
+ + +
MaxModelMatrix  +
+
+ +

+Definition at line 148 of file driver.h. +

+

00148 { MaxModelMatrix= 16 };
+
+

+ + + + +
+ + +
enum NL3D::IDriver::TMessageBoxIcon [inherited] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + + + + + + + +
noIcon  +
handIcon  +
questionIcon  +
exclamationIcon  +
asteriskIcon  +
warningIcon  +
errorIcon  +
informationIcon  +
stopIcon  +
iconCount  +
+
+ +

+Definition at line 133 of file driver.h. +

+

+

+ + + + +
+ + +
enum NL3D::IDriver::TMessageBoxId [inherited] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + + + + + +
okId  +
yesId  +
noId  +
abortId  +
retryId  +
cancelId  +
ignoreId  +
idCount  +
+
+ +

+Definition at line 131 of file driver.h. +

+

+

+ + + + +
+ + +
enum NL3D::IDriver::TMessageBoxType [inherited] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + + + + +
okType  +
okCancelType  +
yesNoType  +
abortRetryIgnoreType  +
yesNoCancelType  +
retryCancelType  +
typeCount  +
+
+ +

+Definition at line 132 of file driver.h. +

+

+

+ + + + +
+ + +
enum NL3D::IDriver::TPolygonMode [inherited] +
+
+ + + + + +
+   + + +

+Driver's polygon modes.

+

See also:
setPolygonMode, getPolygonMode
+
Enumeration values:
+ + + + +
Filled  +
Line  +
Point  +
+
+ +

+Definition at line 140 of file driver.h. +

+Referenced by NL3D::IDriver::getPolygonMode(). +

+

00140 { Filled=0, Line, Point };
+
+

+ + + + +
+ + +
enum NL3D::IDriver::TTransform [inherited] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + + + +
Identity  +
Inverse  +
Transpose  +
InverseTranspose  +
NumTransform  +
+
+ +

+Definition at line 833 of file driver.h. +

+

00834         {
+00835                 Identity=0,
+00836                 Inverse,
+00837                 Transpose,
+00838                 InverseTranspose,
+00839                 NumTransform
+00840         };
+
+

+ + + + +
+ + +
enum NL3D::IDriver::TVBHardType [inherited] +
+
+ + + + + +
+   + + +

+Driver VertexBufferHard type.

See also:
createVertexBufferHard()
+
Enumeration values:
+ + + + +
VBHardAGP  +
VBHardVRAM  +
CountVBHard  +
+
+ +

+Definition at line 155 of file driver.h. +

+

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NL3D::CDriverGL::CDriverGL  ) 
+
+ + + + + +
+   + + +

+buildCausticCubeMapTex(); +

+Definition at line 190 of file driver_opengl.cpp. +

+References _AGPVertexArrayRange, _AllocatedTextureMemory, _ATIDriverVersion, _ATIFogRangeFixed, _CurrentFogColor, _CurrentGlNormalize, _CurrentMaterial, _CurrentTexAddrMode, _CurrentVertexArrayRange, _CurrentVertexBufferHard, _CurVBHardLockCount, _FogEnabled, _FogEnd, _FogStart, _ForceDXTCCompression, _ForceNormalize, _ForceTextureResizePower, _FullScreen, _Initialized, _LastVertexSetupIsLightMap, _LightDirty, _LightMapLastStageEnv, _LightMapLUT, _LightMapUVMap, _LightSetupDirty, _MaterialAllTextureTouchedFlag, _MaxVerticesByVBHard, _ModelViewMatrixDirty, _NumVBHardProfileFrame, _NVCurrentVARPtr, _NVCurrentVARSize, _NVTextureShaderEnabled, _OffScreen, _PolygonSmooth, _ProjMatDirty, _RenderSetupDirty, _SlowUnlockVBHard, _SpecularBatchOn, _StageSupportEMBM, _SumTextureMemoryUsed, _SupportVBHard, _UserTexMatEnabled, _VBHardProfiling, _VRAMVertexArrayRange, ARBWaterShader, ATIWaterShaderHandle, ATIWaterShaderHandleNoDiffuseMap, NL3D::CMaterial::CTexEnv::Env, NL3D::IDRV_MAT_MAXTEXTURES, NL3D::IDRV_TOUCHED_TEX, MaxLight, NL3D_DRV_MAX_LIGHTMAP, and uint. +

+

00191 {       
+00192         _OffScreen = false;
+00193 
+00194 #ifdef NL_OS_WINDOWS
+00195         _PBuffer = NULL;
+00196         _hWnd = NULL;
+00197         _hRC = NULL;
+00198         _hDC = NULL;
+00199         _NeedToRestaureGammaRamp = false;
+00200 #elif defined (NL_OS_UNIX) // NL_OS_WINDOWS
+00201 
+00202         cursor = None;
+00203         
+00204 #ifdef XF86VIDMODE
+00205         // zero the old screen mode
+00206         memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
+00207 #endif //XF86VIDMODE
+00208 
+00209 #endif // NL_OS_UNIX
+00210 
+00211         _FullScreen= false;
+00212 
+00213         _CurrentMaterial=NULL;
+00214         _Initialized = false;
+00215 
+00216         _FogEnabled= false;
+00217         _FogEnd = _FogStart = 0.f;
+00218         _CurrentFogColor[0]= 0;
+00219         _CurrentFogColor[1]= 0;
+00220         _CurrentFogColor[2]= 0;
+00221         _CurrentFogColor[3]= 0;
+00222 
+00223 
+00224         _LightSetupDirty= false;
+00225         _ModelViewMatrixDirty= false;
+00226         _RenderSetupDirty= false;
+00227         // All lights default pos.
+00228         uint i;
+00229         for(i=0;i<MaxLight;i++)
+00230                 _LightDirty[i]= false;
+00231 
+00232         
+00233 
+00234         _CurrentGlNormalize= false;
+00235         _ForceNormalize= false;
+00236 
+00237         _AGPVertexArrayRange= NULL;
+00238         _VRAMVertexArrayRange= NULL;
+00239         _CurrentVertexArrayRange= NULL;
+00240         _CurrentVertexBufferHard= NULL;
+00241         _NVCurrentVARPtr= NULL;
+00242         _NVCurrentVARSize= 0;
+00243         _SupportVBHard= false;
+00244         _SlowUnlockVBHard= false;
+00245         _MaxVerticesByVBHard= 0;
+00246 
+00247         _AllocatedTextureMemory= 0;
+00248 
+00249         _ForceDXTCCompression= false;
+00250         _ForceTextureResizePower= 0;
+00251 
+00252         _SumTextureMemoryUsed = false;
+00253 
+00254         _NVTextureShaderEnabled = false;
+00255 
+00256 
+00257         // Compute the Flag which say if one texture has been changed in CMaterial.
+00258         _MaterialAllTextureTouchedFlag= 0;
+00259         for(i=0; i < IDRV_MAT_MAXTEXTURES; i++)
+00260         {
+00261                 _MaterialAllTextureTouchedFlag|= IDRV_TOUCHED_TEX[i];
+00262                 _CurrentTexAddrMode[i] = GL_NONE;
+00263         }
+00264 
+00265 
+00266         _UserTexMatEnabled = 0;
+00267         
+00268         // Ligtmap preca.
+00269         _LastVertexSetupIsLightMap= false;
+00270         for(i=0; i < IDRV_MAT_MAXTEXTURES; i++)
+00271                 _LightMapUVMap[i]= -1;
+00272         // reserve enough space to never reallocate, nor test for reallocation.
+00273         _LightMapLUT.resize(NL3D_DRV_MAX_LIGHTMAP);
+00274         // must set replace for alpha part.
+00275         _LightMapLastStageEnv.Env.OpAlpha= CMaterial::Replace;
+00276         _LightMapLastStageEnv.Env.SrcArg0Alpha= CMaterial::Texture;
+00277         _LightMapLastStageEnv.Env.OpArg0Alpha= CMaterial::SrcAlpha;
+00278 
+00279         _ProjMatDirty = true;
+00280 
+00281         std::fill(_StageSupportEMBM, _StageSupportEMBM + IDRV_MAT_MAXTEXTURES, false);
+00282 
+00283         ATIWaterShaderHandleNoDiffuseMap = 0;
+00284         ATIWaterShaderHandle = 0;
+00285 
+00286         _ATIDriverVersion = 0;
+00287         _ATIFogRangeFixed = true;
+00288 
+00289         std::fill(ARBWaterShader, ARBWaterShader + 4, 0);
+00290 
+00292 
+00293         _SpecularBatchOn= false;
+00294 
+00295         _PolygonSmooth= false;
+00296 
+00297         _VBHardProfiling= false;
+00298         _CurVBHardLockCount= 0;
+00299         _NumVBHardProfileFrame= 0;
+00300 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CDriverGL::~CDriverGL  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Definition at line 304 of file driver_opengl.cpp. +

+References release(). +

+

00305 {
+00306         release();
+00307 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::activate  )  [virtual]
+
+ + + + + +
+   + + +

+Before rendering via a driver in a thread, must activate() (per thread). +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1473 of file driver_opengl.cpp. +

+

01474 {
+01475 #ifdef NL_OS_WINDOWS
+01476         HGLRC hglrc=wglGetCurrentContext();
+01477         if (hglrc!=_hRC)
+01478         {
+01479                 wglMakeCurrent(_hDC,_hRC);
+01480         }
+01481 #elif defined (NL_OS_UNIX)
+01482         GLXContext nctx=glXGetCurrentContext();
+01483         if (nctx != NULL && nctx!=ctx)
+01484         {
+01485                 glXMakeCurrent(dpy, win,ctx);
+01486         }
+01487 #endif // NL_OS_WINDOWS
+01488         return true;
+01489 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::activateTexEnvColor uint  stage,
NLMISC::CRGBA  col
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1137 of file driver_opengl_texture.cpp. +

+References _CurrentTexEnv, NL3D::CMaterial::CTexEnv::ConstantColor, forceActivateTexEnvColor(), and uint. +

+

01138 {       
+01139         if (col != _CurrentTexEnv[stage].ConstantColor)
+01140         {       
+01141                 forceActivateTexEnvColor(stage, col);   
+01142         }
+01143 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::activateTexEnvColor uint  stage,
const CMaterial::CTexEnv env
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1159 of file driver_opengl_texture.cpp. +

+References _CurrentTexEnv, NL3D::CMaterial::CTexEnv::ConstantColor, forceActivateTexEnvColor(), and uint. +

+Referenced by setTextureEnvFunction(), setupCloudPass(), setupLightMapPass(), setupPPLNoSpecPass(), and setupPPLPass(). +

+

01160 {
+01161         if(_CurrentTexEnv[stage].ConstantColor!= env.ConstantColor)
+01162         { 
+01163                 forceActivateTexEnvColor(stage, env);
+01164         }
+01165 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::activateTexEnvMode uint  stage,
const CMaterial::CTexEnv env
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1147 of file driver_opengl_texture.cpp. +

+References _CurrentTexEnv, _CurrentTexEnvSpecial, NL3D::CMaterial::CTexEnv::EnvPacked, forceActivateTexEnvMode(), TexEnvSpecialDisabled, and uint. +

+Referenced by setTextureEnvFunction(), setupLightMapPass(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularBegin(), setupSpecularPass(), and setupWaterPassNV20(). +

+

01148 {
+01149         // If a special Texture environnement is setuped, or if not the same normal texture environnement,
+01150         // must setup a new normal Texture environnement.
+01151         if( _CurrentTexEnvSpecial[stage] != TexEnvSpecialDisabled || _CurrentTexEnv[stage].EnvPacked!= env.EnvPacked)
+01152         { 
+01153                 forceActivateTexEnvMode(stage, env);
+01154         }
+01155 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::activateTexture uint  stage,
ITexture tex
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 941 of file driver_opengl_texture.cpp. +

+References _CurrentTexture, _CurrentTextureInfoGL, _DriverGLStates, _Extensions, _SumTextureMemoryUsed, _TextureUsed, NL3D::CDriverGLStates::activeTextureARB(), NL3D::CGlExtensions::ARBTextureCubeMap, NL3D::ITexture::getMagFilter(), NL3D::ITexture::getMinFilter(), NL3D::getTextureGl(), NL3D::ITexture::getWrapS(), NL3D::ITexture::getWrapT(), NL3D::ITexture::isTextureCube(), NL3D::CDriverGLStates::setTextureMode(), NL3D::translateMagFilterToGl(), NL3D::translateMinFilterToGl(), NL3D::translateWrapToGl(), and uint. +

+Referenced by beginSpecularMultiPass(), setupCloudPass(), setupLightMapPass(), setupMaterial(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularBegin(), setupTextureEx(), setupWaterPassARB(), setupWaterPassNV20(), setupWaterPassR200(), and swapTextureHandle(). +

+

00942 {       
+00943         if (this->_CurrentTexture[stage]!=tex)
+00944         {
+00945                 _DriverGLStates.activeTextureARB(stage);
+00946                 if(tex)
+00947                 {
+00948                         // get the drv info. should be not NULL.
+00949                         CTextureDrvInfosGL*     gltext;
+00950                         gltext= getTextureGl(*tex);
+00951 
+00952                         // Profile, log the use of this texture
+00953                         //=========================================
+00954                         if (_SumTextureMemoryUsed)
+00955                         {
+00956                                 // Insert the pointer of this texture
+00957                                 _TextureUsed.insert (gltext);
+00958                         }
+00959 
+00960 
+00961                         if(tex->isTextureCube())
+00962                         {
+00963                                 // setup texture mode, after activeTextureARB()
+00964                                 _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
+00965 
+00966                                 if(_Extensions.ARBTextureCubeMap)
+00967                                 {
+00968                                         // Activate texturing...
+00969                                         //======================
+00970 
+00971                                         // If the shared texture is the same than before, no op.
+00972                                         if(_CurrentTextureInfoGL[stage] != gltext)
+00973                                         {
+00974                                                 // Cache setup.
+00975                                                 _CurrentTextureInfoGL[stage]= gltext;
+00976 
+00977                                                 // setup this texture
+00978                                                 glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);
+00979                                                 
+00980 
+00981                                                 // Change parameters of texture, if necessary.
+00982                                                 //============================================
+00983                                                 if(gltext->MagFilter!= tex->getMagFilter())
+00984                                                 {
+00985                                                         gltext->MagFilter= tex->getMagFilter();
+00986                                                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
+00987                                                 }
+00988                                                 if(gltext->MinFilter!= tex->getMinFilter())
+00989                                                 {
+00990                                                         gltext->MinFilter= tex->getMinFilter();
+00991                                                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
+00992                                                 }
+00993                                         }
+00994                                 }
+00995                         }
+00996                         else
+00997                         {
+00998                                 // setup texture mode, after activeTextureARB()
+00999                                 _DriverGLStates.setTextureMode(CDriverGLStates::Texture2D);                                                             
+01000 
+01001                                 // Activate texture...
+01002                                 //======================
+01003 
+01004                                 // If the shared texture is the same than before, no op.
+01005                                 if(_CurrentTextureInfoGL[stage] != gltext)
+01006                                 {
+01007                                         // Cache setup.
+01008                                         _CurrentTextureInfoGL[stage]= gltext;
+01009 
+01010                                         // setup this texture
+01011                                         glBindTexture(GL_TEXTURE_2D, gltext->ID);                                                               
+01012 
+01013 
+01014                                         // Change parameters of texture, if necessary.
+01015                                         //============================================
+01016                                         if(gltext->WrapS!= tex->getWrapS())
+01017                                         {
+01018                                                 gltext->WrapS= tex->getWrapS();
+01019                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, translateWrapToGl(gltext->WrapS, _Extensions));
+01020                                         }
+01021                                         if(gltext->WrapT!= tex->getWrapT())
+01022                                         {
+01023                                                 gltext->WrapT= tex->getWrapT();
+01024                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, translateWrapToGl(gltext->WrapT, _Extensions));
+01025                                         }
+01026                                         if(gltext->MagFilter!= tex->getMagFilter())
+01027                                         {
+01028                                                 gltext->MagFilter= tex->getMagFilter();
+01029                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
+01030                                         }
+01031                                         if(gltext->MinFilter!= tex->getMinFilter())
+01032                                         {
+01033                                                 gltext->MinFilter= tex->getMinFilter();                                 
+01034                                                 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
+01035                                         }
+01036                                 }
+01037                         }
+01038                 }
+01039                 else
+01040                 {
+01041                         // Force no texturing for this stage.
+01042                         _CurrentTextureInfoGL[stage]= NULL;
+01043                         // setup texture mode, after activeTextureARB()
+01044                         _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);                                                                       
+01045                 }
+01046 
+01047                 this->_CurrentTexture[stage]= tex;      
+01048         }       
+01049 
+01050         return true;
+01051 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::activeEXTVertexShader CVertexProgram program  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1148 of file driver_opengl_vertex_program.cpp. +

+References _LastSetuppedVP, _VertexProgramEnabled, CVertexProgamDrvInfosGL, GL_VERTEX_SHADER_EXT, NL3D::CVertexProgamDrvInfosGL::ID, NL3D::ItVtxPrgDrvInfoPtrList, nglBindVertexShaderEXT, nlerror, nlwarning, CVPParser::parse(), program, setupEXTVertexShader(), and CVPParser::TProgram. +

+Referenced by activeVertexProgram(). +

+

01149 {
+01150         // Setup or unsetup ?
+01151         if (program)
+01152         {               
+01153                 // Driver info
+01154                 CVertexProgamDrvInfosGL *drvInfo;
+01155 
+01156                 // Program setuped ?
+01157                 if (program->_DrvInfo==NULL)
+01158                 {
+01159                         // try to parse the program
+01160                         CVPParser parser;
+01161                         CVPParser::TProgram parsedProgram;
+01162                         std::string errorOutput;
+01163                         bool result = parser.parse(program->getProgram().c_str(), parsedProgram, errorOutput);
+01164                         if (!result)
+01165                         {
+01166                                 nlwarning("Unable to parse a vertex program.");
+01167                                 #ifdef NL_DEBUG
+01168                                         nlerror(errorOutput.c_str());
+01169                                 #endif
+01170                                 return false;
+01171                         }
+01172 
+01173                         /* 
+01174                         FILE *f = fopen("c:\\test.txt", "wb");
+01175                         if (f)
+01176                         {
+01177                                 std::string vpText;
+01178                                 CVPParser::dump(parsedProgram, vpText);
+01179                                 fwrite(vpText.c_str(), vpText.size(), 1, f);
+01180                                 fclose(f);
+01181                         }
+01182                         */
+01183 
+01184                         // Insert into driver list. (so it is deleted when driver is deleted).
+01185                         ItVtxPrgDrvInfoPtrList  it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end());
+01186 
+01187                         // Create a driver info
+01188                         *it = drvInfo = new CVertexProgamDrvInfosGL (this, it);
+01189                         // Set the pointer
+01190                         program->_DrvInfo=drvInfo;
+01191 
+01192                         if (!setupEXTVertexShader(parsedProgram, drvInfo->ID, drvInfo->Variants, drvInfo->UsedVertexComponents))
+01193                         {
+01194                                 delete drvInfo;
+01195                                 program->_DrvInfo = NULL;
+01196                                 _VtxPrgDrvInfos.erase(it);
+01197                                 return false;
+01198                         }
+01199                 }
+01200                 else
+01201                 {
+01202                         // Cast the driver info pointer
+01203                         drvInfo=safe_cast<CVertexProgamDrvInfosGL*>((IVertexProgramDrvInfos*)program->_DrvInfo);
+01204                 }
+01205 
+01206                 glEnable( GL_VERTEX_SHADER_EXT);
+01207                 _VertexProgramEnabled = true;
+01208                 nglBindVertexShaderEXT( drvInfo->ID );
+01209                 _LastSetuppedVP = program;
+01210         }
+01211         else
+01212         {               
+01213                 glDisable( GL_VERTEX_SHADER_EXT );
+01214                 _VertexProgramEnabled = false;          
+01215         }
+01216         return true;    
+01217 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::activeNVVertexProgram CVertexProgram program  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 79 of file driver_opengl_vertex_program.cpp. +

+References _LastSetuppedVP, _VertexProgramEnabled, CVertexProgamDrvInfosGL, GL_PROGRAM_ERROR_POSITION_NV, GL_VERTEX_PROGRAM_NV, NL3D::CVertexProgamDrvInfosGL::ID, NL3D::ItVtxPrgDrvInfoPtrList, nglBindProgramNV, nglLoadProgramNV, nlassert, nlinfo, nlwarning, offset, CVPParser::parse(), program, CVPParser::TProgram, and uint. +

+Referenced by activeVertexProgram(). +

+

00080 {
+00081         // Setup or unsetup ?
+00082         if (program)
+00083         {
+00084                 // Enable vertex program
+00085                 glEnable (GL_VERTEX_PROGRAM_NV);
+00086                 _VertexProgramEnabled= true;
+00087 
+00088 
+00089                 // Driver info
+00090                 CVertexProgamDrvInfosGL *drvInfo;
+00091 
+00092                 // Program setuped ?
+00093                 if (program->_DrvInfo==NULL)
+00094                 {
+00098                         CVPParser parser;
+00099                         CVPParser::TProgram parsedProgram;
+00100                         std::string errorOutput;
+00101                         bool result = parser.parse(program->getProgram().c_str(), parsedProgram, errorOutput);
+00102                         if (!result)
+00103                         {
+00104                                 nlwarning("Unable to parse a vertex program :");
+00105                                 nlwarning(errorOutput.c_str());
+00106                                 #ifdef NL_DEBUG
+00107                                         nlassert(0);
+00108                                 #endif
+00109                                 return false;
+00110                         }
+00111 
+00112                         // Insert into driver list. (so it is deleted when driver is deleted).
+00113                         ItVtxPrgDrvInfoPtrList  it= _VtxPrgDrvInfos.insert(_VtxPrgDrvInfos.end());
+00114 
+00115                         // Create a driver info
+00116                         *it = drvInfo = new CVertexProgamDrvInfosGL (this, it);
+00117 
+00118                         // Set the pointer
+00119                         program->_DrvInfo=drvInfo;                                              
+00120 
+00121                         // Compile the program
+00122                         nglLoadProgramNV (GL_VERTEX_PROGRAM_NV, drvInfo->ID, program->getProgram().length(), (const GLubyte*)program->getProgram().c_str());
+00123 
+00124                         // Get loading error code
+00125                         GLint errorOff;
+00126                         glGetIntegerv (GL_PROGRAM_ERROR_POSITION_NV, &errorOff);
+00127 
+00128                         // Compilation error ?
+00129                         if (errorOff>=0)
+00130                         {
+00131                                 // String length
+00132                                 uint length = program->getProgram ().length();
+00133                                 const char* sString= program->getProgram ().c_str();
+00134 
+00135                                 // Line count and char count
+00136                                 uint line=1;
+00137                                 uint charC=1;
+00138 
+00139                                 // Find the line
+00140                                 uint offset=0;
+00141                                 while ((offset<length)&&(offset<(uint)errorOff))
+00142                                 {
+00143                                         if (sString[offset]=='\n')
+00144                                         {
+00145                                                 line++;
+00146                                                 charC=1;
+00147                                         }
+00148                                         else
+00149                                                 charC++;
+00150 
+00151                                         // Next character
+00152                                         offset++;
+00153                                 }
+00154 
+00155                                 // Show the error
+00156                                 nlinfo ("Vertex program syntax error line %d character %d\n", line, charC);
+00157 
+00158                                 // Disable vertex program
+00159                                 glDisable (GL_VERTEX_PROGRAM_NV);
+00160                                 _VertexProgramEnabled= false;
+00161 
+00162                                 // Setup not ok
+00163                                 return false;
+00164                         }
+00165 
+00166                         // Setup ok
+00167                         return true;
+00168                 }
+00169                 else
+00170                 {
+00171                         // Cast the driver info pointer
+00172                         drvInfo=safe_cast<CVertexProgamDrvInfosGL*>((IVertexProgramDrvInfos*)program->_DrvInfo);
+00173                 }
+00174 
+00175                 // Setup this program
+00176                 nglBindProgramNV (GL_VERTEX_PROGRAM_NV, drvInfo->ID);
+00177                 _LastSetuppedVP = program;
+00178 
+00179                 // Ok
+00180                 return true;
+00181         }
+00182         else // Unsetup
+00183         {
+00184                 // Disable vertex program
+00185                 glDisable (GL_VERTEX_PROGRAM_NV);
+00186                 _VertexProgramEnabled= false;
+00187                 // Ok
+00188                 return true;
+00189         }
+00190 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::activeVertexBuffer CVertexBuffer VB,
uint  first,
uint  end
[virtual]
+
+ + + + + +
+   + + +

+active a current VB, for future render(). This method suppose that only vertices in given range will be used in future render(). This could be usefull for DX or OpenGL driver. Undefined results if primitives in render() use vertices not in this range.

+NB: please make sure you have setuped / unsetuped the current vertex program BEFORE activate the vertex buffer.

+

Parameters:
+ + + + +
VB the vertexBuffer to activate.
first the first vertex important for render (begin to 0). nlassert(first<=end);
end the last vertex important for render, +1. count==end-first. nlassert(end<=VB.getNumVertices);
+
+
See also:
activeVertexProgram
+ +

+Implements NL3D::IDriver. +

+Definition at line 87 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _LastVB, NL3D::IVertexBufferHardGL::disable(), fenceOnCurVBHardIfNeeded(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getVertexFormat(), nlassert, setupGlArrays(), NL3D::CVertexBufferInfo::setupVertexBuffer(), setupVertexBuffer(), uint, and uint32. +

+

00088 {
+00089         // NB: must duplicate changes in activeVertexBufferHard()
+00090 
+00091         uint32  flags;
+00092 
+00093         if (!setupVertexBuffer(VB))
+00094                 return false;
+00095 
+00096         if (VB.getNumVertices()==0)
+00097                 return true;
+00098 
+00099         nlassert(end<=VB.getNumVertices());
+00100         nlassert(first<=end);
+00101 
+00102         // Get VB flags, to setup matrixes and arrays.
+00103         flags=VB.getVertexFormat();
+00104 
+00105 
+00106         // 2. Setup Arrays.
+00107         //===================
+00108 
+00109         // Fence mgt.
+00110         fenceOnCurVBHardIfNeeded(NULL);
+00111 
+00112         // For MultiPass Material.
+00113         _LastVB.setupVertexBuffer(VB);
+00114 
+00115         // Disable the current vertexBufferHard if setuped.
+00116         if(_CurrentVertexBufferHard)
+00117                 _CurrentVertexBufferHard->disable();
+00118 
+00119         // Setup the OpenGL arrays.
+00120         setupGlArrays(_LastVB);
+00121 
+00122 
+00123         return true;
+00124 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::activeVertexBuffer CVertexBuffer VB  )  [virtual]
+
+ + + + + +
+   + + +

+active a current VB, for future render(). This method suppose that all vertices in the VB will be used.

+NB: please make sure you have setuped / unsetuped the current vertex program BEFORE activate the vertex buffer.

+

See also:
activeVertexProgram
+ +

+Implements NL3D::IDriver. +

+Definition at line 128 of file driver_opengl_vertex.cpp. +

+References NL3D::CVertexBuffer::getNumVertices(). +

+Referenced by swapBuffers(). +

+

00129 {
+00130         return activeVertexBuffer(VB, 0, VB.getNumVertices());
+00131 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::activeVertexBufferHard IVertexBufferHard VB  )  [virtual]
+
+ + + + + +
+   + + +

+active a current VB Hard, for future render().

+NB: please make sure you have setuped / unsetuped the current vertex program BEFORE activate the vertex buffer.

+

See also:
activeVertexProgram
+ +

+Implements NL3D::IDriver. +

+Definition at line 580 of file driver_opengl_vertex.cpp. +

+References _LastVB, NL3D::IVertexBufferHardGL::enable(), fenceOnCurVBHardIfNeeded(), NL3D::IVertexBufferHard::getNumVertices(), NL3D::IVertexBufferHard::getVertexFormat(), nlassert, setupGlArrays(), NL3D::CVertexBufferInfo::setupVertexBufferHard(), and uint32. +

+

00581 {
+00582         // NB: must duplicate changes in activeVertexBuffer()
+00583 
+00584         nlassert(iVB);
+00585         IVertexBufferHardGL             *VB= safe_cast<IVertexBufferHardGL*>(iVB);
+00586 
+00587         uint32  flags;
+00588 
+00589         if (VB->getNumVertices()==0)
+00590                 return;
+00591 
+00592         // Get VB flags, to setup matrixes and arrays.
+00593         flags=VB->getVertexFormat();
+00594 
+00595 
+00596         // 2. Setup Arrays.
+00597         //===================
+00598 
+00599         // Fence mgt.
+00600         fenceOnCurVBHardIfNeeded(VB);
+00601 
+00602         // For MultiPass Material.
+00603         _LastVB.setupVertexBufferHard(*VB);
+00604 
+00605         // Enable the vertexArrayRange of this array.
+00606         VB->enable();
+00607 
+00608         // Setup the OpenGL arrays.
+00609         setupGlArrays(_LastVB);
+00610 
+00611 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::activeVertexProgram CVertexProgram program  )  [private, virtual]
+
+ + + + + +
+   + + +

+Activate / disactivate a vertex program

+

Parameters:
+ + +
program is a pointer on a vertex program. Can be NULL to disable the current vertex program.
+
+
Returns:
true if setup/unsetup successed, false else.
+ +

+Implements NL3D::IDriver. +

+Definition at line 1220 of file driver_opengl_vertex_program.cpp. +

+References _Extensions, activeEXTVertexShader(), activeNVVertexProgram(), NL3D::CGlExtensions::EXTVertexShader, NL3D::CGlExtensions::NVVertexProgram, and program. +

+

01221 {
+01222         // Extension here ?
+01223         if (_Extensions.NVVertexProgram)
+01224         {
+01225                 return activeNVVertexProgram(program);
+01226         }
+01227         else if (_Extensions.EXTVertexShader)
+01228         {
+01229                 return activeEXTVertexShader(program);          
+01230         }
+01231 
+01232         // Can't do anything
+01233         return false;
+01234 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::appendVBHardLockProfile NLMISC::TTicks  time,
IVertexBufferHard vb
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 3131 of file driver_opengl.cpp. +

+References _CurVBHardLockCount, _VBHardProfiles, and NLMISC::TTicks. +

+Referenced by NL3D::CVertexBufferHardGLNVidia::lock(). +

+

03132 {
+03133         // must allocate a new place?
+03134         if(_CurVBHardLockCount>=_VBHardProfiles.size())
+03135         {
+03136                 _VBHardProfiles.resize(_VBHardProfiles.size()+1);
+03137                 // set the original VBHard
+03138                 _VBHardProfiles[_CurVBHardLockCount].VBHard= vb;
+03139         }
+03140 
+03141         // Accumulate.
+03142         _VBHardProfiles[_CurVBHardLockCount].AccumTime+= time;
+03143         // if change of VBHard for this chrono place
+03144         if(_VBHardProfiles[_CurVBHardLockCount].VBHard != vb)
+03145         {
+03146                 // flag, and set new
+03147                 _VBHardProfiles[_CurVBHardLockCount].VBHard= vb;
+03148                 _VBHardProfiles[_CurVBHardLockCount].Change= true;
+03149         }
+03150 
+03151         // next!
+03152         _CurVBHardLockCount++;
+03153 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginCloudMultiPass  )  [private]
+
+ + + + + +
+   + + +

+

Todo:
Optimize the cloud multipass with register combiner
+ +

+Definition at line 1726 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, NL3D::CMaterial::getShader(), nlassert, and sint. +

+Referenced by beginMultiPass(). +

+

01727 {
+01728         nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
+01729         return 1;
+01730 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginLightMapMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 653 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _DriverGLStates, _LastVB, _NLightMapPass, computeLightMapInfos(), NL3D::CDriverGLStates::enableColorArray(), NL3D::CDriverGLStates::enableLighting(), sint, uint, and NL3D::CVertexBufferInfo::VertexFormat. +

+Referenced by beginMultiPass(). +

+

00654 {
+00655         const CMaterial &mat= *_CurrentMaterial;
+00656 
+00657         // compute how many lightmap and pass we must process.
+00658         computeLightMapInfos (mat);
+00659 
+00660         // Too be sure, disable vertex coloring / lightmap.
+00661         _DriverGLStates.enableLighting(false);
+00662         // reset VertexColor array if necessary.
+00663         if (_LastVB.VertexFormat & CVertexBuffer::PrimaryColorFlag)
+00664                 _DriverGLStates.enableColorArray(false);
+00665 
+00666         // Manage too if no lightmaps.
+00667         return  std::max (_NLightMapPass, (uint)1);
+00668 }
+
+

+ + + + +
+ + + + + + + + + +
virtual sint NL3D::CDriverGL::beginMaterialMultiPass  )  [inline, virtual]
+
+ + + + + +
+   + + +

+init multipass for _CurrentMaterial. return number of pass required to render this material. +

+NB: setupMaterial() must be called before thoses methods. NB: This is intended to be use with the rendering of simple primitives. NB: Other render calls performs the needed setup automatically +

+Implements NL3D::IDriver. +

+Definition at line 506 of file driver_opengl.h. +

+References beginMultiPass(), and sint. +

+

00506 {       return beginMultiPass(); }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginMultiPass  )  [private]
+
+ + + + + +
+   + + +

+init multipass for _CurrentMaterial. return number of pass required to render this material. +

+NB: setupMaterial() must be called before thoses methods. +

+Definition at line 529 of file driver_opengl_material.cpp. +

+References _CurrentMaterialSupportedShader, beginCloudMultiPass(), beginLightMapMultiPass(), beginPPLMultiPass(), beginPPLNoSpecMultiPass(), beginSpecularMultiPass(), beginWaterMultiPass(), and sint. +

+Referenced by beginMaterialMultiPass(), render(), renderOrientedQuads(), renderPoints(), renderQuads(), and renderTriangles(). +

+

00530 {
+00531         // Depending on material type and hardware, return number of pass required to draw this material.
+00532         switch(_CurrentMaterialSupportedShader)
+00533         {
+00534         case CMaterial::LightMap: 
+00535                 return  beginLightMapMultiPass();
+00536         case CMaterial::Specular: 
+00537                 return  beginSpecularMultiPass();
+00538         case CMaterial::Water:
+00539                 return  beginWaterMultiPass();
+00540         case CMaterial::PerPixelLighting:
+00541                 return  beginPPLMultiPass();
+00542         case CMaterial::PerPixelLightingNoSpec:
+00543                 return  beginPPLNoSpecMultiPass();      
+00544         /* case CMaterial::Caustics:
+00545                 return  beginCausticsMultiPass(); */
+00546         case CMaterial::Cloud:
+00547                 return  beginCloudMultiPass();
+00548 
+00549         // All others materials require just 1 pass.
+00550         default: return 1;
+00551         }
+00552 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginPPLMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1367 of file driver_opengl_material.cpp. +

+References nlassert, sint, and supportPerPixelLighting(). +

+Referenced by beginMultiPass(). +

+

01368 {
+01369         #ifdef NL_DEBUG
+01370                 nlassert(supportPerPixelLighting(true)); // make sure the hardware can do that
+01371         #endif
+01372         return 1;
+01373 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginPPLNoSpecMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1552 of file driver_opengl_material.cpp. +

+References nlassert, sint, and supportPerPixelLighting(). +

+Referenced by beginMultiPass(). +

+

01553 {
+01554         #ifdef NL_DEBUG
+01555                 nlassert(supportPerPixelLighting(false)); // make sure the hardware can do that
+01556         #endif
+01557         return 1;
+01558 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginSpecularMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1035 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _Extensions, _SpecularBatchOn, activateTexture(), NL3D::CGlExtensions::ARBTextureCubeMap, NL3D::CGlExtensions::ATIXTextureEnvCombine3, NL3D::CMaterial::getTexture(), inlGetNumTextStages(), min, NL3D::CGlExtensions::NVTextureEnvCombine4, setupSpecularBegin(), sint, and uint. +

+Referenced by beginMultiPass(). +

+

01036 {
+01037         const CMaterial &mat= *_CurrentMaterial;
+01038 
+01039         // activate the 2 textures here
+01040         uint    stage;
+01041         uint    numStages= std::min(2, inlGetNumTextStages());
+01042         for(stage=0 ; stage<numStages; stage++)
+01043         {
+01044                 ITexture        *text= mat.getTexture(stage);
+01045 
+01046                 // activate the texture, or disable texturing if NULL.
+01047                 activateTexture(stage,text);
+01048         }
+01049 
+01050         // End specular , only if not Batching mode.
+01051         if(!_SpecularBatchOn)
+01052                 setupSpecularBegin();
+01053 
+01054         // Manage the rare case when the SpecularMap is not provided (fault of graphist).
+01055         if(mat.getTexture(1)==NULL)
+01056                 return 1;
+01057 
+01058         if(!_Extensions.ARBTextureCubeMap)
+01059                 return 1;
+01060         
+01061         if( _Extensions.NVTextureEnvCombine4 || _Extensions.ATIXTextureEnvCombine3) // NVidia or ATI optimization
+01062                 return 1;
+01063         else
+01064                 return 2;
+01065 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::beginWaterMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1866 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, NL3D::CMaterial::getShader(), nlassert, and sint. +

+Referenced by beginMultiPass(). +

+

01867 {
+01868         nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
+01869         return 1;
+01870 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::checkForPerPixelLightingSupport  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2427 of file driver_opengl.cpp. +

+References _Extensions, _SupportPerPixelShader, _SupportPerPixelShaderNoSpec, NL3D::CGlExtensions::ARBTextureCubeMap, NL3D::CGlExtensions::ATIXTextureEnvCombine3, NL3D::CGlExtensions::EXTVertexShader, NL3D::CGlExtensions::NbTextureStages, NL3D::CGlExtensions::NVTextureEnvCombine4, and NL3D::CGlExtensions::NVVertexProgram. +

+

02428 {
+02429         // we need at least 3 texture stages and cube map support + EnvCombine4 or 3 support    
+02430         // TODO : support for EnvCombine3
+02431         // TODO : support for less than 3 stages
+02432 
+02433         _SupportPerPixelShaderNoSpec = (_Extensions.NVTextureEnvCombine4 || _Extensions.ATIXTextureEnvCombine3)
+02434                                                                    && _Extensions.ARBTextureCubeMap
+02435                                                                    && _Extensions.NbTextureStages >= 3
+02436                                                                    && (_Extensions.NVVertexProgram || _Extensions.EXTVertexShader);
+02437         
+02438         _SupportPerPixelShader = (_Extensions.NVTextureEnvCombine4 || _Extensions.ATIXTextureEnvCombine3) 
+02439                                                          && _Extensions.ARBTextureCubeMap
+02440                                                          && _Extensions.NbTextureStages >= 2
+02441                                                          && (_Extensions.NVVertexProgram || _Extensions.EXTVertexShader);       
+02442 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::cleanLightSetup  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 179 of file driver_opengl_light.cpp. +

+References _LightDirty, _LightEnable, _LightMode, _LightSetupDirty, _MaxDriverLight, _PZBCameraPos, _ViewMtx, _WorldLightDirection, _WorldLightPos, NLMISC::CMatrix::get(), nlassert, uint, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+Referenced by doRefreshRenderSetup(). +

+

00180 {
+00181         // Should be dirty
+00182         nlassert (_LightSetupDirty);
+00183         
+00184         // First light
+00185         bool first=true;
+00186 
+00187         // For each lights
+00188         for (uint i=0; i<_MaxDriverLight; i++)
+00189         {
+00190                 // Is this light enabled and dirty?
+00191                 if (_LightEnable[i] && _LightDirty[i])
+00192                 {
+00193                         // If first light
+00194                         if (first)
+00195                         {
+00196                                 first=false;
+00197 
+00198                                 // Push the matrix
+00199                                 glPushMatrix ();
+00200 
+00201                                 // Load the view matrix
+00202                                 glLoadMatrixf (_ViewMtx.get());
+00203                         }
+00204 
+00205                         // Light is directionnal ?
+00206                         if (_LightMode[i]==(uint)CLight::DirectionalLight)
+00207                         {
+00208                                 // GL vector
+00209                                 GLfloat vectorGL[4];
+00210 
+00211                                 // Set the GL array
+00212                                 vectorGL[0]=-_WorldLightDirection[i].x;
+00213                                 vectorGL[1]=-_WorldLightDirection[i].y;
+00214                                 vectorGL[2]=-_WorldLightDirection[i].z;
+00215                                 vectorGL[3]=0.f;
+00216         
+00217                                 // Set it
+00218                                 glLightfv ((GLenum)(GL_LIGHT0+i), (GLenum)GL_POSITION, vectorGL);
+00219                         }
+00220 
+00221                         // Spotlight ?
+00222                         if (_LightMode[i]==(uint)CLight::SpotLight)
+00223                         {
+00224                                 // GL vector
+00225                                 GLfloat vectorGL[4];
+00226 
+00227                                 // Set the GL array
+00228                                 vectorGL[0]=_WorldLightDirection[i].x;
+00229                                 vectorGL[1]=_WorldLightDirection[i].y;
+00230                                 vectorGL[2]=_WorldLightDirection[i].z;
+00231         
+00232                                 // Set it
+00233                                 glLightfv ((GLenum)(GL_LIGHT0+i), (GLenum)GL_SPOT_DIRECTION, vectorGL);
+00234                         }
+00235 
+00236                         // Position 
+00237                         if (_LightMode[i]!=(uint)CLight::DirectionalLight)
+00238                         {
+00239                                 // GL vector
+00240                                 GLfloat vectorGL[4];
+00241 
+00242                                 // Set the GL array
+00243                                 // Must Substract CameraPos, because ViewMtx may not be the exact view.
+00244                                 vectorGL[0]=_WorldLightPos[i].x - _PZBCameraPos.x;
+00245                                 vectorGL[1]=_WorldLightPos[i].y - _PZBCameraPos.y;
+00246                                 vectorGL[2]=_WorldLightPos[i].z - _PZBCameraPos.z;
+00247                                 vectorGL[3]=1.f;
+00248         
+00249                                 // Set it
+00250                                 glLightfv ((GLenum)(GL_LIGHT0+i), (GLenum)GL_POSITION, vectorGL);
+00251                         }
+00252 
+00253                         // Cleaned!
+00254                         _LightDirty[i]= false;
+00255                 }
+00256         }
+00257 
+00258         // Pop old matrix
+00259         if (!first)
+00260                 glPopMatrix ();
+00261 
+00262         // Clean flag
+00263         _LightSetupDirty=false;
+00264 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::clear2D CRGBA  rgba  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1511 of file driver_opengl.cpp. +

+References NLMISC::CRGBA::A, NLMISC::CRGBA::B, NLMISC::CRGBA::G, and NLMISC::CRGBA::R. +

+

01512 {
+01513         glClearColor((float)rgba.R/255.0f,(float)rgba.G/255.0f,(float)rgba.B/255.0f,(float)rgba.A/255.0f);
+01514         glClear(GL_COLOR_BUFFER_BIT);
+01515         return true;
+01516 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::clearZBuffer float  zval = 1  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1520 of file driver_opengl.cpp. +

+References _DriverGLStates, and NL3D::CDriverGLStates::enableZWrite(). +

+

01521 {
+01522         glClearDepth(zval);
+01523         _DriverGLStates.enableZWrite(true);
+01524         glClear(GL_DEPTH_BUFFER_BIT);
+01525         return true;
+01526 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::clipRect NLMISC::CRect rect  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2111 of file driver_opengl.cpp. +

+References NLMISC::CRect::bottom(), NLMISC::clamp(), getWindowSize(), NLMISC::CRect::Height, height, NLMISC::CRect::right(), sint32, uint32, NLMISC::CRect::Width, width, NLMISC::CRect::X, and NLMISC::CRect::Y. +

+Referenced by getBufferPart(), and getZBufferPart(). +

+

02112 {
+02113         // Clip the wanted rectangle with window.
+02114         uint32 width, height;
+02115         getWindowSize(width, height);
+02116 
+02117         sint32  xr=rect.right() ,yr=rect.bottom();
+02118         
+02119         clamp((sint32&)rect.X, (sint32)0, (sint32)width);
+02120         clamp((sint32&)rect.Y, (sint32)0, (sint32)height);
+02121         clamp((sint32&)xr, (sint32)rect.X, (sint32)width);
+02122         clamp((sint32&)yr, (sint32)rect.Y, (sint32)height);
+02123         rect.Width= xr-rect.X;
+02124         rect.Height= yr-rect.Y;
+02125 
+02126         return rect.Width>0 && rect.Height>0;
+02127 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::computeLightMapInfos const CMaterial mat  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 619 of file driver_opengl_material.cpp. +

+References _Extensions, _LightMapLUT, NL3D::CMaterial::_LightMaps, _NLightMapPass, _NLightMapPerPass, _NLightMaps, NL3D::CGlExtensions::ATIXTextureEnvCombine3, inlGetNumTextStages(), NL3D_DRV_MAX_LIGHTMAP, nlassert, NL3D::CGlExtensions::NVTextureEnvCombine4, uint, and uint32. +

+Referenced by beginLightMapMultiPass(). +

+

00620 {
+00621         static const uint32 RGBMaskPacked = CRGBA(255,255,255,0).getPacked();
+00622 
+00623         // For optimisation consideration, suppose there is not too much lightmap.
+00624         nlassert(mat._LightMaps.size()<=NL3D_DRV_MAX_LIGHTMAP);
+00625 
+00626         // Compute number of lightmaps really used (ie factor not NULL), and build the LUT.
+00627         _NLightMaps = 0;
+00628         // For all lightmaps of the material.
+00629         for (uint i = 0; i < mat._LightMaps.size(); ++i)
+00630         {
+00631                 // If the lightmap's factor is not null.
+00632                 if (mat._LightMaps[i].Factor.getPacked() & RGBMaskPacked)
+00633                 {
+00634                         _LightMapLUT[_NLightMaps] = i;
+00635                         ++_NLightMaps;
+00636                 }
+00637         }
+00638 
+00639         // Compute how many pass, according to driver caps.
+00640         _NLightMapPerPass = inlGetNumTextStages()-1;
+00641         // Can do more than 2 texture stages only if NVTextureEnvCombine4 or ATIXTextureEnvCombine3
+00642         if (!_Extensions.NVTextureEnvCombine4 && !_Extensions.ATIXTextureEnvCombine3)
+00643                 _NLightMapPerPass = 1;
+00644 
+00645         // Number of pass.
+00646         _NLightMapPass = (_NLightMaps + _NLightMapPerPass-1)/(_NLightMapPerPass);
+00647 
+00648         // NB: _NLightMaps==0 means there is no lightmaps at all.
+00649 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
uint NL3D::CDriverGL::computeMipMapMemoryUsage uint  w,
uint  h,
GLint  glfmt
const [private]
+
+ + + + + +
+   + + +

+??? +

+Definition at line 215 of file driver_opengl_texture.cpp. +

+References GL_DSDT_NV, GL_DU8DV8_ATI, nlstop, uint, and w. +

+Referenced by setupTextureEx(). +

+

00216 {
+00217         switch(glfmt)
+00218         {
+00219         case GL_RGBA8:          return w*h* 4;
+00220         // Well this is ugly, but simple :). GeForce 888 is stored as 32 bits.
+00221         case GL_RGB8:           return w*h* 4;
+00222         case GL_RGBA4:          return w*h* 2;
+00223         case GL_RGB5_A1:        return w*h* 2;
+00224         case GL_RGB5:           return w*h* 2;
+00225         case GL_LUMINANCE8:     return w*h* 1;
+00226         case GL_ALPHA8:         return w*h* 1;
+00227         case GL_LUMINANCE8_ALPHA8:      return w*h* 2;
+00228         case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:   return w*h /2;
+00229         case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:  return w*h /2;
+00230         case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:  return w*h* 1;
+00231         case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:  return w*h* 1;
+00232         case GL_DU8DV8_ATI:
+00233         case GL_DSDT_NV:                                                return w*h* 2;
+00234         };
+00235 
+00236         // One format has not been coded.
+00237         nlstop;
+00238 
+00240         return w*h* 4;
+00241 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::copyFrameBufferToTexture ITexture tex,
uint32  level,
uint32  offsetx,
uint32  offsety,
uint32  x,
uint32  y,
uint32  width,
uint32  height
[virtual]
+
+ + + + + +
+   + + +

+Copy a portion of the FrameBuffer into a texture. The texture must have been right sized before the call. This mark the texture as valid, but doesn't copy data to system memory. This also mean that regenerating texture datas will erase what has been copied before in the device memory. This doesn't work with compressed textures. Ideally, the FrameBuffer should have the same format than the texture.

Parameters:
+ + + + + + + + + +
tex the texture to copy to.
level the mipmap to copy texture to.
xoffset x position within the destination texture
yoffset y position within the destination texture
x x position widthin the framebuffer
y y position widthin the framebuffer
width width of the area to be copied.
height height of the area to be copied.
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2185 of file driver_opengl.cpp. +

+References _CurrentTexture, _CurrentTextureInfoGL, _DriverGLStates, NL3D::CDriverGLStates::activeTextureARB(), getGlTextureFormat(), height, NL3D::CTextureDrvInfosGL::ID, NL3D::ITexture::isTextureCube(), level, nlassert, NL3D::CDriverGLStates::setTextureMode(), setupTexture(), NL3D::ITexture::TextureDrvShare, uint32, width, x, and y. +

+

02194 {
+02195         nlassert(!tex->isTextureCube());
+02196         bool compressed = false;
+02197         getGlTextureFormat(*tex, compressed);
+02198         nlassert(!compressed);  
+02199         // first, mark the texture as valid, and make sure there is a corresponding texture in the device memory        
+02200         setupTexture(*tex);     
+02201         CTextureDrvInfosGL*     gltext = (CTextureDrvInfosGL*)(ITextureDrvInfos*)(tex->TextureDrvShare->DrvTexture);
+02202         _DriverGLStates.activeTextureARB(0);
+02203         // setup texture mode, after activeTextureARB()
+02204         _DriverGLStates.setTextureMode(CDriverGLStates::Texture2D);
+02205         glBindTexture(GL_TEXTURE_2D, gltext->ID);       
+02206         glCopyTexSubImage2D(GL_TEXTURE_2D, level, offsetx, offsety, x, y, width, height);       
+02207         // disable texturing.
+02208         _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
+02209         _CurrentTexture[0] = NULL;
+02210         _CurrentTextureInfoGL[0] = NULL;
+02211 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
virtual IVertexBufferHard* NL3D::IDriver::createVertexBufferHard uint16  vertexFormat,
const uint8 typeArray,
uint32  numVertices,
TVBHardType  vbType,
const uint8 uvRouting
[pure virtual, inherited]
+
+ + + + + +
+   + + +

+create a IVertexBufferHard. delete it with deleteVertexBufferHard. NB: user should (must) keep a CRefPtr<> on this ptr, because if driver is deleted (for any reason) the pointer will be no longer valid.

+NB: return NULL if driver do not support the requested VertexBufferHard.Reason for failures are:

    +
  • Driver do not support VertexBufferHard at all. ie supportVertexBufferHard() return false.
  • Driver do not support the vbType wanted or the vertexFormat for vertexBufferHard
  • Driver do not support the numVertices wanted.
  • Driver can't allocate any more ressource.
+

+

Parameters:
+ + + + + +
vertexFormat see CVertexBuffer::setVertexFormat().
numVertices the number of vertices to be created.
vbType kind of RAM shere the VB will be allocated.
uvRouting is the uv routing table. If NULL, set the default routing table.
+
+
Returns:
a vertexBufferHard interface.
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IVertexBufferHard * NL3D::CDriverGL::createVertexBufferHard uint16  vertexFormat,
const uint8 typeArray,
uint32  numVertices,
IDriver::TVBHardType  vbType,
const uint8 uvRouting
[virtual]
+
+ + + + + +
+   + + +

+ +

+Definition at line 516 of file driver_opengl_vertex.cpp. +

+References _AGPVertexArrayRange, _MaxVerticesByVBHard, _VertexBufferHardSet, _VRAMVertexArrayRange, NL3D::IVertexArrayRange::createVBHardGL(), NL3D::CPtrSet< IVertexBufferHardGL >::insert(), uint16, uint32, and uint8. +

+

00517 {
+00518         // choose the VertexArrayRange of good type
+00519         IVertexArrayRange       *vertexArrayRange= NULL;
+00520         switch(vbType)
+00521         {
+00522         case IDriver::VBHardAGP: 
+00523                 vertexArrayRange= _AGPVertexArrayRange;
+00524                 break;
+00525         case IDriver::VBHardVRAM:
+00526                 vertexArrayRange= _VRAMVertexArrayRange;
+00527                 break;
+00528         };
+00529 
+00530         // If this one at least created (an extension support it).
+00531         if( !vertexArrayRange )
+00532                 return NULL;
+00533         else
+00534         {
+00535                 // check max vertex
+00536                 if(numVertices > _MaxVerticesByVBHard)
+00537                         return NULL;
+00538 
+00539                 // Create a CVertexBufferHardGL
+00540                 IVertexBufferHardGL             *vb;
+00541                 // let the VAR create the vbhard.
+00542                 vb= vertexArrayRange->createVBHardGL(vertexFormat, typeArray, numVertices, uvRouting);
+00543                 // if fails
+00544                 if(!vb)
+00545                 {
+00546                         return NULL;
+00547                 }
+00548                 else
+00549                 {
+00550                         // insert in list.
+00551                         return _VertexBufferHardSet.insert(vb);
+00552                 }
+00553         }
+00554 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::deleteARBFragmentPrograms  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2996 of file driver_opengl.cpp. +

+References ARBWaterShader, GLuint(), nglDeleteProgramsARB, and uint. +

+Referenced by deleteFragmentShaders(), and initFragmentShaders(). +

+

02997 {
+02998         for(uint k = 0; k < 4; ++k)
+02999         {
+03000                 if (ARBWaterShader[k])
+03001                 {
+03002                         GLuint progId = (GLuint) ARBWaterShader[k];
+03003                         nglDeleteProgramsARB(1, &progId);
+03004                         ARBWaterShader[k] = 0;
+03005                 }
+03006         }
+03007 
+03008 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::deleteFragmentShaders  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 3011 of file driver_opengl.cpp. +

+References ATIWaterShaderHandle, ATIWaterShaderHandleNoDiffuseMap, deleteARBFragmentPrograms(), GLuint(), and nglDeleteFragmentShaderATI. +

+Referenced by release(). +

+

03012 {       
+03013         deleteARBFragmentPrograms();
+03014         if (ATIWaterShaderHandleNoDiffuseMap)
+03015         {               
+03016                 nglDeleteFragmentShaderATI((GLuint) ATIWaterShaderHandleNoDiffuseMap);          
+03017                 ATIWaterShaderHandleNoDiffuseMap = 0;
+03018         }
+03019         if (ATIWaterShaderHandle)
+03020         {               
+03021                 nglDeleteFragmentShaderATI((GLuint) ATIWaterShaderHandle);              
+03022                 ATIWaterShaderHandle = 0;
+03023         }
+03024 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::deleteVertexBufferHard IVertexBufferHard VB  )  [virtual]
+
+ + + + + +
+   + + +

+delete a IVertexBufferHard. NB: VertexBufferHard are automatically deleted at IDriver::release(); +

+Implements NL3D::IDriver. +

+Definition at line 558 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _VertexBufferHardSet, NL3D::IVertexBufferHardGL::disable(), NL3D::CPtrSet< IVertexBufferHardGL >::erase(), NL3D::IVertexBufferHard::lock(), and NL3D::IVertexBufferHard::unlock(). +

+

00559 {
+00560         // If one _CurrentVertexBufferHard enabled, first End its drawning, and disable it.
+00561         // This is very important, because after deletion, the space is free. 
+00562         // If the GPU has not finisehd his drawing, and if any allocation occurs on this free space, and if 
+00563         // the user locks to fill this space (feww!) Then some data crash may results....
+00564         if(_CurrentVertexBufferHard)
+00565         {
+00566                 // Must ensure it has ended any drawing
+00567                 _CurrentVertexBufferHard->lock();
+00568                 _CurrentVertexBufferHard->unlock();
+00569                 // disable the VBHard.
+00570                 _CurrentVertexBufferHard->disable();
+00571         }
+00572 
+00573         // Then just delete the VBuffer hard from list.
+00574         _VertexBufferHardSet.erase(safe_cast<IVertexBufferHardGL*>(VB));
+00575 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::disableHardwareTextureShader  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 392 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::DisableHardwareTextureShader. +

+

00393 {
+00394         _Extensions.DisableHardwareTextureShader= true;
+00395 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::disableHardwareVertexArrayAGP  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 387 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::DisableHardwareVertexArrayAGP. +

+

00388 {
+00389         _Extensions.DisableHardwareVertexArrayAGP= true;
+00390 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::disableHardwareVertexProgram  )  [virtual]
+
+ + + + + +
+   + + +

+Disable some Feature that may be supported by the Hardware Call before setDisplay() to work properly +

+Implements NL3D::IDriver. +

+Definition at line 382 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::DisableHardwareVertexProgram. +

+

00383 {
+00384         _Extensions.DisableHardwareVertexProgram= true;
+00385 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::disableUserTextureMatrix  ) 
+
+ + + + + +
+   + + +

+disable all texture matrix +

+ +

+Definition at line 197 of file driver_opengl_material.cpp. +

+References _DriverGLStates, _UserTexMatEnabled, NL3D::CDriverGLStates::activeTextureARB(), and uint. +

+Referenced by setupMaterial(). +

+

00198 { 
+00199         if (_UserTexMatEnabled != 0)            
+00200         {
+00201                 glMatrixMode(GL_TEXTURE);               
+00202                 uint k = 0;
+00203                 do
+00204                 {
+00205                         if (_UserTexMatEnabled & (1 << k)) // user matrix for this stage
+00206                         {                                               
+00207                                 _DriverGLStates.activeTextureARB(k);
+00208                                 glLoadIdentity();
+00209                                 _UserTexMatEnabled &= ~ (1 << k);
+00210                                                                 
+00211                         }                       
+00212                         ++k;
+00213                 }
+00214                 while (_UserTexMatEnabled != 0);
+00215                 glMatrixMode(GL_MODELVIEW);
+00216         }
+00217 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::doRefreshRenderSetup  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 156 of file driver_opengl_matrix.cpp. +

+References _ForceNormalize, _LightSetupDirty, _ModelViewMatrix, _ModelViewMatrixDirty, _RenderSetupDirty, cleanLightSetup(), enableGlNormalize(), NLMISC::CMatrix::get(), NLMISC::CMatrix::hasScalePart(), and nlassert. +

+Referenced by refreshRenderSetup(). +

+

00157 {
+00158         // Check if the light setup has been modified first
+00159         if (_LightSetupDirty)
+00160                 // Recompute light setup
+00161                 cleanLightSetup ();
+00162 
+00163         // Check light setup is good
+00164         nlassert (_LightSetupDirty==false);
+00165 
+00166 
+00167         // Check if must update the modelViewMatrix
+00168         if( _ModelViewMatrixDirty )
+00169         {
+00170                 // By default, the first model matrix is active
+00171                 glLoadMatrixf( _ModelViewMatrix.get() );
+00172                 // enable normalize if matrix has scale.
+00173                 enableGlNormalize( _ModelViewMatrix.hasScalePart() || _ForceNormalize );
+00174                 // clear.
+00175                 _ModelViewMatrixDirty= false;
+00176         }
+00177 
+00178         // render setup is cleaned.
+00179         _RenderSetupDirty= false;
+00180 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::enableFog bool  enable  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2239 of file driver_opengl.cpp. +

+References _DriverGLStates, _FogEnabled, and NL3D::CDriverGLStates::enableFog(). +

+

02240 {
+02241         _DriverGLStates.enableFog(enable);
+02242         _FogEnabled= enable;
+02243 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::enableGlNormalize bool  normalize  )  [inline, private]
+
+ + + + + +
+   + + +

+Test/activate normalisation of normal. +

+ +

+Definition at line 852 of file driver_opengl.h. +

+References _CurrentGlNormalize. +

+Referenced by doRefreshRenderSetup(), and forceNormalize(). +

+

00853         {
+00854                 if(_CurrentGlNormalize!=normalize)
+00855                 {
+00856                         _CurrentGlNormalize= normalize;
+00857                         if(normalize)
+00858                                 glEnable(GL_NORMALIZE);
+00859                         else
+00860                                 glDisable(GL_NORMALIZE);
+00861                 }
+00862         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::enableLight uint8  num,
bool  enable = true
[virtual]
+
+ + + + + +
+   + + +

+Enable / disable light.

+You must call setLight() if you active the ligth.

+

Parameters:
+ + + +
num is the number of the light to enable / disable.
enable is true to enable the light, false to disable it.
+
+
See also:
setLight()
+ +

+Implements NL3D::IDriver. +

+Definition at line 135 of file driver_opengl_light.cpp. +

+References _LightDirty, _LightEnable, _LightSetupDirty, _MaxDriverLight, _RenderSetupDirty, num, and uint8. +

+

00136 {
+00137         // Check light count is good
+00138 //      nlassert (num<_MaxDriverLight);
+00139 
+00140         // Enable glLight
+00141         if (num<_MaxDriverLight)
+00142         {
+00143                 // Enable the light
+00144                 _LightEnable[num]=enable;
+00145 
+00146                 // Enable GL
+00147                 if (enable)
+00148                 {
+00149                         glEnable ((GLenum)(GL_LIGHT0+num));
+00150                         // If this light is dirty, and reenabled, then it must be refresh at next render => set the global flag.
+00151                         if(_LightDirty[num])
+00152                         {
+00153                                 _LightSetupDirty= true;
+00154                                 _RenderSetupDirty= true;
+00155                         }
+00156                 }
+00157                 else
+00158                         glDisable ((GLenum)(GL_LIGHT0+num));
+00159         }
+00160 }
+
+

+ + + + +
+ + + + + + + + + + +
NLMISC::IKeyboardDevice * NL3D::CDriverGL::enableLowLevelKeyboard bool  enable  )  [virtual]
+
+ + + + + +
+   + + +

+Enable / disable a low level keyboard. Such a keyboard can only send KeyDown and KeyUp event. It just consider the keyboard as a gamepad with lots of buttons... This returns a interface to some parameters when it is supported, or NULL otherwise. The interface pointer is valid as long as the low level keyboard is enabled. A call to disable the keyboard returns NULL, and restore the default keyboard behaviour +

+Implements NL3D::IDriver. +

+Definition at line 2487 of file driver_opengl.cpp. +

+

02488 {
+02489 #ifdef NL_OS_WINDOWS
+02490                 if (_EventEmitter.getNumEmitters() < 2) return NULL;
+02491                 NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast<NLMISC::CDIEventEmitter *>(_EventEmitter.getEmitter(1));
+02492                 if (enable)
+02493                 {
+02494                         try
+02495                         {
+02496                                 NLMISC::IKeyboardDevice *md = diee->getKeyboardDevice();
+02497                                 return md;
+02498                         }
+02499                         catch (EDirectInput &)
+02500                         {
+02501                                 return NULL;
+02502                         }
+02503                 }
+02504                 else
+02505                 {
+02506                         diee->releaseKeyboard();
+02507                         return NULL;
+02508                 }
+02509 #else
+02510                 return NULL;
+02511 #endif
+02512 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
NLMISC::IMouseDevice * NL3D::CDriverGL::enableLowLevelMouse bool  enable,
bool  exclusive
[virtual]
+
+ + + + + +
+   + + +

+Enable / disable low level mouse. This allow to take advantage of some options (speed of the mouse, automatic wrapping) It returns a interface to these parameters when it is supported, or NULL otherwise The interface pointer is valid as long as the low level mouse is enabled. A call to disable the mouse returns NULL, and restore the default mouse behaviour NB : - In this mode the mouse cursor isn't drawn.

    +
  • Calls to showCursor have no effects
      +
    • Calls to setCapture have no effects
    +
+ +

+Implements NL3D::IDriver. +

+Definition at line 2459 of file driver_opengl.cpp. +

+

02460 {
+02461 #ifdef NL_OS_WINDOWS
+02462                 if (_EventEmitter.getNumEmitters() < 2) return NULL;
+02463                 NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast<CDIEventEmitter *>(_EventEmitter.getEmitter(1));              
+02464                 if (enable)
+02465                 {
+02466                         try
+02467                         {
+02468                                 NLMISC::IMouseDevice *md = diee->getMouseDevice(exclusive);
+02469                                 return md;
+02470                         }
+02471                         catch (EDirectInput &)
+02472                         {
+02473                                 return NULL;
+02474                         }
+02475                 }
+02476                 else
+02477                 {
+02478                         diee->releaseMouse();                   
+02479                         return NULL;
+02480                 }
+02481 #else
+02482                 return NULL;
+02483 #endif
+02484 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::enableNVTextureShader bool  enabled  )  [private]
+
+ + + + + +
+   + + +

+nv texture shaders. Should be used only if this caps is present! +

+ +

+Definition at line 2409 of file driver_opengl.cpp. +

+References _NVTextureShaderEnabled, and GL_TEXTURE_SHADER_NV. +

+Referenced by setupMaterial(), and setupWaterPassNV20(). +

+

02410 {               
+02411         if (enabled != _NVTextureShaderEnabled)
+02412         {
+02413 
+02414                 if (enabled)
+02415                 {                                                       
+02416                         glEnable(GL_TEXTURE_SHADER_NV);                 
+02417                 }
+02418                 else
+02419                 {                                               
+02420                         glDisable(GL_TEXTURE_SHADER_NV);                
+02421                 }
+02422                 _NVTextureShaderEnabled = enabled;
+02423         }       
+02424 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::enablePolygonSmoothing bool  smooth  )  [virtual]
+
+ + + + + +
+   + + +

+Use AntiAliasing For polygons (GL_POLYGON_SMOOTH like, not the FSAA). See GL_POLYGON_SMOOTH help, and GL_SRC_ALPHA_SATURATE OpenGL doc (not yet implemented now since used only for alpha part in ShadowMap gen) +

+Implements NL3D::IDriver. +

+Definition at line 3061 of file driver_opengl.cpp. +

+References _PolygonSmooth. +

+

03062 {
+03063         if(smooth)
+03064                 glEnable(GL_POLYGON_SMOOTH);
+03065         else
+03066                 glDisable(GL_POLYGON_SMOOTH);
+03067         _PolygonSmooth= smooth;
+03068 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::enableUsedTextureMemorySum bool  enable  )  [virtual]
+
+ + + + + +
+   + + +

+Enable the sum of texture memory used since last swapBuffers() call. To retrieve the memory used call getUsedTextureMemory(). +

+Implements NL3D::IDriver. +

+Definition at line 2334 of file driver_opengl.cpp. +

+References _SumTextureMemoryUsed, and nlinfo. +

+

02335 {
+02336         if (enable)
+02337                 nlinfo ("PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL\n");
+02338         _SumTextureMemoryUsed=enable;
+02339 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::enableVertexProgramDoubleSidedColor bool  doubleSided  )  [private, virtual]
+
+ + + + + +
+   + + +

+Activate VertexProgram 2Sided Color mode. In 2Sided mode, the BackFace (if material 2Sided enabled) read the result from o[BFC0], and not o[COL0]. default is false. you should reset to false after use. NB: no-op if not supporte by driver +

+Implements NL3D::IDriver. +

+Definition at line 1427 of file driver_opengl_vertex_program.cpp. +

+References _Extensions, GL_VERTEX_PROGRAM_TWO_SIDE_NV, and NL3D::CGlExtensions::NVVertexProgram. +

+

01428 {
+01429         // Vertex program exist ?
+01430         if (_Extensions.NVVertexProgram)
+01431         {
+01432                 // change mode (not cached because supposed to be rare)
+01433                 if(doubleSided)
+01434                         glEnable (GL_VERTEX_PROGRAM_TWO_SIDE_NV);
+01435                 else
+01436                         glDisable (GL_VERTEX_PROGRAM_TWO_SIDE_NV);
+01437         }       
+01438 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endCloudMultiPass  )  [private]
+
+ + + + + +
+   + + +

+

Todo:
Optimize the cloud multipass with register combiner
+ +

+Definition at line 1859 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, NL3D::CMaterial::getShader(), and nlassert. +

+Referenced by endMultiPass(). +

+

01860 {
+01861         nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
+01862 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endLightMapMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 920 of file driver_opengl_material.cpp. +

+References _CurrentFogColor, _CurrentMaterial, _DriverGLStates, _FogEnabled, _LastVertexSetupIsLightMap, NL3D::CMaterial::_LightMapsMulx2, _NLightMapPass, _NLightMapPerPass, NL3D::CDriverGLStates::activeTextureARB(), and uint32. +

+Referenced by endMultiPass(). +

+

00921 {
+00922         // Cache it. reseted in setupGLArrays(), and setupMaterial()
+00923         _LastVertexSetupIsLightMap= true;
+00924 
+00925         // If multi-pass, then must reset the fog color
+00926         if(_NLightMapPass>=2 && _FogEnabled)
+00927         {
+00928                 glFogfv(GL_FOG_COLOR, _CurrentFogColor);
+00929         }
+00930 
+00931         // nothing to do with blending/lighting, since always setuped in activeMaterial().
+00932         // If material is the same, then it is still a lightmap material (if changed => touched => different!)
+00933         // So no need to reset lighting/blending here.
+00934 
+00935         // Clean up all stage for Multiply x 2
+00936         if (_CurrentMaterial->_LightMapsMulx2)
+00937         {
+00938                 for (uint32 i = 0; i < (_NLightMapPerPass+1); ++i)
+00939                 {
+00940                         _DriverGLStates.activeTextureARB(i);
+00941                         glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1);
+00942                 }
+00943         }
+00944 }
+
+

+ + + + +
+ + + + + + + + + +
virtual void NL3D::CDriverGL::endMaterialMultiPass  )  [inline, virtual]
+
+ + + + + +
+   + + +

+end multipass for this material. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 510 of file driver_opengl.h. +

+References endMultiPass(). +

+

00510 {       endMultiPass(); }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endMultiPass  )  [private]
+
+ + + + + +
+   + + +

+end multipass for this material. +

+ +

+Definition at line 587 of file driver_opengl_material.cpp. +

+References _CurrentMaterialSupportedShader, endCloudMultiPass(), endLightMapMultiPass(), endPPLMultiPass(), endPPLNoSpecMultiPass(), endSpecularMultiPass(), and endWaterMultiPass(). +

+Referenced by endMaterialMultiPass(), render(), renderOrientedQuads(), renderPoints(), renderQuads(), and renderTriangles(). +

+

00588 {
+00589         switch(_CurrentMaterialSupportedShader)
+00590         {
+00591         case CMaterial::LightMap: 
+00592                 endLightMapMultiPass();
+00593                 break;
+00594         case CMaterial::Specular: 
+00595                 endSpecularMultiPass();
+00596                 break;
+00597         case CMaterial::Water:
+00598                 endWaterMultiPass();
+00599                 return;
+00600         case CMaterial::PerPixelLighting:
+00601                 endPPLMultiPass();
+00602                 break;
+00603         case CMaterial::PerPixelLightingNoSpec:
+00604                 endPPLNoSpecMultiPass();
+00605                 break;  
+00606         /* case CMaterial::Caustics:
+00607                 endCausticsMultiPass();
+00608                 break; */
+00609         case CMaterial::Cloud:
+00610                 endCloudMultiPass();
+00611                 break;  
+00612         // All others materials do not require multi pass.
+00613         default: return;
+00614         }
+00615 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endPPLMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1545 of file driver_opengl_material.cpp. +

+Referenced by endMultiPass(). +

+

01546 {       
+01547         // nothing to do there ...
+01548 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endPPLNoSpecMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1638 of file driver_opengl_material.cpp. +

+Referenced by endMultiPass(). +

+

01639 {       
+01640         // nothing to do there ...
+01641 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::endProfileVBHardLock std::vector< std::string > &  result  )  [virtual]
+
+ + + + + +
+   + + +

+If the driver support it, stop profile VBHard locks, and "print" result No-Op if already profiling NB: The results are the Locks in Chronogical time (since last swapBuffers). Since multiple frame are summed, an "*" is marked againts the VBHard name to show if it was not always this one (ptr test and not name test) in the chronogical order. NB: if the driver does not support VBHard or VBHard profiling (like ATI VBHard), result is empty. NB: ???? string is displayed if the VBHard has no name or if was just deleted. +

+Implements NL3D::IDriver. +

+Definition at line 3093 of file driver_opengl.cpp. +

+References _NumVBHardProfileFrame, _VBHardProfiles, _VBHardProfiling, NL3D::CDriverGL::CVBHardProfile::AccumTime, NL3D::CDriverGL::CVBHardProfile::Change, NLMISC::smprintf(), NLMISC::toString(), uint, and NL3D::CDriverGL::CVBHardProfile::VBHard. +

+

03094 {
+03095         if(!_VBHardProfiling)
+03096                 return;
+03097 
+03098         // Fill infos.
+03099         result.clear();
+03100         result.resize(_VBHardProfiles.size() + 1);
+03101         float   total= 0;
+03102         for(uint i=0;i<_VBHardProfiles.size();i++)
+03103         {
+03104                 const   uint tmpSize= 256;
+03105                 char    tmp[tmpSize];
+03106                 CVBHardProfile  &vbProf= _VBHardProfiles[i];
+03107                 const char      *vbName;
+03108                 if(vbProf.VBHard && !vbProf.VBHard->getName().empty())
+03109                 {
+03110                         vbName= vbProf.VBHard->getName().c_str();
+03111                 }
+03112                 else
+03113                 {
+03114                         vbName= "????";
+03115                 }
+03116                 // Display in ms.
+03117                 float   timeLock= (float)CTime::ticksToSecond(vbProf.AccumTime)*1000 / max(_NumVBHardProfileFrame,1U);
+03118                 smprintf(tmp, tmpSize, "%16s%c: %2.3f ms", vbName, vbProf.Change?'*':' ', timeLock );
+03119                 total+= timeLock;
+03120 
+03121                 result[i]= tmp;
+03122         }
+03123         result[_VBHardProfiles.size()]= toString("Total: %2.3f", total);
+03124         
+03125         // clear.
+03126         _VBHardProfiling= false;
+03127         contReset(_VBHardProfiles);
+03128 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endSpecularBatch  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 977 of file driver_opengl_material.cpp. +

+References _SpecularBatchOn, and setupSpecularEnd(). +

+

00978 {
+00979         _SpecularBatchOn= false;
+00980 
+00981         setupSpecularEnd();
+00982 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endSpecularMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1236 of file driver_opengl_material.cpp. +

+References _SpecularBatchOn, and setupSpecularEnd(). +

+Referenced by endMultiPass(). +

+

01237 {
+01238         // End specular , only if not Batching mode.
+01239         if(!_SpecularBatchOn)
+01240                 setupSpecularEnd();
+01241 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::endWaterMultiPass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2179 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _Extensions, ARBWaterShader, ATIWaterShaderHandleNoDiffuseMap, NL3D::CMaterial::getShader(), GL_FRAGMENT_PROGRAM_ARB, GL_FRAGMENT_SHADER_ATI, nlassert, and NL3D::CGlExtensions::NVTextureShader. +

+Referenced by endMultiPass(). +

+

02180 {
+02181         nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
+02182         // NB : as fragment shaders / programms bypass the texture envs, no special env enum is added (c.f CTexEnvSpecial)
+02183         if (_Extensions.NVTextureShader) return;
+02184         if (ARBWaterShader[0])  
+02185         {
+02186                 glDisable(GL_FRAGMENT_PROGRAM_ARB);
+02187         }
+02188         else
+02189         if (ATIWaterShaderHandleNoDiffuseMap)   
+02190         {
+02191                 glDisable(GL_FRAGMENT_SHADER_ATI);                                              
+02192         }
+02196 }
+
+

+ + + + +
+ + + + + + + + + +
ModeList NL3D::CDriverGL::enumModes  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 358 of file driver_opengl.cpp. +

+References NL3D::GfxMode::Depth, NL3D::GfxMode::Height, NL3D::ModeList, sint, uint16, uint8, NL3D::GfxMode::Width, and NL3D::GfxMode::Windowed. +

+

00359 {
+00360         ModeList        ML;
+00361 #ifdef NL_OS_WINDOWS
+00362         DEVMODE         devmode;
+00363         sint            n;
+00364         GfxMode         Mode;
+00365 
+00366         n=0;
+00367         while( EnumDisplaySettings(NULL, n, &devmode) )
+00368         {
+00369                 Mode.Windowed=false;
+00370                 Mode.Width=(uint16)devmode.dmPelsWidth;
+00371                 Mode.Height=(uint16)devmode.dmPelsHeight;       
+00372                 Mode.Depth=(uint8)devmode.dmBitsPerPel; 
+00373                 ML.push_back(Mode);
+00374                 n++;    
+00375         }
+00376 #endif // NL_OS_WINDOWS
+00377         return ML;
+00378 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::fenceOnCurVBHardIfNeeded IVertexBufferHardGL newVBHard  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1319 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, NL3D::CVertexBufferHardGLNVidia::getLockHintStatic(), NL3D::IVertexBufferHardGL::GPURenderingAfterFence, NL3D::CVertexBufferHardGLNVidia::setFence(), and NL3D::IVertexBufferHardGL::VBType. +

+Referenced by activeVertexBuffer(), and activeVertexBufferHard(). +

+

01320 {
+01321         // If old is not a VBHard, or if not a NVidia VBHard, no-op.
+01322         if( _CurrentVertexBufferHard==NULL || !_CurrentVertexBufferHard->VBType == IVertexBufferHardGL::NVidiaVB)
+01323                 return;
+01324 
+01325         // if we do not activate the same (NB: newVBHard==NULL if not a VBHard).
+01326         if(_CurrentVertexBufferHard!=newVBHard)
+01327         {
+01328                 // get NVidia interface
+01329                 CVertexBufferHardGLNVidia       *vbHardNV= static_cast<CVertexBufferHardGLNVidia*>(_CurrentVertexBufferHard);
+01330 
+01331                 // If some render() have been done with this VB.
+01332                 if( vbHardNV->GPURenderingAfterFence )
+01333                 {
+01334                         /*
+01335                                 Since we won't work with this VB for a long time, we set a fence.
+01336 
+01337                                 NB: if the fence was previously set. NV_Fence Specification says that the new ONE replaces it.
+01338                                 This is EXACTLY what we wants, since the old one is no more interesting.
+01339 
+01340                                 NB: never insert a fence for said "Static Lock" VBHard. Those VBHard are said to be "static"
+01341                                 therefore, user should never modify them (else lock() is much slower...)
+01342                         */
+01343                         if( !vbHardNV->getLockHintStatic() )
+01344                                 vbHardNV->setFence();
+01345                         // Since we have set a new Fence, we won't need to do it at next vbHardNV->lock()
+01346                         vbHardNV->GPURenderingAfterFence= false;
+01347                 }
+01348         }
+01349 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::fillBuffer CBitmap bitmap  )  [virtual]
+
+ + + + + +
+   + + +

+fill the RGBA back buffer

+

Parameters:
+ + +
bitmap will be written in the buffer. no-op if bad size.
+
+
Returns:
true if success
+ +

+Implements NL3D::IDriver. +

+Definition at line 2171 of file driver_opengl.cpp. +

+References NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getPixelFormat(), NLMISC::CBitmap::getPixels(), NLMISC::CBitmap::getWidth(), getWindowSize(), NLMISC::CRect::Height, and NLMISC::CRect::Width. +

+

02172 {
+02173         CRect   rect(0,0);
+02174         getWindowSize(rect.Width, rect.Height);
+02175         if( rect.Width!=bitmap.getWidth() || rect.Height!=bitmap.getHeight() || bitmap.getPixelFormat()!=CBitmap::RGBA )
+02176                 return false;
+02177 
+02178         glPixelStorei(GL_UNPACK_ALIGNMENT,1);
+02179         glDrawPixels (rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, &(bitmap.getPixels()[0]) );
+02180 
+02181         return true;
+02182 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::finish  )  [virtual]
+
+ + + + + +
+   + + +

+force the driver to flush all command. glFinish() in opengl. Interesting only for debug and profiling purpose. +

+Implements NL3D::IDriver. +

+Definition at line 3028 of file driver_opengl.cpp. +

+

03029 {
+03030         glFinish();
+03031 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::fogEnabled  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2234 of file driver_opengl.cpp. +

+References _FogEnabled. +

+

02235 {
+02236         return _FogEnabled;
+02237 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::forceActivateTexEnvColor uint  stage,
const CMaterial::CTexEnv env
[inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 712 of file driver_opengl.h. +

+References NL3D::CMaterial::CTexEnv::ConstantColor, forceActivateTexEnvColor(), and uint. +

+

00713         {       
+00714                 forceActivateTexEnvColor(stage, env.ConstantColor);     
+00715         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::forceActivateTexEnvColor uint  stage,
NLMISC::CRGBA  col
[inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 699 of file driver_opengl.h. +

+References _CurrentTexEnv, _DriverGLStates, NLMISC::CRGBA::A, NL3D::CDriverGLStates::activeTextureARB(), NLMISC::CRGBA::B, NL3D::CMaterial::CTexEnv::ConstantColor, NLMISC::CRGBA::G, NLMISC::CRGBA::R, and uint. +

+Referenced by activateTexEnvColor(), forceActivateTexEnvColor(), and swapBuffers(). +

+

00700         {
+00701                 static  const float     OO255= 1.0f/255;        
+00702                 _CurrentTexEnv[stage].ConstantColor= col;
+00703                 // Setup the gl cte color.
+00704                 _DriverGLStates.activeTextureARB(stage);
+00705                 GLfloat         glcol[4];
+00706                 glcol[0]= col.R*OO255;
+00707                 glcol[1]= col.G*OO255;
+00708                 glcol[2]= col.B*OO255;
+00709                 glcol[3]= col.A*OO255;
+00710                 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, glcol);        
+00711         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::forceActivateTexEnvMode uint  stage,
const CMaterial::CTexEnv env
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1054 of file driver_opengl_texture.cpp. +

+References _CurrentTexEnv, _CurrentTexEnvSpecial, _DriverGLStates, _Extensions, NL3D::CDriverGLStates::activeTextureARB(), NL3D::CMaterial::CTexEnv::Env, NL3D::CMaterial::CTexEnv::EnvPacked, NL3D::CGlExtensions::EXTTextureEnvCombine, GL_BUMP_ENVMAP_ATI, TexEnvSpecialDisabled, and uint. +

+Referenced by activateTexEnvMode(), and swapBuffers(). +

+

01055 {
+01056         // This maps the CMaterial::TTexOperator
+01057         static  const   GLenum  operatorLUT[9]= { GL_REPLACE, GL_MODULATE, GL_ADD, GL_ADD_SIGNED_EXT, 
+01058                 GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_INTERPOLATE_EXT, GL_BUMP_ENVMAP_ATI };
+01059 
+01060         // This maps the CMaterial::TTexSource
+01061         static  const   GLenum  sourceLUT[4]= { GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
+01062 
+01063         // This maps the CMaterial::TTexOperand
+01064         static  const   GLenum  operandLUT[4]= { GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };
+01065 
+01066         // This maps the CMaterial::TTexOperator, used for openGL Arg2 setup.
+01067         static  const   GLenum  interpolateSrcLUT[8]= { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, 
+01068                 GL_TEXTURE, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_CONSTANT_EXT };
+01069 
+01070 
+01071 
+01072         // cache mgt.
+01073         _CurrentTexEnv[stage].EnvPacked= env.EnvPacked;
+01074         // Disable Special tex env f().
+01075         _CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled;
+01076 
+01077 
+01078         // Setup the gl env mode.
+01079         _DriverGLStates.activeTextureARB(stage);
+01080         // "Normal drivers", setup EnvCombine.
+01081         if(_Extensions.EXTTextureEnvCombine)
+01082         {
+01083                 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01084 
+01085 
+01086                 // RGB.
+01087                 //=====
+01088                 // Operator.
+01089                 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, operatorLUT[env.Env.OpRGB] );
+01090                 // Arg0.
+01091                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, sourceLUT[env.Env.SrcArg0RGB] );
+01092                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, operandLUT[env.Env.OpArg0RGB]);
+01093                 // Arg1.
+01094                 if(env.Env.OpRGB > CMaterial::Replace)
+01095                 {
+01096                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, sourceLUT[env.Env.SrcArg1RGB] );
+01097                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, operandLUT[env.Env.OpArg1RGB]);
+01098                         // Arg2.
+01099                         if(env.Env.OpRGB >= CMaterial::InterpolateTexture )
+01100                         {
+01101                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, interpolateSrcLUT[env.Env.OpRGB] );
+01102                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
+01103                         }
+01104                 }
+01105 
+01106 
+01107                 // Alpha.
+01108                 //=====
+01109                 // Operator.
+01110                 glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, operatorLUT[env.Env.OpAlpha] );
+01111                 // Arg0.
+01112                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, sourceLUT[env.Env.SrcArg0Alpha] );
+01113                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, operandLUT[env.Env.OpArg0Alpha]);
+01114                 // Arg1.
+01115                 if(env.Env.OpAlpha > CMaterial::Replace)
+01116                 {
+01117                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, sourceLUT[env.Env.SrcArg1Alpha] );
+01118                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, operandLUT[env.Env.OpArg1Alpha]);
+01119                         // Arg2.
+01120                         if(env.Env.OpAlpha >= CMaterial::InterpolateTexture )
+01121                         {
+01122                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, interpolateSrcLUT[env.Env.OpAlpha] );
+01123                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
+01124                         }
+01125                 }
+01126         }
+01127         // Very Bad drivers.
+01128         else
+01129         {
+01130                 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+01131         }
+01132 
+01133 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::forceDXTCCompression bool  dxtcComp  )  [virtual]
+
+ + + + + +
+   + + +

+if true force all the uncompressed RGBA 32 bits and RGBA 24 bits texture to be DXTC5 compressed. Do this only during upload if ITexture::allowDegradation() is true and if ITexture::UploadFormat is "Automatic" and if bitmap format is RGBA. +

+Implements NL3D::IDriver. +

+Definition at line 1169 of file driver_opengl_texture.cpp. +

+References _ForceDXTCCompression. +

+

01170 {
+01171         _ForceDXTCCompression= dxtcComp;
+01172 }
+
+

+ + + + +
+ + + + + + + + + + +
virtual void NL3D::CDriverGL::forceNormalize bool  normalize  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Force input normal to be normalized by the driver. default is false. NB: driver force the normalisation himself if:

    +
  • current Model matrix has a scale.
+ +

+Implements NL3D::IDriver. +

+Definition at line 298 of file driver_opengl.h. +

+References _ForceNormalize, and enableGlNormalize(). +

+

00299         {
+00300                 _ForceNormalize= normalize;
+00301                 // if ForceNormalize, must enable GLNormalize now.
+00302                 if(normalize)
+00303                         enableGlNormalize(true);
+00304         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::forceTextureResize uint  divisor  )  [virtual]
+
+ + + + + +
+   + + +

+if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..) to be divided by Divisor (2, 4, 8...) Default is 1. NB: this is done only on TextureFile +

+Implements NL3D::IDriver. +

+Definition at line 1175 of file driver_opengl_texture.cpp. +

+References _ForceTextureResizePower, NLMISC::clamp(), NLMISC::getPowerOf2(), and uint. +

+

01176 {
+01177         clamp(divisor, 1U, 256U);
+01178 
+01179         // 16 -> 4.
+01180         _ForceTextureResizePower= getPowerOf2(divisor);
+01181 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::getAvailableVertexAGPMemory  )  [virtual]
+
+ + + + + +
+   + + +

+Return the amount of AGP memory allocated by initVertexArrayRange() to store vertices. +

+Implements NL3D::IDriver. +

+Definition at line 1299 of file driver_opengl_vertex.cpp. +

+References _AGPVertexArrayRange, NL3D::IVertexArrayRange::sizeAllocated(), and uint32. +

+Referenced by profileVBHardAllocation(). +

+

01300 {
+01301         if (_AGPVertexArrayRange)
+01302                 return _AGPVertexArrayRange->sizeAllocated();
+01303         else
+01304                 return 0;
+01305 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::getAvailableVertexVRAMMemory  )  [virtual]
+
+ + + + + +
+   + + +

+Return the amount of video memory allocated by initVertexArrayRange() to store vertices. +

+Implements NL3D::IDriver. +

+Definition at line 1309 of file driver_opengl_vertex.cpp. +

+References _VRAMVertexArrayRange, NL3D::IVertexArrayRange::sizeAllocated(), and uint32. +

+Referenced by profileVBHardAllocation(). +

+

01310 {
+01311         if (_VRAMVertexArrayRange)
+01312                 return _VRAMVertexArrayRange->sizeAllocated();
+01313         else
+01314                 return 0;
+01315 }
+
+

+ + + + +
+ + + + + + + + + +
uint8 NL3D::CDriverGL::getBitPerPixel  )  [virtual]
+
+ + + + + +
+   + + +

+Return the depth of the driver after init(). +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2054 of file driver_opengl.cpp. +

+References uint8. +

+

02055 {
+02056         return _Depth;
+02057 }
+
+

+ + + + +
+ + + + + + + + + +
NLMISC::CRGBA NL3D::CDriverGL::getBlendConstantColor  )  const [virtual]
+
+ + + + + +
+   + + +

+see supportBlendConstantColor(). Get the current Blend Constant Color. +

+Implements NL3D::IDriver. +

+Definition at line 2576 of file driver_opengl.cpp. +

+References _CurrentBlendConstantColor. +

+

02577 {
+02578         return  _CurrentBlendConstantColor;
+02579 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::getBuffer CBitmap bitmap  )  [virtual]
+
+ + + + + +
+   + + +

+get the RGBA back buffer

+

Parameters:
+ + +
bitmap the buffer will be written in this bitmap
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2164 of file driver_opengl.cpp. +

+References getBufferPart(), getWindowSize(), NLMISC::CRect::Height, and NLMISC::CRect::Width. +

+

02165 {
+02166         CRect   rect(0,0);
+02167         getWindowSize(rect.Width, rect.Height);
+02168         getBufferPart(bitmap, rect);
+02169 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::getBufferPart CBitmap bitmap,
NLMISC::CRect rect
[virtual]
+
+ + + + + +
+   + + +

+get a part of the RGBA back buffer NB: 0,0 is the bottom left corner of the screen.

+

Parameters:
+ + + +
bitmap the buffer will be written in this bitmap
rect the in/out (wanted/clipped) part of Color buffer to retrieve.
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2131 of file driver_opengl.cpp. +

+References clipRect(), NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NLMISC::CRect::Height, NLMISC::CBitmap::reset(), NLMISC::CBitmap::resize(), NLMISC::CRect::Width, NLMISC::CRect::X, and NLMISC::CRect::Y. +

+Referenced by getBuffer(). +

+

02132 {
+02133         bitmap.reset();
+02134 
+02135         if(clipRect(rect))
+02136         {
+02137                 bitmap.resize(rect.Width, rect.Height, CBitmap::RGBA);
+02138                 glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_RGBA, GL_UNSIGNED_BYTE, bitmap.getPixels ().getPtr());
+02139         }
+02140 }
+
+

+ + + + +
+ + + + + + + + + +
CTextureCube* NL3D::CDriverGL::getDiffuseCubeMap  )  [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 821 of file driver_opengl.h. +

+References getSpecularCubeMap(). +

+

00821 { return getSpecularCubeMap(1); }
+
+

+ + + + +
+ + + + + + + + + +
virtual void* NL3D::CDriverGL::getDisplay  )  [inline, virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 229 of file driver_opengl.h. +

+

00230         {
+00231 #ifdef NL_OS_WINDOWS
+00232                 return (void*)_hWnd;
+00233 #else // NL_OS_WINDOWS
+00234                 return NULL;
+00235 #endif // NL_OS_WINDOWS
+00236         }
+
+

+ + + + +
+ + + + + + + + + + +
uint NL3D::CDriverGL::getDoubleClickDelay bool  hardwareMouse  )  [virtual]
+
+ + + + + +
+   + + +

+Get the delay in ms for mouse double clicks. +

+Implements NL3D::IDriver. +

+Definition at line 2527 of file driver_opengl.cpp. +

+References NLMISC::IMouseDevice::getDoubleClickDelay(), and uint. +

+

02528 {
+02529 #ifdef NL_OS_WINDOWS
+02530                 NLMISC::IMouseDevice *md = NULL;
+02531                 if (_EventEmitter.getNumEmitters() >= 2)
+02532                 {               
+02533                         NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast<CDIEventEmitter *>(_EventEmitter.getEmitter(1));                                      
+02534                         if (diee->isMouseCreated())
+02535                         {                       
+02536                                 try
+02537                                 {
+02538                                         md = diee->getMouseDevice(hardwareMouse);                                       
+02539                                 }
+02540                                 catch (EDirectInput &)
+02541                                 {
+02542                                         // could not get device ..                                      
+02543                                 }                       
+02544                         }
+02545                 }
+02546                 if (md)
+02547                 {
+02548                         return md->getDoubleClickDelay();
+02549                 }
+02550                 // try to read the good value from windows
+02551                 return ::GetDoubleClickTime();
+02552 #else
+02553                 // FIXME: FAKE FIX
+02554                 return 250;
+02555 #endif
+02556 }
+
+

+ + + + +
+ + + + + + + + + +
virtual const char* NL3D::CDriverGL::getDriverInformation  )  [inline, virtual]
+
+ + + + + +
+   + + +

+Get driver informations. get the nel name of the driver (ex: "Opengl 1.2 NeL Driver") +

+Implements NL3D::IDriver. +

+Definition at line 389 of file driver_opengl.h. +

+

00390         {
+00391                 return "Opengl 1.2 NeL Driver";
+00392         }
+
+

+ + + + +
+ + + + + + + + + + +
virtual NLMISC::IEventEmitter* NL3D::CDriverGL::getEventEmitter void   )  [inline, virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 249 of file driver_opengl.h. +

+

00249 { return&_EventEmitter; };
+
+

+ + + + +
+ + + + + + + + + +
CRGBA NL3D::CDriverGL::getFogColor  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2293 of file driver_opengl.cpp. +

+References _CurrentFogColor, NLMISC::CRGBA::A, NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::CRGBA::R, and uint8. +

+

02294 {
+02295         CRGBA   ret;
+02296         ret.R= (uint8)(_CurrentFogColor[0]*255);
+02297         ret.G= (uint8)(_CurrentFogColor[1]*255);
+02298         ret.B= (uint8)(_CurrentFogColor[2]*255);
+02299         ret.A= (uint8)(_CurrentFogColor[3]*255);
+02300         return ret;
+02301 }
+
+

+ + + + +
+ + + + + + + + + +
float NL3D::CDriverGL::getFogEnd  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2287 of file driver_opengl.cpp. +

+References _FogEnd. +

+

02288 {
+02289         return _FogEnd;
+02290 }
+
+

+ + + + +
+ + + + + + + + + +
float NL3D::CDriverGL::getFogStart  )  const [virtual]
+
+ + + + + +
+   + + +

+Get. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2281 of file driver_opengl.cpp. +

+References _FogStart. +

+

02282 {
+02283         return _FogStart;
+02284 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
GLint NL3D::CDriverGL::getGlTextureFormat ITexture tex,
bool &  compressed
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 99 of file driver_opengl_texture.cpp. +

+References _Extensions, _ForceDXTCCompression, NL3D::ITexture::allowDegradation(), NL3D::CGlExtensions::ATIEnvMapBumpMap, NL3D::CGlExtensions::EXTTextureCompressionS3TC, NLMISC::CBitmap::getPixelFormat(), NL3D::ITexture::getUploadFormat(), GL_DSDT_NV, GL_DU8DV8_ATI, nlassert, and NL3D::CGlExtensions::NVTextureShader. +

+Referenced by copyFrameBufferToTexture(), setupTextureEx(), and uploadTexture(). +

+

00100 {
+00101         ITexture::TUploadFormat         texfmt= tex.getUploadFormat();
+00102 
+00103         // If auto, retrieve the pixel format of the bitmap.
+00104         if(texfmt== ITexture::Auto)
+00105         {
+00106                 switch(tex.getPixelFormat())
+00107                 {
+00108                         case CBitmap::RGBA: 
+00109                                 if(_ForceDXTCCompression && tex.allowDegradation() )
+00110                                         texfmt= ITexture::DXTC5;
+00111                                 else
+00112                                         texfmt= ITexture::RGBA8888;
+00113                                 break;
+00114                         case CBitmap::DXTC1: texfmt= ITexture::DXTC1; break;
+00115                         case CBitmap::DXTC1Alpha: texfmt= ITexture::DXTC1Alpha; break;
+00116                         case CBitmap::DXTC3: texfmt= ITexture::DXTC3; break;
+00117                         case CBitmap::DXTC5: texfmt= ITexture::DXTC5; break;
+00118                         case CBitmap::Luminance: texfmt= ITexture::Luminance; break;
+00119                         case CBitmap::Alpha: texfmt= ITexture::Alpha; break;
+00120                         case CBitmap::AlphaLuminance: texfmt= ITexture::AlphaLuminance; break;
+00121                         case CBitmap::DsDt: texfmt= ITexture::DsDt; break;
+00122                         default: texfmt= ITexture::RGBA8888; break;
+00123                 }
+00124         }
+00125 
+00126 
+00127         // Get gl tex format, try S3TC compressed ones.
+00128         if(_Extensions.EXTTextureCompressionS3TC)
+00129         {
+00130                 compressed= true;
+00131                 // Try Compressed ones.
+00132                 switch(texfmt)
+00133                 {
+00134                         case ITexture::DXTC1:           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
+00135                         case ITexture::DXTC1Alpha:      return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+00136                         case ITexture::DXTC3:           return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+00137                         case ITexture::DXTC5:           return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
+00138                         default: break;
+00139                 }
+00140         }
+00141 
+00142 
+00143         // Get standard gl tex format.
+00144         compressed= false;
+00145         switch(texfmt)
+00146         {
+00147                 case ITexture::RGBA8888: return GL_RGBA8;
+00148                 case ITexture::RGBA4444: return GL_RGBA4;
+00149                 case ITexture::RGBA5551: return GL_RGB5_A1;
+00150                 case ITexture::RGB888: return GL_RGB8;
+00151                 case ITexture::RGB565: return GL_RGB5;
+00152                 case ITexture::Luminance: return GL_LUMINANCE8;
+00153                 case ITexture::Alpha: return GL_ALPHA8;
+00154                 case ITexture::AlphaLuminance: return GL_LUMINANCE8_ALPHA8;
+00155                 case ITexture::DsDt: 
+00156                         if (_Extensions.NVTextureShader) return GL_DSDT_NV;
+00157                         else if (_Extensions.ATIEnvMapBumpMap) return GL_DU8DV8_ATI;
+00158                         else
+00159                         {                       
+00160                                 nlassert(0);
+00161                                 return 0;
+00162                         }
+00163                 break;
+00164                 default: return GL_RGBA8;
+00165         }
+00166 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::getHwnd  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 205 of file driver_opengl.h. +

+References uint32. +

+

00206         {
+00207 #ifdef NL_OS_WINDOWS
+00208                 return (uint32)_hWnd;
+00209 #else // NL_OS_WINDOWS
+00210                 return 0;
+00211 #endif // NL_OS_WINDOWS
+00212         }
+
+

+ + + + +
+ + + + + + + + + +
virtual uint32 NL3D::CDriverGL::getImplementationVersion  )  const [inline, virtual]
+
+ + + + + +
+   + + +

+Get the driver version. Not the same than interface version. Incremented at each implementation change.

+

See also:
InterfaceVersion
+ +

+Implements NL3D::IDriver. +

+Definition at line 384 of file driver_opengl.h. +

+References ReleaseVersion, and uint32. +

+

00385         {
+00386                 return ReleaseVersion;
+00387         }
+
+

+ + + + +
+ + + + + + + + + +
NLMISC::IInputDeviceManager * NL3D::CDriverGL::getLowLevelInputDeviceManager  )  [virtual]
+
+ + + + + +
+   + + +

+Check wether there is a low level device manager available, and get its interface. Return NULL if not available From this interface you can deal with mouse and keyboard as above, but you can also manage game device (joysticks, joypads ...) +

+Implements NL3D::IDriver. +

+Definition at line 2515 of file driver_opengl.cpp. +

+

02516 {
+02517 #ifdef NL_OS_WINDOWS
+02518                 if (_EventEmitter.getNumEmitters() < 2) return NULL;
+02519                 NLMISC::CDIEventEmitter *diee = NLMISC::safe_cast<NLMISC::CDIEventEmitter *>(_EventEmitter.getEmitter(1));
+02520                 return diee;
+02521 #else
+02522                 return NULL;
+02523 #endif
+02524 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CDriverGL::getMaxLight  )  const [virtual]
+
+ + + + + +
+   + + +

+return the number of light supported by driver. typically 8.

+

See also:
enableLight() setLight()
+ +

+Implements NL3D::IDriver. +

+Definition at line 35 of file driver_opengl_light.cpp. +

+References _MaxDriverLight, and uint. +

+

00036 {
+00037         // return min(maxLight supported by openGL, MaxLight=8).
+00038         return _MaxDriverLight;
+00039 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CDriverGL::getMaxVerticesByVertexBufferHard  )  const [virtual]
+
+ + + + + +
+   + + +

+return How many vertices VertexBufferHard support +

+Implements NL3D::IDriver. +

+Definition at line 509 of file driver_opengl_vertex.cpp. +

+References _MaxVerticesByVBHard, and uint. +

+

00510 {
+00511         return _MaxVerticesByVBHard;
+00512 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::getModes std::vector< GfxMode > &  modes  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1412 of file driver_opengl.cpp. +

+References NL3D::GfxMode::Depth, NL3D::GfxMode::Frequency, NL3D::GfxMode::Height, sint, uint16, uint8, and NL3D::GfxMode::Width. +

+

01413 {
+01414 #ifdef NL_OS_WINDOWS
+01415         sint modeIndex = 0;
+01416         DEVMODE devMode;
+01417         while (EnumDisplaySettings (NULL, modeIndex, &devMode))
+01418         {
+01419                 // Keep only 16 and 32 bits
+01420                 if ((devMode.dmBitsPerPel == 16 ) || (devMode.dmBitsPerPel == 32))
+01421                 {
+01422                         // Add this mode
+01423                         GfxMode mode;
+01424                         mode.Width = (uint16)devMode.dmPelsWidth;
+01425                         mode.Height = (uint16)devMode.dmPelsHeight;
+01426                         mode.Depth = (uint8)devMode.dmBitsPerPel;
+01427                         mode.Frequency = devMode.dmDisplayFrequency;
+01428                         modes.push_back (mode);
+01429                 }
+01430 
+01431                 // Mode index
+01432                 modeIndex++;
+01433         }
+01434 #endif
+01435         return true;
+01436 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::getNbTextureStages  )  const [virtual]
+
+ + + + + +
+   + + +

+Get the number of texture stage avaliable, for multitexturing (Normal material shaders). Valid only after setDisplay(). +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2582 of file driver_opengl.cpp. +

+References inlGetNumTextStages(), and sint. +

+

02583 {
+02584         return inlGetNumTextStages();
+02585 }
+
+

+ + + + +
+ + + + + + + + + +
TPolygonMode NL3D::IDriver::getPolygonMode  )  [inline, inherited]
+
+ + + + + +
+   + + +

+Get the global polygon mode.

+

Parameters:
+ + +
polygon mode choose in this driver.
+
+
See also:
setPolygonMode(), TPolygonMode
+ +

+Definition at line 817 of file driver.h. +

+References NL3D::IDriver::_PolygonMode, and NL3D::IDriver::TPolygonMode. +

+Referenced by NL3D::CDriverUser::getPolygonMode(). +

+

00818         {
+00819                 return _PolygonMode;
+00820         }
+
+

+ + + + +
+ + + + + + + + + +
const sint& NLMISC::CRefCount::getRefCount  )  const [inline, inherited]
+
+ + + + + +
+   + + +

+ +

+Definition at line 70 of file smart_ptr.h. +

+References NLMISC::CRefCount::crefs, and sint. +

+

00071         {
+00072                 return  crefs;
+00073         }
+
+

+ + + + +
+ + + + + + + + + + +
CTextureCube * NL3D::CDriverGL::getSpecularCubeMap uint  exp  )  [private]
+
+ + + + + +
+   + + +

+get (and if necessary, build) a cube map used for specular lighting. The range for exponent is limited, and only the best fit is used +

+ +

+Definition at line 1266 of file driver_opengl_material.cpp. +

+References _SpecularTextureCubes, NL3D::BuildCubeMap(), NLMISC::clamp(), NL3D::CTextureCube::getTexture(), nlassert, NL3D::ITexture::setUploadFormat(), NLMISC::smprintf(), uint, and uint16. +

+Referenced by getDiffuseCubeMap(), setupPPLNoSpecPass(), and setupPPLPass(). +

+

01267 {
+01268         const uint DiffuseMapSize = 64;
+01269         const uint SpecularMapSize = 32;
+01270         const uint SpecularMapSizeHighExponent = 64;
+01271         const float HighExponent = 128.f;
+01272         const uint MaxExponent = 512;
+01273         // this gives the cube map to use given an exponent (from 0 to 128)
+01274         static uint16 expToCubeMap[MaxExponent];        
+01275         // this gives the exponent used by a given cube map (not necessarily ordered)
+01276         static float cubeMapExp[] = 
+01277         {
+01278                 1.f, 4.f, 8.f, 24.f, 48.f, 128.f, 256.f, 511.f
+01279         };
+01280         const uint numCubeMap = sizeof(expToCubeMap) / sizeof(float);
+01281         static bool tableBuilt = false;
+01282 
+01283         if (!tableBuilt)
+01284         {
+01285                 for (uint k = 0; k < MaxExponent; ++k)
+01286                 {                       
+01287                         uint nearest = 0;
+01288                         float diff = (float) MaxExponent;
+01289                         // look for the nearest exponent
+01290                         for (uint l = 0; l < numCubeMap; ++l)
+01291                         {
+01292                                 float newDiff = ::fabsf(k - cubeMapExp[l]);
+01293                                 if (newDiff < diff)
+01294                                 {
+01295                                         diff = newDiff;
+01296                                         nearest = l;
+01297                                 }
+01298                         }
+01299                         expToCubeMap[k] = nearest;
+01300                 }
+01301                 tableBuilt = true;              
+01302         }
+01303 
+01304         if (_SpecularTextureCubes.empty())
+01305         {
+01306                 _SpecularTextureCubes.resize(MaxExponent);
+01307         }
+01308 
+01309                 
+01310         NLMISC::clamp(exp, 1u, (MaxExponent - 1));
+01311 
+01312 
+01313         uint cubeMapIndex = expToCubeMap[(uint) exp];
+01314         nlassert(cubeMapIndex < numCubeMap);    
+01315         
+01316         
+01317         if (_SpecularTextureCubes[cubeMapIndex] != NULL) // has the cube map already been cted ?
+01318         { 
+01319                 return _SpecularTextureCubes[cubeMapIndex]; 
+01320         }
+01321         else // build the cube map
+01322         {               
+01323                 float exponent    = cubeMapExp[cubeMapIndex];
+01324                 CSpecCubeMapFunctor scmf(exponent);
+01325                 const uint bufSize = 128;
+01326                 char name[bufSize];
+01327                 NLMISC::smprintf(name, bufSize, "#SM%d", cubeMapIndex);
+01328                 CTextureCube *tc;
+01329                 if (exponent == 1)
+01330                 {
+01331                         tc = BuildCubeMap(DiffuseMapSize,  scmf, false, name);
+01332                 }
+01333                 else
+01334                 {               
+01335                         tc = BuildCubeMap(exponent >= HighExponent ? SpecularMapSizeHighExponent
+01336                                                                                                           : SpecularMapSize,
+01337                                                           scmf,
+01338                                                           false,
+01339                                                           name);
+01340                 }
+01341 
+01342                 static const CTextureCube::TFace numToFace[] =
+01343                 { CTextureCube::positive_x,
+01344                   CTextureCube::negative_x, 
+01345                   CTextureCube::positive_y, 
+01346                   CTextureCube::negative_y, 
+01347                   CTextureCube::positive_z, 
+01348                   CTextureCube::negative_z 
+01349                 };
+01350 
+01351                 if (exponent != 1.f)
+01352                 {
+01353                         // force 16 bit for specular part, 32 bit if exponent is 1 (diffuse part)
+01354                         for (uint k = 0; k < 6; ++k)
+01355                         {
+01356                                 nlassert(tc->getTexture(numToFace[k]));
+01357                                 tc->getTexture(numToFace[k])->setUploadFormat(ITexture::RGB565);
+01358                         }
+01359                 }
+01360 
+01361                 _SpecularTextureCubes[cubeMapIndex] = tc;
+01362                 return tc;
+01363         }
+01364 }
+
+

+ + + + +
+ + + + + + + + + + +
CMaterial::TShader NL3D::CDriverGL::getSupportedShader CMaterial::TShader  shader  )  [private]
+
+ + + + + +
+   + + +

+test wether the given shader is supported, and gives back a supported shader +

+ +

+Definition at line 221 of file driver_opengl_material.cpp. +

+References _SupportPerPixelShader, _SupportPerPixelShaderNoSpec, and inlGetNumTextStages(). +

+Referenced by setupMaterial(). +

+

00222 {
+00223         switch (shader)
+00224         {
+00225         case CMaterial::PerPixelLighting: return _SupportPerPixelShader ? CMaterial::PerPixelLighting : CMaterial::Normal;
+00226         case CMaterial::PerPixelLightingNoSpec: return _SupportPerPixelShaderNoSpec ? CMaterial::PerPixelLightingNoSpec : CMaterial::Normal;
+00227         // Lightmap and Specular work only if at least 2 text stages.
+00228         case CMaterial::LightMap: return (inlGetNumTextStages()>=2) ? CMaterial::LightMap : CMaterial::Normal;
+00229         case CMaterial::Specular: return (inlGetNumTextStages()>=2) ? CMaterial::Specular : CMaterial::Normal;
+00230                 default: return shader;         
+00231         }
+00232 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CDriverGL::getSwapVBLInterval  )  [virtual]
+
+ + + + + +
+   + + +

+get the number of VBL wait when a swapBuffers() is issued. 0 means no synchronisation to the VBL +

+ +

+Implements NL3D::IDriver. +

+Definition at line 3046 of file driver_opengl.cpp. +

+References _Extensions, uint, and NL3D::CGlExtensions::WGLEXTSwapControl. +

+

03047 {
+03048 #ifdef NL_OS_WINDOWS
+03049         if(_Extensions.WGLEXTSwapControl)
+03050         {
+03051                 return wglGetSwapIntervalEXT();
+03052         }
+03053         else
+03054                 return 0;
+03055 #else
+03056         return 0;
+03057 #endif
+03058 }
+
+

+ + + + +
+ + + + + + + + + + +
uint NL3D::CDriverGL::getTextureHandle const ITexture tex  )  [virtual]
+
+ + + + + +
+   + + +

+Advanced usage. Get the texture Handle. Usefull for texture sorting for instance NB: if the texture is not setuped in the driver, 0 is returned. NB: if implementation does not support it, 0 may be returned. OpenGL ones return the Texture ID. NB: unlike isTextureExist(), this method is not thread safe. +

+Implements NL3D::IDriver. +

+Definition at line 1217 of file driver_opengl_texture.cpp. +

+References NL3D::CTextureDrvInfosGL::ID, NL3D::ITexture::TextureDrvShare, and uint. +

+

01218 {
+01219         // If DrvShare not setuped
+01220         if(!tex.TextureDrvShare)
+01221                 return 0;
+01222 
+01223         // If DrvInfo not setuped
+01224         const CTextureDrvInfosGL        *t0= (const CTextureDrvInfosGL*)(const ITextureDrvInfos*)(tex.TextureDrvShare->DrvTexture);
+01225         if(!t0)
+01226                 return 0;
+01227 
+01228         return t0->ID;
+01229 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::IDriver::getTextureShareName const ITexture tex,
std::string &  output
[static, inherited]
+
+ + + + + +
+   + + +

+Get the driver share texture name +

+Definition at line 277 of file driver.cpp. +

+References NL3D::ITexture::getShareName(), NL3D::ITexture::getUploadFormat(), NL3D::ITexture::mipMapOn(), NLMISC::smprintf(), NLMISC::strlwr(), and uint32. +

+Referenced by NL3D::IDriver::invalidateShareTexture(), isTextureExist(), and setupTextureEx(). +

+

00278 {
+00279         // Create the shared Name.
+00280         output= strlwr(tex.getShareName());
+00281 
+00282         // append format Id of the texture.
+00283         static char     fmt[256];
+00284         smprintf(fmt, 256, "@Fmt:%d", (uint32)tex.getUploadFormat());
+00285         output+= fmt;
+00286 
+00287         // append mipmap info
+00288         if(tex.mipMapOn())
+00289                 output+= "@MMp:On";
+00290         else
+00291                 output+= "@MMp:Off";
+00292 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::getUsedTextureMemory  )  const [virtual]
+
+ + + + + +
+   + + +

+Return the amount of texture video memory used since last swapBuffers() call. Before use this method, you should enable the sum with enableUsedTextureMemorySum(). +

+Implements NL3D::IDriver. +

+Definition at line 2343 of file driver_opengl.cpp. +

+References _TextureUsed, NL3D::CTextureDrvInfosGL::TextureMemory, and uint32. +

+

02344 {
+02345         // Sum memory used
+02346         uint32 memory=0;
+02347 
+02348         // For each texture used
+02349         set<CTextureDrvInfosGL*>::iterator ite=_TextureUsed.begin();
+02350         while (ite!=_TextureUsed.end())
+02351         {
+02352                 // Get the gl texture
+02353                 CTextureDrvInfosGL*     gltext;
+02354                 gltext= (*ite);
+02355 
+02356                 // Sum the memory used by this texture
+02357                 memory+=gltext->TextureMemory;
+02358 
+02359                 // Next texture
+02360                 ite++;
+02361         }
+02362 
+02363         // Return the count
+02364         return memory;
+02365 }
+
+

+ + + + +
+ + + + + + + + + +
const char * NL3D::CDriverGL::getVideocardInformation  )  [virtual]
+
+ + + + + +
+   + + +

+Get videocard informations. get the official name of the driver +

+Implements NL3D::IDriver. +

+Definition at line 2059 of file driver_opengl.cpp. +

+References _Initialized, and NLMISC::smprintf(). +

+

02060 {
+02061         static char name[1024];
+02062 
+02063         if (!_Initialized) return "OpenGL isn't initialized";
+02064 
+02065         const char *vendor = (const char *) glGetString (GL_VENDOR);
+02066         const char *renderer = (const char *) glGetString (GL_RENDERER);
+02067         const char *version = (const char *) glGetString (GL_VERSION);
+02068 
+02069         smprintf(name, 1024, "%s / %s / %s", vendor, renderer, version);
+02070         return name;
+02071 }
+
+

+ + + + +
+ + + + + + + + + +
CMatrix NL3D::CDriverGL::getViewMatrix  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 118 of file driver_opengl_matrix.cpp. +

+References _UserViewMtx. +

+

00119 {
+00120         return _UserViewMtx;
+00121 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::getViewport CViewport viewport  )  [virtual]
+
+ + + + + +
+   + + +

+Get the current viewport +

+Implements NL3D::IDriver. +

+Definition at line 1866 of file driver_opengl.cpp. +

+References _CurrViewport. +

+

01867 {
+01868         viewport = _CurrViewport;       
+01869 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::getWindowPos uint32 x,
uint32 y
[virtual]
+
+ + + + + +
+   + + +

+Get the position of the window always (0,0) in fullscreen. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2017 of file driver_opengl.cpp. +

+References _OffScreen, uint32, x, and y. +

+

02018 {
+02019 #ifdef NL_OS_WINDOWS
+02020         // Off-srceen rendering ?
+02021         if (_OffScreen)
+02022         {
+02023                 if (_PBuffer)
+02024                 {
+02025                         x = y = 0;
+02026                 }
+02027         }
+02028         else
+02029         {
+02030                 if (_hWnd)
+02031                 {
+02032                         x = (uint32)(_WindowX);
+02033                         y = (uint32)(_WindowY);
+02034                 }
+02035         }
+02036 #elif defined (NL_OS_UNIX)
+02037         x = y = 0;
+02038 #endif // NL_OS_UNIX
+02039 }
+
+

+ + + + +
+ + + + + + + + + +
emptyProc NL3D::CDriverGL::getWindowProc  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1462 of file driver_opengl.cpp. +

+References NL3D::emptyProc. +

+

01463 {
+01464 #ifdef NL_OS_WINDOWS
+01465         return (emptyProc)GlWndProc;
+01466 #else // NL_OS_WINDOWS
+01467         return NULL;
+01468 #endif // NL_OS_WINDOWS
+01469 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::getWindowSize uint32 width,
uint32 height
[virtual]
+
+ + + + + +
+   + + +

+Get the width and the height of the window. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1989 of file driver_opengl.cpp. +

+References _OffScreen, height, uint32, WGL_PBUFFER_HEIGHT_ARB, WGL_PBUFFER_WIDTH_ARB, and width. +

+Referenced by clipRect(), fillBuffer(), getBuffer(), and getZBuffer(). +

+

01990 {
+01991 #ifdef NL_OS_WINDOWS
+01992         // Off-srceen rendering ?
+01993         if (_OffScreen)
+01994         {
+01995                 if (_PBuffer)
+01996                 {
+01997                         wglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width );
+01998                         wglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height );
+01999                 }
+02000         }
+02001         else
+02002         {
+02003                 if (_hWnd)
+02004                 {
+02005                         width = (uint32)(_WindowWidth);
+02006                         height = (uint32)(_WindowHeight);
+02007                 }
+02008         }
+02009 #elif defined (NL_OS_UNIX)
+02010         XWindowAttributes xwa;
+02011         XGetWindowAttributes (dpy, win, &xwa);
+02012         width = (uint32) xwa.width;
+02013         height = (uint32) xwa.height;
+02014 #endif // NL_OS_UNIX
+02015 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::getZBuffer std::vector< float > &  zbuffer  )  [virtual]
+
+ + + + + +
+   + + +

+get the ZBuffer (back buffer).

+

Parameters:
+ + +
zbuffer the returned array of Z. size of getWindowSize() .
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2157 of file driver_opengl.cpp. +

+References getWindowSize(), getZBufferPart(), NLMISC::CRect::Height, and NLMISC::CRect::Width. +

+

02158 {
+02159         CRect   rect(0,0);
+02160         getWindowSize(rect.Width, rect.Height);
+02161         getZBufferPart(zbuffer, rect);
+02162 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::getZBufferPart std::vector< float > &  zbuffer,
NLMISC::CRect rect
[virtual]
+
+ + + + + +
+   + + +

+get a part of the ZBuffer (back buffer). NB: 0,0 is the bottom left corner of the screen.

+

Parameters:
+ + + +
zbuffer the returned array of Z. size of rec.Width*rec.Height.
rect the in/out (wanted/clipped) part of ZBuffer to retrieve.
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2143 of file driver_opengl.cpp. +

+References clipRect(), NLMISC::CRect::Height, NLMISC::CRect::Width, NLMISC::CRect::X, and NLMISC::CRect::Y. +

+Referenced by getZBuffer(). +

+

02144 {
+02145         zbuffer.clear();
+02146 
+02147         if(clipRect(rect))
+02148         {
+02149                 zbuffer.resize(rect.Width*rect.Height);
+02150                 glPixelTransferf(GL_DEPTH_SCALE, 1.0f) ;
+02151                 glPixelTransferf(GL_DEPTH_BIAS, 0.f) ;
+02152                 glReadPixels (rect.X, rect.Y, rect.Width, rect.Height, GL_DEPTH_COMPONENT , GL_FLOAT, &(zbuffer[0]));
+02153         }
+02154 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::init uint  windowIcon = 0  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 310 of file driver_opengl.cpp. +

+References nlwarning, retrieveATIDriverVersion(), and uint. +

+

00311 {
+00312 #ifdef NL_OS_WINDOWS
+00313         WNDCLASS                wc;
+00314 
+00315         if (!_Registered)
+00316         {
+00317                 memset(&wc,0,sizeof(wc));
+00318                 wc.style                        = CS_HREDRAW | CS_VREDRAW ;//| CS_DBLCLKS;
+00319                 wc.lpfnWndProc          = (WNDPROC)WndProc;
+00320                 wc.cbClsExtra           = 0;
+00321                 wc.cbWndExtra           = 0;
+00322                 wc.hInstance            = GetModuleHandle(NULL);
+00323                 wc.hIcon                        = (HICON)windowIcon;
+00324                 wc.hCursor                      = LoadCursor(NULL,IDC_ARROW);
+00325                 wc.hbrBackground        = WHITE_BRUSH;
+00326                 wc.lpszClassName        = "NLClass";
+00327                 wc.lpszMenuName         = NULL;
+00328                 if ( !RegisterClass(&wc) ) 
+00329                 {
+00330                         return false;
+00331                 }
+00332                 _Registered=1;
+00333         }
+00334 
+00335         // Backup monitor color parameters
+00336         HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL);
+00337         if (dc)
+00338         {
+00339                 _NeedToRestaureGammaRamp = GetDeviceGammaRamp (dc, _GammaRampBackuped) != FALSE;
+00340 
+00341                 // Release the DC
+00342                 ReleaseDC (NULL, dc);
+00343         }
+00344         else
+00345         {
+00346                 nlwarning ("(CDriverGL::init): can't create DC");
+00347         }
+00348 
+00349         // ati specific : try to retrieve driver version
+00350         retrieveATIDriverVersion();
+00351 
+00352 #endif
+00353         return true;
+00354 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::initCausticCubeMap  )  [static, private]
+
+ + + + + +
+   + + +

+

+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::initEMBM  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2686 of file driver_opengl.cpp. +

+References _DriverGLStates, _Extensions, _StageSupportEMBM, NL3D::CDriverGLStates::activeTextureARB(), NL3D::CGlExtensions::ATIEnvMapBumpMap, GL_BUMP_NUM_TEX_UNITS_ATI, GL_BUMP_TARGET_ATI, GL_BUMP_TEX_UNITS_ATI, NL3D::IDRV_MAT_MAXTEXTURES, nglGetTexBumpParameterivATI, supportEMBM(), and uint. +

+

02687 {
+02688         if (supportEMBM())
+02689         {       
+02690                 std::fill(_StageSupportEMBM, _StageSupportEMBM + IDRV_MAT_MAXTEXTURES, false);
+02691                 if (_Extensions.ATIEnvMapBumpMap)
+02692                 {               
+02693                         // Test which stage support EMBM
+02694                         GLint numEMBMUnits;
+02695                         nglGetTexBumpParameterivATI(GL_BUMP_NUM_TEX_UNITS_ATI, &numEMBMUnits);
+02696                         std::vector<GLint> EMBMUnits(numEMBMUnits);
+02697                         // get array of units that supports EMBM
+02698                         nglGetTexBumpParameterivATI(GL_BUMP_TEX_UNITS_ATI, &EMBMUnits[0]);
+02699                         uint k;
+02700                         for(k = 0; k < (EMBMUnits.size() - 1); ++k)
+02701                         {
+02702                                 uint stage = EMBMUnits[k] - GL_TEXTURE0_ARB;
+02703                                 if (stage < (IDRV_MAT_MAXTEXTURES - 1))
+02704                                 {
+02705                                         _StageSupportEMBM[k] = true;
+02706                                 }               
+02707                         } 
+02708                         // setup each stage to apply the bump map to the next stage
+02709                         for(k = 0; k < IDRV_MAT_MAXTEXTURES - 1; ++k)
+02710                         {
+02711                                 if (_StageSupportEMBM[k])
+02712                                 {       
+02713                                         // setup each stage so that it apply EMBM on the next stage
+02714                                         _DriverGLStates.activeTextureARB(k);
+02715                                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);   
+02716                                         glTexEnvi(GL_TEXTURE_ENV, GL_BUMP_TARGET_ATI, GL_TEXTURE0_ARB + k + 1);                         
+02717                                 }
+02718                         }
+02719                         _DriverGLStates.activeTextureARB(0);
+02720                 }
+02721         }
+02722 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::initFragmentShaders  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2920 of file driver_opengl.cpp. +

+References _Extensions, NL3D::CGlExtensions::ARBFragmentProgram, ARBWaterShader, NL3D::CGlExtensions::ATIFragmentShader, ATIWaterShaderHandle, ATIWaterShaderHandleNoDiffuseMap, deleteARBFragmentPrograms(), NL3D::fetchPerturbedEnvMapR200(), GL_MOV_ATI, GL_MUL_ATI, GL_REG_0_ATI, GL_REG_2_ATI, GL_REG_3_ATI, GL_SWIZZLE_STR_ATI, NL3D::loadARBFragmentProgramStringNative(), nglAlphaFragmentOp1ATI, nglAlphaFragmentOp2ATI, nglBeginFragmentShaderATI, nglBindFragmentShaderATI, nglColorFragmentOp1ATI, nglColorFragmentOp2ATI, nglEndFragmentShaderATI, nglGenFragmentShadersATI, nglSampleMapATI, nlassert, nlwarning, uint, NL3D::WaterCodeForARBFragmentProgram, NL3D::WaterCodeNoDiffuseForARBFragmentProgram, NL3D::WaterCodeNoDiffuseWithFogForARBFragmentProgram, and NL3D::WaterCodeWithFogForARBFragmentProgram. +

+

02921 {
+02923         // WATER SHADERS //
+02925 
+02926         // the ARB_fragment_program is prioritary over other extensions when present
+02927         if (_Extensions.ARBFragmentProgram)
+02928         {
+02929                 
+02930                 ARBWaterShader[0] = loadARBFragmentProgramStringNative(WaterCodeNoDiffuseForARBFragmentProgram);
+02931                 ARBWaterShader[1] = loadARBFragmentProgramStringNative(WaterCodeNoDiffuseWithFogForARBFragmentProgram);
+02932                 ARBWaterShader[2] = loadARBFragmentProgramStringNative(WaterCodeForARBFragmentProgram);
+02933                 ARBWaterShader[3] = loadARBFragmentProgramStringNative(WaterCodeWithFogForARBFragmentProgram);
+02934                 bool ok = true;
+02935                 for(uint k = 0; k < 4; ++k)
+02936                 {
+02937                         if (!ARBWaterShader[k])
+02938                         {
+02939                                 ok = false;
+02940                                 deleteARBFragmentPrograms();
+02941                                 break;
+02942                         }
+02943                 }       
+02944                 if (ok) return;
+02945         }
+02946         
+02947         if (_Extensions.ATIFragmentShader)
+02948         {
+02949                 ATIWaterShaderHandleNoDiffuseMap = nglGenFragmentShadersATI(1);
+02950                 ATIWaterShaderHandle = nglGenFragmentShadersATI(1);
+02951                 if (!ATIWaterShaderHandle || !ATIWaterShaderHandleNoDiffuseMap)
+02952                 {
+02953                         ATIWaterShaderHandleNoDiffuseMap = ATIWaterShaderHandle = 0;
+02954                         nlwarning("Couldn't generate water shader using ATI_fragment_shader !");
+02955                         return;
+02956                 }
+02957                 else
+02958                 {
+02959 
+02960                         glGetError();
+02961                         // Water shader for R200 : we just add the 2 bump map contributions (du, dv). We then use this contribution to perturbate the envmap
+02962                         nglBindFragmentShaderATI(ATIWaterShaderHandleNoDiffuseMap);
+02963                         nglBeginFragmentShaderATI();                    
+02964                         //
+02965                         fetchPerturbedEnvMapR200();
+02966                         nglColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, GL_REG_2_ATI, GL_NONE, GL_NONE);
+02967                         nglAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_REG_2_ATI, GL_NONE, GL_NONE);
+02968                         //                      
+02969                         nglEndFragmentShaderATI();
+02970                         GLenum error = glGetError();
+02971                     nlassert(error == GL_NONE);
+02972 
+02973                         // The same but with a diffuse map added
+02974                         nglBindFragmentShaderATI(ATIWaterShaderHandle);
+02975                         nglBeginFragmentShaderATI();
+02976                         //
+02977                         fetchPerturbedEnvMapR200();
+02978 
+02979                         nglSampleMapATI(GL_REG_3_ATI, GL_TEXTURE3_ARB, GL_SWIZZLE_STR_ATI); // fetch envmap at perturbed texcoords
+02980                         nglColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, GL_REG_3_ATI, GL_NONE, GL_NONE, GL_REG_2_ATI, GL_NONE, GL_NONE); // scale bumpmap 1 & add envmap coords
+02981                         nglAlphaFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_REG_3_ATI, GL_NONE, GL_NONE, GL_REG_2_ATI, GL_NONE, GL_NONE);
+02982 
+02983 
+02984                         nglEndFragmentShaderATI();
+02985                         error = glGetError();
+02986                     nlassert(error == GL_NONE);
+02987                         nglBindFragmentShaderATI(0);                    
+02988                 }
+02989         }       
+02990 
+02991         // if none of the previous programs worked, fallback on NV_texture_shader, or (todo) simpler shader
+02992         
+02993 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::initVertexArrayRange uint  agpMem,
uint  vramMem
[virtual]
+
+ + + + + +
+   + + +

+Allocate the initial VertexArray Memory. (no-op if !supportVertexBufferHard()). VertexArrayRange is first reseted, so any VBhard created before will be deleted. NB: call it after setDisplay(). But setDisplay() by default call initVertexArrayRange(16Mo, 0); so this is not necessary. NB: If allocation fails, mem/=2, and retry, until mem < 500K.

Parameters:
+ + + +
agpMem ammount of AGP Memory required. if 0, reseted.
vramMem ammount of VRAM Memory required. if 0, reseted.
+
+
Returns:
false if one the Buffer has not been allocated (at least at 500K).
+ +

+Implements NL3D::IDriver. +

+Definition at line 1229 of file driver_opengl_vertex.cpp. +

+References _AGPVertexArrayRange, _MaxVerticesByVBHard, _VRAMVertexArrayRange, NL3D::IVertexArrayRange::allocate(), NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE, nlinfo, resetVertexArrayRange(), supportVertexBufferHard(), and uint. +

+

01230 {
+01231         if(!supportVertexBufferHard())
+01232                 return false;
+01233         
+01234         // must be supported
+01235         if(!_AGPVertexArrayRange || !_VRAMVertexArrayRange)
+01236                 return false;
+01237 
+01238         // First, reset any VBHard created.
+01239         resetVertexArrayRange();
+01240         bool    ok= true;
+01241 
+01242         // Try to allocate AGPMemory.
+01243         if(agpMem>0)
+01244         {
+01245                 agpMem&= ~15;   // ensure 16-bytes aligned mem count (maybe usefull :) ).
+01246                 agpMem= max(agpMem, (uint)NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE);
+01247                 while(agpMem>= NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
+01248                 {
+01249                         if(_AGPVertexArrayRange->allocate(agpMem, IDriver::VBHardAGP))
+01250                         {
+01251                                 nlinfo("VAR: %.d vertices supported", _MaxVerticesByVBHard);
+01252                                 nlinfo("VAR: Success to allocate %.1f Mo of AGP VAR Ram", agpMem / 1000000.f);
+01253                                 break;
+01254                         }
+01255                         else
+01256                         {
+01257                                 agpMem/=2;
+01258                                 agpMem &=~15;
+01259                         }
+01260                 }
+01261 
+01262                 if(agpMem< NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
+01263                 {
+01264                         nlinfo("VAR: %.d vertices supported", _MaxVerticesByVBHard);
+01265                         nlinfo("VAR: Failed to allocate %.1f Mo of AGP VAR Ram", NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE / 1000000.f);
+01266                         ok= false;
+01267                 }
+01268         }
+01269 
+01270 
+01271         // Try to allocate VRAMMemory.
+01272         if(vramMem>0)
+01273         {
+01274                 vramMem&= ~15;  // ensure 16-bytes aligned mem count (maybe usefull :) ).
+01275                 vramMem= max(vramMem, (uint)NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE);
+01276                 while(vramMem>= NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
+01277                 {
+01278                         if(_VRAMVertexArrayRange->allocate(vramMem, IDriver::VBHardVRAM))
+01279                                 break;
+01280                         else
+01281                         {
+01282                                 vramMem/=2;
+01283                                 vramMem &=~15;
+01284                         }
+01285                 }
+01286 
+01287                 if(vramMem< NL3D_DRV_VERTEXARRAY_MINIMUM_SIZE)
+01288                 {
+01289                         ok= false;
+01290                 }
+01291         }
+01292 
+01293 
+01294         return ok;
+01295 }
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CDriverGL::inlGetNumTextStages  )  const [inline, private]
+
+ + + + + +
+   + + +

+Same as getNbTextureStages(), but faster because inline, and not virtual!! +

+ +

+Definition at line 1017 of file driver_opengl.h. +

+References _Extensions, NL3D::CGlExtensions::NbTextureStages, and sint. +

+Referenced by beginSpecularMultiPass(), computeLightMapInfos(), getNbTextureStages(), getSupportedShader(), resetLightMapVertexSetup(), resetTextureShaders(), setMatrix2DForTextureOffsetAddrMode(), setupGlArraysStd(), setupLightMapPass(), setupMaterial(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularBegin(), setupTextureEx(), setupWaterPassARB(), setupWaterPassNV20(), setupWaterPassR200(), swapBuffers(), swapTextureHandle(), toggleGlArraysForEXTVertexShader(), and toggleGlArraysForNVVertexProgram(). +

+

01017 {return _Extensions.NbTextureStages;}
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::IDriver::invalidateShareTexture ITexture  )  [inherited]
+
+ + + + + +
+   + + +

+Invalidate shared texture +

+Definition at line 243 of file driver.cpp. +

+References NL3D::IDriver::_SyncTexDrvInfos, NL3D::IDriver::_TexDrvShares, and NL3D::IDriver::getTextureShareName(). +

+

00244 {
+00245         // Create the shared Name.
+00246         std::string     name;
+00247         getTextureShareName (texture, name);
+00248 
+00249         // Look for the driver info for this share name
+00250         CSynchronized<TTexDrvInfoPtrMap>::CAccessor access(&_SyncTexDrvInfos);
+00251         TTexDrvInfoPtrMap &rTexDrvInfos = access.value();
+00252         TTexDrvInfoPtrMap::iterator iteDrvInfo = rTexDrvInfos.find (name);
+00253         if (iteDrvInfo != rTexDrvInfos.end())
+00254         {
+00255                 // Now parse all shared info
+00256                 TTexDrvSharePtrList::iterator shareIte = _TexDrvShares.begin ();
+00257                 while (shareIte != _TexDrvShares.end ())
+00258                 {
+00259                         // Good one ?
+00260                         if ((*shareIte)->DrvTexture == iteDrvInfo->second)
+00261                         {
+00262                                 // Remove this one
+00263                                 TTexDrvSharePtrList::iterator toRemove = shareIte;
+00264                                 shareIte++;
+00265                                 delete (*toRemove);
+00266                         }
+00267                         else 
+00268                                 shareIte++;
+00269                 }
+00270 
+00271                 // Ok
+00272                 return true;
+00273         }
+00274         return false;
+00275 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::isActive  )  [virtual]
+
+ + + + + +
+   + + +

+Return true if driver is still active. Return false else. If he user close the window, must return false. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2045 of file driver_opengl.cpp. +

+

02046 {
+02047 #ifdef NL_OS_WINDOWS
+02048         return (IsWindow(_hWnd) != 0);
+02049 #elif defined (NL_OS_UNIX)
+02050         return true;
+02051 #endif // NL_OS_UNIX
+02052 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::isEMBMSupportedAtStage uint  stage  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2664 of file driver_opengl.cpp. +

+References _StageSupportEMBM, NL3D::IDRV_MAT_MAXTEXTURES, nlassert, supportEMBM(), and uint. +

+

02665 {
+02666         nlassert(supportEMBM());
+02667         nlassert(stage < IDRV_MAT_MAXTEXTURES);
+02668         return _StageSupportEMBM[stage];
+02669 
+02670 }
+
+

+ + + + +
+ + + + + + + + + +
virtual bool NL3D::CDriverGL::isForceNormalize  )  const [inline, virtual]
+
+ + + + + +
+   + + +

+return the forceNormalize() state. +

+Implements NL3D::IDriver. +

+Definition at line 306 of file driver_opengl.h. +

+References _ForceNormalize. +

+

00307         {
+00308                 return _ForceNormalize;
+00309         }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::isPolygonSmoothingEnabled  )  const [virtual]
+
+ + + + + +
+   + + +

+see enablePolygonSmoothing() +

+ +

+Implements NL3D::IDriver. +

+Definition at line 3071 of file driver_opengl.cpp. +

+References _PolygonSmooth. +

+

03072 {
+03073         return _PolygonSmooth;
+03074 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::isTextureAddrModeSupported CMaterial::TTexAddressingMode  mode  )  const [virtual]
+
+ + + + + +
+   + + +

+test wether a texture addressing mode is supported +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2384 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::NVTextureShader. +

+

02385 {
+02386         if (_Extensions.NVTextureShader)
+02387         {
+02388                 // all the given addessing mode are supported with this extension
+02389                 return true;
+02390         }
+02391         else
+02392         {                       
+02393                 return false;
+02394         }
+02395 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::isTextureExist const ITexture tex  )  [virtual]
+
+ + + + + +
+   + + +

+is the texture is set up in the driver NB: this method is thread safe. +

+Implements NL3D::IDriver. +

+Definition at line 1493 of file driver_opengl.cpp. +

+References NL3D::IDriver::getTextureShareName(). +

+

01494 {
+01495         bool result;
+01496 
+01497         // Create the shared Name.
+01498         std::string     name;
+01499         getTextureShareName (tex, name);
+01500 
+01501         {
+01502                 CSynchronized<TTexDrvInfoPtrMap>::CAccessor access(&_SyncTexDrvInfos);
+01503                 TTexDrvInfoPtrMap &rTexDrvInfos = access.value();
+01504                 result = (rTexDrvInfos.find(name) != rTexDrvInfos.end());
+01505         }
+01506         return result;
+01507 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::isVertexProgramEmulated  )  const [private, virtual]
+
+ + + + + +
+   + + +

+Does the driver supports vertex program, but emulated by CPU ? +

+Implements NL3D::IDriver. +

+Definition at line 71 of file driver_opengl_vertex_program.cpp. +

+References _Extensions, and NL3D::CGlExtensions::NVVertexProgramEmulated. +

+

00072 {
+00073         return _Extensions.NVVertexProgramEmulated;
+00074 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::isVertexProgramEnabled  )  const [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 979 of file driver_opengl.h. +

+References _VertexProgramEnabled. +

+Referenced by setupGlArrays(), toggleGlArraysForEXTVertexShader(), and toggleGlArraysForNVVertexProgram(). +

+

00980         {
+00981                 // Don't use glIsEnabled, too slow.
+00982                 return _VertexProgramEnabled;
+00983         }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::isVertexProgramSupported  )  const [private, virtual]
+
+ + + + + +
+   + + +

+Does the driver supports vertex programs ? +

+Implements NL3D::IDriver. +

+Definition at line 65 of file driver_opengl_vertex_program.cpp. +

+References _Extensions, NL3D::CGlExtensions::EXTVertexShader, and NL3D::CGlExtensions::NVVertexProgram. +

+

00066 {       
+00067         return _Extensions.NVVertexProgram || _Extensions.EXTVertexShader;
+00068 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::isWaterShaderSupported  )  const [virtual]
+
+ + + + + +
+   + + +

+test wether a texture addressing mode is supported +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2376 of file driver_opengl.cpp. +

+References _Extensions, NL3D::CGlExtensions::ARBFragmentProgram, NL3D::CGlExtensions::ATIFragmentShader, NL3D::CGlExtensions::EXTVertexShader, NL3D::CGlExtensions::NVTextureShader, and NL3D::CGlExtensions::NVVertexProgram. +

+

02377 {
+02378         if (!_Extensions.EXTVertexShader && !_Extensions.NVVertexProgram) return false; // should support vertex programms
+02379         if (!_Extensions.NVTextureShader && !_Extensions.ATIFragmentShader && !_Extensions.ARBFragmentProgram) return false;
+02380         return true;
+02381 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::mapTextureStageToUV uint  stage,
uint  uv
[virtual]
+
+ + + + + +
+   + + +

+Say what Texture Stage use what UV coord. by default activeVertexBuffer*() methods map all stage i to UV i. You can change this behavior, after calling activeVertexBuffer*(), by using this method.

+eg: mapTextureStageToUV(0,2) will force the 0th texture stage to use the 2th UV.

+Warning! This DOESN'T work with VertexProgram enabled!! (assert)

+Warning!: some CMaterial Shader may change automatically this behavior too when setupMaterial() (and so render*()) is called. But Normal shader doesn't do it. +

+Implements NL3D::IDriver. +

+Definition at line 479 of file driver_opengl_vertex.cpp. +

+References _LastVB, setupUVPtr(), and uint. +

+

00480 {
+00481         // Just call it for last VertexBuffer setuped.
+00482         setupUVPtr(stage, _LastVB, uv);
+00483 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::multiplyModelMatrix const CMatrix mtx  )  [virtual]
+
+ + + + + +
+   + + +

+multipliy the model matrix. NB: you must use multiplyModelMatrix() AFTER setupModelMatrix() (and so setupViewMatrix()) or an other multiplyModelMatrix(), or else undefined results.

+Using of multiplyModelMatrix() instead of just one setupModelMatrix() may be usefull for precision consideration. +

+Implements NL3D::IDriver. +

+Definition at line 143 of file driver_opengl_matrix.cpp. +

+References _ModelViewMatrix, _ModelViewMatrixDirty, and _RenderSetupDirty. +

+

00144 {
+00145         // Dirt flags.
+00146         _ModelViewMatrixDirty= true;
+00147         _RenderSetupDirty= true;
+00148 
+00149 
+00150         // multiply this modelMatrix with the _ModelViewMatrix.
+00151         _ModelViewMatrix= _ModelViewMatrix*mtx;
+00152 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::profileAllocatedTextureMemory  )  [virtual]
+
+ + + + + +
+   + + +

+Return the amount of Texture memory requested. taking mipmap, compression, texture format, etc... into account. NB: because of GeForce*, RGB888 is considered to be 32 bits. So it may be false for others cards :). +

+Implements NL3D::IDriver. +

+Definition at line 2313 of file driver_opengl.cpp. +

+References _AllocatedTextureMemory, and uint32. +

+

02314 {
+02315         return _AllocatedTextureMemory;
+02316 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::profileRenderedPrimitives CPrimitiveProfile pIn,
CPrimitiveProfile pOut
[virtual]
+
+ + + + + +
+   + + +

+Get the number of primitives rendered from the last swapBuffers() call.

Parameters:
+ + + +
pIn the number of requested rendered primitive.
pOut the number of effective rendered primitive. pOut==pIn if no multi-pass material is used (Lightmap, Specular ...).
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2305 of file driver_opengl.cpp. +

+References _PrimitiveProfileIn, and _PrimitiveProfileOut. +

+

02306 {
+02307         pIn= _PrimitiveProfileIn;
+02308         pOut= _PrimitiveProfileOut;
+02309 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::profileSetupedMaterials  )  const [virtual]
+
+ + + + + +
+   + + +

+Get the number of material setuped from the last swapBuffers() call. +

+Implements NL3D::IDriver. +

+Definition at line 2320 of file driver_opengl.cpp. +

+References _NbSetupMaterialCall, and uint32. +

+

02321 {
+02322         return _NbSetupMaterialCall;
+02323 }
+
+

+ + + + +
+ + + + + + + + + +
uint32 NL3D::CDriverGL::profileSetupedModelMatrix  )  const [virtual]
+
+ + + + + +
+   + + +

+Get the number of matrix setuped from the last swapBuffers() call. +

+Implements NL3D::IDriver. +

+Definition at line 2327 of file driver_opengl.cpp. +

+References _NbSetupModelMatrixCall, and uint32. +

+

02328 {
+02329         return _NbSetupModelMatrixCall;
+02330 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::profileVBHardAllocation std::vector< std::string > &  result  )  [virtual]
+
+ + + + + +
+   + + +

+display VBhards allocated +

+Implements NL3D::IDriver. +

+Definition at line 3157 of file driver_opengl.cpp. +

+References _VertexBufferHardSet, getAvailableVertexAGPMemory(), getAvailableVertexVRAMMemory(), NL3D::IVertexBufferHard::getName(), NL3D::IVertexBufferHard::getNumVertices(), NL3D::IVertexBufferHard::getVertexSize(), NL3D::CPtrSet< IVertexBufferHardGL >::Set, NLMISC::toString(), and uint. +

+

03158 {
+03159         result.clear();
+03160         result.reserve(1000);
+03161         result.push_back(toString("Memory Allocated: %4d Ko in AGP / %4df Ko in VRAM", 
+03162                 getAvailableVertexAGPMemory()/1000, getAvailableVertexVRAMMemory()/1000 ));
+03163         result.push_back(toString("Num VBHard: %d", _VertexBufferHardSet.Set.size()));
+03164 
+03165         uint    totalMemUsed= 0;
+03166         set<IVertexBufferHardGL*>::iterator     it;
+03167         for(it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++)
+03168         {
+03169                 IVertexBufferHardGL     *vbHard= *it;
+03170                 if(vbHard)
+03171                 {
+03172                         uint    vSize= vbHard->getVertexSize();
+03173                         uint    numVerts= vbHard->getNumVertices();
+03174                         totalMemUsed+= vSize*numVerts;
+03175                 }
+03176         }
+03177         result.push_back(toString("Mem Used: %4d Ko", totalMemUsed/1000) );
+03178         
+03179         for(it= _VertexBufferHardSet.Set.begin(); it!=_VertexBufferHardSet.Set.end(); it++)
+03180         {
+03181                 IVertexBufferHardGL     *vbHard= *it;
+03182                 if(vbHard)
+03183                 {
+03184                         uint    vSize= vbHard->getVertexSize();
+03185                         uint    numVerts= vbHard->getNumVertices();
+03186                         result.push_back(toString("  %16s: %4d ko (format: %d / numVerts: %d)", 
+03187                                 vbHard->getName().c_str(), vSize*numVerts/1000, vSize, numVerts ));
+03188                 }
+03189         }
+03190 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::refreshProjMatrixFromGL  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2589 of file driver_opengl.cpp. +

+References _GLProjMat, _ProjMatDirty, and NLMISC::CMatrix::set(). +

+Referenced by setConstantMatrix(). +

+

02590 {
+02591         if (!_ProjMatDirty) return;     
+02592         float mat[16];
+02593         glGetFloatv(GL_PROJECTION_MATRIX, mat);
+02594         _GLProjMat.set(mat);    
+02595         _ProjMatDirty = false;
+02596 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::refreshRenderSetup  )  [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 865 of file driver_opengl.h. +

+References _RenderSetupDirty, and doRefreshRenderSetup(). +

+Referenced by render(), renderOrientedQuads(), renderPoints(), renderQuads(), renderSimpleTriangles(), renderTriangles(), and setConstantMatrix(). +

+

00866         {
+00867                 // check if something to change.
+00868                 if(_RenderSetupDirty)
+00869                 {
+00870                         doRefreshRenderSetup();
+00871                 }
+00872         }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::release  )  [virtual]
+
+ + + + + +
+   + + +

+Deriver should calls IDriver::release() first, to destroy all driver components (textures, shaders, VBuffers). +

+ +

+Reimplemented from NL3D::IDriver. +

+Definition at line 1667 of file driver_opengl.cpp. +

+References _AGPVertexArrayRange, _FullScreen, _Initialized, _OffScreen, _VRAMVertexArrayRange, deleteFragmentShaders(), nlinfo, nlwarning, and resetVertexArrayRange(). +

+Referenced by ~CDriverGL(). +

+

01668 {
+01669         // release only if the driver was initialized
+01670         if (!_Initialized) return true;
+01671 
+01672         // Call IDriver::release() before, to destroy textures, shaders and VBs...
+01673         IDriver::release();
+01674 
+01675 
+01676         deleteFragmentShaders();        
+01677 
+01678         // release caustic cube map
+01679 //      _CauticCubeMap = NULL;
+01680 
+01681         // Reset VertexArrayRange.
+01682         resetVertexArrayRange();
+01683 
+01684         // delete containers
+01685         delete _AGPVertexArrayRange;
+01686         delete _VRAMVertexArrayRange;
+01687         _AGPVertexArrayRange= NULL;
+01688         _VRAMVertexArrayRange= NULL;
+01689 
+01690 #ifdef NL_OS_WINDOWS
+01691         // Then delete.
+01692         // wglMakeCurrent(NULL,NULL);
+01693 
+01694         // Off-screen rendering ?
+01695         if (_OffScreen)
+01696         {
+01697                 if (_PBuffer)
+01698                 {
+01699                         wglDeleteContext( _hRC );
+01700                         wglReleasePbufferDCARB( _PBuffer, _hDC );
+01701                         wglDestroyPbufferARB( _PBuffer );
+01702                 }
+01703         }
+01704         else
+01705         {
+01706                 if (_hRC)
+01707                         wglDeleteContext(_hRC);
+01708                 if (_hWnd&&_hDC)
+01709                 {
+01710                         ReleaseDC(_hWnd,_hDC);
+01711                         if (_DestroyWindow)
+01712                                 DestroyWindow (_hWnd);
+01713                 }
+01714 
+01715                 if(_FullScreen)
+01716                 {
+01717                         ChangeDisplaySettings(&_OldScreenMode, 0);
+01718                         _FullScreen= false;
+01719                 }
+01720         }
+01721 
+01722         _hRC=NULL;
+01723         _hDC=NULL;
+01724         _hWnd=NULL;
+01725         _PBuffer = NULL;
+01726 
+01727         // Restaure monitor color parameters
+01728         if (_NeedToRestaureGammaRamp)
+01729         {
+01730                 HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL);
+01731                 if (dc)
+01732                 {
+01733                         if (!SetDeviceGammaRamp (dc, _GammaRampBackuped))
+01734                                 nlwarning ("(CDriverGL::release): SetDeviceGammaRamp failed");
+01735 
+01736                         // Release the DC
+01737                         ReleaseDC (NULL, dc);
+01738                 }
+01739                 else
+01740                 {
+01741                         nlwarning ("(CDriverGL::release): can't create DC");
+01742                 }
+01743         }
+01744 
+01745 #elif defined (NL_OS_UNIX)// NL_OS_WINDOWS
+01746  
+01747 #ifdef XF86VIDMODE
+01748         if(_FullScreen)
+01749         {
+01750                 XF86VidModeModeInfo info;
+01751                 nlinfo("Switching back to original mode \n");
+01752  
+01753                 // This is a bit ugly - a quick hack to copy the ModeLine structure 
+01754                 // into the modeInfo structure.
+01755                 memcpy((XF86VidModeModeLine *)((char *)&info + sizeof(info.dotclock)),&_OldScreenMode, sizeof(XF86VidModeModeLine));
+01756                 info.dotclock = _OldDotClock;
+01757  
+01758                 nlinfo("Mode is %dx%d,\n",info.hdisplay,info.vdisplay);
+01759                 XF86VidModeSwitchToMode(dpy,DefaultScreen(dpy),&info);
+01760                 nlinfo("Switching viewporr to %d,%d,\n",_OldX, _OldY);
+01761                 XF86VidModeSetViewPort(dpy,DefaultScreen(dpy),_OldX,_OldY);
+01762                 // Ungrab the keyboard (probably not necessary);
+01763                 XUngrabKeyboard(dpy, CurrentTime);
+01764         }
+01765 #endif // XF86VIDMODE
+01766 
+01767 #endif // NL_OS_UNIX
+01768 
+01769 
+01770         // released
+01771         _Initialized= false;
+01772 
+01773         return true;
+01774 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::IDriver::removeShaderPtr ItShaderPtrList  shaderIt  )  [protected, inherited]
+
+ + + + + +
+   + + +

+ +

+Definition at line 232 of file driver.cpp. +

+References NL3D::IDriver::_Shaders, and NL3D::ItShaderPtrList. +

+Referenced by NL3D::IShader::~IShader(). +

+

00233 {
+00234         _Shaders.erase(shaderIt);
+00235 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::IDriver::removeTextureDrvInfoPtr ItTexDrvInfoPtrMap  texDrvInfoIt  )  [protected, inherited]
+
+ + + + + +
+   + + +

+ +

+Definition at line 219 of file driver.cpp. +

+References NL3D::IDriver::_SyncTexDrvInfos, and NL3D::ItTexDrvInfoPtrMap. +

+Referenced by NL3D::ITextureDrvInfos::~ITextureDrvInfos(). +

+

00220 {
+00221         CSynchronized<TTexDrvInfoPtrMap>::CAccessor access(&_SyncTexDrvInfos);
+00222         TTexDrvInfoPtrMap &rTexDrvInfos = access.value();
+00223 
+00224         rTexDrvInfos.erase(texDrvInfoIt);
+00225 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::IDriver::removeTextureDrvSharePtr ItTexDrvSharePtrList  texDrvShareIt  )  [protected, inherited]
+
+ + + + + +
+   + + +

+ +

+Definition at line 227 of file driver.cpp. +

+References NL3D::IDriver::_TexDrvShares, and NL3D::ItTexDrvSharePtrList. +

+Referenced by NL3D::CTextureDrvShare::~CTextureDrvShare(). +

+

00228 {
+00229         _TexDrvShares.erase(texDrvShareIt);
+00230 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::IDriver::removeVBDrvInfoPtr ItVBDrvInfoPtrList  vbDrvInfoIt  )  [protected, inherited]
+
+ + + + + +
+   + + +

+remove ptr from the lists in the driver. +

+ +

+Definition at line 214 of file driver.cpp. +

+References NL3D::IDriver::_VBDrvInfos, and NL3D::ItVBDrvInfoPtrList. +

+Referenced by NL3D::IVBDrvInfos::~IVBDrvInfos(). +

+

00215 {
+00216         _VBDrvInfos.erase(vbDrvInfoIt);
+00217 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::IDriver::removeVtxPrgDrvInfoPtr ItVtxPrgDrvInfoPtrList  vtxPrgDrvInfoIt  )  [protected, inherited]
+
+ + + + + +
+   + + +

+ +

+Definition at line 237 of file driver.cpp. +

+References NL3D::IDriver::_VtxPrgDrvInfos, and NL3D::ItVtxPrgDrvInfoPtrList. +

+Referenced by NL3D::IVertexProgramDrvInfos::~IVertexProgramDrvInfos(). +

+

00238 {
+00239         _VtxPrgDrvInfos.erase(vtxPrgDrvInfoIt);
+00240 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::render CPrimitiveBlock PB,
CMaterial Mat
[virtual]
+
+ + + + + +
+   + + +

+render a block of primitive with previously setuped VertexBuffer / Matrixes. +

+Implements NL3D::IDriver. +

+Definition at line 135 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _PrimitiveProfileIn, _PrimitiveProfileOut, beginMultiPass(), endMultiPass(), NL3D::CPrimitiveBlock::getLinePointer(), NL3D::CPrimitiveBlock::getNumLine(), NL3D::CPrimitiveBlock::getNumQuad(), NL3D::CPrimitiveBlock::getNumTri(), NL3D::CPrimitiveBlock::getQuadPointer(), NL3D::CPrimitiveBlock::getTriPointer(), NL3D::IVertexBufferHardGL::GPURenderingAfterFence, NL3D::CPrimitiveProfile::NLines, NL3D::CPrimitiveProfile::NQuads, NL3D::CPrimitiveProfile::NTriangles, refreshRenderSetup(), setupMaterial(), setupPass(), and uint. +

+

00136 {       
+00137         // update matrix and Light in OpenGL if needed
+00138         refreshRenderSetup();
+00139 
+00140         // setup material
+00141         if ( !setupMaterial(Mat) )
+00142                 return false;
+00143 
+00144         
+00145 
+00146         // render primitives.
+00147         //==============================
+00148         // start multipass.
+00149         uint    nPass;
+00150         nPass= beginMultiPass();
+00151         // draw all passes.
+00152         for(uint pass=0;pass<nPass; pass++)
+00153         {
+00154                 // setup the pass.
+00155                 setupPass(pass);                
+00156                 // draw the primitives.
+00157                 if(PB.getNumTri()!=0)
+00158                         glDrawElements(GL_TRIANGLES,3*PB.getNumTri(),GL_UNSIGNED_INT,PB.getTriPointer());
+00159                 if(PB.getNumQuad()!=0)
+00160                         glDrawElements(GL_QUADS,4*PB.getNumQuad(),GL_UNSIGNED_INT,PB.getQuadPointer());
+00161                 if(PB.getNumLine()!=0)
+00162                         glDrawElements(GL_LINES,2*PB.getNumLine(),GL_UNSIGNED_INT,PB.getLinePointer());
+00163         }
+00164         // end multipass.
+00165         endMultiPass();
+00166 
+00167 
+00168         // Profiling.
+00169         _PrimitiveProfileIn.NLines+= PB.getNumLine();
+00170         _PrimitiveProfileIn.NTriangles+= PB.getNumTri();
+00171         _PrimitiveProfileIn.NQuads+= PB.getNumQuad();
+00172         _PrimitiveProfileOut.NLines+= PB.getNumLine() * nPass;
+00173         _PrimitiveProfileOut.NTriangles+= PB.getNumTri() * nPass;
+00174         _PrimitiveProfileOut.NQuads+= PB.getNumQuad() * nPass;
+00175 
+00176         // We have render some prims. inform the VBHard.
+00177         if(_CurrentVertexBufferHard)
+00178                 _CurrentVertexBufferHard->GPURenderingAfterFence= true;
+00179 
+00180         return true;
+00181 
+00182 
+00183 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::renderOrientedQuads CMaterial mat,
uint32  startIndex,
uint32  numQuads
[virtual]
+
+ + + + + +
+   + + +

+Render quads with previously setuped VertexBuffer / Matrixes. There's a garanty for the orientation of its diagonal, which is drawn as follow :

+3----2 | / | | / | |/ | 0----1

+The rendering may be slower than with 'renderQuads', however This orientation is not garanteed with renderQuads, and depends on the hardware +

+Implements NL3D::IDriver. +

+Definition at line 291 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _PrimitiveProfileIn, _PrimitiveProfileOut, beginMultiPass(), endMultiPass(), NL3D::IVertexBufferHardGL::GPURenderingAfterFence, min, NL3D::CPrimitiveProfile::NQuads, refreshRenderSetup(), setupMaterial(), setupPass(), uint, uint16, and uint32. +

+

00292 {
+00293         if (!numQuads) return;
+00294         
+00295         // update matrix and Light in OpenGL if needed
+00296         refreshRenderSetup();
+00297 
+00298         // setup material
+00299         if ( !setupMaterial(mat) )
+00300                 return; 
+00301 
+00302         const uint32 QUAD_BATCH_SIZE = 2048;
+00303         static GLshort defaultIndices[QUAD_BATCH_SIZE * 6];
+00304         static bool     init = false;
+00305         if (!init)
+00306         {
+00307                 // setup the base index buffer
+00308                 for(uint k = 0; k < QUAD_BATCH_SIZE; ++k)
+00309                 {
+00310                         // first tri
+00311                         defaultIndices[k * 6] = (GLshort) (k * 4);
+00312                         defaultIndices[k * 6 + 1] = (GLshort) (k * 4 + 2);
+00313                         defaultIndices[k * 6 + 2] = (GLshort) (k * 4 + 1);
+00314                         // second tri
+00315                         defaultIndices[k * 6 + 3] = (GLshort) (k * 4);
+00316                         defaultIndices[k * 6 + 4] = (GLshort) (k * 4 + 2);
+00317                         defaultIndices[k * 6 + 5] = (GLshort) (k * 4 + 3);
+00318                 }
+00319                 init = true;
+00320         }
+00321 
+00322         // render primitives.
+00323         //==============================
+00324         // start multipass.
+00325         uint    nPass;
+00326         nPass= beginMultiPass();
+00327         // draw all passes.
+00328         for(uint pass=0;pass<nPass; pass++)
+00329         {
+00330                 // setup the pass.
+00331                 setupPass(pass);
+00332                 
+00333                 uint32 currIndex = startIndex;
+00334                 uint32 numLeftQuads = numQuads;
+00335 
+00336                 // draw first batch of quads using the static setupped array
+00337                 if (startIndex < QUAD_BATCH_SIZE)
+00338                 {
+00339                         // draw first quads (as pair of tri to have guaranteed orientation)
+00340                         uint numQuadsToDraw = std::min(QUAD_BATCH_SIZE - startIndex, numQuads);
+00341                         glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, defaultIndices + 6 * startIndex);
+00342                         numLeftQuads -= numQuadsToDraw;
+00343                         currIndex += 4 * numQuadsToDraw;
+00344                 }
+00345 
+00346                 // draw remaining quads
+00347                 while (numLeftQuads)
+00348                 {
+00349                         // TODO : resetting vertex pointer would avoid the need to rebuild indices each times
+00350                         uint32 numQuadsToDraw = std::min(numLeftQuads, QUAD_BATCH_SIZE);
+00351                         // draw all quads
+00352                         if (4 * numQuadsToDraw + currIndex <= (1 << 16))
+00353                         {
+00354                                 // indices fits on 16 bits
+00355                                 GLshort indices[QUAD_BATCH_SIZE * 6];
+00356                                 GLshort *curr = indices;
+00357                                 GLshort *end = indices + 6 * numQuadsToDraw;
+00358                                 uint16 vertexIndex = (uint16) currIndex;
+00359                                 do 
+00360                                 {
+00361                                         *curr++ = vertexIndex;
+00362                                         *curr++ = vertexIndex + 2;
+00363                                         *curr++ = vertexIndex + 1;
+00364                                         *curr++ = vertexIndex;
+00365                                         *curr++ = vertexIndex + 2;
+00366                                         *curr++ = vertexIndex + 3;
+00367                                         vertexIndex += 4;
+00368                                 } 
+00369                                 while(curr != end);
+00370                                 glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_SHORT, indices);
+00371                         }
+00372                         else
+00373                         {       
+00374                                 // indices fits on 32 bits
+00375                                 GLint indices[QUAD_BATCH_SIZE];
+00376                                 GLint *curr = indices;
+00377                                 GLint *end = indices + 6 * numQuadsToDraw;
+00378                                 uint32 vertexIndex = currIndex;
+00379                                 do 
+00380                                 {
+00381                                         *curr++ = vertexIndex;
+00382                                         *curr++ = vertexIndex + 2;
+00383                                         *curr++ = vertexIndex + 1;
+00384                                         *curr++ = vertexIndex;
+00385                                         *curr++ = vertexIndex + 2;
+00386                                         *curr++ = vertexIndex + 3;
+00387                                         vertexIndex += 4;
+00388                                 } 
+00389                                 while(curr != end);
+00390                                 glDrawElements(GL_TRIANGLES, 6 * numQuadsToDraw, GL_UNSIGNED_INT, indices);
+00391                         }
+00392                         numLeftQuads -= numQuadsToDraw;
+00393                         currIndex += 4 * numQuadsToDraw;
+00394                 }
+00395         }
+00396         // end multipass.
+00397         endMultiPass();
+00398 
+00399 
+00400         // Profiling.
+00401         _PrimitiveProfileIn.NQuads  += numQuads ;
+00402         _PrimitiveProfileOut.NQuads += numQuads  * nPass;
+00403 
+00404         // We have render some prims. inform the VBHard.
+00405         if(_CurrentVertexBufferHard)
+00406                 _CurrentVertexBufferHard->GPURenderingAfterFence= true;
+00407 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::renderPoints CMaterial Mat,
uint32  numPoints
[virtual]
+
+ + + + + +
+   + + +

+render points with previously setuped VertexBuffer / Matrixes. +

+Implements NL3D::IDriver. +

+Definition at line 253 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _PrimitiveProfileIn, _PrimitiveProfileOut, beginMultiPass(), endMultiPass(), NL3D::IVertexBufferHardGL::GPURenderingAfterFence, NL3D::CPrimitiveProfile::NPoints, refreshRenderSetup(), setupMaterial(), setupPass(), uint, and uint32. +

+

00254 {
+00255         // update matrix and Light in OpenGL if needed
+00256         refreshRenderSetup();
+00257 
+00258         // setup material
+00259         if ( !setupMaterial(Mat) )
+00260                 return; 
+00261 
+00262 
+00263         // render primitives.
+00264         //==============================
+00265         // start multipass.
+00266         uint    nPass;
+00267         nPass= beginMultiPass();
+00268         // draw all passes.
+00269         for(uint pass=0;pass<nPass; pass++)
+00270         {
+00271                 // setup the pass.
+00272                 setupPass(pass);
+00273                 // draw the primitives.
+00274                 if(numPoints)
+00275                         glDrawArrays(GL_POINTS,0, numPoints);
+00276         }
+00277         // end multipass.
+00278         endMultiPass();
+00279 
+00280 
+00281         // Profiling.
+00282         _PrimitiveProfileIn.NPoints+= numPoints;
+00283         _PrimitiveProfileOut.NPoints+= numPoints * nPass;
+00284 
+00285         // We have render some prims. inform the VBHard.
+00286         if(_CurrentVertexBufferHard)
+00287                 _CurrentVertexBufferHard->GPURenderingAfterFence= true;
+00288 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::renderQuads CMaterial Mat,
uint32  startIndex,
uint32  numQuads
[virtual]
+
+ + + + + +
+   + + +

+render quads with previously setuped VertexBuffer / Matrixes. Quads are stored as a sequence in the vertex buffer. +

+Implements NL3D::IDriver. +

+Definition at line 410 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _PrimitiveProfileIn, _PrimitiveProfileOut, beginMultiPass(), endMultiPass(), NL3D::IVertexBufferHardGL::GPURenderingAfterFence, NL3D::CPrimitiveProfile::NQuads, refreshRenderSetup(), setupMaterial(), setupPass(), uint, and uint32. +

+

00411 {
+00412         // update matrix and Light in OpenGL if needed
+00413         refreshRenderSetup();
+00414 
+00415         // setup material
+00416         if ( !setupMaterial(Mat) )
+00417                 return; 
+00418 
+00419 
+00420         // render primitives.
+00421         //==============================
+00422         // start multipass.
+00423         uint    nPass;
+00424         nPass= beginMultiPass();
+00425         // draw all passes.
+00426         for(uint pass=0;pass<nPass; pass++)
+00427         {
+00428                 // setup the pass.
+00429                 setupPass(pass);
+00430                 // draw the primitives.
+00431                 if(numQuads)
+00432                         glDrawArrays(GL_QUADS, startIndex << 2, numQuads << 2) ;
+00433         }
+00434         // end multipass.
+00435         endMultiPass();
+00436 
+00437 
+00438         // Profiling.
+00439         _PrimitiveProfileIn.NQuads  += numQuads ;
+00440         _PrimitiveProfileOut.NQuads += numQuads  * nPass;
+00441 
+00442         // We have render some prims. inform the VBHard.
+00443         if(_CurrentVertexBufferHard)
+00444                 _CurrentVertexBufferHard->GPURenderingAfterFence= true;
+00445 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::renderSimpleTriangles uint32 tri,
uint32  ntris
[virtual]
+
+ + + + + +
+   + + +

+render a list of triangles with previously setuped VertexBuffer / Matrixes, AND previously setuped MATERIAL!! This use the last material setuped. It should be a "Normal shader" material, because no multi-pass is allowed with this method. Actually, it is like a straight drawTriangles() in OpenGL. NB: nlassert() if ntris is 0!!!! this is unlike other render() call methods. For optimisation concern. NB: this is usefull for landscape.... +

+Implements NL3D::IDriver. +

+Definition at line 226 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _PrimitiveProfileIn, _PrimitiveProfileOut, NL3D::IVertexBufferHardGL::GPURenderingAfterFence, nlassert, NL3D::CPrimitiveProfile::NTriangles, refreshRenderSetup(), and uint32. +

+

00227 {
+00228         nlassert(ntris>0);
+00229 
+00230         // update matrix and Light in OpenGL if needed
+00231         refreshRenderSetup();
+00232 
+00233 
+00234         // Don't setup any material here.
+00235         
+00236         // render primitives.
+00237         //==============================
+00238         // NO MULTIPASS HERE!!
+00239         // draw the primitives. (nb: ntrsi>0).
+00240         glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, tri);
+00241 
+00242         // Profiling.
+00243         _PrimitiveProfileIn.NTriangles+= ntris;
+00244         _PrimitiveProfileOut.NTriangles+= ntris;
+00245 
+00246         // We have render some prims. inform the VBHard.
+00247         if(_CurrentVertexBufferHard)
+00248                 _CurrentVertexBufferHard->GPURenderingAfterFence= true;
+00249 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::renderTriangles CMaterial Mat,
uint32 tri,
uint32  ntris
[virtual]
+
+ + + + + +
+   + + +

+render a list of triangles with previously setuped VertexBuffer / Matrixes. NB: this "was" usefull for landscape.... +

+Implements NL3D::IDriver. +

+Definition at line 187 of file driver_opengl_vertex.cpp. +

+References _CurrentVertexBufferHard, _PrimitiveProfileIn, _PrimitiveProfileOut, beginMultiPass(), endMultiPass(), NL3D::IVertexBufferHardGL::GPURenderingAfterFence, NL3D::CPrimitiveProfile::NTriangles, refreshRenderSetup(), setupMaterial(), setupPass(), uint, and uint32. +

+

00188 {
+00189         // update matrix and Light in OpenGL if needed
+00190         refreshRenderSetup();
+00191 
+00192         // setup material
+00193         if ( !setupMaterial(Mat) )
+00194                 return;
+00195 
+00196         
+00197         // render primitives.
+00198         //==============================
+00199         // start multipass.
+00200         uint    nPass;
+00201         nPass= beginMultiPass();
+00202         // draw all passes.
+00203         for(uint pass=0;pass<nPass; pass++)
+00204         {
+00205                 // setup the pass.
+00206                 setupPass(pass);
+00207                 // draw the primitives.
+00208                 if(ntris!=0)
+00209                         glDrawElements(GL_TRIANGLES,3*ntris,GL_UNSIGNED_INT, tri);
+00210         }
+00211         // end multipass.
+00212         endMultiPass();
+00213 
+00214 
+00215         // Profiling.
+00216         _PrimitiveProfileIn.NTriangles+= ntris;
+00217         _PrimitiveProfileOut.NTriangles+= ntris * nPass;
+00218 
+00219         // We have render some prims. inform the VBHard.
+00220         if(_CurrentVertexBufferHard)
+00221                 _CurrentVertexBufferHard->GPURenderingAfterFence= true;
+00222 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::resetLightMapVertexSetup  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 948 of file driver_opengl_material.cpp. +

+References _DriverGLStates, _LastVB, _LastVertexSetupIsLightMap, _LightMapUVMap, NL3D::CDriverGLStates::enableColorArray(), inlGetNumTextStages(), setupUVPtr(), sint, and NL3D::CVertexBufferInfo::VertexFormat. +

+Referenced by setupMaterial(). +

+

00949 {
+00950         // special for all stage, std UV behavior.
+00951         for(sint i=0; i<inlGetNumTextStages(); i++)
+00952         {
+00953                 // normal behavior: each texture has its own UV.
+00954                 setupUVPtr(i, _LastVB, i);
+00955                 // reset cache
+00956                 _LightMapUVMap[i]= -1;
+00957         }
+00958 
+00959         // pop VertexColor array if necessary.
+00960         if (_LastVB.VertexFormat & CVertexBuffer::PrimaryColorFlag)
+00961                 _DriverGLStates.enableColorArray(true);
+00962 
+00963         // flag
+00964         _LastVertexSetupIsLightMap= false;
+00965 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::resetTextureShaders  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1440 of file driver_opengl.cpp. +

+References _CurrentTexAddrMode, _DriverGLStates, _Extensions, _NVTextureShaderEnabled, NL3D::CDriverGLStates::activeTextureARB(), GL_PREVIOUS_TEXTURE_INPUT_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_SHADER_NV, inlGetNumTextStages(), NL3D::CGlExtensions::NVTextureShader, and uint. +

+

01441 {       
+01442         if (_Extensions.NVTextureShader)
+01443         {
+01444                 glEnable(GL_TEXTURE_SHADER_NV);
+01445                 for (uint stage = 0; stage < (uint) inlGetNumTextStages(); ++stage)
+01446                 {               
+01447                         _DriverGLStates.activeTextureARB(stage);
+01448                         if (stage != 0)
+01449                         {
+01450                                 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + stage - 1);     
+01451                         }
+01452                         glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);       
+01453                         _CurrentTexAddrMode[stage] = GL_NONE;                   
+01454                 }
+01455                 glDisable(GL_TEXTURE_SHADER_NV);
+01456                 _NVTextureShaderEnabled = false;
+01457         }
+01458 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::resetVertexArrayRange  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1207 of file driver_opengl_vertex.cpp. +

+References _AGPVertexArrayRange, _CurrentVertexBufferHard, _VertexBufferHardSet, _VRAMVertexArrayRange, NL3D::CPtrSet< IVertexBufferHardGL >::clear(), NL3D::IVertexBufferHardGL::disable(), NL3D::IVertexArrayRange::free(), NL3D::IVertexBufferHard::lock(), and NL3D::IVertexBufferHard::unlock(). +

+Referenced by initVertexArrayRange(), and release(). +

+

01208 {
+01209         if(_CurrentVertexBufferHard)
+01210         {
+01211                 // Must ensure it has ended any drawing
+01212                 _CurrentVertexBufferHard->lock();
+01213                 _CurrentVertexBufferHard->unlock();
+01214                 // disable it
+01215                 _CurrentVertexBufferHard->disable();
+01216         }
+01217         // Clear any VertexBufferHard created.
+01218         _VertexBufferHardSet.clear();
+01219 
+01220         // After, Clear the 2 vertexArrayRange, if any.
+01221         if(_AGPVertexArrayRange)
+01222                 _AGPVertexArrayRange->free();
+01223         if(_VRAMVertexArrayRange)
+01224                 _VRAMVertexArrayRange->free();
+01225 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::retrieveATIDriverVersion  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 3199 of file driver_opengl.cpp. +

+References _ATIDriverVersion, _ATIFogRangeFixed, NLMISC::strlwr(), and uint. +

+Referenced by init(). +

+

03200 {
+03201         _ATIDriverVersion = 0;
+03202         // we may need this driver version to fix flaws of previous ati drivers version (fog issue with V.P)
+03203         #ifdef NL_OS_WINDOWS
+03204                 // get from the registry
+03205                 HKEY parentKey;
+03206                 // open key about current video card
+03207                 LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}", 0, KEY_READ, &parentKey);
+03208                 if (result == ERROR_SUCCESS)
+03209                 {
+03210                         // find last config
+03211                         DWORD keyIndex = 0;                     
+03212                         uint latestConfigVersion = 0;
+03213                         char subKeyName[256];
+03214                         char latestSubKeyName[256] = "";
+03215                         DWORD nameBufferSize = sizeof(subKeyName) / sizeof(subKeyName[0]);
+03216                         FILETIME lastWriteTime;
+03217                         bool configFound = false;
+03218                         for(;;)
+03219                         {                       
+03220                                 nameBufferSize = sizeof(subKeyName) / sizeof(subKeyName[0]);
+03221                                 result = RegEnumKeyEx(parentKey, keyIndex, subKeyName, &nameBufferSize, NULL, NULL, NULL, &lastWriteTime);
+03222                                 if (result == ERROR_NO_MORE_ITEMS) break;
+03223                                 if (result == ERROR_SUCCESS)
+03224                                 {               
+03225                                         // see if the name is numerical.
+03226                                         bool isNumerical = true;
+03227                                         for(uint k = 0; k < nameBufferSize; ++k)
+03228                                         {
+03229                                                 if (!isdigit(subKeyName[k]))
+03230                                                 {
+03231                                                         isNumerical = false;
+03232                                                         break;
+03233                                                 }
+03234                                         }
+03235                                         if (isNumerical)
+03236                                         {
+03237                                                 uint configVersion = atoi(subKeyName);
+03238                                                 if (configVersion >= latestConfigVersion)
+03239                                                 {
+03240                                                         configFound = true;
+03241                                                         latestConfigVersion = configVersion;                                                    
+03242                                                         strcpy(latestSubKeyName, subKeyName);
+03243                                                 }
+03244                                         }
+03245                                         ++ keyIndex;
+03246                                 }
+03247                                 else
+03248                                 {               
+03249                                         RegCloseKey(parentKey);
+03250                                         return;
+03251                                 }
+03252                         }
+03253                         if (configFound)
+03254                         {
+03255                                 HKEY subKey;
+03256                                 result = RegOpenKeyEx(parentKey, latestSubKeyName, 0, KEY_READ, &subKey);
+03257                                 if (result == ERROR_SUCCESS)
+03258                                 {
+03259                                         // see if it is a radeon card
+03260                                         DWORD valueType;
+03261                                         char driverDesc[256];
+03262                                         DWORD driverDescBufSize = sizeof(driverDesc) / sizeof(driverDesc[0]);
+03263                                         result = RegQueryValueEx(subKey, "DriverDesc", NULL, &valueType, (unsigned char *) driverDesc, &driverDescBufSize);
+03264                                         if (result == ERROR_SUCCESS && valueType == REG_SZ)
+03265                                         {                                               
+03266                                                 NLMISC::strlwr(driverDesc);
+03267                                                 if (strstr(driverDesc, "radeon")) // is it a radeon card ?
+03268                                                 {
+03269                                                         char driverVersion[256];
+03270                                                         DWORD driverVersionBufSize = sizeof(driverVersion) / sizeof(driverVersion[0]);
+03271                                                         result = RegQueryValueEx(subKey, "DriverVersion", NULL, &valueType, (unsigned char *) driverVersion, &driverVersionBufSize);
+03272                                                         if (result == ERROR_SUCCESS && valueType == REG_SZ)
+03273                                                         {
+03274                                                                 int subVersionNumber[4];
+03275                                                                 if (sscanf(driverVersion, "%d.%d.%d.%d", &subVersionNumber[0], &subVersionNumber[1], &subVersionNumber[2], &subVersionNumber[3]) == 4)
+03276                                                                 {
+03277                                                                         _ATIDriverVersion = (uint) subVersionNumber[3];
+03282                                                                         if (_ATIDriverVersion < 6343)
+03283                                                                         {
+03284                                                                                 _ATIFogRangeFixed = false;
+03285                                                                         }
+03286                                                                 }
+03287                                                         }
+03288                                                 }
+03289                                         }
+03290                                 }
+03291                                 RegCloseKey(subKey);
+03292                         }
+03293                         RegCloseKey(parentKey);
+03294                 }               
+03295         #endif                  
+03296 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setAmbientColor CRGBA  color  )  [virtual]
+
+ + + + + +
+   + + +

+Set ambiant.

+

Parameters:
+ + +
color is the new global ambiant color for the scene.
+
+
See also:
setLight(), enableLight()
+ +

+Implements NL3D::IDriver. +

+Definition at line 164 of file driver_opengl_light.cpp. +

+References NLMISC::CRGBA::B, NLMISC::CRGBA::G, and NLMISC::CRGBA::R. +

+

00165 {
+00166         // Gl array
+00167         GLfloat array[4];
+00168         array[0]=(float)color.R/255.f;
+00169         array[1]=(float)color.G/255.f;
+00170         array[2]=(float)color.B/255.f;
+00171         array[3]=1.f;
+00172 
+00173         // Set the color
+00174         glLightModelfv (GL_LIGHT_MODEL_AMBIENT, array);
+00175 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setBlendConstantColor NLMISC::CRGBA  col  )  [virtual]
+
+ + + + + +
+   + + +

+see supportBlendConstantColor(). Set the current Blend Constant Color. +

+Implements NL3D::IDriver. +

+Definition at line 2564 of file driver_opengl.cpp. +

+References _CurrentBlendConstantColor, _Extensions, NL3D::CGlExtensions::EXTBlendColor, and nglBlendColorEXT. +

+

02565 {
+02566         // bkup
+02567         _CurrentBlendConstantColor= col;
+02568 
+02569         // update GL
+02570         if(!_Extensions.EXTBlendColor)
+02571                 return;
+02572         static const    float   OO255= 1.0f/255;
+02573         nglBlendColorEXT(col.R*OO255, col.G*OO255, col.B*OO255, col.A*OO255);
+02574 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setCapture bool  b  )  [virtual]
+
+ + + + + +
+   + + +

+If true, capture the mouse to force it to stay under the window. NB : this has no effects if a low level mouse is used +

+Implements NL3D::IDriver. +

+Definition at line 2074 of file driver_opengl.cpp. +

+

02075 {
+02076 #ifdef NL_OS_WINDOWS
+02077 
+02078         if (b)
+02079         {
+02080                 RECT client;
+02081                 GetClientRect (_hWnd, &client);
+02082                 POINT pt1,pt2;
+02083                 pt1.x = client.left;
+02084                 pt1.y = client.top;
+02085                 ClientToScreen (_hWnd, &pt1);
+02086                 pt2.x = client.right;
+02087                 pt2.y = client.bottom;
+02088                 ClientToScreen (_hWnd, &pt2);
+02089                 client.bottom = pt2.y;
+02090                 client.top = pt1.y;
+02091                 client.left = pt1.x;
+02092                 client.right = pt2.x;
+02093                 ClipCursor (&client);
+02094         }
+02095         else
+02096                 ClipCursor (NULL);
+02097 
+02098         /*
+02099         if (b)
+02100                 SetCapture (_hWnd);
+02101         else
+02102                 ReleaseCapture ();
+02103         */
+02104 
+02105 #elif defined (NL_OS_UNIX)
+02106 
+02107 #endif // NL_OS_UNIX
+02108 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setColorMask bool  bRed,
bool  bGreen,
bool  bBlue,
bool  bAlpha
[virtual]
+
+ + + + + +
+   + + +

+Set the color mask filter through where the operation done will pass. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1530 of file driver_opengl.cpp. +

+

01531 {
+01532         glColorMask (bRed, bGreen, bBlue, bAlpha);
+01533 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstant uint  index,
uint  num,
const double *  src
[private, virtual]
+
+ + + + + +
+   + + +

+setup several 4 double csts taken from the given tab +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1327 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, NL3D::CGlExtensions::EXTVertexShader, GL_VERTEX_PROGRAM_NV, index, nglProgramParameters4dvNV, nglSetInvariantEXT, num, NL3D::CGlExtensions::NVVertexProgram, src, and uint. +

+

01328 {
+01329         // Vertex program exist ?
+01330         if (_Extensions.NVVertexProgram)
+01331         {
+01332                 nglProgramParameters4dvNV(GL_VERTEX_PROGRAM_NV, index, num, src);
+01333         }
+01334         else if (_Extensions.EXTVertexShader)
+01335         {
+01336                 for(uint k = 0; k < num; ++k)
+01337                 {                                       
+01338                         nglSetInvariantEXT(_EVSConstantHandle + index + k, GL_DOUBLE, (void *) (src + 4 * k));
+01339                 }
+01340         }
+01341 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstant uint  index,
uint  num,
const float *  src
[private, virtual]
+
+ + + + + +
+   + + +

+setup several 4 float csts taken from the given tab +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1310 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, NL3D::CGlExtensions::EXTVertexShader, GL_VERTEX_PROGRAM_NV, index, nglProgramParameters4fvNV, nglSetInvariantEXT, num, NL3D::CGlExtensions::NVVertexProgram, src, and uint. +

+

01311 {
+01312         // Vertex program exist ?
+01313         if (_Extensions.NVVertexProgram)
+01314         {
+01315                 nglProgramParameters4fvNV(GL_VERTEX_PROGRAM_NV, index, num, src);
+01316         }       
+01317         else if (_Extensions.EXTVertexShader)
+01318         {
+01319                 for(uint k = 0; k < num; ++k)
+01320                 {                                       
+01321                         nglSetInvariantEXT(_EVSConstantHandle + index + k, GL_FLOAT, (void *) (src + 4 * k));
+01322                 }
+01323         }       
+01324 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstant uint  indexStart,
const NLMISC::CVectorD value
[private, virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1293 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, NL3D::CGlExtensions::EXTVertexShader, GL_VERTEX_PROGRAM_NV, index, nglProgramParameter4dNV, nglSetInvariantEXT, NL3D::CGlExtensions::NVVertexProgram, uint, and value. +

+

01294 {
+01295         // Vertex program exist ?
+01296         if (_Extensions.NVVertexProgram)
+01297         {
+01298                 // Setup constant
+01299                 nglProgramParameter4dNV (GL_VERTEX_PROGRAM_NV, index, value.x, value.y, value.z, 0);
+01300         }
+01301         else if (_Extensions.EXTVertexShader)
+01302         {
+01303                 double datas[] = { value.x, value.y, value.z, 0 };
+01304                 nglSetInvariantEXT(_EVSConstantHandle + index, GL_DOUBLE, datas);
+01305         }
+01306 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstant uint  indexStart,
const NLMISC::CVector value
[private, virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1275 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, NL3D::CGlExtensions::EXTVertexShader, GL_VERTEX_PROGRAM_NV, index, nglProgramParameter4fNV, nglSetInvariantEXT, NL3D::CGlExtensions::NVVertexProgram, uint, and value. +

+

01276 {
+01277         // Vertex program exist ?
+01278         if (_Extensions.NVVertexProgram)
+01279         {
+01280                 // Setup constant
+01281                 nglProgramParameter4fNV (GL_VERTEX_PROGRAM_NV, index, value.x, value.y, value.z, 0);    
+01282         }
+01283         else if (_Extensions.EXTVertexShader)
+01284         {
+01285                 float datas[] = { value.x, value.y, value.z, 0 };
+01286                 nglSetInvariantEXT(_EVSConstantHandle + index, GL_FLOAT, datas);
+01287         }
+01288 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstant uint  index,
double ,
double ,
double ,
double 
[private, virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1257 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, NL3D::CGlExtensions::EXTVertexShader, GL_VERTEX_PROGRAM_NV, index, nglProgramParameter4dNV, nglSetInvariantEXT, NL3D::CGlExtensions::NVVertexProgram, and uint. +

+

01258 {
+01259         // Vertex program exist ?
+01260         if (_Extensions.NVVertexProgram)
+01261         {
+01262                 // Setup constant
+01263                 nglProgramParameter4dNV (GL_VERTEX_PROGRAM_NV, index, d0, d1, d2, d3);
+01264         }
+01265         else if (_Extensions.EXTVertexShader)
+01266         {
+01267                 double datas[] = { d0, d1, d2, d3 };
+01268                 nglSetInvariantEXT(_EVSConstantHandle + index, GL_DOUBLE, datas);
+01269         }
+01270 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstant uint  index,
float ,
float ,
float ,
float 
[private, virtual]
+
+ + + + + +
+   + + +

+Setup constant values. +

+Implements NL3D::IDriver. +

+Definition at line 1239 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, NL3D::CGlExtensions::EXTVertexShader, GL_VERTEX_PROGRAM_NV, index, nglProgramParameter4fNV, nglSetInvariantEXT, NL3D::CGlExtensions::NVVertexProgram, and uint. +

+Referenced by setupFog(). +

+

01240 {
+01241         // Vertex program exist ?
+01242         if (_Extensions.NVVertexProgram)
+01243         {
+01244                 // Setup constant
+01245                 nglProgramParameter4fNV (GL_VERTEX_PROGRAM_NV, index, f0, f1, f2, f3);
+01246         }
+01247         else if (_Extensions.EXTVertexShader)
+01248         {
+01249                 float datas[] = { f0, f1, f2, f3 };
+01250                 nglSetInvariantEXT(_EVSConstantHandle + index, GL_FLOAT, datas);
+01251         }                
+01252 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
virtual void NL3D::IDriver::setConstantMatrix uint  index,
TMatrix  matrix,
TTransform  transform
[pure virtual, inherited]
+
+ + + + + +
+   + + +

+Setup constants with a current matrix.

+This call must be done after setFrustum(), setupViewMatrix() or setupModelMatrix() to get correct results.

+

Parameters:
+ + + + +
index is the base constant index where to store the matrix. This index must be a multiple of 4.
matrix is the matrix id to store in the constants
transform is the transformation to apply to the matrix before store it in the constants.
+
+ +

+Referenced by NL3D::CMeshVPPerPixelLight::begin(), NL3D::CLandscape::render(), NL3D::CWaterModel::setupMaterialNVertexShader(), NL3D::CMeshVPWindTree::setupPerInstanceConstants(), and NL3D::CVegetableManager::setupVertexProgramConstants().

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setConstantMatrix uint  index,
IDriver::TMatrix  matrix,
IDriver::TTransform  transform
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1366 of file driver_opengl_vertex_program.cpp. +

+References _EVSConstantHandle, _Extensions, _GLProjMat, _ModelViewMatrix, NL3D::CGlExtensions::EXTVertexShader, NLMISC::CMatrix::get(), GL_IDENTITY_NV, GL_VERTEX_PROGRAM_NV, GLMatrix, GLTransform, index, NLMISC::CMatrix::invert(), matrix, nglSetInvariantEXT, nglTrackMatrixNV, NL3D::CGlExtensions::NVVertexProgram, refreshProjMatrixFromGL(), refreshRenderSetup(), transform, NLMISC::CMatrix::transpose(), and uint. +

+

01367 {
+01368         // Vertex program exist ?
+01369         if (_Extensions.NVVertexProgram)
+01370         {
+01371                 // First, ensure that the render setup is correclty setuped.
+01372                 refreshRenderSetup();
+01373 
+01374                 // Track the matrix
+01375                 nglTrackMatrixNV (GL_VERTEX_PROGRAM_NV, index, GLMatrix[matrix], GLTransform[transform]);
+01376                 // Release Track => matrix data is copied.
+01377                 nglTrackMatrixNV (GL_VERTEX_PROGRAM_NV, index, GL_NONE, GL_IDENTITY_NV);
+01378         }
+01379         else if (_Extensions.EXTVertexShader)
+01380         {
+01381                 // First, ensure that the render setup is correctly setuped.
+01382                 refreshRenderSetup();           
+01383                 CMatrix mat;            
+01384                 switch (matrix)
+01385                 {
+01386                         case IDriver::ModelView:
+01387                                 mat = _ModelViewMatrix;
+01388                         break;
+01389                         case IDriver::Projection:
+01390                         {
+01391                                 refreshProjMatrixFromGL();
+01392                                 mat = _GLProjMat;
+01393                         }
+01394                         break;
+01395                         case IDriver::ModelViewProjection:
+01396                                 refreshProjMatrixFromGL();                              
+01397                                 mat = _GLProjMat * _ModelViewMatrix;
+01398                         break;
+01399                 }
+01400 
+01401                 switch(transform)
+01402                 {
+01403                         case IDriver::Identity: break;
+01404                         case IDriver::Inverse:
+01405                                 mat.invert();
+01406                         break;          
+01407                         case IDriver::Transpose:
+01408                                 mat.transpose();                                                                
+01409                         break;
+01410                         case IDriver::InverseTranspose:
+01411                                 mat.invert();
+01412                                 mat.transpose();                                
+01413                         break;
+01414                 }
+01415                 mat.transpose();
+01416                 float matDatas[16];
+01417                 mat.get(matDatas);
+01418                 nglSetInvariantEXT(_EVSConstantHandle + index, GL_FLOAT, matDatas);
+01419                 nglSetInvariantEXT(_EVSConstantHandle + index + 1, GL_FLOAT, matDatas + 4);
+01420                 nglSetInvariantEXT(_EVSConstantHandle + index + 2, GL_FLOAT, matDatas + 8);
+01421                 nglSetInvariantEXT(_EVSConstantHandle + index + 3, GL_FLOAT, matDatas + 12);
+01422         }                
+01423 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::setDisplay void *  wnd,
const GfxMode mode,
bool  show
throw (EBadDisplay) [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 399 of file driver_opengl.cpp. +

+References NL3D::CMaterial::CTexEnv::ConstantColor, GL_CURRENT_VERTEX_EXT, GL_FULL_RANGE_EXT, GL_INVARIANT_EXT, GL_VECTOR_EXT, height, nglBindParameterEXT, nglBindTextureUnitParameterEXT, nglGenSymbolsEXT, NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE, nldebug, nlerror, nlinfo, nlwarning, params, NL3D::registerGlExtensions(), res, NLMISC::CRGBA::set(), sint, uint, WGL_ALPHA_BITS_ARB, WGL_BLUE_BITS_ARB, WGL_DEPTH_BITS_ARB, WGL_DRAW_TO_PBUFFER_ARB, WGL_GREEN_BITS_ARB, WGL_PBUFFER_HEIGHT_ARB, WGL_PBUFFER_WIDTH_ARB, WGL_RED_BITS_ARB, and width. +

+

00400 {
+00401         
+00402         uint width = mode.Width;
+00403         uint height = mode.Height;
+00404 
+00405 
+00406 #ifdef NL_OS_WINDOWS
+00407         
+00408         // Driver caps.
+00409         //=============
+00410         // Retrieve the WGL extensions before init the driver.
+00411         int                                             pf;
+00412 
+00413         _OffScreen = mode.OffScreen;
+00414 
+00415         // Init pointers
+00416         _PBuffer = NULL;
+00417         _hWnd = NULL;
+00418         _WindowWidth = _WindowHeight = _WindowX = _WindowY = 0;
+00419         _hRC = NULL;
+00420         _hDC = NULL;
+00421 
+00422         // Offscreen mode ?
+00423         if (_OffScreen)
+00424         {
+00425                 // Get a hdc
+00426 
+00427                 ULONG WndFlags=WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS;
+00428                 WndFlags&=~WS_VISIBLE;
+00429                 RECT    WndRect;
+00430                 WndRect.left=0;
+00431                 WndRect.top=0;
+00432                 WndRect.right=width;
+00433                 WndRect.bottom=height;
+00434                 AdjustWindowRect(&WndRect,WndFlags,FALSE);
+00435                 HWND tmpHWND = CreateWindow(    "NLClass",
+00436                                                                         "",
+00437                                                                         WndFlags,
+00438                                                                         CW_USEDEFAULT,CW_USEDEFAULT,
+00439                                                                         WndRect.right,WndRect.bottom,
+00440                                                                         NULL,
+00441                                                                         NULL,
+00442                                                                         GetModuleHandle(NULL),
+00443                                                                         NULL);
+00444                 if (!tmpHWND) 
+00445                 {
+00446                         nlwarning ("CDriverGL::setDisplay: CreateWindow failed");
+00447                         return false;
+00448                 }
+00449 
+00450                 // resize the window
+00451                 RECT rc;
+00452                 SetRect (&rc, 0, 0, width, height);
+00453                 _WindowWidth = width;
+00454                 _WindowHeight = height;
+00455                 AdjustWindowRectEx (&rc, GetWindowStyle (_hWnd), GetMenu (_hWnd) != NULL, GetWindowExStyle (_hWnd));
+00456                 SetWindowPos (_hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
+00457                 
+00458                 // Get the 
+00459                 HDC tempHDC = GetDC(tmpHWND);
+00460 
+00461                 _Depth=GetDeviceCaps(tempHDC,BITSPIXEL);
+00462 
+00463                 // ---
+00464                 memset(&_pfd,0,sizeof(_pfd));
+00465                 _pfd.nSize        = sizeof(_pfd);
+00466                 _pfd.nVersion     = 1;
+00467                 _pfd.dwFlags      = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+00468                 _pfd.iPixelType   = PFD_TYPE_RGBA;
+00469                 _pfd.cColorBits   = (char)_Depth;
+00470 
+00471                 // Choose best suited Depth Buffer.
+00472                 if(_Depth<=16)
+00473                 {
+00474                         _pfd.cDepthBits   = 16;
+00475                 }
+00476                 else
+00477                 {
+00478                         _pfd.cDepthBits = 24;
+00479                         _pfd.cAlphaBits = 8;
+00480                 }
+00481                 _pfd.iLayerType   = PFD_MAIN_PLANE;
+00482                 pf=ChoosePixelFormat(tempHDC,&_pfd);
+00483                 if (!pf) 
+00484                 {
+00485                         nlwarning ("CDriverGL::setDisplay: ChoosePixelFormat failed");
+00486                         DestroyWindow (tmpHWND);
+00487                         return false;
+00488                 } 
+00489                 if ( !SetPixelFormat(tempHDC,pf,&_pfd) ) 
+00490                 {
+00491                         nlwarning ("CDriverGL::setDisplay: SetPixelFormat failed");
+00492                         DestroyWindow (tmpHWND);
+00493                         return false;
+00494                 } 
+00495 
+00496                 // Create gl context
+00497                 HGLRC tempGLRC = wglCreateContext(tempHDC);
+00498                 if (tempGLRC == NULL)
+00499                 {
+00500                         DWORD error = GetLastError ();
+00501                         nlwarning ("CDriverGL::setDisplay: wglCreateContext failed: 0x%x", error);
+00502                         DestroyWindow (tmpHWND);
+00503                         _PBuffer = NULL;
+00504                         _hWnd = NULL;
+00505                         _hRC = NULL;
+00506                         _hDC = NULL;
+00507                         return false;
+00508                 }
+00509 
+00510                 // Make the context current
+00511                 if (!wglMakeCurrent(tempHDC,tempGLRC))
+00512                 {
+00513                         DWORD error = GetLastError ();
+00514                         nlwarning ("CDriverGL::setDisplay: wglMakeCurrent failed: 0x%x", error);
+00515                         wglDeleteContext (tempGLRC);
+00516                         DestroyWindow (tmpHWND);
+00517                         _PBuffer = NULL;
+00518                         _hWnd = NULL;
+00519                         _hRC = NULL;
+00520                         _hDC = NULL;
+00521                         return false;
+00522                 }
+00523 
+00524                 // Register WGL functions
+00525                 registerWGlExtensions (_Extensions, tempHDC);
+00526 
+00527                 HDC hdc = wglGetCurrentDC ();
+00528                 if (hdc == NULL)
+00529                 {
+00530                         DWORD error = GetLastError ();
+00531                         nlwarning ("CDriverGL::setDisplay: wglGetCurrentDC failed: 0x%x", error);
+00532                         DestroyWindow (tmpHWND);
+00533                         _PBuffer = NULL;
+00534                         _hWnd = NULL;
+00535                         _hRC = NULL;
+00536                         _hDC = NULL;
+00537                         return false;
+00538                 }
+00539 
+00540                 // Get ready to query for a suitable pixel format that meets our
+00541                 // minimum requirements.
+00542                 int iattributes[2*20];
+00543                 float fattributes[2*20];
+00544                 int nfattribs = 0;
+00545                 int niattribs = 0;
+00546 
+00547                 // Attribute arrays must be “0” terminated – for simplicity, first
+00548                 // just zero-out the array then fill from left to right.
+00549                 for ( int a = 0; a < 2*20; a++ )
+00550                 {
+00551                         iattributes[a] = 0;
+00552                         fattributes[a] = 0;
+00553                 }
+00554                 
+00555                 // Since we are trying to create a pbuffer, the pixel format we
+00556                 // request (and subsequently use) must be “p-buffer capable”.
+00557                 iattributes[2*niattribs ] = WGL_DRAW_TO_PBUFFER_ARB;
+00558                 iattributes[2*niattribs+1] = true;
+00559                 niattribs++;
+00560                 
+00561                 // We require a minimum of 24-bit depth.
+00562                 iattributes[2*niattribs ] = WGL_DEPTH_BITS_ARB;
+00563                 iattributes[2*niattribs+1] = 24;
+00564                 niattribs++;
+00565                 
+00566                 // We require a minimum of 8-bits for each R, G, B, and A.
+00567                 iattributes[2*niattribs ] = WGL_RED_BITS_ARB;
+00568                 iattributes[2*niattribs+1] = 8;
+00569                 niattribs++;
+00570                 iattributes[2*niattribs ] = WGL_GREEN_BITS_ARB;
+00571                 iattributes[2*niattribs+1] = 8;
+00572                 niattribs++;
+00573                 iattributes[2*niattribs ] = WGL_BLUE_BITS_ARB;
+00574                 iattributes[2*niattribs+1] = 8;
+00575                 niattribs++;
+00576                 iattributes[2*niattribs ] = WGL_ALPHA_BITS_ARB;
+00577                 iattributes[2*niattribs+1] = 8;
+00578                 niattribs++;
+00579                 
+00580                 // Now obtain a list of pixel formats that meet these minimum
+00581                 // requirements.
+00582                 int pformat[20];
+00583                 unsigned int nformats;
+00584                 if ( !wglChoosePixelFormatARB ( hdc, iattributes, fattributes,
+00585                         20, pformat, &nformats ) )
+00586                 {
+00587                         nlwarning ( "pbuffer creation error: Couldn't find a suitable pixel format.\n" );
+00588                         wglDeleteContext (tempGLRC);
+00589                         DestroyWindow (tmpHWND);
+00590                         return false;
+00591                 }
+00592 
+00593                 /* After determining a compatible pixel format, the next step is to create a pbuffer of the
+00594                         chosen format. Fortunately this step is fairly easy, as you merely select one of the formats
+00595                         returned in the list in step #2 and call the function: */
+00596                 int iattributes2[1] = {0};
+00597                 // int iattributes2[] = {WGL_PBUFFER_LARGEST_ARB, 1, 0};
+00598                 _PBuffer = wglCreatePbufferARB( hdc, pformat[0], width, height, iattributes2 );
+00599                 if (_PBuffer == NULL)
+00600                 {
+00601                         DWORD error = GetLastError ();
+00602                         nlwarning ("CDriverGL::setDisplay: wglCreatePbufferARB failed: 0x%x", error);
+00603                         wglDeleteContext (tempGLRC);
+00604                         DestroyWindow (tmpHWND);
+00605                         _PBuffer = NULL;
+00606                         _hWnd = NULL;
+00607                         _hRC = NULL;
+00608                         _hDC = NULL;
+00609                         return false;
+00610                 }
+00611 
+00612                 /* After creating a pbuffer, you may use this functions to determine the dimensions of the pbuffer actually created. */
+00613                 if ( !wglQueryPbufferARB( _PBuffer, WGL_PBUFFER_WIDTH_ARB, (int*)&width ) )
+00614                 {
+00615                         DWORD error = GetLastError ();
+00616                         nlwarning ("CDriverGL::setDisplay: wglQueryPbufferARB failed: 0x%x", error);
+00617                         wglDeleteContext (tempGLRC);
+00618                         DestroyWindow (tmpHWND);
+00619                         _PBuffer = NULL;
+00620                         _hWnd = NULL;
+00621                         _hRC = NULL;
+00622                         _hDC = NULL;
+00623                         return false;
+00624                 }
+00625                 if ( !wglQueryPbufferARB( _PBuffer, WGL_PBUFFER_HEIGHT_ARB, (int*)&height ) )
+00626                 {
+00627                         DWORD error = GetLastError ();
+00628                         nlwarning ("CDriverGL::setDisplay: wglQueryPbufferARB failed: 0x%x", error);
+00629                         wglDeleteContext (tempGLRC);
+00630                         DestroyWindow (tmpHWND);
+00631                         _PBuffer = NULL;
+00632                         _hWnd = NULL;
+00633                         _hRC = NULL;
+00634                         _hDC = NULL;
+00635                         return false;
+00636                 }
+00637                 _WindowWidth = width;
+00638                 _WindowHeight = height;
+00639                 
+00640                 /* The next step is to create a device context for the newly created pbuffer. To do this,
+00641                         call the the function: */
+00642                 _hDC = wglGetPbufferDCARB( _PBuffer );
+00643                 if (_hDC == NULL)
+00644                 {
+00645                         DWORD error = GetLastError ();
+00646                         nlwarning ("CDriverGL::setDisplay: wglGetPbufferDCARB failed: 0x%x", error);
+00647                         wglDestroyPbufferARB( _PBuffer );
+00648                         wglDeleteContext (tempGLRC);
+00649                         DestroyWindow (tmpHWND);
+00650                         _PBuffer = NULL;
+00651                         _hWnd = NULL;
+00652                         _hRC = NULL;
+00653                         _hDC = NULL;
+00654                         return false;
+00655                 }
+00656 
+00657 
+00658                 /* The final step of pbuffer creation is to create an OpenGL rendering context and
+00659                         associate it with the handle for the pbuffer’s device context created in step #4. This is done as follows */
+00660                 _hRC = wglCreateContext( _hDC );
+00661                 if (_hRC == NULL)
+00662                 {
+00663                         DWORD error = GetLastError ();
+00664                         nlwarning ("CDriverGL::setDisplay: wglCreateContext failed: 0x%x", error);
+00665                         wglReleasePbufferDCARB( _PBuffer, _hDC );
+00666                         wglDestroyPbufferARB( _PBuffer );
+00667                         wglDeleteContext (tempGLRC);
+00668                         DestroyWindow (tmpHWND);
+00669                         _PBuffer = NULL;
+00670                         _hWnd = NULL;
+00671                         _hRC = NULL;
+00672                         _hDC = NULL;
+00673                         return false;
+00674                 }
+00675 
+00676                 // Get the depth
+00677                 _Depth = GetDeviceCaps (_hDC, BITSPIXEL);
+00678 
+00679                 // Destroy the temp gl context
+00680                 if (!wglDeleteContext (tempGLRC))
+00681                 {
+00682                         DWORD error = GetLastError ();
+00683                         nlwarning ("CDriverGL::setDisplay: wglDeleteContext failed: 0x%x", error);
+00684                 }
+00685 
+00686                 // Destroy the temp windows
+00687                 if (!DestroyWindow (tmpHWND))
+00688                         nlwarning ("CDriverGL::setDisplay: DestroyWindow failed");
+00689 
+00690                 /* After a pbuffer has been successfully created you can use it for off-screen rendering. To do
+00691                         so, you’ll first need to bind the pbuffer, or more precisely, make its GL rendering context
+00692                         the current context that will interpret all OpenGL commands and state changes. */
+00693                 if (!wglMakeCurrent(_hDC,_hRC))
+00694                 {
+00695                         DWORD error = GetLastError ();
+00696                         nlwarning ("CDriverGL::setDisplay: wglMakeCurrent failed: 0x%x", error);
+00697                         wglDeleteContext (_hRC);
+00698                         wglReleasePbufferDCARB( _PBuffer, _hDC );
+00699                         wglDestroyPbufferARB( _PBuffer );
+00700                         DestroyWindow (tmpHWND);
+00701                         _PBuffer = NULL;
+00702                         _hWnd = NULL;
+00703                         _hRC = NULL;
+00704                         _hDC = NULL;
+00705                         return false;
+00706                 }
+00707         }
+00708         else
+00709         {
+00710                 _FullScreen= false;
+00711                 if (wnd)
+00712                 {
+00713                         _hWnd=(HWND)wnd;
+00714                         _DestroyWindow=false;
+00715                 }
+00716                 else
+00717                 {
+00718                         ULONG   WndFlags;
+00719                         RECT    WndRect;
+00720 
+00721                         // Must destroy this window
+00722                         _DestroyWindow=true;
+00723 
+00724                         if(mode.Windowed)
+00725                                 WndFlags=WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS;
+00726                         else
+00727                         {
+00728                                 WndFlags=WS_POPUP;
+00729 
+00730                                 _FullScreen= true;
+00731                                 DEVMODE         devMode;
+00732                                 _OldScreenMode.dmSize= sizeof(DEVMODE);
+00733                                 _OldScreenMode.dmDriverExtra= 0;
+00734                                 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &_OldScreenMode);
+00735                                 _OldScreenMode.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY ;
+00736 
+00737                                 devMode.dmSize= sizeof(DEVMODE);
+00738                                 devMode.dmDriverExtra= 0;
+00739                                 devMode.dmFields= DM_PELSWIDTH | DM_PELSHEIGHT;
+00740                                 devMode.dmPelsWidth= width;
+00741                                 devMode.dmPelsHeight= height;
+00742 
+00743                                 if(mode.Depth > 0)
+00744                                 {
+00745                                         devMode.dmBitsPerPel= mode.Depth;
+00746                                         devMode.dmFields |= DM_BITSPERPEL;
+00747                                 }
+00748 
+00749                                 if(mode.Frequency > 0)
+00750                                 {
+00751                                         devMode.dmDisplayFrequency= mode.Frequency;
+00752                                         devMode.dmFields |= DM_DISPLAYFREQUENCY;
+00753                                 }
+00754 
+00755                                 if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
+00756                                         return false;
+00757                         }
+00758                         WndRect.left=0;
+00759                         WndRect.top=0;
+00760                         WndRect.right=width;
+00761                         WndRect.bottom=height;
+00762                         AdjustWindowRect(&WndRect,WndFlags,FALSE);
+00763                         _hWnd = CreateWindow(   "NLClass",
+00764                                                                         "",
+00765                                                                         WndFlags,
+00766                                                                         CW_USEDEFAULT,CW_USEDEFAULT,
+00767                                                                         WndRect.right,WndRect.bottom,
+00768                                                                         NULL,
+00769                                                                         NULL,
+00770                                                                         GetModuleHandle(NULL),
+00771                                                                         NULL);
+00772                         if (_hWnd == NULL) 
+00773                         {
+00774                                 DWORD res = GetLastError();
+00775                                 nlwarning("CreateWindow failed: %u", res);
+00776                                 return false;
+00777                         }
+00778 
+00779                         SetWindowLong (_hWnd, GWL_USERDATA, (LONG)this);
+00780 
+00781                         // resize the window
+00782                         RECT rc;
+00783                         SetRect (&rc, 0, 0, width, height);
+00784                         AdjustWindowRectEx (&rc, GetWindowStyle (_hWnd), GetMenu (_hWnd) != NULL, GetWindowExStyle (_hWnd));
+00785                         SetWindowPos (_hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
+00786 
+00787                         if (show || _FullScreen)
+00788                                 ShowWindow(_hWnd,SW_SHOW);
+00789                 }
+00790 
+00791                 // Init Window Width and Height
+00792                 RECT clientRect;
+00793                 GetClientRect (_hWnd, &clientRect);
+00794                 _WindowWidth = clientRect.right-clientRect.left;
+00795                 _WindowHeight = clientRect.bottom-clientRect.top;
+00796                 _WindowX = clientRect.left;
+00797                 _WindowY = clientRect.top;
+00798 
+00799                 _hDC=GetDC(_hWnd);
+00800                 wglMakeCurrent(_hDC,NULL);
+00801                 _Depth=GetDeviceCaps(_hDC,BITSPIXEL);
+00802                 // ---
+00803                 memset(&_pfd,0,sizeof(_pfd));
+00804                 _pfd.nSize        = sizeof(_pfd);
+00805                 _pfd.nVersion     = 1;
+00806                 _pfd.dwFlags      = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+00807                 _pfd.iPixelType   = PFD_TYPE_RGBA;
+00808                 _pfd.cColorBits   = (char)_Depth;
+00809                 // Choose best suited Depth Buffer.
+00810                 if(_Depth<=16)
+00811                 {
+00812                         _pfd.cDepthBits   = 16;
+00813                 }
+00814                 else
+00815                 {
+00816                         _pfd.cDepthBits = 24;
+00817                         _pfd.cAlphaBits = 8;
+00818                 }
+00819                 _pfd.iLayerType   = PFD_MAIN_PLANE;
+00820                 pf=ChoosePixelFormat(_hDC,&_pfd);
+00821                 if (!pf) 
+00822                 {
+00823                         return false;
+00824                 }
+00825 
+00826                 if ( !SetPixelFormat(_hDC,pf,&_pfd) ) 
+00827                 {
+00828                         return false;
+00829                 } 
+00830                 _hRC=wglCreateContext(_hDC);
+00831                 wglMakeCurrent(_hDC,_hRC);
+00832         }
+00833 
+00835         while (_EventEmitter.getNumEmitters() != 0)
+00836         {
+00837                 _EventEmitter.removeEmitter(_EventEmitter.getEmitter(_EventEmitter.getNumEmitters() - 1));
+00838         }
+00839         NLMISC::CWinEventEmitter *we = new NLMISC::CWinEventEmitter;
+00840         // setup the event emitter, and try to retrieve a direct input interface
+00841         _EventEmitter.addEmitter(we, true /*must delete*/); // the main emitter
+00843         try
+00844         {
+00845                 NLMISC::CDIEventEmitter *diee = NLMISC::CDIEventEmitter::create(GetModuleHandle(NULL), _hWnd, we);
+00846                 if (diee)
+00847                 {
+00848                         _EventEmitter.addEmitter(diee, true);
+00849                 }
+00850         }
+00851         catch(EDirectInput &e)
+00852         {
+00853                 nlinfo(e.what());
+00854         }
+00855 
+00856 #elif defined(NL_OS_UNIX) // NL_OS_WINDOWS
+00857 
+00858         dpy = XOpenDisplay(NULL);
+00859         if (dpy == NULL)
+00860         {
+00861           nlerror ("XOpenDisplay failed on '%s'",getenv("DISPLAY"));
+00862         }
+00863         else
+00864           {
+00865             nldebug("XOpenDisplay on '%s' OK", getenv("DISPLAY"));
+00866           }
+00867 
+00868         int sAttribList[] =
+00869         {
+00870           GLX_RGBA,
+00871           GLX_DOUBLEBUFFER,
+00872           //GLX_BUFFER_SIZE, 16,
+00873           GLX_DEPTH_SIZE, 16,
+00874           GLX_RED_SIZE, 4,
+00875           GLX_GREEN_SIZE, 4,
+00876           GLX_BLUE_SIZE, 4,
+00877           //GLX_ALPHA_SIZE, 8,
+00878           None
+00879         };
+00880         /*
+00881         int sAttribList[] =
+00882         {
+00883           GLX_RGBA,
+00884           GLX_DOUBLEBUFFER,
+00885           //GLX_BUFFER_SIZE, 32,
+00886           GLX_DEPTH_SIZE, 32,
+00887           GLX_RED_SIZE, 8,
+00888           GLX_GREEN_SIZE, 8,
+00889           GLX_BLUE_SIZE, 8,
+00890           GLX_ALPHA_SIZE, 8,
+00891           None
+00892           };
+00893         */
+00894         XVisualInfo *visual_info = glXChooseVisual (dpy, DefaultScreen(dpy), sAttribList);
+00895 
+00896         if(visual_info == NULL)
+00897           {
+00898             nlerror("glXChooseVisual() failed");
+00899           }
+00900         else
+00901           {
+00902             nldebug("glXChooseVisual OK");
+00903           }
+00904 
+00905         ctx = glXCreateContext (dpy, visual_info, None, GL_TRUE);
+00906 
+00907         if(ctx == NULL)
+00908           {
+00909             nlerror("glXCreateContext() failed");
+00910           }
+00911         else
+00912           {
+00913             nldebug("glXCreateContext() OK");
+00914           }
+00915 
+00916         Colormap cmap = XCreateColormap (dpy, RootWindow(dpy, DefaultScreen(dpy)), visual_info->visual, AllocNone);
+00917 
+00918         XSetWindowAttributes attr;
+00919         attr.colormap = cmap;
+00920         attr.background_pixel = BlackPixel(dpy, DefaultScreen(dpy));
+00921         
+00922 #ifdef XF86VIDMODE
+00923         // If we're going to attempt fullscreen, we need to set redirect to True,
+00924         // This basically places the window with no borders in the top left 
+00925         // corner of the screen.
+00926         if (mode.Windowed)
+00927         {
+00928                 attr.override_redirect = False;
+00929         }
+00930         else
+00931         {
+00932                 attr.override_redirect = True;
+00933         }
+00934 #else
+00935         attr.override_redirect = False;
+00936 #endif
+00937 
+00938         int attr_flags = CWOverrideRedirect | CWColormap | CWBackPixel;
+00939 
+00940         win = XCreateWindow (dpy, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, width, height, 0, visual_info->depth, InputOutput, visual_info->visual, attr_flags, &attr);        
+00941 
+00942         if(!win)
+00943           {
+00944             nlerror("XCreateWindow() failed");
+00945           }
+00946         else
+00947           {
+00948             nldebug("XCreateWindow() OK");
+00949           }
+00950 
+00951         XSizeHints size_hints;
+00952         size_hints.x = 0;
+00953         size_hints.y = 0;
+00954         size_hints.width = width;
+00955         size_hints.height = height;
+00956         size_hints.flags = PSize | PMinSize | PMaxSize;
+00957         size_hints.min_width = width;
+00958         size_hints.min_height = height;
+00959         size_hints.max_width = width;
+00960         size_hints.max_height = height;
+00961 
+00962         XTextProperty text_property;
+00963         char *title="NeL window";
+00964         XStringListToTextProperty(&title, 1, &text_property);
+00965 
+00966         XSetWMProperties (dpy, win, &text_property, &text_property,  0, 0, &size_hints, 0, 0);
+00967         glXMakeCurrent (dpy, win, ctx);
+00968         XMapRaised (dpy, win);
+00969 
+00970         XSelectInput (dpy, win,
+00971                       KeyPressMask|
+00972                       KeyReleaseMask|
+00973                       ButtonPressMask|
+00974                       ButtonReleaseMask|
+00975                       PointerMotionMask
+00976                       );
+00977 
+00978         XMapWindow(dpy, win);
+00979 
+00980         _EventEmitter.init (dpy, win);
+00981 
+00982 //      XEvent event;
+00983 //      XIfEvent(dpy, &event, WaitForNotify, (char *)this);
+00984 
+00985 #ifdef XF86VIDMODE
+00986         if (!mode.Windowed)
+00987         {
+00988 
+00989                 // Set window to the right size, map it to the display, and raise it
+00990                 // to the front
+00991                 XResizeWindow(dpy,win,width,height);
+00992                 XMapRaised(dpy,win);
+00993                 XRaiseWindow(dpy, win);
+00994 
+00995                 // grab the mouse and keyboard on the fullscreen window 
+00996                 if ((XGrabPointer(dpy, win, True, 0,
+00997                                                   GrabModeAsync, GrabModeAsync,
+00998                                                   win, None, CurrentTime) != GrabSuccess) ||
+00999                         (XGrabKeyboard(dpy, win, True,
+01000                                                    GrabModeAsync, GrabModeAsync, CurrentTime) != 0) )
+01001                 {
+01002                         // Until I work out how to deal with this nicely, it just gives
+01003                         // an error and exits the prorgam.
+01004                         nlerror("Unable to grab keyboard and mouse\n");
+01005                 }
+01006                 else
+01007                 {
+01008                         // Save the old screen mode and dotclock
+01009                         memset(&_OldScreenMode, 0, sizeof(_OldScreenMode));
+01010                         XF86VidModeGetModeLine(dpy, 
+01011                                                                    DefaultScreen(dpy),
+01012                                                                    &_OldDotClock,
+01013                                                                    &_OldScreenMode);
+01014                         // Save the old viewport
+01015                         XF86VidModeGetViewPort(dpy, 
+01016                                                                    DefaultScreen(dpy),
+01017                                                                    &_OldX,
+01018                                                                    &_OldY);
+01019     
+01020                         // get a list of modes, search for an appropriate one.
+01021                         XF86VidModeModeInfo **modes;
+01022                         int nmodes;
+01023                         if (XF86VidModeGetAllModeLines(dpy,
+01024                                                                                    DefaultScreen(dpy),
+01025                                                                                    &nmodes,&modes))
+01026                         {
+01027                                 int mode_index = -1; // Gah, magic numbers all bad. 
+01028                                 for (int i = 0; i < nmodes; i++)
+01029                                 {
+01030                                         nldebug("Available mode - %dx%d\n",width,height);
+01031                                         if( (modes[i]->hdisplay == width) &&
+01032                                                 (modes[i]->vdisplay == height))
+01033                                         {
+01034                                                 mode_index = i;
+01035                                         }
+01036                                 }
+01037                                 // Switch to the mode
+01038                                 if (mode_index != -1)
+01039                                 {
+01040                                         if(XF86VidModeSwitchToMode(dpy,
+01041                                                                                            DefaultScreen(dpy), 
+01042                                                                                            modes[mode_index]))
+01043                                         {
+01044                                                 nlinfo("Switching to mode %dx%d,\n",width, 
+01045                                                            height);
+01046                                                 XF86VidModeSetViewPort(dpy,DefaultScreen(dpy),0, 0);
+01047                                                 _FullScreen = true;
+01048                                         }
+01049                                 }
+01050                                 else
+01051                                 {
+01052                                         // This is a problem, since we've nuked the border from 
+01053                                         // window in the setup stage, until I work out how
+01054                                         // to get it back (recreate window? seems excessive)
+01055                                         nlerror("Couldn't find an appropriate mode %dx%d\n",
+01056                                                         width,
+01057                                                         height);
+01058                                 }
+01059                         }
+01060                 }
+01061         }
+01062 
+01063 #endif // XF86VIDMODE
+01064 
+01065 #endif // NL_OS_UNIX
+01066 
+01067 
+01068         // Driver caps.
+01069         //=============
+01070         // Retrieve the extensions for the current context.
+01071         NL3D::registerGlExtensions (_Extensions);       
+01072         //
+01073 #ifdef NL_OS_WINDOWS
+01074         NL3D::registerWGlExtensions (_Extensions, _hDC);
+01075 #endif // ifdef NL_OS_WINDOWS
+01076 
+01077         // Check required extensions!!
+01078         // ARBMultiTexture is a opengl 1.2 required extension.
+01079         if(!_Extensions.ARBMultiTexture)
+01080         {
+01081                 nlwarning("Missing Required GL extension: GL_ARB_multitexture. Update your driver");
+01082                 throw EBadDisplay("Missing Required GL extension: GL_ARB_multitexture. Update your driver");
+01083         }
+01084         if(!_Extensions.EXTTextureEnvCombine)
+01085         {
+01086                 nlwarning("Missing Important GL extension: GL_EXT_texture_env_combine => All envcombine are setup to GL_MODULATE!!!");
+01087         }
+01088 
+01089 
+01090         // init _DriverGLStates
+01091         _DriverGLStates.init(_Extensions.ARBTextureCubeMap);
+01092 
+01093 
+01094         // Init OpenGL/Driver defaults.
+01095         //=============================
+01096         glViewport(0,0,width,height);
+01097         glMatrixMode(GL_PROJECTION);
+01098         glLoadIdentity();
+01099         glOrtho(0,width,height,0,-1.0f,1.0f);   
+01100         glMatrixMode(GL_MODELVIEW);
+01101         glLoadIdentity();
+01102         glDisable(GL_AUTO_NORMAL);
+01103         glDisable(GL_COLOR_MATERIAL);
+01104         glEnable(GL_DITHER);
+01105         glDisable(GL_FOG);
+01106         glDisable(GL_LINE_SMOOTH);
+01107         glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
+01108         glEnable(GL_DEPTH_TEST);
+01109         glDisable(GL_NORMALIZE);
+01110         glDisable(GL_COLOR_SUM_EXT);
+01111         _CurrViewport.init(0.f, 0.f, 1.f, 1.f);
+01112         _CurrentGlNormalize= false;
+01113         _ForceNormalize= false;
+01114         // Setup defaults for blend, lighting ...
+01115         _DriverGLStates.forceDefaults(inlGetNumTextStages());
+01116         // Default delta camera pos.
+01117         _PZBCameraPos= CVector::Null;
+01118 
+01119         if (_NVTextureShaderEnabled)
+01120         {
+01121                 enableNVTextureShader(false);           
+01122         }
+01123 
+01124         // Be always in EXTSeparateSpecularColor.       
+01125         if(_Extensions.EXTSeparateSpecularColor)
+01126         {
+01127                 glLightModeli((GLenum)GL_LIGHT_MODEL_COLOR_CONTROL_EXT, GL_SEPARATE_SPECULAR_COLOR_EXT);
+01128         }
+01129 
+01130         _VertexProgramEnabled= false;
+01131         _LastSetupGLArrayVertexProgram= false;
+01132 
+01133 
+01134         // Init VertexArrayRange according to supported extenstion.
+01135         _SupportVBHard= false;
+01136         _SlowUnlockVBHard= false;
+01137         _MaxVerticesByVBHard= 0;
+01138         // Try with NVidia ext first.
+01139         if(_Extensions.NVVertexArrayRange)
+01140         {
+01141                 _AGPVertexArrayRange= new CVertexArrayRangeNVidia(this);
+01142                 _VRAMVertexArrayRange= new CVertexArrayRangeNVidia(this);
+01143                 _SupportVBHard= true;
+01144                 _MaxVerticesByVBHard= _Extensions.NVVertexArrayRangeMaxVertex;
+01145         }
+01146         // Else, try with ATI ext
+01147         else if(_Extensions.ATIVertexArrayObject)
+01148         {
+01149                 if (!_Extensions.ATIMapObjectBuffer)
+01150                 {               
+01151                         _AGPVertexArrayRange= new CVertexArrayRangeATI(this);
+01152                         _VRAMVertexArrayRange= new CVertexArrayRangeATI(this);                  
+01153                         // BAD ATI extension scheme.
+01154                         _SlowUnlockVBHard= true;                
+01155                 }
+01156                 else
+01157                 {
+01158                         _AGPVertexArrayRange= new CVertexArrayRangeMapObjectATI(this);
+01159                         _VRAMVertexArrayRange= new CVertexArrayRangeMapObjectATI(this);                 
+01160                 }
+01161                 _SupportVBHard= true;
+01162                 // _MaxVerticesByVBHard= 65535; // should always work with recent drivers.              
+01163                 // tmp fix for ati
+01164                 _MaxVerticesByVBHard= 32267;
+01165         }
+01166 
+01167         // Reset VertexArrayRange.
+01168         _CurrentVertexArrayRange= NULL;
+01169         _CurrentVertexBufferHard= NULL;
+01170         _NVCurrentVARPtr= NULL;
+01171         _NVCurrentVARSize= 0;
+01172         if(_SupportVBHard)
+01173         {
+01174                 // try to allocate 16Mo by default of AGP Ram.
+01175                 initVertexArrayRange(NL3D_DRV_VERTEXARRAY_AGP_INIT_SIZE, 0);
+01176 
+01177                 // If not success to allocate at least a minimum space in AGP, then disable completely VBHard feature
+01178                 if( _AGPVertexArrayRange->sizeAllocated()==0 )
+01179                 {
+01180                         // reset any allocated VRAM space.
+01181                         resetVertexArrayRange();
+01182 
+01183                         // delete containers
+01184                         delete _AGPVertexArrayRange;
+01185                         delete _VRAMVertexArrayRange;
+01186                         _AGPVertexArrayRange= NULL;
+01187                         _VRAMVertexArrayRange= NULL;
+01188 
+01189                         // disable.
+01190                         _SupportVBHard= false;
+01191                         _SlowUnlockVBHard= false;
+01192                         _MaxVerticesByVBHard= 0;
+01193                 }
+01194         }
+01195 
+01196         // Init embm if present
+01197         //===========================================================
+01198         initEMBM();
+01199 
+01200         // Init fragment shaders if present
+01201         //===========================================================
+01202         initFragmentShaders();
+01203 
+01204 
+01205 
+01206         // Activate the default texture environnments for all stages.
+01207         //===========================================================
+01208         for(sint stage=0;stage<inlGetNumTextStages(); stage++)
+01209         {
+01210                 // init no texture.
+01211                 _CurrentTexture[stage]= NULL;
+01212                 _CurrentTextureInfoGL[stage]= NULL;
+01213                 // texture are disabled in DriverGLStates.forceDefaults().
+01214                 
+01215                 // init default env.
+01216                 CMaterial::CTexEnv      env;    // envmode init to default.
+01217                 env.ConstantColor.set(255,255,255,255);
+01218                 forceActivateTexEnvMode(stage, env);
+01219                 forceActivateTexEnvColor(stage, env);
+01220 
+01221                 // Not special TexEnv.
+01222                 _CurrentTexEnvSpecial[stage]= TexEnvSpecialDisabled;
+01223                                 
+01224                 // set All TexGen by default to identity matrix (prefer use the textureMatrix scheme)
+01225                 _DriverGLStates.activeTextureARB(stage);
+01226                 GLfloat         params[4];
+01227                 params[0]=1; params[1]=0; params[2]=0; params[3]=0;
+01228                 glTexGenfv(GL_S, GL_OBJECT_PLANE, params);
+01229                 glTexGenfv(GL_S, GL_EYE_PLANE, params);
+01230                 params[0]=0; params[1]=1; params[2]=0; params[3]=0;
+01231                 glTexGenfv(GL_T, GL_OBJECT_PLANE, params);
+01232                 glTexGenfv(GL_T, GL_EYE_PLANE, params);
+01233                 params[0]=0; params[1]=0; params[2]=1; params[3]=0;
+01234                 glTexGenfv(GL_R, GL_OBJECT_PLANE, params);
+01235                 glTexGenfv(GL_R, GL_EYE_PLANE, params);
+01236                 params[0]=0; params[1]=0; params[2]=0; params[3]=1;
+01237                 glTexGenfv(GL_Q, GL_OBJECT_PLANE, params);
+01238                 glTexGenfv(GL_Q, GL_EYE_PLANE, params);
+01239         }
+01240         resetTextureShaders();
+01241 
+01242         // Get num of light for this driver
+01243         int numLight;
+01244         glGetIntegerv (GL_MAX_LIGHTS, &numLight);
+01245         _MaxDriverLight=(uint)numLight;
+01246         if (_MaxDriverLight>MaxLight)
+01247                 _MaxDriverLight=MaxLight;
+01248 
+01249         // Reset the lights position flags
+01250         for (uint i=0; i<MaxLight; i++)
+01251                 _LightEnable[i]=false;
+01252 
+01253 
+01254         _PPLExponent = 1.f;
+01255         _PPLightDiffuseColor = NLMISC::CRGBA::White;
+01256         _PPLightSpecularColor = NLMISC::CRGBA::White;
+01257 
+01258         // Backward compatibility: default lighting is Light0 default openGL
+01259         // meaning that light direction is always (0,1,0) in eye-space
+01260         // use enableLighting(0....), to get normal behaviour
+01261         glEnable(GL_LIGHT0);
+01262 
+01263         _Initialized = true;
+01264 
+01265         _ForceDXTCCompression= false;
+01266         _ForceTextureResizePower= 0;
+01267 
+01268         // Reset profiling.
+01269         _AllocatedTextureMemory= 0;
+01270         _TextureUsed.clear();
+01271         _PrimitiveProfileIn.reset();
+01272         _PrimitiveProfileOut.reset();
+01273         _NbSetupMaterialCall= 0;
+01274         _NbSetupModelMatrixCall= 0;
+01275 
+01276         // check wether per pixel lighting shader is supported
+01277         checkForPerPixelLightingSupport();
+01278 
+01279         // if EXTVertexShader is used, bind  the standard GL arrays, and allocate constant
+01280         if (!_Extensions.NVVertexProgram && _Extensions.EXTVertexShader)
+01281         {
+01282                         _EVSPositionHandle = nglBindParameterEXT(GL_CURRENT_VERTEX_EXT);
+01283                         _EVSNormalHandle   = nglBindParameterEXT(GL_CURRENT_NORMAL);
+01284                         _EVSColorHandle    = nglBindParameterEXT(GL_CURRENT_COLOR);
+01285                         if (!_EVSPositionHandle || !_EVSNormalHandle || !_EVSColorHandle)
+01286                         {
+01287                                 nlwarning("Unable to bind input parameters for use with EXT_vertex_shader, vertex program support is disabled");
+01288                                 _Extensions.EXTVertexShader = false;
+01289                         }
+01290                         else
+01291                         {                       
+01292                                 // bind texture units
+01293                                 for(uint k = 0; k < 8; ++k)
+01294                                 {                               
+01295                                         _EVSTexHandle[k] = nglBindTextureUnitParameterEXT(GL_TEXTURE0_ARB + k, GL_CURRENT_TEXTURE_COORDS);
+01296                                 }
+01297                                 // Other attributes are managed using variant pointers :
+01298                                 // Secondary color
+01299                                 // Fog Coords
+01300                                 // Skin Weight
+01301                                 // Skin palette
+01302                                 // This mean that they must have 4 components
+01303 
+01304                                 // Allocate invariants. One assitionnal variant is needed for fog coordinate if fog bug is not fixed in driver version
+01305                                 _EVSConstantHandle = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_INVARIANT_EXT, GL_FULL_RANGE_EXT, _EVSNumConstant + (_ATIFogRangeFixed ? 0 : 1));
+01306 
+01307                                 if (_EVSConstantHandle == 0)
+01308                                 {
+01309                                         nlwarning("Unable to allocate constants for EXT_vertex_shader, vertex program support is disabled");
+01310                                         _Extensions.EXTVertexShader = false;
+01311                                 }
+01312                         }
+01313         }
+01314 
+01315         return true;
+01316 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setEMBMMatrix const uint  stage,
const float  mat[4]
[virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2673 of file driver_opengl.cpp. +

+References _DriverGLStates, _Extensions, NL3D::CDriverGLStates::activeTextureARB(), NL3D::CGlExtensions::ATIEnvMapBumpMap, GL_BUMP_ROT_MATRIX_ATI, NL3D::IDRV_MAT_MAXTEXTURES, nglTexBumpParameterfvATI, nlassert, supportEMBM(), and uint. +

+

02674 {
+02675         nlassert(supportEMBM());
+02676         nlassert(stage < IDRV_MAT_MAXTEXTURES);
+02677         // 
+02678         if (_Extensions.ATIEnvMapBumpMap)
+02679         {
+02680                 _DriverGLStates.activeTextureARB(stage);
+02681                 nglTexBumpParameterfvATI(GL_BUMP_ROT_MATRIX_ATI, const_cast<float *>(mat));
+02682         }
+02683 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setFrustum float  left,
float  right,
float  bottom,
float  top,
float  znear,
float  zfar,
bool  perspective = true
[virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 31 of file driver_opengl_matrix.cpp. +

+References _OODeltaZ, and _ProjMatDirty. +

+

00032 {
+00033         glMatrixMode(GL_PROJECTION);
+00034         glLoadIdentity();
+00035         if (perspective)
+00036         {
+00037                 glFrustum(left,right,bottom,top,znear,zfar);
+00038         }
+00039         else
+00040         {
+00041                 glOrtho(left,right,bottom,top,znear,zfar);
+00042         }
+00043         _ProjMatDirty = true;
+00044 
+00045         // Backup znear and zfar for zbias setup
+00046         _OODeltaZ = 1 / (zfar - znear);
+00047 
+00048         glMatrixMode(GL_MODELVIEW);
+00049 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setLight uint8  num,
const CLight light
[virtual]
+
+ + + + + +
+   + + +

+Setup a light.

+You must call enableLight() to active the ligth.

+

Parameters:
+ + + +
num is the number of the light to set.
light is a light to set in this slot.
+
+
See also:
enableLight()
+ +

+Implements NL3D::IDriver. +

+Definition at line 43 of file driver_opengl_light.cpp. +

+References _LightDirty, _LightMode, _LightSetupDirty, _MaxDriverLight, _RenderSetupDirty, _WorldLightDirection, _WorldLightPos, NLMISC::CRGBA::B, NLMISC::CRGBA::G, NL3D::CLight::getAmbiant(), NL3D::CLight::getConstantAttenuation(), NL3D::CLight::getCutoff(), NL3D::CLight::getDiffuse(), NL3D::CLight::getDirection(), NL3D::CLight::getExponent(), NL3D::CLight::getLinearAttenuation(), NL3D::CLight::getMode(), NL3D::CLight::getPosition(), NL3D::CLight::getQuadraticAttenuation(), NL3D::CLight::getSpecular(), num, NLMISC::CRGBA::R, and uint8. +

+

00044 {
+00045         // Check light count is good
+00046 //      nlassert (num<_MaxDriverLight);
+00047         
+00048         // Set the light
+00049         if (num<_MaxDriverLight)
+00050         {
+00051                 // GL light number
+00052                 GLenum lightNum=(GLenum)(GL_LIGHT0+num);
+00053 
+00054                 // Get light mode
+00055                 CLight::TLightMode mode=light.getMode ();
+00056 
+00057                 // Copy the mode
+00058                 _LightMode[num]=mode;
+00059 
+00060                 // Set the ambiant color
+00061                 GLfloat colorGL[4];
+00062                 CRGBA colorNeL=light.getAmbiant ();
+00063                 colorGL[0]=(float)colorNeL.R/255.f;
+00064                 colorGL[1]=(float)colorNeL.G/255.f;
+00065                 colorGL[2]=(float)colorNeL.B/255.f;
+00066                 colorGL[3]=1.f;
+00067                 glLightfv (lightNum, GL_AMBIENT, colorGL);
+00068 
+00069                 // Set the diffuse color
+00070                 colorNeL=light.getDiffuse ();
+00071                 colorGL[0]=(float)colorNeL.R/255.f;
+00072                 colorGL[1]=(float)colorNeL.G/255.f;
+00073                 colorGL[2]=(float)colorNeL.B/255.f;
+00074                 colorGL[3]=1.f;
+00075                 glLightfv (lightNum, GL_DIFFUSE, colorGL);
+00076 
+00077                 // Set the specular color
+00078                 colorNeL=light.getSpecular ();
+00079                 colorGL[0]=(float)colorNeL.R/255.f;
+00080                 colorGL[1]=(float)colorNeL.G/255.f;
+00081                 colorGL[2]=(float)colorNeL.B/255.f;
+00082                 colorGL[3]=1.f;
+00083                 glLightfv (lightNum, GL_SPECULAR, colorGL);
+00084 
+00085                 // Set light attenuation
+00086                 glLightf (lightNum, GL_CONSTANT_ATTENUATION, light.getConstantAttenuation());
+00087                 glLightf (lightNum, GL_LINEAR_ATTENUATION, light.getLinearAttenuation());
+00088                 glLightf (lightNum, GL_QUADRATIC_ATTENUATION, light.getQuadraticAttenuation());
+00089 
+00090                 // Set the position
+00091                 if ((mode==CLight::DirectionalLight)||(mode==CLight::SpotLight))
+00092                 {
+00093                         // Get the direction of the light
+00094                         _WorldLightDirection[num]=light.getDirection ();
+00095                 }
+00096 
+00097                 if (mode!=CLight::DirectionalLight)
+00098                 {
+00099                         // Get the position of the light
+00100                         _WorldLightPos[num]=light.getPosition ();
+00101                 }
+00102 
+00103                 if (mode==CLight::SpotLight)
+00104                 {
+00105                         // Get the exponent of the spot
+00106                         float exponent=light.getExponent ();
+00107 
+00108                         // Set it
+00109                         glLightf (lightNum, GL_SPOT_EXPONENT, exponent);
+00110 
+00111                         // Get the cutoff of the spot
+00112                         float cutoff=180.f*(light.getCutoff ()/(float)NLMISC::Pi);
+00113 
+00114                         // Set it
+00115                         glLightf (lightNum, GL_SPOT_CUTOFF, cutoff);
+00116                 }
+00117                 else
+00118                 {
+00119                         // Disactive spot properties
+00120                         glLighti (lightNum, GL_SPOT_CUTOFF, 180);
+00121                         glLighti (lightNum, GL_SPOT_EXPONENT, 0);
+00122                 }
+00123 
+00124                 // Flag this light as dirt.
+00125                 _LightDirty[num]= true;
+00126 
+00127                 // dirt the lightSetup and hence the render setup
+00128                 _LightSetupDirty= true;
+00129                 _RenderSetupDirty=true;
+00130         }
+00131 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setMatrix2DForTextureOffsetAddrMode const uint  stage,
const float  mat[4]
[virtual]
+
+ + + + + +
+   + + +

+setup the 2D matrix for the OffsetTexture, OffsetTextureScale and OffsetTexture addressing mode It should be stored as the following [a0 a1] [a2 a3] +

+Implements NL3D::IDriver. +

+Definition at line 2398 of file driver_opengl.cpp. +

+References _DriverGLStates, NL3D::CDriverGLStates::activeTextureARB(), GL_OFFSET_TEXTURE_MATRIX_NV, GL_TEXTURE_SHADER_NV, inlGetNumTextStages(), nlassert, supportTextureShaders(), and uint. +

+

02399 {
+02400         if (!supportTextureShaders()) return;
+02401         //nlassert(supportTextureShaders());
+02402         nlassert(stage < (uint) inlGetNumTextStages() );
+02403         _DriverGLStates.activeTextureARB(stage);
+02404         glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat);
+02405 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::setMode const GfxMode mode  )  [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1333 of file driver_opengl.cpp. +

+References _FullScreen, NL3D::GfxMode::Depth, NL3D::GfxMode::Frequency, NL3D::GfxMode::Height, NL3D::GfxMode::Width, and NL3D::GfxMode::Windowed. +

+

01334 {
+01335 #ifdef NL_OS_WINDOWS
+01336         if (mode.Windowed)
+01337         {
+01338                 if (_FullScreen)
+01339                 {
+01340                         ChangeDisplaySettings (NULL,0);
+01341                         modifyStyle(_hWnd, GWL_STYLE, WS_POPUP, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS);
+01342                 }
+01343                 _WindowWidth  = mode.Width;
+01344                 _WindowHeight = mode.Height;
+01345 
+01346         }
+01347         else
+01348         {
+01349                 _WindowWidth  = mode.Width;
+01350                 _WindowHeight = mode.Height;
+01351                 _Depth= mode.Depth;
+01352 
+01353                 DEVMODE         devMode;
+01354                 if (!_FullScreen)
+01355                 {
+01356                         _OldScreenMode.dmSize= sizeof(DEVMODE);
+01357                         _OldScreenMode.dmDriverExtra= 0;
+01358                         EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &_OldScreenMode);
+01359                         _OldScreenMode.dmFields= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY ;
+01360                 }
+01361 
+01362                 devMode.dmSize= sizeof(DEVMODE);
+01363                 devMode.dmDriverExtra= 0;
+01364                 devMode.dmFields= DM_PELSWIDTH | DM_PELSHEIGHT;
+01365                 devMode.dmPelsWidth= _WindowWidth;
+01366                 devMode.dmPelsHeight= _WindowHeight;
+01367 
+01368                 if(mode.Depth > 0)
+01369                 {
+01370                         devMode.dmBitsPerPel= mode.Depth;
+01371                         devMode.dmFields |= DM_BITSPERPEL;
+01372                 }
+01373 
+01374                 if(mode.Frequency > 0)
+01375                 {
+01376                         devMode.dmDisplayFrequency= mode.Frequency;
+01377                         devMode.dmFields |= DM_DISPLAYFREQUENCY;
+01378                 }
+01379 
+01380                 if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
+01381                         return false;
+01382                 
+01383                 if (!_FullScreen)
+01384                 {
+01385                         modifyStyle(_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS, WS_POPUP);
+01386                 }
+01387         }
+01388 
+01389         // Resize the window
+01390         RECT rc;
+01391         SetRect (&rc, 0, 0, _WindowWidth, _WindowHeight);
+01392         AdjustWindowRectEx (&rc, GetWindowStyle (_hWnd), false, GetWindowExStyle (_hWnd));
+01393         SetWindowPos (_hWnd, NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER | SWP_NOACTIVATE );
+01394 
+01395         ShowWindow(_hWnd, SW_SHOW);
+01396 
+01397         // Init Window Width and Height
+01398         RECT clientRect;
+01399         GetClientRect (_hWnd, &clientRect);
+01400         _WindowWidth = clientRect.right-clientRect.left;
+01401         _WindowHeight = clientRect.bottom-clientRect.top;
+01402         _WindowX = clientRect.left;
+01403         _WindowY = clientRect.top;
+01404         _FullScreen = !mode.Windowed;
+01405 #else 
+01406         // TODO linux version !!!
+01407 #endif
+01408         return true;
+01409 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::setMonitorColorProperties const CMonitorColorProperties properties  )  [virtual]
+
+ + + + + +
+   + + +

+Setup monitor color properties.

+Return false if setup failed. +

+Implements NL3D::IDriver. +

+Definition at line 2600 of file driver_opengl.cpp. +

+References NL3D::CMonitorColorProperties::Contrast, NL3D::CMonitorColorProperties::Gamma, NL3D::CMonitorColorProperties::Luminosity, min, nlwarning, uint, and value. +

+

02601 {
+02602 #ifdef NL_OS_WINDOWS
+02603         
+02604         // Get a DC
+02605         HDC dc = CreateDC ("DISPLAY", NULL, NULL, NULL);
+02606         if (dc)
+02607         {
+02608                 // The ramp
+02609                 WORD ramp[256*3];
+02610 
+02611                 // For each composant
+02612                 uint c;
+02613                 for( c=0; c<3; c++ )
+02614                 {
+02615                         uint i;
+02616                         for( i=0; i<256; i++ )
+02617                         {
+02618                                 // Floating value
+02619                                 float value = (float)i / 256;
+02620 
+02621                                 // Contrast
+02622                                 value = (float) max (0.0f, (value-0.5f) * (float) pow (3.f, properties.Contrast[c]) + 0.5f );
+02623 
+02624                                 // Gamma
+02625                                 value = (float) pow (value, (properties.Gamma[c]>0) ? 1 - 3 * properties.Gamma[c] / 4 : 1 - properties.Gamma[c] );
+02626 
+02627                                 // Luminosity
+02628                                 value = value + properties.Luminosity[c] / 2.f;
+02629                                 ramp[i+(c<<8)] = min (65535, max (0, (int)(value * 65535)));
+02630                         }
+02631                 }
+02632 
+02633                 // Set the ramp
+02634                 bool result = SetDeviceGammaRamp (dc, ramp) != FALSE;
+02635                 
+02636                 // Release the DC
+02637                 ReleaseDC (NULL, dc);
+02638 
+02639                 // Returns result
+02640                 return result;
+02641         }
+02642         else
+02643         {
+02644                 nlwarning ("(CDriverGL::setMonitorColorProperties): can't create DC");
+02645                 return false;
+02646         }
+02647 
+02648 #else
+02649 
+02650         nlwarning ("CDriverGL::setMonitorColorProperties not implemented");
+02651         return false;
+02652 
+02653 #endif
+02654 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setMousePos float  x,
float  y
[virtual]
+
+ + + + + +
+   + + +

+x and y must be between 0.0 and 1.0 +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1967 of file driver_opengl.cpp. +

+References x, and y. +

+

01968 {
+01969 #ifdef NL_OS_WINDOWS
+01970         if (_hWnd)
+01971         {
+01972                 // NeL window coordinate to MSWindows coordinates
+01973                 POINT pt;
+01974                 pt.x = (int)((float)(_WindowWidth)*x);
+01975                 pt.y = (int)((float)(_WindowHeight)*(1.0f-y));
+01976                 ClientToScreen (_hWnd, &pt);
+01977                 SetCursorPos(pt.x, pt.y);
+01978         }
+01979 #elif defined (NL_OS_UNIX)
+01980         XWindowAttributes xwa;
+01981         XGetWindowAttributes (dpy, win, &xwa);
+01982         int x1 = (int)(x * (float) xwa.width);
+01983         int y1 = (int)((1.0f - y) * (float) xwa.height);
+01984         XWarpPointer (dpy, None, win, None, None, None, None, x1, y1);
+01985 #endif // NL_OS_UNIX
+01986 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setPerPixelLightingLight CRGBA  diffuse,
CRGBA  specular,
float  shininess
[virtual]
+
+ + + + + +
+   + + +

+Setup the light used for per pixel lighting. The given values should have been modulated by the material diffuse and specular. This is only useful for material that have their shader set as 'PerPixelLighting'

Parameters:
+ + +
the light used for per pixel lighting
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 2451 of file driver_opengl.cpp. +

+References _PPLExponent, _PPLightDiffuseColor, and _PPLightSpecularColor. +

+

02452 {
+02453         _PPLExponent = shininess;
+02454         _PPLightDiffuseColor = diffuse;
+02455         _PPLightSpecularColor = specular;
+02456 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setPolygonMode TPolygonMode  mode  )  [virtual]
+
+ + + + + +
+   + + +

+Set the global polygon mode. Can be filled, line or point. The implementation driver must call IDriver::setPolygonMode and active this mode.

+

Parameters:
+ + +
polygon mode choose in this driver.
+
+
See also:
getPolygonMode(), TPolygonMode
+ +

+Reimplemented from NL3D::IDriver. +

+Definition at line 2214 of file driver_opengl.cpp. +

+

02215 {
+02216         IDriver::setPolygonMode (mode);
+02217 
+02218         // Set the polygon mode
+02219         switch (_PolygonMode)
+02220         {
+02221         case Filled:
+02222                 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+02223                 break;
+02224         case Line:
+02225                 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+02226                 break;
+02227         case Point:
+02228                 glPolygonMode (GL_FRONT_AND_BACK, GL_POINT);
+02229                 break;
+02230         }
+02231 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setSwapVBLInterval uint  interval  )  [virtual]
+
+ + + + + +
+   + + +

+set the number of VBL wait when a swapBuffers() is issued. 0 means no synchronisation to the VBL Default depends of the 3D driver setup. Values >1 may be clamped to 1 by the driver. +

+Implements NL3D::IDriver. +

+Definition at line 3035 of file driver_opengl.cpp. +

+References _Extensions, uint, and NL3D::CGlExtensions::WGLEXTSwapControl. +

+

03036 {
+03037 #ifdef NL_OS_WINDOWS
+03038         if(_Extensions.WGLEXTSwapControl)
+03039         {
+03040                 wglSwapIntervalEXT(interval);
+03041         }
+03042 #endif
+03043 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setTextureEnvFunction uint  stage,
CMaterial mat
+
+ + + + + +
+   + + +

+Setup texture env functions. Used by setupMaterial. +

+ +

+Definition at line 117 of file driver_opengl_material.cpp. +

+References _DriverGLStates, NL3D::CMaterial::_TexEnvs, activateTexEnvColor(), activateTexEnvMode(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CMaterial::getTexCoordGen(), NL3D::CMaterial::getTexCoordGenMode(), NL3D::CMaterial::getTexture(), NL3D::ITexture::isTextureCube(), NL3D::CDriverGLStates::setTexGenMode(), and uint. +

+Referenced by setupMaterial(). +

+

00118 {
+00119         ITexture        *text= mat.getTexture(stage);
+00120         if(text)
+00121         {
+00122                 CMaterial::CTexEnv      &env= mat._TexEnvs[stage];
+00123 
+00124                 // Activate the env for this stage.
+00125                 // NB: Thoses calls use caching.
+00126                 activateTexEnvMode(stage, env);
+00127                 activateTexEnvColor(stage, env);
+00128 
+00129                 // Activate texture generation mapping
+00130                 _DriverGLStates.activeTextureARB(stage);
+00131                 if (mat.getTexCoordGen (stage))
+00132                 {
+00133                         // set mode and enable.
+00134                         CMaterial::TTexCoordGenMode     mode= mat.getTexCoordGenMode(stage);
+00135                         if(mode==CMaterial::TexCoordGenReflect)
+00136                         {
+00137                                 // Cubic or normal ?
+00138                                 if (text->isTextureCube ())
+00139                                         _DriverGLStates.setTexGenMode (stage, GL_REFLECTION_MAP_ARB);
+00140                                 else
+00141                                         _DriverGLStates.setTexGenMode (stage, GL_SPHERE_MAP);
+00142                         }
+00143                         else if(mode==CMaterial::TexCoordGenObjectSpace)
+00144                         {
+00145                                 _DriverGLStates.setTexGenMode (stage, GL_OBJECT_LINEAR);
+00146                         }
+00147                         else if(mode==CMaterial::TexCoordGenEyeSpace)
+00148                                 _DriverGLStates.setTexGenMode (stage, GL_EYE_LINEAR);
+00149                 }
+00150                 else
+00151                 {
+00152                         // Disable.
+00153                         _DriverGLStates.setTexGenMode(stage, 0);
+00154                 }
+00155         }
+00156 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setTextureShaders const uint8 addressingModes,
const NLMISC::CSmartPtr< ITexture > *  textures
[private]
+
+ + + + + +
+   + + +

+set texture shaders from stage 0 to stage IDRV_MAT_MAXTEXTURES - 1 textures are needed to setup the right kind of shader (cubic or 2d texture) +

+Definition at line 238 of file driver_opengl_material.cpp. +

+References _CurrentTexAddrMode, _DriverGLStates, NL3D::CDriverGLStates::activeTextureARB(), NL3D::convTexAddr(), GL_SHADER_OPERATION_NV, GL_TEXTURE_SHADER_NV, NL3D::IDRV_MAT_MAXTEXTURES, uint, and uint8. +

+Referenced by setupMaterial(), and setupWaterPassNV20(). +

+

00239 {
+00240         GLenum glAddrMode;
+00241         for (uint stage = 0; stage < IDRV_MAT_MAXTEXTURES; ++stage)
+00242         {                                                                               
+00243                 convTexAddr(textures[stage], (CMaterial::TTexAddressingMode) addressingModes[stage], glAddrMode);
+00244 
+00245                 if (glAddrMode != _CurrentTexAddrMode[stage]) // addressing mode different from the one in the device?
+00246         
+00247                 {
+00248                         _DriverGLStates.activeTextureARB(stage);
+00249                         glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, glAddrMode);                            
+00250                         _CurrentTexAddrMode[stage] = glAddrMode;                                        
+00251                 }
+00252         }       
+00253 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupCloudPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+

Todo:
Optimize the cloud multipass with register combiner
+ +

+Definition at line 1733 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _CurrentTexEnvSpecial, _DriverGLStates, _Extensions, activateTexEnvColor(), activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CMaterial::getColor(), NL3D::CMaterial::getShader(), NL3D::CMaterial::getTexture(), nlassert, NL3D::CGlExtensions::NVTextureEnvCombine4, TexEnvSpecialCloudStage0, TexEnvSpecialCloudStage1, and uint. +

+Referenced by setupPass(). +

+

01734 {
+01735         nlassert(_CurrentMaterial->getShader() == CMaterial::Cloud);
+01736 
+01737         const CMaterial &mat= *_CurrentMaterial;
+01738         
+01739         activateTexture(0, mat.getTexture(0));
+01740         activateTexture(1, mat.getTexture(0));
+01741 
+01742         if (_CurrentTexEnvSpecial[0] != TexEnvSpecialCloudStage0)
+01743         {
+01744                 _CurrentTexEnvSpecial[0] = TexEnvSpecialCloudStage0;
+01745                 _CurrentTexEnvSpecial[1] = TexEnvSpecialCloudStage1;
+01746 
+01747                 if (_Extensions.NVTextureEnvCombine4)
+01748                 {
+01749                         // Setup 1st Stage
+01750                         _DriverGLStates.activeTextureARB(0);
+01751                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);         
+01752                         //== colors ==
+01753                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01754                         // Arg0 = 0
+01755                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO);
+01756                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01757                         // Arg1 = 0
+01758                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO);
+01759                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01760                         // Arg2 = 0
+01761                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO);
+01762                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01763                         // Arg3 = 0
+01764                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01765                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_SRC_COLOR);
+01766 
+01767                         //== alpha ==
+01768                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD);
+01769                         // Arg0 = AT0
+01770                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE0_ARB);
+01771                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
+01772                         // Arg1 = AWPOS
+01773                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PRIMARY_COLOR_EXT);
+01774                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
+01775                         // Arg2 = AT1
+01776                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE1_ARB);
+01777                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
+01778                         // Arg3 = 1-AWPOS
+01779                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_PRIMARY_COLOR_EXT);
+01780                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_ONE_MINUS_SRC_ALPHA);
+01781 
+01782                         // Setup 2nd Stage
+01783                         _DriverGLStates.activeTextureARB(1);
+01784                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);         
+01785                         //== colors ==
+01786                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01787                         // Arg0 = 0
+01788                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO);
+01789                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01790                         // Arg1 = 0
+01791                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO);
+01792                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01793                         // Arg2 = 0
+01794                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO);
+01795                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01796                         // Arg3 = 0
+01797                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01798                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_SRC_COLOR);
+01799 
+01800                         //== alpha ==
+01801                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD);
+01802                         // Arg0 = AT0*AWPOS+AT1*(1-AWPOS)
+01803                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
+01804                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
+01805                         // Arg1 = AINT
+01806                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_CONSTANT_EXT);
+01807                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
+01808                         // Arg2 = 0
+01809                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);
+01810                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
+01811                         // Arg3 = 0
+01812                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO);
+01813                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_ALPHA);
+01814 
+01815                 }
+01816                 else
+01817                 {                       
+01818                         _DriverGLStates.activeTextureARB(0);
+01819                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01820                         // Operator.
+01821                         glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);
+01822                         glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_INTERPOLATE_EXT);                                            
+01823                         // Arg0.
+01824                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO );
+01825                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01826                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE0_ARB );
+01827                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
+01828                         // Arg1.
+01829                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO );
+01830                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01831                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_TEXTURE1_ARB );
+01832                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
+01833                         // Arg2.
+01834                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO );
+01835                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01836                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_PRIMARY_COLOR_EXT );
+01837                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
+01838                         _DriverGLStates.activeTextureARB(1);
+01839                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01840                         // Operator.
+01841                         glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
+01842                         glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE);           
+01843                         // Arg0.
+01844                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_ZERO );
+01845                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01846                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT );
+01847                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
+01848                         // Arg1.
+01849                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO );
+01850                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01851                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_CONSTANT_EXT );
+01852                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);                 
+01853                 }
+01854         }
+01855         activateTexEnvColor (1, mat.getColor());
+01856 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::setupEXTVertexShader const CVPParser::TProgram program,
GLuint  id,
uint  variants[EVSNumVariants],
uint16 usedInputRegisters
[private]
+
+ + + + + +
+   + + +

+Setup a vertex shader from its parsed program +

+Don't know why, but on some implementation of EXT_vertex_shader, can't write a single components to the fog coordinate.. So we force the mask to 0xf (only the x coordinate is used anyway). +

+Definition at line 372 of file driver_opengl_vertex_program.cpp. +

+References _ATIFogRangeFixed, _EVSColorHandle, _EVSConstantHandle, _EVSNormalHandle, _EVSNumConstant, _EVSPositionHandle, _EVSTexHandle, CVPSwizzle::Comp, NL3D::convInputRegisterToVBFlag(), NL3D::convOutputRegisterToEXTVertexShader(), NL3D::convSwizzleToGLFormat(), NL3D::doSwizzle(), NL3D::doWriteMask(), EVS_INFO, EVSFogCoordsVariant, EVSPaletteSkinVariant, EVSSecondaryColorVariant, EVSSkinWeightVariant, GL_FULL_RANGE_EXT, GL_LOCAL_CONSTANT_EXT, GL_LOCAL_EXT, GL_NORMALIZED_RANGE_EXT, GL_ONE_EXT, GL_OP_ADD_EXT, GL_OP_CLAMP_EXT, GL_OP_DOT3_EXT, GL_OP_DOT4_EXT, GL_OP_EXP_BASE_2_EXT, GL_OP_FLOOR_EXT, GL_OP_FRAC_EXT, GL_OP_INDEX_EXT, GL_OP_LOG_BASE_2_EXT, GL_OP_MADD_EXT, GL_OP_MAX_EXT, GL_OP_MIN_EXT, GL_OP_MOV_EXT, GL_OP_MUL_EXT, GL_OP_NEGATE_EXT, GL_OP_POWER_EXT, GL_OP_RECIP_EXT, GL_OP_RECIP_SQRT_EXT, GL_OP_SET_GE_EXT, GL_OP_SET_LT_EXT, GL_OUTPUT_COLOR0_EXT, GL_OUTPUT_COLOR1_EXT, GL_OUTPUT_FOG_EXT, GL_OUTPUT_TEXTURE_COORD0_EXT, GL_OUTPUT_TEXTURE_COORD7_EXT, GL_SCALAR_EXT, GL_VARIANT_EXT, GL_VECTOR_EXT, GL_VERTEX_SHADER_OPTIMIZED_EXT, GL_W_EXT, GL_X_EXT, GL_Y_EXT, GL_Z_EXT, GL_ZERO_EXT, GLboolean(), GLuint(), index, CVPOperand::Indexed, CVPSwizzle::isIdentity(), CVPParser::isInputUsed(), CVPOperand::Negate, nglBeginVertexShaderEXT, nglBindVertexShaderEXT, nglEndVertexShaderEXT, nglExtractComponentEXT, nglGenSymbolsEXT, nglInsertComponentEXT, nglSetLocalConstantEXT, nglShaderOp1EXT, nglShaderOp2EXT, nglShaderOp3EXT, nlassert, nlinfo, nlstop, nlwarning, program, CVPOperand::Swizzle, NLMISC::toString(), CVPParser::TProgram, CVPOperand::Type, uint, uint16, and CVPOperand::Value. +

+Referenced by activeEXTVertexShader(). +

+

00373 {
+00374         // counter to see what is generated
+00375         uint numOp = 0;
+00376         uint numOpIndex = 0;
+00377         uint numSwizzle = 0;
+00378         uint numEC = 0; // extract component
+00379         uint numIC = 0; // insert component
+00380         uint numWM = 0; // write maks
+00381 
+00382         
+00383         #ifdef DEBUG_SETUP_EXT_VERTEX_SHADER
+00384                 nlinfo("**********************************************************");
+00385         #endif  
+00386 
+00387         // clear last error
+00388         GLenum glError = glGetError();
+00389 
+00390         //variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
+00391 
+00392         // allocate the symbols
+00393         nglBindVertexShaderEXT(id);
+00394         nglBeginVertexShaderEXT();
+00395         {       
+00396                 
+00397                 // Allocate register and variant
+00398                 
+00399                 // allocate registers
+00400                 GLuint firstRegister = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 12); // 12 register
+00401                 GLuint firstTempRegister = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 4); // 4  temp register used for swizzle & indexing
+00402                 GLuint firstTempScalar = nglGenSymbolsEXT(GL_SCALAR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 3); // 3  temp scalars used for EXPP & LOGG emulation
+00403                 GLuint firstAddressRegister = nglGenSymbolsEXT(GL_SCALAR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);              
+00404 
+00405                 // allocate needed variants                             
+00406                 if (CVPParser::isInputUsed(program, CVPOperand::ISecondaryColor)) 
+00407                 {               
+00408                         variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
+00409                         if (!variants[EVSSecondaryColorVariant])
+00410                         {
+00411                                 nlwarning("EXT_vertex_shader : can't allocate variant for secondary color");
+00412                                 return false;
+00413                         }
+00414                 }
+00415                 else
+00416                 {
+00417                         variants[EVSSecondaryColorVariant] = 0;
+00418                 }
+00419                 if (CVPParser::isInputUsed(program, CVPOperand::IFogCoord)) 
+00420                 {               
+00421                         variants[EVSFogCoordsVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);
+00422                         if (!variants[EVSFogCoordsVariant])
+00423                         {
+00424                                 nlwarning("EXT_vertex_shader : can't allocate variant for fog coords");
+00425                                 return false;
+00426                         }
+00427                 }
+00428                 else
+00429                 {
+00430                         variants[EVSFogCoordsVariant] = 0;
+00431                 }
+00432                 if (CVPParser::isInputUsed(program, CVPOperand::IWeight)) 
+00433                 {               
+00434                         variants[EVSSkinWeightVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_NORMALIZED_RANGE_EXT, 1);
+00435                         if (!variants[EVSSkinWeightVariant])
+00436                         {
+00437                                 nlwarning("EXT_vertex_shader : can't allocate variant for skin weight");
+00438                                 return false;
+00439                         }
+00440                 }
+00441                 else
+00442                 {
+00443                         variants[EVSSkinWeightVariant] = 0;
+00444                 }
+00445                 if (CVPParser::isInputUsed(program, CVPOperand::IPaletteSkin)) 
+00446                 {               
+00447                         variants[EVSPaletteSkinVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);variants[EVSSecondaryColorVariant] = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_VARIANT_EXT, GL_FULL_RANGE_EXT, 1);
+00448                         if (!variants[EVSPaletteSkinVariant])
+00449                         {
+00450                                 nlwarning("EXT_vertex_shader : can't allocate variant for palette skin");
+00451                                 return false;
+00452                         }
+00453                 }
+00454                 else
+00455                 {
+00456                         variants[EVSPaletteSkinVariant] = 0;
+00457                 }
+00458                 
+00459                 // allocate one temporary register for fog before conversion
+00460                 GLuint fogTemp;
+00461                 if (!_ATIFogRangeFixed)
+00462                 {
+00463                         fogTemp = nglGenSymbolsEXT(GL_VECTOR_EXT, GL_LOCAL_EXT, GL_FULL_RANGE_EXT, 1);
+00464                 }
+00465 
+00466 
+00467                 // local constant : 0 and 1
+00468                 GLuint cteOne = nglGenSymbolsEXT(GL_SCALAR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1);
+00469                 GLuint cteZero = nglGenSymbolsEXT(GL_SCALAR_EXT, GL_LOCAL_CONSTANT_EXT, GL_FULL_RANGE_EXT, 1);
+00470 
+00471 
+00472                 float oneValue = 1.f;
+00473                 float zeroValue = 0.f;
+00474 
+00475                 nglSetLocalConstantEXT( cteOne, GL_FLOAT, &oneValue);
+00476                 nglSetLocalConstantEXT( cteZero, GL_FLOAT, &zeroValue);
+00477 
+00478 
+00479                 
+00480                 if (firstRegister == 0)
+00481                 {
+00482                         nlwarning("Unable to allocate local registers for EXT_vertex_shader");
+00483                         return false;
+00484                 }
+00485                 if (firstTempRegister == 0)
+00486                 {
+00487                         nlwarning("Unable to allocate local temp registers for EXT_vertex_shader");
+00488                         return false;
+00489                 }
+00490                 if (firstTempScalar == 0)
+00491                 {
+00492                         nlwarning("Unable to allocate temp scalar registers for EXT_vertex_shader");
+00493                         return false;
+00494                 }
+00495                 if (firstAddressRegister == 0)
+00496                 {
+00497                         nlwarning("Unable to allocate address register for EXT_vertex_shader");
+00498                         return false;
+00499                 }
+00500                 
+00501                 // Mask of output component that are being written
+00502                 uint componentWritten[16];
+00503                 std::fill(componentWritten, componentWritten + 16, 0);
+00504                 
+00505                 //
+00506                 GLuint srcValue[3];
+00507                 //
+00508                 GLuint destValue;
+00509                 GLuint maskedDestValue;
+00510                 
+00511 
+00512                 uint l;
+00513                 // convert each instruction of the vertex program
+00514                 for(uint k = 0; k < program.size(); ++k)
+00515                 {
+00516                         // get src values, eventually applying swizzle, negate, and index on them
+00517                         uint numSrc = program[k].getNumUsedSrc();
+00518                         for(l = 0; l < numSrc; ++l)
+00519                         {
+00520                                 EVS_INFO(("Build source " + toString(l)).c_str());
+00521                                 const CVPOperand &operand = program[k].getSrc(l);
+00522                                 switch (operand.Type)
+00523                                 {
+00524                                         case CVPOperand::InputRegister: 
+00525                                         {
+00526                                                 switch(operand.Value.InputRegisterValue)
+00527                                                 {
+00528                                                         case  0: srcValue[l] = _EVSPositionHandle; EVS_INFO("Src = position"); break;
+00529                                                         case  1: srcValue[l] = variants[EVSSkinWeightVariant]; EVS_INFO("Src = skin weight"); break;
+00530                                                         case  2: srcValue[l] = _EVSNormalHandle; EVS_INFO("Src = normal"); break;
+00531                                                         case  3: srcValue[l] = _EVSColorHandle; EVS_INFO("Src = color 0"); break;
+00532                                                         case  4: srcValue[l] = variants[EVSSecondaryColorVariant]; EVS_INFO("Src = color 1"); break;
+00533                                                         case  5: srcValue[l] = variants[EVSFogCoordsVariant]; EVS_INFO("Src = fog coord"); break;
+00534                                                         case  6: srcValue[l] = variants[EVSPaletteSkinVariant]; EVS_INFO("Src = palette skin"); break;
+00535                                                         case  7: nlstop; // not supported
+00536                                                         case  8:
+00537                                                         case  9:
+00538                                                         case  10:
+00539                                                         case  11:
+00540                                                         case  12:
+00541                                                         case  13:
+00542                                                         case  14:
+00543                                                         case  15:
+00544                                                         {                                                               
+00545                                                                 EVS_INFO(("Src = Tex" + toString(operand.Value.InputRegisterValue - 8)).c_str());
+00546                                                                 srcValue[l] = _EVSTexHandle[operand.Value.InputRegisterValue - 8];
+00547                                                                 if (srcValue[l] == 0)
+00548                                                                 {                                                               
+00549                                                                         nlwarning("Trying to read an unaccessible texture coords for the device when using EXT_vertex_shader, shader loading failed.");
+00550                                                                         return false;
+00551                                                                 }
+00552                                                         }
+00553                                                         break;
+00554                                                         default:
+00555                                                                 nlstop; // invalid value
+00556                                                         break;
+00557                                                 }
+00558                                         }
+00559                                         break;
+00560                                         case CVPOperand::Constant: 
+00561                                                 nlassert(operand.Value.ConstantValue < _EVSNumConstant); // constant index too high
+00562                                                 srcValue[l] = _EVSConstantHandle + operand.Value.ConstantValue;                                                                                                 
+00563                                                 EVS_INFO(("Src = constant" + toString(operand.Value.ConstantValue)).c_str());
+00564                                         break;
+00565                                         case CVPOperand::Variable: 
+00566                                                 srcValue[l] = firstRegister + operand.Value.VariableValue;
+00567                                                 EVS_INFO(("Src = variable register" + toString(operand.Value.VariableValue)).c_str());
+00568                                         break;
+00569                                         default:
+00570                                                 nlassert(0);
+00571                                         break;
+00572                                 }
+00573                                 // test if indexed access is used (can be used on one register only)
+00574                                 if (operand.Type == CVPOperand::Constant && operand.Indexed)
+00575                                 {
+00576                                         nglShaderOp2EXT(GL_OP_INDEX_EXT, firstTempRegister + 3, firstAddressRegister, srcValue[l]);
+00577                                         EVS_INFO("GL_OP_INDEX_EXT");
+00578                                         ++ numOpIndex;
+00579                                         srcValue[l] = firstTempRegister + 3;
+00580                                         glError = glGetError();
+00581                                         nlassert(glError == GL_NO_ERROR);
+00582                                 }
+00583 
+00584                                 // test if swizzle or negate is used
+00585                                 if (!operand.Swizzle.isIdentity() || operand.Negate)
+00586                                 {
+00587                                         // if the instruction reads a scalar, no need for swizzle (except if negate is used)
+00588                                         if (!                                           
+00589                                                 (
+00590                                                  (program[k].Opcode == CVPInstruction::RSQ
+00591                                                   || program[k].Opcode == CVPInstruction::RCP
+00592                                                   || program[k].Opcode == CVPInstruction::LOG
+00593                                                   || program[k].Opcode == CVPInstruction::EXPP
+00594                                              ) 
+00595                                                  && 
+00596                                                  !operand.Negate
+00597                                                 )
+00598                                         )
+00599                                         {                                       
+00600                                                 // need a temp register for swizzle and/or negate
+00601                                                 doSwizzle(firstTempRegister + l, srcValue[l],
+00602                                                                           convSwizzleToGLFormat(operand.Swizzle.Comp[0], operand.Negate),
+00603                                                                           convSwizzleToGLFormat(operand.Swizzle.Comp[1], operand.Negate),
+00604                                                                           convSwizzleToGLFormat(operand.Swizzle.Comp[2], operand.Negate),
+00605                                                                           convSwizzleToGLFormat(operand.Swizzle.Comp[3], operand.Negate));                                              
+00606                                                 ++numSwizzle;
+00607                                                 srcValue[l] = firstTempRegister + l;
+00608                                                 glError = glGetError();
+00609                                                 nlassert(glError == GL_NO_ERROR);
+00610                                         }
+00611                                 }
+00612                         }
+00613 
+00614                         // get dest value
+00615                         const CVPOperand &destOperand = program[k].Dest;
+00616                         switch(destOperand.Type)
+00617                         {
+00618                                 case CVPOperand::Variable: 
+00619                                         destValue = firstRegister + destOperand.Value.VariableValue; 
+00620                                 break;
+00621                                 case CVPOperand::OutputRegister:
+00622                                         if (_ATIFogRangeFixed || destOperand.Value.OutputRegisterValue != CVPOperand::OFogCoord)
+00623                                         {                                       
+00624                                                 destValue = convOutputRegisterToEXTVertexShader(destOperand.Value.OutputRegisterValue);
+00625                                         }
+00626                                         else
+00627                                         {                                                                                               
+00628                                                 destValue = fogTemp;                                            
+00629                                         }
+00630                                 break;
+00631                                 case CVPOperand::AddressRegister:
+00632                                         destValue = firstAddressRegister;
+00633                                 break;
+00634                                 default:
+00635                                         nlassert(0);
+00636                                 break;
+00637                         }
+00638 
+00639                         uint writeMask = program[k].Dest.WriteMask;
+00640                         CVPInstruction::EOpcode opcode = program[k].Opcode;
+00641                         uint outputRegisterIndex = 0;
+00642                         if (destOperand.Type != CVPOperand::AddressRegister)
+00643                         {                       
+00644                                 outputRegisterIndex = destOperand.Value.OutputRegisterValue;
+00645                                 nlassert(outputRegisterIndex < 16);
+00646                         }
+00647 
+00648                         // Tells wether the output has already been written before the final write mask. This happens with instructions LOG, EXPP, LIT, RSQ and RCP,
+00649                         // because they write their output component by components
+00650                         bool outputWritten = false;
+00651 
+00652                         // test for write mask                                          
+00653                         if (writeMask != 0x0f) 
+00654                         {                                       
+00658                                 if (!(destOperand.Type == CVPOperand::OutputRegister && destOperand.Value.OutputRegisterValue == CVPOperand::OFogCoord))
+00659                                 {
+00660                                         // For instructions that write their output components by components, we don't need an intermediary register
+00661                                         if (opcode == CVPInstruction::LOG
+00662                                                 || opcode == CVPInstruction::EXPP
+00663                                                 || opcode == CVPInstruction::LIT
+00664                                                 || opcode == CVPInstruction::RSQ
+00665                                                 || opcode == CVPInstruction::RCP
+00666                                            )
+00667                                         {
+00668                                                 outputWritten = true;   
+00669                                         }
+00670                                         else
+00671                                         {                                       
+00672                                                 maskedDestValue = destValue;
+00673                                                 // use a temp register before masking
+00674                                                 destValue = firstTempRegister;
+00675                                         }
+00676                                 }
+00677                                 else
+00678                                 {
+00679                                         componentWritten[outputRegisterIndex] = 0xf;
+00680                                 }
+00681                         }
+00682                         else
+00683                         {
+00684                                 if (destOperand.Type == CVPOperand::OutputRegister)
+00685                                 {
+00686                                         componentWritten[outputRegisterIndex] = 0xf; // say all components have been written for that output                            
+00687                                 }
+00688                         }                       
+00689                         
+00690                         // generate opcode
+00691                         switch (opcode)
+00692                         {
+00693                                 case  CVPInstruction::ARL:
+00694                                 {                                       
+00695                                         nlassert(program[k].Src1.Swizzle.isScalar());
+00696                                         GLuint index = program[k].Src1.Swizzle.Comp[0];
+00697                                         nglExtractComponentEXT(firstAddressRegister, srcValue[0],  index);
+00698                                         EVS_INFO("Extract component");
+00699                                         ++numEC;
+00700                                 }
+00701                                 break;
+00702                                 case  CVPInstruction::MOV:
+00703                                 {                                                                                       
+00704                                         nglShaderOp1EXT(GL_OP_MOV_EXT, destValue, srcValue[0]);                                 
+00705                                         EVS_INFO("GL_OP_MOV_EXT");
+00706                                         ++numOp;                                        
+00707                                 }
+00708                                 break;
+00709                                 case  CVPInstruction::MUL: 
+00710                                         nglShaderOp2EXT(GL_OP_MUL_EXT, destValue, srcValue[0], srcValue[1]); 
+00711                                         EVS_INFO("GL_OP_MUL_EXT");
+00712                                         ++numOp;
+00713                                 break;
+00714                                 case  CVPInstruction::ADD: 
+00715                                         nglShaderOp2EXT(GL_OP_ADD_EXT, destValue, srcValue[0], srcValue[1]); 
+00716                                         EVS_INFO("GL_OP_ADD_EXT");
+00717                                         ++numOp;
+00718                                 break;
+00719                                 case  CVPInstruction::MAD: 
+00720                                         nglShaderOp3EXT(GL_OP_MADD_EXT, destValue, srcValue[0], srcValue[1], srcValue[2]); 
+00721                                         EVS_INFO("GL_OP_MADD_EXT");
+00722                                         ++numOp;
+00723                                 break;
+00724                                 case  CVPInstruction::RSQ:
+00725                                 {
+00726                                         nlassert(program[k].Src1.Swizzle.isScalar());
+00727                                         // extract the component we need
+00728                                         GLuint index = program[k].Src1.Swizzle.Comp[0];
+00729                                         nglExtractComponentEXT(firstTempScalar, srcValue[0],  index);
+00730                                         EVS_INFO("Extract component");
+00731                                         ++numEC;
+00732                                         nglShaderOp1EXT(GL_OP_RECIP_SQRT_EXT, firstTempScalar + 1, firstTempScalar);
+00733                                         EVS_INFO("GL_OP_RECIP_SQRT_EXT");
+00734                                         ++numOp;
+00735                                         // duplicate result in destination
+00736                                         for(uint l = 0; l < 4; ++l)
+00737                                         {
+00738                                                 if (writeMask & (1 << l))
+00739                                                 {                                               
+00740                                                         nglInsertComponentEXT(destValue, firstTempScalar + 1, l);
+00741                                                         EVS_INFO("Insert component");
+00742                                                         nlassert(glGetError() == GL_NO_ERROR);
+00743                                                 }
+00744                                         }
+00745                                 }
+00746                                 break;
+00747                                 case  CVPInstruction::DP3: 
+00748                                         nglShaderOp2EXT(GL_OP_DOT3_EXT, destValue, srcValue[0], srcValue[1]);
+00749                                         EVS_INFO("GL_OP_DOT3_EXT");
+00750                                         ++numOp;
+00751                                 break;
+00752                                 case  CVPInstruction::DP4: 
+00753                                         nglShaderOp2EXT(GL_OP_DOT4_EXT, destValue, srcValue[0], srcValue[1]); 
+00754                                         EVS_INFO("GL_OP_DOT4_EXT");
+00755                                         ++numOp;
+00756                                 break;
+00757                                 case  CVPInstruction::DST: 
+00758                                         doSwizzle(firstTempRegister, srcValue[0], GL_ONE_EXT, GL_Y_EXT, GL_Z_EXT, GL_ONE_EXT);
+00759                                         EVS_INFO("GL_OP_DOT4_EXT");
+00760                                         ++numOp;
+00761                                         doSwizzle(firstTempRegister + 1, srcValue[1], GL_ONE_EXT, GL_Y_EXT, GL_ONE_EXT, GL_W_EXT);                                      
+00762                                         ++numSwizzle;
+00763                                         nglShaderOp2EXT(GL_OP_MUL_EXT, destValue, firstTempRegister, firstTempRegister + 1);
+00764                                         EVS_INFO("GL_OP_MUL_EXT");
+00765                                         ++numOp;
+00766                                 break;                                  
+00767                                 case  CVPInstruction::LIT:
+00768                                 {
+00769                                         uint writeMask = program[k].Dest.WriteMask;                                     
+00770                                         nglExtractComponentEXT(firstTempScalar, srcValue[0], 0); // extract X from the source
+00771                                         if (writeMask & 4)
+00772                                         {                                       
+00773                                                 nglExtractComponentEXT(firstTempScalar + 1, srcValue[0], 1); // extract Y from the source
+00774                                                 EVS_INFO("Extract component");
+00775                                                 ++numEC;
+00776                                                 nglExtractComponentEXT(firstTempScalar + 2, srcValue[0], 3); // extract W from the source
+00777                                                 EVS_INFO("Extract component");
+00778                                                 ++numEC;
+00779                                                 // result = X > 0 ? Y^W : 0                                     
+00780                                                 nglShaderOp2EXT(GL_OP_POWER_EXT, firstTempScalar + 2, firstTempScalar + 1, firstTempScalar + 2);
+00781                                                 EVS_INFO("GL_OP_POWER_EXT");
+00782                                                 ++numOp;
+00783                                                 nglShaderOp2EXT(GL_OP_SET_GE_EXT, firstTempScalar + 1, firstTempScalar, cteZero);
+00784                                                 EVS_INFO("GL_OP_SET_GE_EXT");
+00785                                                 ++numOp;
+00786                                                 nglShaderOp2EXT(GL_OP_MUL_EXT, firstTempScalar + 2, firstTempScalar + 2, firstTempScalar + 1);
+00787                                                 EVS_INFO("GL_OP_MUL_EXT");
+00788                                                 ++numOp;
+00789                                                 // store result
+00790                                                 nglInsertComponentEXT(destValue, firstTempScalar + 2, 2);
+00791                                                 EVS_INFO("Insert component");
+00792                                                 ++numIC;
+00793                                         }
+00794                                         if (writeMask & 2) 
+00795                                         {
+00796                                                 // clamp N.L to [0, 1]
+00797                                                 nglShaderOp3EXT(GL_OP_CLAMP_EXT, firstTempScalar, firstTempScalar, cteZero, cteOne);
+00798                                                 EVS_INFO("GL_OP_CLAMP_EXT");
+00799                                                 ++numOp;
+00800                                                 nglInsertComponentEXT(destValue, firstTempScalar, 1);
+00801                                                 EVS_INFO("Insert component");
+00802                                                 ++numIC;
+00803                                         }
+00804                                         // set x and w to 1 if they are not masked
+00805                                         if (writeMask & (1 + 8)) 
+00806                                         {                                       
+00807                                                 doSwizzle(destValue, destValue, 
+00808                                                                           (writeMask & 1) ? GL_ONE_EXT : GL_X_EXT,
+00809                                                                           GL_Y_EXT,
+00810                                                                           GL_Z_EXT,
+00811                                                                           (writeMask & 8) ? GL_ONE_EXT : GL_W_EXT);                                             
+00812                                                 ++numSwizzle;
+00813                                         }                                       
+00814                                                  
+00815                                 }
+00816                                 break;
+00817                                 case  CVPInstruction::MIN: 
+00818                                         nglShaderOp2EXT(GL_OP_MIN_EXT, destValue, srcValue[0], srcValue[1]);
+00819                                         EVS_INFO("GL_OP_MIN_EXT");
+00820                                         ++numOp;
+00821                                 break;
+00822                                 case  CVPInstruction::MAX: 
+00823                                         nglShaderOp2EXT(GL_OP_MAX_EXT, destValue, srcValue[0], srcValue[1]);
+00824                                         EVS_INFO("GL_OP_MAX_EXT");
+00825                                         ++numOp;
+00826                                 break;
+00827                                 case  CVPInstruction::SLT: 
+00828                                         nglShaderOp2EXT(GL_OP_SET_LT_EXT, destValue, srcValue[0], srcValue[1]);
+00829                                         EVS_INFO("GL_OP_SET_LT_EXT");
+00830                                         ++numOp;
+00831                                 break;
+00832                                 case  CVPInstruction::SGE: 
+00833                                         nglShaderOp2EXT(GL_OP_SET_GE_EXT, destValue, srcValue[0], srcValue[1]);
+00834                                         EVS_INFO("GL_OP_SET_GE_EXT");
+00835                                         ++numOp;
+00836                                 break;
+00837                                 case  CVPInstruction::EXPP:
+00838                                 {                       
+00839                                         uint writeMask = program[k].Dest.WriteMask;
+00840                                         nlassert(program[k].Src1.Swizzle.isScalar());
+00841                                         GLuint compIndex = program[k].Src1.Swizzle.Comp[0];
+00842                                         nglExtractComponentEXT(firstTempScalar + 2, srcValue[0], compIndex); // extract W from the source
+00843                                         EVS_INFO("Extract component");
+00844                                         ++numEC;
+00845                                         if (writeMask & 1)
+00846                                         {                                       
+00847                                                 nglShaderOp1EXT(GL_OP_FLOOR_EXT, firstTempScalar, firstTempScalar + 2); // (int) W
+00848                                                 EVS_INFO("GL_OP_FLOOR_EXT");
+00849                                                 ++numOp;
+00850                                                 nglShaderOp1EXT(GL_OP_EXP_BASE_2_EXT, firstTempScalar, firstTempScalar); // 2 ^ (int) W         
+00851                                                 EVS_INFO("GL_OP_EXP_BASE_2_EXT");
+00852                                                 ++numOp;
+00853                                         }
+00854                                         if (writeMask & 2) 
+00855                                         {                                       
+00856                                                 nglShaderOp1EXT(GL_OP_FRAC_EXT, firstTempScalar + 1, firstTempScalar + 2); // frac(W)
+00857                                                 EVS_INFO("GL_OP_FRAC_EXT");
+00858                                                 ++numOp;
+00859                                         }
+00860                                         if (writeMask & 4) nglShaderOp1EXT(GL_OP_EXP_BASE_2_EXT, firstTempScalar + 2, firstTempScalar + 2); // 2 ^W
+00861                                         // store the results
+00862                                         if (writeMask & 1) { nglInsertComponentEXT(destValue, firstTempScalar, 0); EVS_INFO("Insert component"); ++numIC;  }
+00863                                         if (writeMask & 2) { nglInsertComponentEXT(destValue, firstTempScalar + 1, 1); EVS_INFO("Insert component"); ++numIC; }
+00864                                         if (writeMask & 4) { nglInsertComponentEXT(destValue, firstTempScalar + 2, 2); EVS_INFO("Insert component"); ++numIC; }
+00865                                         // set W to 1 and leave other values unchanged
+00866                                         if (writeMask & 8) { doSwizzle(destValue, destValue, GL_X_EXT, GL_Y_EXT, GL_Z_EXT, GL_ONE_EXT); ++numSwizzle; }
+00867                                 }
+00868                                 break;
+00869                                 case  CVPInstruction::LOG:
+00870                                 {                                       
+00871                                         uint writeMask = program[k].Dest.WriteMask;
+00872                                         nlassert(program[k].Src1.Swizzle.isScalar());
+00873                                         // extract the component we need
+00874                                         nglExtractComponentEXT(firstTempScalar, srcValue[0], (GLuint) program[k].Src1.Swizzle.Comp[0]);
+00875                                         EVS_INFO("Extract component");
+00876                                         ++numEC;
+00877                                         // get abs(src) : abs(src) = max(src, -src)
+00878                                         nglShaderOp1EXT(GL_OP_NEGATE_EXT, firstTempScalar + 1, firstTempScalar);
+00879                                         EVS_INFO("GL_OP_NEGATE_EXT");
+00880                                         ++numOp;
+00881                                         nglShaderOp2EXT(GL_OP_MAX_EXT, firstTempScalar, firstTempScalar, firstTempScalar + 1);
+00882                                         EVS_INFO("GL_OP_MAX_EXT");
+00883                                         ++numOp;
+00884                                         nglShaderOp1EXT(GL_OP_LOG_BASE_2_EXT, firstTempScalar, firstTempScalar); // (int) W
+00885                                         EVS_INFO("GL_OP_LOG_BASE_2_EXT");
+00886                                         ++numOp;
+00887                                         // store the results
+00888                                         for(uint l = 0; l < 4; ++l)
+00889                                         {
+00890                                                 if (writeMask & (1 << l))
+00891                                                 {                                               
+00892                                                         nglInsertComponentEXT(destValue, firstTempScalar, l);
+00893                                                         EVS_INFO("Insert component");
+00894                                                         nlassert(glGetError() == GL_NO_ERROR);
+00895                                                 }
+00896                                         }                                       
+00897                                 }
+00898                                 break;
+00899                                 case  CVPInstruction::RCP:
+00900                                 {
+00901                                         uint writeMask = program[k].Dest.WriteMask;
+00902                                         nlassert(program[k].Src1.Swizzle.isScalar());
+00903                                         // extract the component we need
+00904                                         nglExtractComponentEXT(firstTempScalar, srcValue[0], (GLuint) program[k].Src1.Swizzle.Comp[0]);
+00905                                         EVS_INFO("Extract component");
+00906                                         ++numEC;
+00907                                         nglShaderOp1EXT(GL_OP_RECIP_EXT, firstTempScalar + 1, firstTempScalar);
+00908                                         EVS_INFO("GL_OP_RECIP_EXT");
+00909                                         ++numOp;
+00910                                         // duplicate result in destination
+00911                                         for(uint l = 0; l < 4; ++l)
+00912                                         {
+00913                                                 if (writeMask & (1 << l))
+00914                                                 {                                               
+00915                                                         nglInsertComponentEXT(destValue, firstTempScalar + 1, l);
+00916                                                         EVS_INFO("insert component");
+00917                                                         ++numIC;
+00918                                                 }
+00919                                         }
+00920                                 }                                       
+00921                                 break;
+00922                         }
+00923 
+00924                         glError = glGetError();
+00925                         nlassert(glError == GL_NO_ERROR);
+00926 
+00927                                 
+00928                         // apply write mask if any
+00929                         if (writeMask != 0x0f)
+00930                         {                                                                       
+00931                                 if ((destOperand.Type == CVPOperand::OutputRegister && destOperand.Value.OutputRegisterValue != CVPOperand::OFogCoord))
+00932                                 {
+00933                                         uint &outputMask = componentWritten[outputRegisterIndex];
+00934                                         // is a texture coordinate or a color being written ?
+00935                                         if ((maskedDestValue >= GL_OUTPUT_TEXTURE_COORD0_EXT && maskedDestValue <= GL_OUTPUT_TEXTURE_COORD7_EXT)
+00936                                                 || maskedDestValue == GL_OUTPUT_COLOR0_EXT
+00937                                                 || maskedDestValue == GL_OUTPUT_COLOR1_EXT
+00938                                            )
+00939                                         {                                       
+00940                                                 // test if this is the last time this output will be written
+00941                                                 bool found = false;
+00942                                                 // if this was the last write for this output, must set unfilled component
+00943                                                 // NB : this loop could be optimized, but vertex program are rather short for now ..
+00944                                                 for(uint m = k + 1; m < program.size(); ++m)
+00945                                                 {
+00946                                                         if (program[m].Dest.Type == CVPOperand::OutputRegister) // another output to this texture ?
+00947                                                         {
+00948                                                                 if (program[m].Dest.Value.OutputRegisterValue == program[k].Dest.Value.OutputRegisterValue)
+00949                                                                 {
+00950                                                                         found = true;
+00951                                                                         break;
+00952                                                                 }
+00953                                                         }
+00954                                                 }
+00955 
+00956                                                 if (found)
+00957                                                 {
+00958                                                         if (!outputWritten)
+00959                                                         {                                                       
+00960                                                                 // write values
+00961                                                                 doWriteMask(maskedDestValue, destValue,
+00962                                                                                                 writeMask & 1 ? GL_TRUE : GL_FALSE,
+00963                                                                                                 writeMask & 2 ? GL_TRUE : GL_FALSE,
+00964                                                                                                 writeMask & 4 ? GL_TRUE : GL_FALSE,
+00965                                                                                                 writeMask & 8 ? GL_TRUE : GL_FALSE);
+00966                                                                 ++numWM;
+00967                                                         }
+00968                                                 }
+00969                                                 else // this is the last write, check if the mask is complete
+00970                                                 {
+00971                                                         if ((outputMask | writeMask) == 0xf)
+00972                                                         {
+00973                                                                 if (!outputWritten)
+00974                                                                 {
+00975                                                                         // ok, after this call everything has been written
+00976                                                                         // write values
+00977                                                                             doWriteMask(maskedDestValue, destValue,
+00978                                                                                                         writeMask & 1 ? GL_TRUE : GL_FALSE,
+00979                                                                                                         writeMask & 2 ? GL_TRUE : GL_FALSE,
+00980                                                                                                         writeMask & 4 ? GL_TRUE : GL_FALSE,
+00981                                                                                                         writeMask & 8 ? GL_TRUE : GL_FALSE);
+00982                                                                         ++numWM;
+00983                                                                 }
+00984                                                         }
+00985                                                         else
+00986                                                         {
+00987                                                                 uint prevMask = outputMask;
+00988                                                                 uint newMask  = writeMask | outputMask;
+00989                                                                 
+00990                                                                 // complete unused entries
+00991 
+00992                                                                 // if primary color is output, then the default color is white
+00993                                                                 if (maskedDestValue == GL_OUTPUT_COLOR0_EXT)
+00994                                                                 {
+00995                                                                         doSwizzle(firstTempRegister, destValue,
+00996                                                                                                   newMask & 1 ? GL_X_EXT : GL_ONE_EXT,
+00997                                                                                                   newMask & 2 ? GL_Y_EXT : GL_ONE_EXT,
+00998                                                                                                   newMask & 4 ? GL_Z_EXT : GL_ONE_EXT,
+00999                                                                                                   newMask & 8 ? GL_W_EXT : GL_ONE_EXT);
+01000                                                                 }
+01001                                                                 else
+01002                                                                 {                                                               
+01003                                                                         doSwizzle(firstTempRegister, destValue,
+01004                                                                                                   newMask & 1 ? GL_X_EXT : GL_ZERO_EXT,
+01005                                                                                                   newMask & 2 ? GL_Y_EXT : GL_ZERO_EXT,
+01006                                                                                                   newMask & 4 ? GL_Z_EXT : GL_ZERO_EXT,
+01007                                                                                                   newMask & 8 ? GL_W_EXT : GL_ONE_EXT);
+01008                                                                 }
+01009                                                                 if (!outputWritten)
+01010                                                                 {                                                       
+01011                                                                         ++numWM;
+01012                                                                             doWriteMask(maskedDestValue, firstTempRegister,
+01013                                                                                                         prevMask & 1 ? GL_FALSE : GL_TRUE,
+01014                                                                                                         prevMask & 2 ? GL_FALSE : GL_TRUE,
+01015                                                                                                         prevMask & 4 ? GL_FALSE : GL_TRUE,
+01016                                                                                                         prevMask & 8 ? GL_FALSE : GL_TRUE
+01017                                                                                                   );                                                                    
+01018                                                                         ++numWM;
+01019                                                                 }
+01020                                                                 outputMask = 0xf;
+01021                                                         }
+01022                                                 }                                                                               
+01023                                         }
+01024                                         else
+01025                                         {
+01026                                                 if (!outputWritten)
+01027                                                 {
+01028                                                             doWriteMask(maskedDestValue, destValue,
+01029                                                                                         writeMask & 1 ? GL_TRUE : GL_FALSE,
+01030                                                                                         writeMask & 2 ? GL_TRUE : GL_FALSE,
+01031                                                                                         writeMask & 4 ? GL_TRUE : GL_FALSE,
+01032                                                                                         writeMask & 8 ? GL_TRUE : GL_FALSE);
+01033                                                         ++numWM;
+01034                                                 }
+01035                                         }
+01036                                         // complete the mask 
+01037                                         outputMask |= writeMask;
+01038                                 }
+01039                                 else if (destOperand.Type != CVPOperand::OutputRegister)
+01040                                 {
+01041                                         if (!outputWritten)
+01042                                         {
+01043                                                     doWriteMask(maskedDestValue, destValue,
+01044                                                                                 writeMask & 1 ? GL_TRUE : GL_FALSE,
+01045                                                                                 writeMask & 2 ? GL_TRUE : GL_FALSE,
+01046                                                                                 writeMask & 4 ? GL_TRUE : GL_FALSE,
+01047                                                                                 writeMask & 8 ? GL_TRUE : GL_FALSE);
+01048                                                 ++numWM;
+01049                                         }
+01050                                 }                               
+01051                         }
+01052 
+01053                         glError = glGetError();
+01054                         nlassert(glError == GL_NO_ERROR);
+01055                 }
+01056 
+01057                 
+01058 
+01059                 // if color have not been written, write with default values            
+01060                 if (componentWritten[CVPOperand::OPrimaryColor] == 0)
+01061                 {
+01062                         // we specify vertex coord has input for swizzle, but we don't read any component.. 
+01063                         doSwizzle(GL_OUTPUT_COLOR0_EXT, _EVSPositionHandle, GL_ZERO_EXT, GL_ZERO_EXT, GL_ZERO_EXT, GL_ONE_EXT);
+01064                         EVS_INFO("Swizzle (Complete primary color)");
+01065                         ++numSwizzle;
+01066                 }
+01067                 else
+01068                 {
+01069                         nlassert(componentWritten[CVPOperand::OPrimaryColor] == 0xf);
+01070                 }
+01071                 if (componentWritten[CVPOperand::OSecondaryColor] == 0)
+01072                 {
+01073                         // we specify vertex coord has input for swizzle, but we don't read any component..
+01074                         doSwizzle(GL_OUTPUT_COLOR1_EXT, _EVSPositionHandle, GL_ZERO_EXT, GL_ZERO_EXT, GL_ZERO_EXT, GL_ONE_EXT);
+01075                         EVS_INFO("Swizzle (Complete secondary color)");
+01076                         ++numSwizzle;
+01077                 }
+01078                 else
+01079                 {
+01080                         nlassert(componentWritten[CVPOperand::OSecondaryColor] == 0xf);
+01081                 }
+01082                 nlassert(componentWritten[CVPOperand::OHPosition] == 0xf); // should have written all component of position     
+01083 
+01084                 glError = glGetError(); 
+01085                 nlassert(glError == GL_NO_ERROR);
+01086 
+01087                 // if fog has been written, perform conversion (if there's no ATI driver fix)
+01088                 if (!_ATIFogRangeFixed && componentWritten[CVPOperand::OFogCoord] == 0xf)
+01089                 {
+01090                         // Well this could be avoided, but we should make 2 cases for each vertex program.. :(
+01091                         doSwizzle(firstTempRegister, _EVSConstantHandle + _EVSNumConstant, GL_X_EXT, GL_X_EXT, GL_X_EXT, GL_X_EXT);
+01092                         doSwizzle(firstTempRegister + 1, _EVSConstantHandle + _EVSNumConstant, GL_Y_EXT, GL_Y_EXT, GL_Y_EXT, GL_Y_EXT);                 
+01093                         nglShaderOp3EXT(GL_OP_MADD_EXT, firstTempRegister + 2, fogTemp, firstTempRegister, firstTempRegister + 1);
+01094                         EVS_INFO("Use MAD for fog conversion");
+01095                         nglExtractComponentEXT(GL_OUTPUT_FOG_EXT, firstTempRegister + 2, 0);                    
+01096                         EVS_INFO("Extract component to fog");
+01097                 }
+01098 
+01099                 glError = glGetError();
+01100                 nlassert(glError == GL_NO_ERROR);
+01101         }
+01102         nglEndVertexShaderEXT();
+01103 
+01104         /*glError = glGetError();
+01105         nlassert(glError == GL_NO_ERROR);*/
+01106 
+01107         GLboolean optimizedShader;
+01108         glGetBooleanv(GL_VERTEX_SHADER_OPTIMIZED_EXT, &optimizedShader);
+01109         if (!optimizedShader)
+01110         {
+01111                 nlwarning("Failed to optimize a vertex program with the EXT_vertex_shader extension, this shader will be disabled");
+01112                 return false;
+01113         }       
+01114 
+01115         // see which input registers are used
+01116         usedInputRegisters = 0;
+01117         
+01118         uint k, l;
+01119         // convert each instruction of the vertex program
+01120         for(k = 0; k < program.size(); ++k)
+01121         {
+01122                 uint numSrc = program[k].getNumUsedSrc();
+01123                 for(l = 0; l < numSrc; ++l)
+01124                 {
+01125                         const CVPOperand &op = program[k].getSrc(l);
+01126                         if (op.Type == CVPOperand::InputRegister)
+01127                         {
+01128                                 usedInputRegisters |= convInputRegisterToVBFlag(op.Value.InputRegisterValue);
+01129                         }
+01130                 }               
+01131         }
+01132 
+01133 #ifdef DEBUG_SETUP_EXT_VERTEX_SHADER
+01134         nlinfo("========================");
+01135         nlinfo("num Opcode  = %d", numOp);
+01136         nlinfo("num Indexing = %d", numOpIndex);
+01137         nlinfo("num Swizzle = %d", numSwizzle);
+01138         nlinfo("num extract component = %d", numEC);
+01139         nlinfo("num insert component = %d", numIC);     
+01140         nlinfo("num write mask = %d", numWM);
+01141 #endif
+01142 
+01143         return true;
+01144                         
+01145 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setupFog float  start,
float  end,
CRGBA  color
[virtual]
+
+ + + + + +
+   + + +

+setup fog parameters. fog must enabled to see result. start and end are in [0,1] range. +

+ +

+Special : with vertex program, using the extension EXT_vertex_shader, fog is emulated using 1 more constant to scale result to [0, 1] +

+Implements NL3D::IDriver. +

+Definition at line 2245 of file driver_opengl.cpp. +

+References _ATIFogRangeFixed, _CurrentFogColor, _EVSNumConstant, _Extensions, _FogEnd, _FogStart, NLMISC::CRGBA::A, NLMISC::CRGBA::B, NL3D::CGlExtensions::EXTVertexShader, NLMISC::CRGBA::G, NL3D::CGlExtensions::NVVertexProgram, NLMISC::CRGBA::R, and setConstant(). +

+

02246 {
+02247         glFogf(GL_FOG_MODE, GL_LINEAR);
+02248         glFogf(GL_FOG_START, start);
+02249         glFogf(GL_FOG_END, end);
+02250 
+02251         _CurrentFogColor[0]= color.R/255.0f;
+02252         _CurrentFogColor[1]= color.G/255.0f;
+02253         _CurrentFogColor[2]= color.B/255.0f;
+02254         _CurrentFogColor[3]= color.A/255.0f;
+02255 
+02256         glFogfv(GL_FOG_COLOR, _CurrentFogColor);
+02257 
+02260         if (_Extensions.EXTVertexShader && !_Extensions.NVVertexProgram)
+02261         {
+02262                 if (!_ATIFogRangeFixed)
+02263                 {               
+02264                         // last constant is used to store fog informations (fog must be rescaled to [0, 1], because of a driver bug)
+02265                         if (start != end)
+02266                         {               
+02267                                 setConstant(_EVSNumConstant, 1.f / (start - end), - end / (start - end), 0, 0);                 
+02268                         }
+02269                         else
+02270                         {
+02271                                 setConstant(_EVSNumConstant, 0.f, 0, 0, 0);
+02272                         }
+02273                 }
+02274         }
+02275         _FogStart = start;
+02276         _FogEnd = end;
+02277 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupGlArrays CVertexBufferInfo vb  )  [private]
+
+ + + + + +
+   + + +

+setup GL arrays, with a vb info. +

+ +

+

Todo:
yoyo, or nico: this code should change with ATI VertexProgram. For now, ATI VBHard is only coded for non-VertexProgram case.
+ +

+Definition at line 1033 of file driver_opengl_vertex.cpp. +

+References _Extensions, _LastVertexSetupIsLightMap, NL3D::CGlExtensions::EXTVertexShader, isVertexProgramEnabled(), NL3D::CGlExtensions::NVVertexProgram, setupGlArraysForEXTVertexShader(), setupGlArraysForNVVertexProgram(), setupGlArraysStd(), toggleGlArraysForEXTVertexShader(), toggleGlArraysForNVVertexProgram(), uint32, and NL3D::CVertexBufferInfo::VertexFormat. +

+Referenced by activeVertexBuffer(), and activeVertexBufferHard(). +

+

01034 {
+01035         uint32  flags= vb.VertexFormat;
+01036 
+01041         // Standard case (NVVertexProgram or no vertex program case)
+01042         if (_Extensions.NVVertexProgram || !_Extensions.EXTVertexShader)
+01043         {       
+01044                 toggleGlArraysForNVVertexProgram();
+01045                 // Use a vertex program ?
+01046                 if (!isVertexProgramEnabled ())
+01047                 {
+01048                         setupGlArraysStd(vb);
+01049                 }
+01050                 else
+01051                 {               
+01052                         setupGlArraysForNVVertexProgram(vb);
+01053                 }
+01054         }       
+01055         else // EXTVertexShader case
+01056         {
+01057                 toggleGlArraysForEXTVertexShader();
+01058                 // Use a vertex program ?
+01059                 if (!isVertexProgramEnabled ())
+01060                 {
+01061                         setupGlArraysStd(vb);
+01062                 }
+01063                 else
+01064                 {               
+01065                         setupGlArraysForEXTVertexShader(vb);
+01066                 }               
+01067         }
+01068         
+01069         // Reset specials flags.
+01070         _LastVertexSetupIsLightMap= false;
+01071 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupGlArraysForEXTVertexShader CVertexBufferInfo vb  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 920 of file driver_opengl_vertex.cpp. +

+References _DriverGLStates, NL3D::CVertexProgram::_DrvInfo, _LastSetuppedVP, NL3D::CVertexBufferInfo::ATIValueOffset, NL3D::CVertexBufferInfo::ATIVBHardMode, NL3D::CVertexBufferInfo::ATIVertexObjectId, NL3D::CDriverGLStates::clientActiveTextureARB(), NL3D::CDriverGLStates::enableVertexAttribArrayForEXTVertexShader(), GLType, GLVertexAttribIndex, nglArrayObjectATI, nglVariantArrayObjectATI, nglVariantPointerEXT, nlassert, nlstop, NumCoordinatesType, NL3D::CVertexBufferInfo::Type, type, uint, uint16, uint32, NL3D::CVertexProgamDrvInfosGL::UsedVertexComponents, value, NL3D::CVertexBufferInfo::ValuePtr, NL3D::CVertexProgamDrvInfosGL::Variants, NL3D::CVertexBufferInfo::VertexFormat, and NL3D::CVertexBufferInfo::VertexSize. +

+Referenced by setupGlArrays(). +

+

00921 {
+00922 
+00923         CVertexProgram *vp = _LastSetuppedVP;
+00924         if (!vp) return;                
+00925         CVertexProgamDrvInfosGL *drvInfo = NLMISC::safe_cast<CVertexProgamDrvInfosGL *>((IVertexProgramDrvInfos *) vp->_DrvInfo);
+00926         if (!drvInfo) return;
+00927         
+00928         uint32  flags= vb.VertexFormat;
+00929 
+00930         // For each value
+00931         for (uint value=0; value<CVertexBuffer::NumValue; value++)
+00932         {
+00933                 // Flag
+00934                 uint16 flag=1<<value;
+00935 
+00936                 // Type
+00937                 CVertexBuffer::TType type=vb.Type[value];
+00938 
+00939                 // Index
+00940                 uint glIndex=GLVertexAttribIndex[value];
+00941 
+00942                 // Not setuped value and used
+00943                 if (flags & flag & drvInfo->UsedVertexComponents)
+00944                 {                                               
+00945                         _DriverGLStates.enableVertexAttribArrayForEXTVertexShader(glIndex, true, drvInfo->Variants);
+00946                         // use variant or open gl standard array
+00947                         switch(value)
+00948                         {
+00949                                         case CVertexBuffer::Position: // position 
+00950                                         {                                       
+00951                                                 nlassert(NumCoordinatesType[type] >= 2);
+00952                                                 if(vb.ATIVBHardMode) nglArrayObjectATI(GL_VERTEX_ARRAY, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Position]);
+00953                                             else                 glVertexPointer(NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00954                                         }
+00955                                         break;
+00956                                         case CVertexBuffer::Weight: // skin weight
+00957                                         {
+00958                                                 nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
+00959                                                 if(vb.ATIVBHardMode) nglVariantArrayObjectATI(drvInfo->Variants[CDriverGL::EVSSkinWeightVariant], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Weight]);
+00960                                             else                 nglVariantPointerEXT(drvInfo->Variants[CDriverGL::EVSSkinWeightVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00961                                         }
+00962                                         break;
+00963                                         case CVertexBuffer::Normal: // normal
+00964                                         {
+00965                                                 nlassert(NumCoordinatesType[type] == 3); // must have 3 components for normals
+00966                                                 if(vb.ATIVBHardMode) nglArrayObjectATI(GL_NORMAL_ARRAY, 3, GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[value]);
+00967                                             else                 glNormalPointer(GLType[type], vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);                                              
+00968                                         }
+00969                                         break;
+00970                                         case CVertexBuffer::PrimaryColor: // color
+00971                                         {
+00972                                                 nlassert(NumCoordinatesType[type] >= 3); // must have 3 or 4 components for primary color
+00973                                                 if(vb.ATIVBHardMode) nglArrayObjectATI(GL_COLOR_ARRAY, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PrimaryColor]);
+00974                                             else                 glColorPointer(NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00975                                         }                                               
+00976                                         break;
+00977                                         case CVertexBuffer::SecondaryColor: // secondary color
+00978                                         {                                                               
+00979                                                 // implemented using a variant, as not available with EXTVertexShader
+00980                                                 nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
+00981                                                 if(vb.ATIVBHardMode) nglVariantArrayObjectATI(drvInfo->Variants[CDriverGL::EVSSecondaryColorVariant], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::SecondaryColor]);
+00982                                             else                 nglVariantPointerEXT(drvInfo->Variants[CDriverGL::EVSSecondaryColorVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);                                                                                                 
+00983                                         }                                               
+00984                                         break;
+00985                                         case CVertexBuffer::Fog: // fog coordinate
+00986                                         {
+00987                                                 // implemented using a variant
+00988                                                 nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
+00989                                                 if(vb.ATIVBHardMode) nglVariantArrayObjectATI(drvInfo->Variants[CDriverGL::EVSFogCoordsVariant], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Fog]);
+00990                                                 else                 nglVariantPointerEXT(drvInfo->Variants[CDriverGL::EVSFogCoordsVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00991                                         }                                               
+00992                                         break;
+00993                                         case CVertexBuffer::PaletteSkin: // palette skin
+00994                                         {                                       
+00995                                                 // implemented using a variant
+00996                                                 nlassert(NumCoordinatesType[type] == 4); // variant, only 4 component supported
+00997                                                 if(vb.ATIVBHardMode) nglVariantArrayObjectATI(drvInfo->Variants[CDriverGL::EVSPaletteSkinVariant], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PaletteSkin]);
+00998                                                 else                 nglVariantPointerEXT(drvInfo->Variants[CDriverGL::EVSPaletteSkinVariant], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00999                                         }
+01000                                         break;
+01001                                         case CVertexBuffer::Empty: // empty
+01002                                                 nlstop
+01003                                         break;
+01004                                         case CVertexBuffer::TexCoord0:
+01005                                         case CVertexBuffer::TexCoord1:
+01006                                         case CVertexBuffer::TexCoord2:
+01007                                         case CVertexBuffer::TexCoord3:
+01008                                         case CVertexBuffer::TexCoord4:
+01009                                         case CVertexBuffer::TexCoord5:
+01010                                         case CVertexBuffer::TexCoord6:
+01011                                         case CVertexBuffer::TexCoord7:
+01012                                         {                       
+01013                                                 _DriverGLStates.clientActiveTextureARB(value - CVertexBuffer::TexCoord0);
+01014                                                 if(vb.ATIVBHardMode) nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ATIVertexObjectId, vb.ATIValueOffset[value]);
+01015                                                 else glTexCoordPointer(NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value ]);
+01016                                         }
+01017                                         break;
+01018                                         default:
+01019                                                 nlstop; // invalid value
+01020                                         break;                                  
+01021                         }                       
+01022                 }
+01023                 else
+01024                 {
+01025                         _DriverGLStates.enableVertexAttribArrayForEXTVertexShader(glIndex, false, drvInfo->Variants);
+01026                 }
+01027         }       
+01028 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupGlArraysForNVVertexProgram CVertexBufferInfo vb  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 838 of file driver_opengl_vertex.cpp. +

+References _DriverGLStates, NL3D::CDriverGLStates::enableColorArray(), NL3D::CDriverGLStates::enableSecondaryColorArray(), NL3D::CDriverGLStates::enableVertexAttribArray(), GLType, GLVertexAttribIndex, nglSecondaryColorPointerEXT, nglVertexAttribPointerNV, NumCoordinatesType, NL3D::CVertexBufferInfo::Type, type, uint, uint16, uint32, value, NL3D::CVertexBufferInfo::ValuePtr, NL3D::CVertexBufferInfo::VertexFormat, and NL3D::CVertexBufferInfo::VertexSize. +

+Referenced by setupGlArrays(). +

+

00839 {                       
+00840         uint32  flags= vb.VertexFormat;
+00841         
+00842         // For each value
+00843         for (uint value=0; value<CVertexBuffer::NumValue; value++)
+00844         {
+00845                 // Flag
+00846                 uint16 flag=1<<value;
+00847 
+00848                 // Type
+00849                 CVertexBuffer::TType type=vb.Type[value];
+00850 
+00851                 // Index
+00852                 uint glIndex=GLVertexAttribIndex[value];
+00853 
+00854                 // Not setuped value and used
+00855                 if (flags & flag)
+00856                 {
+00857                         /* OpenGL Driver Bug with VertexProgram, UChar4 type, and VertexArrayRange.
+00858                                 Don't work and lead to very poor performance (1/10) (VAR is "disabled").
+00859                         */
+00860                         // Test if can use glColorPointer() / glSecondaryColorPointerEXT() instead.
+00861                         if( (glIndex==3 || glIndex==4) )
+00862                         {
+00863                                 if( type == CVertexBuffer::UChar4 )
+00864                                 {
+00865                                         // Must disable VertexAttrib array.
+00866                                         _DriverGLStates.enableVertexAttribArray(glIndex, false);
+00867 
+00868                                         // Active this value, with standard gl calls
+00869                                         if(glIndex==3)
+00870                                         {
+00871                                                 // Primary color
+00872                                                 _DriverGLStates.enableColorArray(true);
+00873                                                 glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
+00874                                         }
+00875                                         else
+00876                                         {
+00877                                                 // Secondary color
+00878                                                 _DriverGLStates.enableSecondaryColorArray(true);
+00879                                                 nglSecondaryColorPointerEXT(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[value]);
+00880                                         }
+00881                                 }
+00882                                 else
+00883                                 {
+00884                                         // Can use normal VertexAttribArray.
+00885                                         // Disable first standard Color Array.
+00886                                         if(glIndex==3)
+00887                                                 _DriverGLStates.enableColorArray(false);
+00888                                         else
+00889                                                 _DriverGLStates.enableSecondaryColorArray(false);
+00890 
+00891                                         // Active this value
+00892                                         _DriverGLStates.enableVertexAttribArray(glIndex, true);
+00893                                         nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00894                                 }
+00895                         }
+00896                         // Else normal case, can't do anything for other values with UChar4....
+00897                         else
+00898                         {
+00899                                 // Active this value
+00900                                 _DriverGLStates.enableVertexAttribArray(glIndex, true);
+00901                                 nglVertexAttribPointerNV (glIndex, NumCoordinatesType[type], GLType[type], vb.VertexSize, vb.ValuePtr[value]);
+00902                         }
+00903                 }
+00904                 else
+00905                 {
+00906                         _DriverGLStates.enableVertexAttribArray(glIndex, false);
+00907                         /* OpenGL Driver Bug with VertexProgram, UChar4 type, and VertexArrayRange.
+00908                                 Must also disable colorArray in standard gl calls.
+00909                         */
+00910                         if(glIndex==3)
+00911                                 _DriverGLStates.enableColorArray(false);
+00912                         else if(glIndex==4)
+00913                                 _DriverGLStates.enableSecondaryColorArray(false);
+00914                 }
+00915         }
+00916 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupGlArraysStd CVertexBufferInfo vb  )  [private]
+
+ + + + + +
+   + + +

+Tools fct used by setupGLArrays. +

+ +

+Definition at line 676 of file driver_opengl_vertex.cpp. +

+References _DriverGLStates, NL3D::CVertexBufferInfo::ATIValueOffset, NL3D::CVertexBufferInfo::ATIVBHardMode, NL3D::CVertexBufferInfo::ATIVertexObjectId, NL3D::CDriverGLStates::enableColorArray(), NL3D::CDriverGLStates::enableNormalArray(), NL3D::CDriverGLStates::enableVertexArray(), inlGetNumTextStages(), nglArrayObjectATI, nlassert, setupUVPtr(), sint, NL3D::CVertexBufferInfo::Type, uint, uint32, NL3D::CVertexBufferInfo::UVRouting, NL3D::CVertexBufferInfo::ValuePtr, NL3D::CVertexBufferInfo::VertexFormat, and NL3D::CVertexBufferInfo::VertexSize. +

+Referenced by setupGlArrays(). +

+

00677 {
+00678         uint32  flags= vb.VertexFormat;
+00679         // setup vertex ptr.
+00680         //-----------
+00681         uint numVertexCoord = CVertexBuffer::NumComponentsType[vb.Type[CVertexBuffer::Position]];
+00682         nlassert (numVertexCoord >= 2);
+00683 
+00684         _DriverGLStates.enableVertexArray(true);
+00685         // Setup ATI VBHard or std ptr.
+00686         if(vb.ATIVBHardMode)
+00687                 nglArrayObjectATI(GL_VERTEX_ARRAY, numVertexCoord, GL_FLOAT, vb.VertexSize, 
+00688                         vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Position]);
+00689         else
+00690                 glVertexPointer(numVertexCoord, GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Position]);
+00691 
+00692 
+00693         // setup normal ptr.
+00694         //-----------
+00695         // Check for normal param in vertex buffer
+00696         if (flags & CVertexBuffer::NormalFlag)
+00697         {
+00698                 // Check type
+00699                 nlassert (vb.Type[CVertexBuffer::Normal]==CVertexBuffer::Float3);
+00700 
+00701                 _DriverGLStates.enableNormalArray(true);
+00702                 // Setup ATI VBHard or std ptr.
+00703                 if(vb.ATIVBHardMode)
+00704                         nglArrayObjectATI(GL_NORMAL_ARRAY, 3, GL_FLOAT, vb.VertexSize, 
+00705                                 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::Normal]);
+00706                 else
+00707                         glNormalPointer(GL_FLOAT, vb.VertexSize, vb.ValuePtr[CVertexBuffer::Normal]);
+00708         }
+00709         else
+00710         {
+00711                 _DriverGLStates.enableNormalArray(false);
+00712         }
+00713 
+00714 
+00715         // Setup Color
+00716         //-----------
+00717         // Check for color param in vertex buffer
+00718         if (flags & CVertexBuffer::PrimaryColorFlag)
+00719         {
+00720                 // Check type
+00721                 nlassert (vb.Type[CVertexBuffer::PrimaryColor]==CVertexBuffer::UChar4);
+00722 
+00723                 _DriverGLStates.enableColorArray(true);
+00724                 // Setup ATI VBHard or std ptr.
+00725                 if(vb.ATIVBHardMode)
+00726                         nglArrayObjectATI(GL_COLOR_ARRAY, 4, GL_UNSIGNED_BYTE, vb.VertexSize, 
+00727                                 vb.ATIVertexObjectId, vb.ATIValueOffset[CVertexBuffer::PrimaryColor]);
+00728                 else
+00729                         glColorPointer(4,GL_UNSIGNED_BYTE, vb.VertexSize, vb.ValuePtr[CVertexBuffer::PrimaryColor]);
+00730         }
+00731         else
+00732                 _DriverGLStates.enableColorArray(false);
+00733 
+00734 
+00735         // Setup Uvs
+00736         //-----------
+00737         // Get the routing
+00738         for(sint i=0; i<inlGetNumTextStages(); i++)
+00739         {
+00740                 // normal behavior: each texture has its own UV.
+00741                 setupUVPtr(i, vb, vb.UVRouting[i]);
+00742         }
+00743 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupLightMapPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 670 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _CurrentTexEnvSpecial, _DriverGLStates, _Extensions, _FogEnabled, _LastVB, _LastVertexSetupIsLightMap, _LightMapLastStageEnv, _LightMapLUT, NL3D::CMaterial::_LightMaps, NL3D::CMaterial::_LightMapsMulx2, _LightMapUVMap, _NLightMapPass, _NLightMapPerPass, _NLightMaps, NLMISC::CRGBA::A, activateTexEnvColor(), activateTexEnvMode(), activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CGlExtensions::ATIXTextureEnvCombine3, NLMISC::CRGBA::B, NL3D::CDriverGLStates::blendFunc(), NL3D::CMaterial::CTexEnv::ConstantColor, NL3D::CDriverGLStates::enableBlend(), NLMISC::CRGBA::G, NL3D::CMaterial::getBlend(), NL3D::CMaterial::getTexture(), GL_MODULATE_ADD_ATIX, inlGetNumTextStages(), min, nlassert, NL3D::CGlExtensions::NVTextureEnvCombine4, NLMISC::CRGBA::R, NL3D::CDriverGLStates::setTexGenMode(), setupUVPtr(), sint, TexEnvSpecialLightMap, uint, uint32, and uint8. +

+Referenced by setupPass(). +

+

00671 {
+00672         const CMaterial &mat= *_CurrentMaterial;
+00673 
+00674         // No lightmap or all blacks??, just setup "black texture" for stage 0.
+00675         if(_NLightMaps==0)
+00676         {
+00677                 ITexture        *text= mat.getTexture(0);
+00678                 activateTexture(0,text);
+00679 
+00680                 // setup std modulate env
+00681                 CMaterial::CTexEnv      env;
+00682                 activateTexEnvMode(0, env);
+00683                 // Since Lighting is disabled, as well as colorArray, must setup alpha.
+00684                 // setup color to 0 => blackness
+00685                 glColor4ub(0, 0, 0, 255);
+00686 
+00687                 // Setup gen tex off
+00688                 _DriverGLStates.activeTextureARB(0);
+00689                 _DriverGLStates.setTexGenMode(0, 0);
+00690 
+00691                 // And disable other stages.
+00692                 for(sint stage=1 ; stage<inlGetNumTextStages() ; stage++)
+00693                 {
+00694                         // disable texturing.
+00695                         activateTexture(stage, NULL);
+00696                 }
+00697 
+00698                 return;
+00699         }
+00700 
+00701         nlassert(pass<_NLightMapPass);
+00702 
+00703 
+00704         // setup Texture Pass.
+00705         //=========================
+00706         uint    lmapId;
+00707         uint    nstages;
+00708         lmapId= pass * _NLightMapPerPass; // Nb lightmaps already processed
+00709         // N lightmaps for this pass, plus the texture.
+00710         nstages= std::min(_NLightMapPerPass, _NLightMaps-lmapId) + 1;
+00711         // setup all stages.
+00712         for(uint stage= 0; stage<(uint)inlGetNumTextStages(); stage++)
+00713         {
+00714                 // if must setup a lightmap stage.
+00715                 if(stage<nstages-1)
+00716                 {
+00717                         // setup lightMap.
+00718                         uint    whichLightMap= _LightMapLUT[lmapId];
+00719                         // get text and factor.
+00720                         ITexture *text   = mat._LightMaps[whichLightMap].Texture;
+00721                         CRGBA lmapFactor = mat._LightMaps[whichLightMap].Factor;
+00722                         lmapFactor.R = (uint8)((((uint32)lmapFactor.R)  * ((uint32)mat._LightMaps[whichLightMap].Color.R)) / 255);
+00723                         lmapFactor.G = (uint8)((((uint32)lmapFactor.G)  * ((uint32)mat._LightMaps[whichLightMap].Color.G)) / 255);
+00724                         lmapFactor.B = (uint8)((((uint32)lmapFactor.B)  * ((uint32)mat._LightMaps[whichLightMap].Color.B)) / 255);
+00725                         lmapFactor.A = 255;
+00726 
+00727                         activateTexture(stage,text);
+00728 
+00729                         // If texture not NULL, Change texture env fonction.
+00730                         //==================================================
+00731                         if(text)
+00732                         {
+00733                                 static CMaterial::CTexEnv       stdEnv;
+00734 
+00735                                 // NB, !_Extensions.NVTextureEnvCombine4, nstages==2, so here always stage==0.
+00736                                 if (stage==0)
+00737                                 {
+00738                                         // do not use consant color to blend lightmap, but incoming diffuse color, for stage0 only.
+00739                                         // (NB: lighting and vertexcolorArray are disabled here)
+00740                                         glColor4ub(lmapFactor.R, lmapFactor.G, lmapFactor.B, 255);
+00741 
+00742                                         // Leave stage as default env (Modulate with previous)
+00743                                         activateTexEnvMode(stage, stdEnv);
+00744 
+00745                                         // Setup gen tex off
+00746                                         _DriverGLStates.activeTextureARB(stage);
+00747                                         _DriverGLStates.setTexGenMode(stage, 0);
+00748                                 }
+00749                                 else
+00750                                 {
+00751                                         // Here, we are sure that texEnvCombine4 or texEnvCombine3 is OK.
+00752                                         nlassert(_Extensions.NVTextureEnvCombine4 || _Extensions.ATIXTextureEnvCombine3);
+00753 
+00754                                         // setup constant color with Lightmap factor.
+00755                                         stdEnv.ConstantColor=lmapFactor;
+00756                                         activateTexEnvColor(stage, stdEnv);
+00757 
+00758                                         // Setup env for texture stage.
+00759                                         _DriverGLStates.activeTextureARB(stage);
+00760                                         _DriverGLStates.setTexGenMode(stage, 0);
+00761                                         
+00762                                         // setup TexEnvCombine4 (ignore alpha part).
+00763                                         if(_CurrentTexEnvSpecial[stage] != TexEnvSpecialLightMap)
+00764                                         {
+00765                                                 // TexEnv is special.
+00766                                                 _CurrentTexEnvSpecial[stage] = TexEnvSpecialLightMap;
+00767                                                 
+00768                                                 if (_Extensions.NVTextureEnvCombine4)
+00769                                                 {                                                                                       
+00770                                                         // What we want to setup is  Texture*Constant + Previous*1.
+00771                                                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+00772 
+00773                                                         // Operator.
+00774                                                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD );
+00775                                                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD );
+00776                                                         // Arg0.
+00777                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+00778                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+00779                                                         // Arg1.
+00780                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT );
+00781                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+00782                                                         // Arg2.
+00783                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+00784                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+00785                                                         // Arg3.
+00786                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+00787                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+00788                                                 }                                                                                                                               
+00789                                                 else
+00790                                                 {
+00791                                                         // ATI EnvCombine3
+00792                                                         // What we want to setup is  Texture*Constant + Previous.
+00793                                                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+00794                                                         // Operator.
+00795                                                         glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATIX);
+00796                                                         glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE_ADD_ATIX);                                          
+00797                                                         // Arg0.
+00798                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+00799                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+00800                                                         // Arg1.
+00801                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT );
+00802                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+00803                                                         // Arg2.
+00804                                                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
+00805                                                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+00806                                                 }
+00807                                         }
+00808                                 }
+00809 
+00810                                 // setup UV, with UV1. Only if needed (cached)
+00811                                 if( !_LastVertexSetupIsLightMap || _LightMapUVMap[stage]!=1 )
+00812                                 {
+00813                                         setupUVPtr(stage, _LastVB, 1);
+00814                                         _LightMapUVMap[stage]= 1;
+00815                                 }
+00816                         }
+00817 
+00818                         // Next lightmap.
+00819                         lmapId++;
+00820                 }
+00821                 else if(stage<nstages)
+00822                 {
+00823                         // optim: do this only for first pass, and last pass only if stage!=nLMapPerPass 
+00824                         // (meaning not the same stage as preceding passes).
+00825                         if(pass==0 || (pass==_NLightMapPass-1 && stage!=_NLightMapPerPass))
+00826                         {
+00827                                 // activate the texture at last stage.
+00828                                 ITexture        *text= mat.getTexture(0);
+00829                                 activateTexture(stage,text);
+00830 
+00831                                 // setup ModulateRGB/ReplaceAlpha env. (this may disable possible COMBINE4_NV setup).
+00832                                 activateTexEnvMode(stage, _LightMapLastStageEnv);
+00833 
+00834                                 // Setup gen tex off
+00835                                 _DriverGLStates.activeTextureARB(stage);
+00836                                 _DriverGLStates.setTexGenMode(stage, 0);
+00837 
+00838                                 // setup UV, with UV0. Only if needed (cached)
+00839                                 if( !_LastVertexSetupIsLightMap || _LightMapUVMap[stage]!=0 )
+00840                                 {
+00841                                         setupUVPtr(stage, _LastVB, 0);
+00842                                         _LightMapUVMap[stage]= 0;
+00843                                 }
+00844 
+00845                                 if (mat._LightMapsMulx2)
+00846                                 {
+00847                                         // Multiply x 2
+00848                                         glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2);
+00849                                 }
+00850                         }
+00851                 }
+00852                 else
+00853                 {
+00854                         // else all other stages are disabled.
+00855                         activateTexture(stage,NULL);
+00856                 }
+00857         }
+00858 
+00859 
+00860         // setup blend / lighting.
+00861         //=========================
+00862 
+00863         /* If multi-pass, then must setup a black Fog color for 1+ pass (just do it for the pass 1).
+00864                 This is because Transparency ONE/ONE is used.
+00865         */
+00866         if(pass==1 && _FogEnabled)
+00867         {
+00868                 static  GLfloat         blackFog[4]= {0,0,0,0};
+00869                 glFogfv(GL_FOG_COLOR, blackFog);
+00870         }
+00871 
+00872         // Blend is different if the material is blended or not
+00873         if( !mat.getBlend() )
+00874         {
+00875                 // Not blended, std case.
+00876                 if(pass==0)
+00877                 {
+00878                         // no transparency for first pass.
+00879                         _DriverGLStates.enableBlend(false);
+00880                 }
+00881                 else if(pass==1)
+00882                 {
+00883                         // setup an Additive transparency (only for pass 1, will be kept for successives pass).
+00884                         _DriverGLStates.enableBlend(true);
+00885                         _DriverGLStates.blendFunc(GL_ONE, GL_ONE);
+00886                 }
+00887         }
+00888         else
+00889         {
+00890                 /* 1st pass, std alphaBlend. 2nd pass, add to background. Demo:
+00891                         T: texture.
+00892                         l0: lightmap (or group of lightmap) of pass 0.
+00893                         l1: lightmap (or group of lightmap) of pass 1. (same thing with 2,3 etc....)
+00894                         B:      Background.
+00895                         A:      Alpha of texture.
+00896 
+00897                         finalResult= T*(l0+l1) * A + B * (1-A).
+00898 
+00899                         We get it in two pass:
+00900                                 fint=                   T*l0 * A + B * (1-A).
+00901                                 finalResult=    T*l1 * A + fint = T*l1 * A + T*l0 * A + B * (1-A)=
+00902                                         T* (l0+l1) * A + B * (1-A)
+00903                 */
+00904                 if(pass==0)
+00905                 {
+00906                         // no transparency for first pass.
+00907                         _DriverGLStates.enableBlend(true);
+00908                         _DriverGLStates.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+00909                 }
+00910                 else if(pass==1)
+00911                 {
+00912                         // setup an Additive transparency (only for pass 1, will be kept for successives pass).
+00913                         _DriverGLStates.enableBlend(true);
+00914                         _DriverGLStates.blendFunc(GL_SRC_ALPHA, GL_ONE);
+00915                 }
+00916         }
+00917 
+00918 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::setupMaterial CMaterial mat  )  [virtual]
+
+ + + + + +
+   + + +

+For objects with caustics, setup the first texture (which actually is the one from the material). +

+ +

+Implements NL3D::IDriver. +

+Definition at line 257 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _CurrentMaterialSupportedShader, _DriverGLStates, _Extensions, _FogEnabled, _LastVertexSetupIsLightMap, NL3D::CMaterial::_LightMaps, _MaterialAllTextureTouchedFlag, _NbSetupMaterialCall, _OODeltaZ, NL3D::CMaterial::_TexAddrMode, NL3D::CMaterial::_Textures, NLMISC::CRGBA::A, activateTexture(), NL3D::CDriverGLStates::alphaFunc(), NL3D::CShaderGL::Ambient, NLMISC::CRGBA::B, NL3D::CDriverGLStates::blendFunc(), NL3D::CMaterial::clearTouched(), NL3D::convBlend(), NL3D::convColor(), NL3D::convZFunction(), NL3D::CDriverGLStates::depthFunc(), NL3D::CShaderGL::Diffuse, disableUserTextureMatrix(), NL3D::CShaderGL::DstBlend, NL3D::CShaderGL::Emissive, NL3D::CDriverGLStates::enableAlphaTest(), NL3D::CDriverGLStates::enableBlend(), NL3D::CDriverGLStates::enableCullFace(), NL3D::CDriverGLStates::enableFog(), NL3D::CDriverGLStates::enableLighting(), enableNVTextureShader(), NL3D::CDriverGLStates::enableZWrite(), NLMISC::CRGBA::G, NL3D::CMaterial::getAlphaTestThreshold(), NL3D::CMaterial::getAmbient(), NL3D::CMaterial::getColor(), NL3D::CMaterial::getDiffuse(), NL3D::CMaterial::getDstBlend(), NL3D::CMaterial::getEmissive(), NL3D::CMaterial::getFlags(), NLMISC::CRGBA::getPacked(), NL3D::CMaterial::getShader(), NL3D::CMaterial::getShininess(), NL3D::CMaterial::getSpecular(), NL3D::CMaterial::getSrcBlend(), getSupportedShader(), NL3D::CMaterial::getTexture(), NL3D::CMaterial::getTouched(), NL3D::CMaterial::getZBias(), NL3D::CMaterial::getZFunc(), NL3D::IDRV_MAT_ALPHA_TEST, NL3D::IDRV_MAT_BLEND, NL3D::IDRV_MAT_DOUBLE_SIDED, NL3D::IDRV_MAT_LIGHTING, NL3D::IDRV_MAT_TEX_ADDR, NL3D::IDRV_MAT_ZWRITE, NL3D::IDRV_TOUCHED_ALL, NL3D::IDRV_TOUCHED_BLENDFUNC, NL3D::IDRV_TOUCHED_LIGHTING, NL3D::IDRV_TOUCHED_SHADER, NL3D::IDRV_TOUCHED_ZFUNC, inlGetNumTextStages(), NL3D::CMaterial::isLightedVertexColor(), NL3D::ItShaderPtrList, NL3D::CGlExtensions::NVTextureShader, NL3D::CShaderGL::PackedAmbient, NL3D::CShaderGL::PackedDiffuse, NL3D::CShaderGL::PackedEmissive, NL3D::CShaderGL::PackedSpecular, NL3D::CMaterial::pShader, NLMISC::CRGBA::R, resetLightMapVertexSetup(), NL3D::CDriverGLStates::setAmbient(), NL3D::CDriverGLStates::setDepthRange(), NL3D::CDriverGLStates::setDiffuse(), NL3D::CDriverGLStates::setEmissive(), NL3D::CDriverGLStates::setShininess(), NL3D::CDriverGLStates::setSpecular(), setTextureEnvFunction(), setTextureShaders(), setupTexture(), setupUserTextureMatrix(), NL3D::CDriverGLStates::setVertexColorLighted(), sint, NL3D::CShaderGL::Specular, NL3D::CShaderGL::SrcBlend, NL3D::CShaderGL::SupportedShader, uint, uint32, and NL3D::CShaderGL::ZComp. +

+Referenced by render(), renderOrientedQuads(), renderPoints(), renderQuads(), and renderTriangles(). +

+

00258 {
+00259         CShaderGL*      pShader;
+00260         GLenum          glenum;
+00261         uint32          touched=mat.getTouched();
+00262         sint            stage;
+00263 
+00264 
+00265         // profile.
+00266         _NbSetupMaterialCall++;
+00267 
+00268 
+00269         // 0. Retrieve/Create driver shader.
+00270         //==================================
+00271         if (!mat.pShader)
+00272         {
+00273                 // insert into driver list. (so it is deleted when driver is deleted).
+00274                 ItShaderPtrList         it= _Shaders.insert(_Shaders.end());
+00275                 // create and set iterator, for future deletion.
+00276                 *it= mat.pShader= new CShaderGL(this, it);
+00277 
+00278                 // Must create all OpenGL shader states.
+00279                 touched= IDRV_TOUCHED_ALL;
+00280         }
+00281         pShader=static_cast<CShaderGL*>((IShader*)(mat.pShader));
+00282 
+00283 
+00284         // 1. Setup modified fields of material.
+00285         //=====================================
+00286         if( touched ) 
+00287         {
+00288                 /* Exception: if only Textures are modified in the material, no need to "Bind OpenGL States", or even to test
+00289                         for change, because textures are activated alone, see below.
+00290                         No problem with delete/new problem (see below), because in this case, IDRV_TOUCHED_ALL is set (see above).
+00291                 */
+00292                 // If any flag is set (but a flag of texture)
+00293                 if( touched & (~_MaterialAllTextureTouchedFlag) )
+00294                 {
+00295                         // Convert Material to driver shader.
+00296                         if (touched & IDRV_TOUCHED_BLENDFUNC)
+00297                         {
+00298                                 convBlend( mat.getSrcBlend(),glenum );
+00299                                 pShader->SrcBlend=glenum;
+00300                                 convBlend( mat.getDstBlend(),glenum );
+00301                                 pShader->DstBlend=glenum;
+00302                         }
+00303                         if (touched & IDRV_TOUCHED_ZFUNC)
+00304                         {
+00305                                 convZFunction( mat.getZFunc(),glenum);
+00306                                 pShader->ZComp= glenum;
+00307                         }
+00308                         if (touched & IDRV_TOUCHED_LIGHTING)
+00309                         {
+00310                                 convColor(mat.getEmissive(), pShader->Emissive);
+00311                                 convColor(mat.getAmbient(), pShader->Ambient);
+00312                                 convColor(mat.getDiffuse(), pShader->Diffuse);
+00313                                 convColor(mat.getSpecular(), pShader->Specular);
+00314                                 pShader->PackedEmissive= mat.getEmissive().getPacked();
+00315                                 pShader->PackedAmbient= mat.getAmbient().getPacked();
+00316                                 pShader->PackedDiffuse= mat.getDiffuse().getPacked();
+00317                                 pShader->PackedSpecular= mat.getSpecular().getPacked();
+00318                         }
+00319                         if (touched & IDRV_TOUCHED_SHADER)
+00320                         {
+00321                                 // Get shader. Fallback to other shader if not supported.
+00322                                 pShader->SupportedShader= getSupportedShader(mat.getShader());
+00323                         }
+00324 
+00325 
+00326                         // Since modified, must rebind all openGL states. And do this also for the delete/new problem.
+00327                         /* If an old material is deleted, _CurrentMaterial is invalid. But this is grave only if a new 
+00328                                 material is created, with the same pointer (bad luck). Since an newly allocated material always 
+00329                                 pass here before use, we are sure to avoid any problems.
+00330                         */
+00331                         _CurrentMaterial= NULL;
+00332                 }
+00333 
+00334                 // Optimize: reset all flags at the end.
+00335                 mat.clearTouched(0xFFFFFFFF);
+00336         }
+00337 
+00338 
+00339         // Now we can get the supported shader from the cache.
+00340         CMaterial::TShader matShader = pShader->SupportedShader;
+00341 
+00342         // setup the global
+00343         _CurrentMaterialSupportedShader= matShader;
+00344 
+00345 
+00346         // 2. Setup / Bind Textures.
+00347         //==========================
+00348         // Must setup textures each frame. (need to test if touched).
+00349         // Must separate texture setup and texture activation in 2 "for"...
+00350         // because setupTexture() may disable all stage.
+00351         if (matShader != CMaterial::Water)
+00352         {       
+00353                 for(stage=0 ; stage<inlGetNumTextStages() ; stage++)
+00354                 {
+00355                         ITexture        *text= mat.getTexture(stage);
+00356                         if (text != NULL && !setupTexture(*text))
+00357                                 return(false);
+00358                 }
+00359         }
+00360         // Here, for Lightmap materials, setup the lightmaps.
+00361         if(matShader == CMaterial::LightMap)
+00362         {
+00363                 for(stage=0 ; stage<(sint)mat._LightMaps.size() ; stage++)
+00364                 {
+00365                         ITexture        *text= mat._LightMaps[stage].Texture;
+00366                         if (text != NULL && !setupTexture(*text))
+00367                                 return(false);
+00368                 }
+00369         }
+00370 
+00371         // Here, for caustic shader, setup the lightmaps
+00372         /*if (matShader == CMaterial::Caustics)
+00373         {
+00374                 if (mat.getTexture(stage))
+00375         }*/
+00376         
+00377 
+00378         // Activate the textures.
+00379         // Do not do it for Lightmap and per pixel lighting , because done in multipass in a very special fashion.
+00380         // This avoid the useless multiple change of texture states per lightmapped object.
+00381         // Don't do it also for Specular because the EnvFunction and the TexGen may be special.
+00382         if(matShader != CMaterial::LightMap
+00383                 && matShader != CMaterial::PerPixelLighting
+00384                 /* && matShader != CMaterial::Caustics  */
+00385                 && matShader != CMaterial::Cloud
+00386                 && matShader != CMaterial::Water
+00387                 && matShader != CMaterial::Specular
+00388            )
+00389         {
+00390                 for(stage=0 ; stage<inlGetNumTextStages() ; stage++)
+00391                 {
+00392                         ITexture        *text= mat.getTexture(stage);
+00393 
+00394                         // activate the texture, or disable texturing if NULL.
+00395                         activateTexture(stage,text);
+00396 
+00397                         // If texture not NULL, Change texture env fonction.
+00398                         //==================================================
+00399                         setTextureEnvFunction(stage, mat);
+00400                 }                               
+00401         }
+00402 
+00403 
+00404         // 3. Bind OpenGL States.
+00405         //=======================
+00406         if (_CurrentMaterial!=&mat)
+00407         {
+00408                 // Bind Blend Part.
+00409                 //=================
+00410                 bool blend = (mat.getFlags()&IDRV_MAT_BLEND)!=0;
+00411                 _DriverGLStates.enableBlend(blend);
+00412                 if(blend)
+00413                         _DriverGLStates.blendFunc(pShader->SrcBlend, pShader->DstBlend);
+00414 
+00415                 // Double Sided Part.
+00416                 //===================
+00417                 // NB: inverse state: DoubleSided <=> !CullFace.
+00418                 uint32  twoSided= mat.getFlags()&IDRV_MAT_DOUBLE_SIDED;
+00419                 _DriverGLStates.enableCullFace( twoSided==0 );
+00420 
+00421 
+00422                 // Alpha Test Part.
+00423                 //=================
+00424                 uint32  alphaTest= mat.getFlags()&IDRV_MAT_ALPHA_TEST;
+00425                 _DriverGLStates.enableAlphaTest(alphaTest);
+00426                 if(alphaTest)
+00427                 {
+00428                         // setup alphaTest threshold.
+00429                         _DriverGLStates.alphaFunc(mat.getAlphaTestThreshold());
+00430                 }
+00431 
+00432 
+00433                 // Bind ZBuffer Part.
+00434                 //===================
+00435                 _DriverGLStates.enableZWrite(mat.getFlags()&IDRV_MAT_ZWRITE);
+00436                 _DriverGLStates.depthFunc(pShader->ZComp);
+00437                 _DriverGLStates.setDepthRange (mat.getZBias () * _OODeltaZ);
+00438 
+00439 
+00440                 // Color-Lighting Part.
+00441                 //=====================
+00442 
+00443                 // Light Part.
+00444                 _DriverGLStates.enableLighting(mat.getFlags()&IDRV_MAT_LIGHTING);
+00445                 if(mat.getFlags()&IDRV_MAT_LIGHTING)
+00446                 {
+00447                         _DriverGLStates.setEmissive(pShader->PackedEmissive, pShader->Emissive);
+00448                         _DriverGLStates.setAmbient(pShader->PackedAmbient, pShader->Ambient);
+00449                         _DriverGLStates.setDiffuse(pShader->PackedDiffuse, pShader->Diffuse);
+00450                         _DriverGLStates.setSpecular(pShader->PackedSpecular, pShader->Specular);
+00451                         _DriverGLStates.setShininess(mat.getShininess());
+00452                         _DriverGLStates.setVertexColorLighted(mat.isLightedVertexColor ());
+00453                 }
+00454                 else
+00455                 {                       
+00456 
+00457                         // Color unlit part.
+00458                         CRGBA   col= mat.getColor();                    
+00459                         glColor4ub(col.R, col.G, col.B, col.A);                 
+00460                         _DriverGLStates.setVertexColorLighted(false);
+00461                 }
+00462                 
+00463                 
+00464                 // Fog Part.
+00465                 //=================
+00466 
+00467                 // Disable fog if dest blend is ONE
+00468                 if (blend && (pShader->DstBlend == GL_ONE))
+00469                 {
+00470                         _DriverGLStates.enableFog(false);
+00471                 }
+00472                 else
+00473                 {
+00474                         // Restaure fog state to its current value
+00475                         _DriverGLStates.enableFog(_FogEnabled);
+00476                 }
+00477                 
+00478                 // Texture shader part.
+00479                 //=====================
+00480 
+00481                 if (_Extensions.NVTextureShader)
+00482                 {
+00483                         if (matShader == CMaterial::Normal)
+00484                         {
+00485                                 // Texture addressing modes (support only via NVTextureShader for now)
+00486                                 //===================================================================                                                           
+00487                                 if ( mat.getFlags() & IDRV_MAT_TEX_ADDR )
+00488                                 {               
+00489                                         enableNVTextureShader(true);
+00490                                         setTextureShaders(&mat._TexAddrMode[0], &mat._Textures[0]);                                     
+00491                                 }
+00492                                 else
+00493                                 {
+00494                                         enableNVTextureShader(false);
+00495                                 }                               
+00496                         }
+00497                         else 
+00498                         {
+00499                                 enableNVTextureShader(false);
+00500                         }
+00501                 }               
+00502 
+00503                 _CurrentMaterial=&mat;
+00504         }
+00505 
+00506 
+00507         // 4. Misc
+00508         //=====================================
+00509 
+00510         // If !lightMap and prec material was lihgtmap => vertex setup is dirty!
+00511         if( matShader != CMaterial::LightMap && _LastVertexSetupIsLightMap )
+00512                 resetLightMapVertexSetup();
+00513 
+00514         // Textures user matrix
+00515         if (matShader == CMaterial::Normal)
+00516         {
+00517                 setupUserTextureMatrix((uint) inlGetNumTextStages(), mat);              
+00518         }
+00519         else // deactivate texture matrix
+00520         {
+00521                 disableUserTextureMatrix();
+00522         }
+00523 
+00524         return true;
+00525 }
+
+

+ + + + +
+ + + + + + + + + + +
virtual void NL3D::CDriverGL::setupMaterialPass uint  pass  )  [inline, virtual]
+
+ + + + + +
+   + + +

+active the ith pass of this material. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 508 of file driver_opengl.h. +

+References setupPass(), and uint. +

+

00508 {       setupPass(pass); }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupModelMatrix const CMatrix mtx  )  [virtual]
+
+ + + + + +
+   + + +

+setup the model matrix.

+NB: you must setupModelMatrix() AFTER setupViewMatrix(), or else undefined results. +

+Implements NL3D::IDriver. +

+Definition at line 124 of file driver_opengl_matrix.cpp. +

+References _ModelViewMatrix, _ModelViewMatrixDirty, _NbSetupModelMatrixCall, _PZBCameraPos, _RenderSetupDirty, _ViewMtx, NLMISC::CMatrix::getPos(), and NLMISC::CMatrix::setPos(). +

+

00125 {
+00126         // profiling
+00127         _NbSetupModelMatrixCall++;
+00128 
+00129 
+00130         // Dirt flags.
+00131         _ModelViewMatrixDirty= true;
+00132         _RenderSetupDirty= true;
+00133 
+00134 
+00135         // Put the matrix in the opengl eye space, and store it.
+00136         CMatrix         mat= mtx;
+00137         // remove first the _PZBCameraPos
+00138         mat.setPos(mtx.getPos() - _PZBCameraPos);
+00139         _ModelViewMatrix= _ViewMtx*mat;
+00140 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+active the ith pass of this material. +

+ +

+Definition at line 554 of file driver_opengl_material.cpp. +

+References _CurrentMaterialSupportedShader, setupCloudPass(), setupLightMapPass(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularPass(), setupWaterPass(), and uint. +

+Referenced by render(), renderOrientedQuads(), renderPoints(), renderQuads(), renderTriangles(), and setupMaterialPass(). +

+

00555 {
+00556         switch(_CurrentMaterialSupportedShader)
+00557         {
+00558         case CMaterial::LightMap: 
+00559                 setupLightMapPass (pass);
+00560                 break;
+00561         case CMaterial::Specular: 
+00562                 setupSpecularPass (pass);
+00563                 break;
+00564         case CMaterial::Water:
+00565                 setupWaterPass(pass);
+00566                 break;
+00567         case CMaterial::PerPixelLighting:
+00568                 setupPPLPass (pass);
+00569                 break;
+00570         case CMaterial::PerPixelLightingNoSpec:
+00571                 setupPPLNoSpecPass (pass);
+00572                 break;  
+00573         /* case CMaterial::Caustics:
+00574                 case CMaterial::Caustics:
+00575                 break; */
+00576         case CMaterial::Cloud:
+00577                 setupCloudPass (pass);
+00578                 break;  
+00579 
+00580         // All others materials do not require multi pass.
+00581         default: return;
+00582         }
+00583 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupPPLNoSpecPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1561 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _CurrentTexEnvSpecial, _DriverGLStates, _Extensions, _PPLightDiffuseColor, activateTexEnvColor(), activateTexEnvMode(), activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CMaterial::CTexEnv::Env, getSpecularCubeMap(), NL3D::CMaterial::getTexture(), GL_MODULATE_ADD_ATIX, inlGetNumTextStages(), nlassert, NL3D::CGlExtensions::NVTextureEnvCombine4, setupTexture(), TexEnvSpecialPPLStage0, and uint. +

+Referenced by setupPass(). +

+

01562 {
+01563         const CMaterial &mat= *_CurrentMaterial;
+01564 
+01565         nlassert(pass == 0);
+01566 
+01567         ITexture *tex0 = getSpecularCubeMap(1);
+01568         if (tex0) setupTexture(*tex0);
+01569         
+01570         if (mat.getTexture(0)) setupTexture(*mat.getTexture(0));
+01571 
+01572         // tex coord 0 = texture coordinates
+01573         // tex coord 1 = normal in tangent space        
+01574 
+01575         activateTexture(0, tex0);
+01576         activateTexture(1, mat.getTexture(0));
+01577 
+01578 
+01579         for (uint k = 2; k < (uint) inlGetNumTextStages(); ++k)
+01580         {
+01581                 activateTexture(k, NULL);
+01582         }
+01583 
+01584         // setup the tex envs
+01585 
+01586 
+01587         // Stage 0 is rgb = DiffuseCubeMap * LightColor + DiffuseGouraud * 1 (TODO : EnvCombine3)
+01588         if(_CurrentTexEnvSpecial[0] != TexEnvSpecialPPLStage0)
+01589         {
+01590                 // TexEnv is special.
+01591                 _CurrentTexEnvSpecial[0] = TexEnvSpecialPPLStage0;
+01592                 _DriverGLStates.activeTextureARB(0);
+01593 
+01594                 if (_Extensions.NVTextureEnvCombine4)
+01595                 {
+01596                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01597                         
+01598                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);                  
+01599                         // Arg0 = Diffuse read in cube map alpha
+01600                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01601                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01602                         // Arg1 = Light color
+01603                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
+01604                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01605                         // Arg2 = Primary color (other light diffuse and 
+01606                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01607                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01608                         // Arg3 = White (= ~ Black)
+01609                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01610                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01611                 }
+01612                 else
+01613                 {
+01614                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01615                         
+01616                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATIX);                    
+01617                         // Arg0 = Diffuse read in cube map alpha
+01618                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01619                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01620                         // Arg2 = Light color
+01621                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
+01622                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01623                         // Arg1 = Primary color (other light diffuse and 
+01624                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01625                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);                   
+01626                 }
+01627         }
+01628         activateTexEnvColor(0, _PPLightDiffuseColor);
+01629 
+01630         // Stage 1      
+01631         static CMaterial::CTexEnv       env;
+01632         env.Env.SrcArg1Alpha = CMaterial::Diffuse;              
+01633         activateTexEnvMode(1, env);
+01634 
+01635 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupPPLPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1376 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _CurrentTexEnvSpecial, _DriverGLStates, _Extensions, _PPLightDiffuseColor, _PPLightSpecularColor, activateTexEnvColor(), activateTexEnvMode(), activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CMaterial::CTexEnv::Env, NL3D::CMaterial::getShininess(), getSpecularCubeMap(), NL3D::CMaterial::getTexture(), GL_MODULATE_ADD_ATIX, inlGetNumTextStages(), nlassert, NL3D::CGlExtensions::NVTextureEnvCombine4, setupTexture(), TexEnvSpecialPPLStage0, TexEnvSpecialPPLStage2, and uint. +

+Referenced by setupPass(). +

+

01377 {
+01378         const CMaterial &mat= *_CurrentMaterial;
+01379 
+01380         nlassert(pass == 0);
+01381 
+01382 /*      ITexture *tex0 = getSpecularCubeMap(1);
+01383         if (tex0) setupTexture(*tex0);
+01384         activateTexture(0, tex0);
+01385         
+01386 
+01387         static CMaterial::CTexEnv       env;
+01388         env.Env.SrcArg0Alpha = CMaterial::Diffuse;              
+01389         env.Env.SrcArg1Alpha = CMaterial::Constant;             
+01390         env.Env.SrcArg0RGB = CMaterial::Diffuse;        
+01391         env.Env.SrcArg1RGB = CMaterial::Constant;
+01392         env.Env.OpRGB = CMaterial::Replace;
+01393         env.Env.OpAlpha = CMaterial::Replace;
+01394         activateTexEnvMode(0, env);
+01395 
+01396         return;*/
+01397 
+01398         ITexture *tex0 = getSpecularCubeMap(1); 
+01399         if (tex0) setupTexture(*tex0);
+01400         ITexture *tex2 = getSpecularCubeMap((uint) mat.getShininess());
+01401         if (tex2) setupTexture(*tex2);
+01402         if (mat.getTexture(0)) setupTexture(*mat.getTexture(0));
+01403 
+01404         // tex coord 0 = texture coordinates
+01405         // tex coord 1 = normal in tangent space
+01406         // tex coord 2 = half angle vector in tangent space
+01407 
+01408         activateTexture(0, tex0);
+01409         activateTexture(1, mat.getTexture(0));
+01410         activateTexture(2, tex2);
+01411 
+01412         for (uint k = 3; k < (uint) inlGetNumTextStages(); ++k)
+01413         {
+01414                 activateTexture(k, NULL);
+01415         }
+01416 
+01417         // setup the tex envs
+01418 
+01419 
+01420         // Stage 0 is rgb = DiffuseCubeMap * LightColor + DiffuseGouraud * 1
+01421         if(_CurrentTexEnvSpecial[0] != TexEnvSpecialPPLStage0)
+01422         {
+01423                 // TexEnv is special.
+01424                 _CurrentTexEnvSpecial[0] = TexEnvSpecialPPLStage0;
+01425                 _DriverGLStates.activeTextureARB(0);
+01426 
+01427                 if (_Extensions.NVTextureEnvCombine4)
+01428                 {               
+01429                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01430                         
+01431                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);                  
+01432                         // Arg0 = Diffuse read in cube map
+01433                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01434                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01435                         // Arg1 = Light color
+01436                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
+01437                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01438                         // Arg2 = Primary color (other light diffuse and 
+01439                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01440                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01441                         // Arg3 = White (= ~ Black)
+01442                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01443                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01444                 }
+01445                 else // use ATI extension
+01446                 {
+01447                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01448                         
+01449                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATIX);                    
+01450                         // Arg0 = Diffuse read in cube map
+01451                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01452                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01453                         // Arg1 = Light color
+01454                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
+01455                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01456                         // Arg2 = Primary color (other light diffuse and 
+01457                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
+01458                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);                   
+01459                 }
+01460         }
+01461         activateTexEnvColor(0, _PPLightDiffuseColor);
+01462 
+01463         // Stage 1      
+01464         static CMaterial::CTexEnv       env;
+01465         env.Env.SrcArg1Alpha = CMaterial::Diffuse;              
+01466         activateTexEnvMode(1, env);
+01467 
+01468 
+01469 
+01470         // Stage 2 is rgb = SpecularCubeMap * SpecularLightColor + Prec * 1
+01471         // alpha = prec alpha
+01472         
+01473         if(_CurrentTexEnvSpecial[2] != TexEnvSpecialPPLStage2)
+01474         {
+01475                 // TexEnv is special.
+01476                 _CurrentTexEnvSpecial[2] = TexEnvSpecialPPLStage2;
+01477                 _DriverGLStates.activeTextureARB(2);
+01478 
+01479                 if (_Extensions.NVTextureEnvCombine4)
+01480                 {
+01481                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);         
+01482                         //== colors ==
+01483                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
+01484                         // Arg0 = Specular read in cube map
+01485                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01486                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01487                         // Arg1 = Light color
+01488                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
+01489                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
+01490                         // Arg2 = Primary color ( + other light diffuse )
+01491                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT);
+01492                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01493                         // Arg3 = White (= ~ Black)
+01494                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO);
+01495                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01496 
+01497                         //== alpha ==
+01498                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD);                        
+01499                         // Arg0 = PREVIOUS ALPHA
+01500                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
+01501                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_COLOR);
+01502                         // Arg1 = 1
+01503                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO);
+01504                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_ONE_MINUS_SRC_COLOR);
+01505                         // Arg2 = 0
+01506                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);
+01507                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_COLOR);
+01508                         // Arg3 = 0
+01509                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO);
+01510                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_COLOR);
+01511                 }
+01512                 else // ATI EnvCombine3
+01513                 {
+01514                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);         
+01515                         //== colors ==
+01516                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATIX);                    
+01517                         // Arg0 = Specular read in cube map
+01518                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
+01519                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
+01520                         // Arg2 = Light color
+01521                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT);
+01522                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR);
+01523                         // Arg1 = Primary color ( + other light diffuse)
+01524                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
+01525                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);                   
+01526 
+01527                         //== alpha ==
+01528                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE_ADD_ATIX);                  
+01529                         // Arg0 = PREVIOUS ALPHA
+01530                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
+01531                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_COLOR);
+01532                         // Arg2 = 1
+01533                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO);
+01534                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_ONE_MINUS_SRC_COLOR);
+01535                         // Arg1 = 0
+01536                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO);
+01537                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_COLOR);
+01538                 }
+01539         }
+01540         activateTexEnvColor(2, _PPLightSpecularColor);  
+01541 
+01542 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupScissor const class CScissor scissor  )  [virtual]
+
+ + + + + +
+   + + +

+Set the current Scissor.

Parameters:
+ + +
scissor is a scissor to setup the current Scissor, in Window relative coordinate (0,1).
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 1874 of file driver_opengl.cpp. +

+References NLMISC::clamp(), height, width, x, and y. +

+

01875 {
+01876         // Get viewport
+01877         float x= scissor.X;
+01878         float width= scissor.Width;
+01879         float height= scissor.Height;
+01880 
+01881         if(x==0 && x==0 && width==1 && height==1)
+01882         {
+01883                 glDisable(GL_SCISSOR_TEST);
+01884         }
+01885         else
+01886         {
+01887 #ifdef NL_OS_WINDOWS
+01888 
+01889                 float y= scissor.Y;
+01890 
+01891                 if (_hWnd)
+01892                 {
+01893                         // Get window rect
+01894                         int clientWidth = _WindowWidth;
+01895                         int clientHeight = _WindowHeight;
+01896 
+01897                         // Setup gl scissor
+01898                         int ix0=(int)floor((float)clientWidth * x + 0.5f);
+01899                         clamp (ix0, 0, clientWidth);
+01900                         int iy0=(int)floor((float)clientHeight* y + 0.5f);
+01901                         clamp (iy0, 0, clientHeight);
+01902 
+01903                         int ix1=(int)floor((float)clientWidth * (x+width) + 0.5f );
+01904                         clamp (ix1, 0, clientWidth);
+01905                         int iy1=(int)floor((float)clientHeight* (y+height) + 0.5f );
+01906                         clamp (iy1, 0, clientHeight);
+01907 
+01908 
+01909                         int iwidth= ix1 - ix0;
+01910                         clamp (iwidth, 0, clientWidth);
+01911                         int iheight= iy1 - iy0;
+01912                         clamp (iheight, 0, clientHeight);
+01913 
+01914                         glScissor (ix0, iy0, iwidth, iheight);
+01915                         glEnable(GL_SCISSOR_TEST);
+01916                 }
+01917 #endif // NL_OS_WINDOWS
+01918         }
+01919 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::setupSpecularBegin  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 985 of file driver_opengl_material.cpp. +

+References _DriverGLStates, _SpecularTexMtx, activateTexEnvMode(), activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CMaterial::CTexEnv::Env, NLMISC::CMatrix::get(), inlGetNumTextStages(), NL3D::CDriverGLStates::setTexGenMode(), and sint. +

+Referenced by beginSpecularMultiPass(), and startSpecularBatch(). +

+

00986 {
+00987         // ---- Reset any textures with id>=2
+00988         sint    stage= 2;
+00989         for(; stage<inlGetNumTextStages() ; stage++)
+00990         {
+00991                 // disable texturing
+00992                 activateTexture(stage, NULL);
+00993         }
+00994 
+00995         // ---- Stage 0 Common Setup.
+00996         // Setup the env for stage 0 only.
+00997         // Result RGB : Texture*Diffuse, Alpha : Texture
+00998         CMaterial::CTexEnv      env;
+00999         env.Env.OpAlpha= CMaterial::Replace;
+01000         activateTexEnvMode(0, env);
+01001 
+01002         // Disable texGen for stage 0
+01003         _DriverGLStates.activeTextureARB(0);
+01004         _DriverGLStates.setTexGenMode(0, 0);
+01005 
+01006         // ---- Stage 1 Common Setup.
+01007         // NB don't setup the TexEnv here (stage1 setuped in setupSpecularPass() according to extensions)
+01008         // For all cases, setup the TexCoord gen for stage1
+01009         _DriverGLStates.activeTextureARB(1);
+01010         
+01011         // todo hulud remove
+01012         // _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
+01013 
+01014         _DriverGLStates.setTexGenMode (1, GL_REFLECTION_MAP_ARB);
+01015         // setup the good matrix for stage 1.
+01016         glMatrixMode(GL_TEXTURE);
+01017         glLoadMatrixf( _SpecularTexMtx.get() );
+01018         glMatrixMode(GL_MODELVIEW);
+01019 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::setupSpecularEnd  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1022 of file driver_opengl_material.cpp. +

+References _DriverGLStates, NL3D::CDriverGLStates::activeTextureARB(), and NL3D::CDriverGLStates::setTexGenMode(). +

+Referenced by endSpecularBatch(), and endSpecularMultiPass(). +

+

01023 {
+01024         // Disable Texture coord generation.
+01025         _DriverGLStates.activeTextureARB(1);
+01026         _DriverGLStates.setTexGenMode(1, 0);
+01027 
+01028         // Happiness !!! we have already enabled the stage 1
+01029         glMatrixMode(GL_TEXTURE);
+01030         glLoadIdentity();
+01031         glMatrixMode(GL_MODELVIEW);
+01032 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupSpecularPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+Support NVidia combine 4 extension to do specular map in a single pass +

+Definition at line 1067 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _CurrentTexEnvSpecial, _DriverGLStates, _Extensions, activateTexEnvMode(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::CGlExtensions::ATIXTextureEnvCombine3, NL3D::CDriverGLStates::blendFunc(), CTexEnvSpecial, NL3D::CDriverGLStates::enableBlend(), NL3D::CMaterial::CTexEnv::Env, NL3D::CMaterial::getTexture(), GL_MODULATE_ADD_ATIX, NL3D::CGlExtensions::NVTextureEnvCombine4, NL3D::CDriverGLStates::setTextureMode(), TexEnvSpecialSpecularStage1, TexEnvSpecialSpecularStage1NoText, and uint. +

+Referenced by setupPass(). +

+

01068 {
+01069         const CMaterial &mat= *_CurrentMaterial;
+01070 
+01071         // Manage the rare case when the SpecularMap is not provided (error of a graphist).
+01072         if(mat.getTexture(1)==NULL)
+01073         {
+01074                 // Just display the texture
+01075                 // NB: setupMaterial() code has correclty setuped textures.
+01076                 return;
+01077         }
+01078 
+01080         if( _Extensions.NVTextureEnvCombine4 )
+01081         {       // Ok we can do it in a single pass
+01082 
+01083                 // Set Stage 1
+01084                 // Special: not the same sepcial env if there is or not texture in stage 0.
+01085                 CTexEnvSpecial          newEnvStage1;
+01086                 if( mat.getTexture(0) == NULL )
+01087                         newEnvStage1= TexEnvSpecialSpecularStage1NoText;
+01088                 else
+01089                         newEnvStage1= TexEnvSpecialSpecularStage1;
+01090                 // Test if same env as prec.
+01091                 if(_CurrentTexEnvSpecial[1] != newEnvStage1)
+01092                 {
+01093                         // TexEnv is special.
+01094                         _CurrentTexEnvSpecial[1] = newEnvStage1;
+01095 
+01096                         _DriverGLStates.activeTextureARB(1);
+01097                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV);
+01098                         // Operator Add (Arg0*Arg1+Arg2*Arg3)
+01099                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD );
+01100                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_ADD );
+01101                         // Arg0.
+01102                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+01103                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
+01104                         // Arg1.
+01105                         if( newEnvStage1 == TexEnvSpecialSpecularStage1NoText )
+01106                         {
+01107                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_ZERO );
+01108                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_ONE_MINUS_SRC_COLOR);
+01109                         }
+01110                         else
+01111                         {
+01112                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
+01113                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_ALPHA );
+01114                         }
+01115                         // Arg2.
+01116                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+01117                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_COLOR );
+01118                         // Arg3.
+01119                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_RGB_NV, GL_ZERO );
+01120                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_RGB_NV, GL_ONE_MINUS_SRC_COLOR);
+01121                         // Result : Texture*Previous.Alpha+Previous
+01122                         // Setup Alpha Diffuse Copy
+01123                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT );
+01124                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA );
+01125                         // Arg1.
+01126                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO );
+01127                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_ONE_MINUS_SRC_ALPHA);
+01128                         // Arg2.
+01129                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO );
+01130                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA );
+01131                         // Arg3.
+01132                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE3_ALPHA_NV, GL_ZERO );
+01133                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND3_ALPHA_NV, GL_SRC_ALPHA);
+01134                 }
+01135         }
+01136         else if (_Extensions.ATIXTextureEnvCombine3)
+01137         {
+01138                 // Ok we can do it in a single pass
+01139 
+01140                 // Set Stage 1
+01141                 // Special: not the same sepcial env if there is or not texture in stage 0.
+01142                 CTexEnvSpecial          newEnvStage1;
+01143                 if( mat.getTexture(0) == NULL )
+01144                         newEnvStage1= TexEnvSpecialSpecularStage1NoText;
+01145                 else
+01146                         newEnvStage1= TexEnvSpecialSpecularStage1;
+01147                 // Test if same env as prec.
+01148                 if(_CurrentTexEnvSpecial[1] != newEnvStage1)
+01149                 {
+01150                         // TexEnv is special.
+01151                         _CurrentTexEnvSpecial[1] = newEnvStage1;
+01152 
+01153                         _DriverGLStates.activeTextureARB(1);
+01154                         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
+01155                         // Operator Add (Arg0*Arg2+Arg1)
+01156                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE_ADD_ATIX );
+01157                         glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE_ADD_ATIX );
+01158                         // Arg0.
+01159                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE );
+01160                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR );
+01161                         // Arg2.
+01162                         if( newEnvStage1 == TexEnvSpecialSpecularStage1NoText )
+01163                         {
+01164                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_ZERO );
+01165                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_ONE_MINUS_SRC_COLOR);
+01166                         }
+01167                         else
+01168                         {
+01169                                 glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PREVIOUS_EXT );
+01170                                 glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA );
+01171                         }
+01172                         // Arg1.
+01173                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT );
+01174                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR );                  
+01175                         // Result : Texture*Previous.Alpha+Previous
+01176                         // Setup Alpha Diffuse Copy
+01177                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT );
+01178                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA );
+01179                         // Arg2.
+01180                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT, GL_ZERO );
+01181                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT, GL_ONE_MINUS_SRC_ALPHA );
+01182                         // Arg1.
+01183                         glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_ZERO );
+01184                         glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
+01185                 }
+01186         }
+01187         else
+01188         { // We have to do it in 2 passes
+01189 
+01190                 // For Both Pass, setup correct Env.
+01191 
+01192                 if( pass == 0 )
+01193                 { // Just display the texture
+01194                         _DriverGLStates.enableBlend(false);
+01195                         _DriverGLStates.activeTextureARB(1);
+01196                         _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
+01197                 }
+01198                 else
+01199                 { // Multiply texture1 by alpha_texture0 and display with add
+01200                         _DriverGLStates.enableBlend(true);
+01201                         _DriverGLStates.blendFunc(GL_ONE, GL_ONE);
+01202 
+01203                         // Set stage 0
+01204                         _DriverGLStates.activeTextureARB(0);
+01205                         CMaterial::CTexEnv      env;
+01206 
+01207                         env.Env.OpRGB = CMaterial::Replace;
+01208                         env.Env.SrcArg0RGB = CMaterial::Texture;
+01209                         env.Env.OpArg0RGB = CMaterial::SrcAlpha;
+01210 
+01211                         activateTexEnvMode(0, env);
+01212 
+01213 
+01214                         // Set stage 1
+01215                         if( mat.getTexture(0) == NULL )
+01216                         {
+01217                                 env.Env.OpRGB = CMaterial::Replace;
+01218                                 env.Env.SrcArg0RGB = CMaterial::Texture;
+01219                                 env.Env.OpArg0RGB = CMaterial::SrcColor;
+01220                         }
+01221                         else
+01222                         {
+01223                                 env.Env.OpRGB = CMaterial::Modulate;
+01224                                 env.Env.SrcArg0RGB = CMaterial::Texture;
+01225                                 env.Env.OpArg0RGB = CMaterial::SrcColor;
+01226                         
+01227                                 env.Env.SrcArg1RGB = CMaterial::Previous;
+01228                                 env.Env.OpArg1RGB = CMaterial::SrcColor;
+01229                         }
+01230 
+01231                         activateTexEnvMode(1, env);
+01232                 }
+01233         }
+01234 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::setupTexture ITexture tex  )  [virtual]
+
+ + + + + +
+   + + +

+setup a texture, generate and upload if needed. same as setupTextureEx(tex, true, dummy); +

+Implements NL3D::IDriver. +

+Definition at line 354 of file driver_opengl_texture.cpp. +

+References setupTextureEx(). +

+Referenced by copyFrameBufferToTexture(), setupMaterial(), setupPPLNoSpecPass(), setupPPLPass(), setupWaterPassARB(), setupWaterPassNV20(), setupWaterPassR200(), and swapTextureHandle(). +

+

00355 {
+00356         bool nTmp;
+00357         return setupTextureEx (tex, true, nTmp);
+00358 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::setupTextureEx ITexture tex,
bool  bUpload,
bool &  bAllUploaded,
bool  bMustRecreateSharedTexture = false
[virtual]
+
+ + + + + +
+   + + +

+setup a texture in the driver.

Parameters:
+ + +
bUpload if true the texture is created and uploaded to VRAM, if false the texture is only created it is useful for the async upload texture to only create the texture and then make invalidate to upload small piece each frame. There is ONE case where bUpload is forced to be true inside the method: if the texture must be converted to RGBA.
+
+
See also:
bAllUploaded
+
Parameters:
+ + + +
bAllUploaded true if any upload arise (texture invalid, must convert texture etc...).
bMustRecreateSharedTexture if true and if the texture supportSharing, then the texture is recreated (and uploaded if bUpload==true) into the shared DrvInfo (if found). Default setup (false) imply that the DrvInfo is only bound to tex (thus creating and uploading nothing) NB: the texture must be at least touch()-ed for the recreate to work.
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 361 of file driver_opengl_texture.cpp. +

+References _AllocatedTextureMemory, _CurrentTexture, _CurrentTextureInfoGL, _DriverGLStates, _Extensions, _ForceTextureResizePower, NL3D::ITexture::_ListInvalidRect, activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), NL3D::ITexture::allowDegradation(), NL3D::CGlExtensions::ARBTextureCubeMap, NLMISC::CBitmap::buildMipMaps(), NLMISC::clamp(), NL3D::ITexture::clearTouched(), NL3D::CTextureDrvInfosGL::Compressed, computeMipMapMemoryUsage(), NLMISC::CBitmap::convertToType(), CTextureDrvInfosGL, NL3D::IDriver::CTextureDrvShare, NL3D::CGlExtensions::EXTTextureCompressionS3TC, NL3D::ITexture::generate(), NL3D::getGlSrcTextureComponentType(), NL3D::getGlSrcTextureFormat(), getGlTextureFormat(), NLMISC::CBitmap::getHeight(), NL3D::ITexture::getMagFilter(), NL3D::ITexture::getMinFilter(), NLMISC::CBitmap::getMipMapCount(), NLMISC::CBitmap::getPixelFormat(), NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NL3D::ITexture::getReleasable(), NLMISC::CBitmap::getSize(), NL3D::CTextureCube::getTexture(), NL3D::getTextureGl(), NL3D::IDriver::getTextureShareName(), NLMISC::CBitmap::getWidth(), NL3D::ITexture::getWrapS(), NL3D::ITexture::getWrapT(), NLMISC::CRect::Height, NL3D::CTextureDrvInfosGL::ID, inlGetNumTextStages(), NL3D::ITexture::isAllInvalidated(), NL3D::ITexture::isTextureCube(), NL3D::ItTexDrvInfoPtrMap, NL3D::ItTexDrvSharePtrList, NL3D::CTextureDrvInfosGL::MagFilter, min, NL3D::CTextureDrvInfosGL::MinFilter, NL3D::CTextureDrvInfosGL::MipMap, NL3D::ITexture::mipMapOn(), NEL_MEASURE_UPLOAD_TIME_END, NEL_MEASURE_UPLOAD_TIME_START, nglCompressedTexImage2DARB, NL3D::ITexture::release(), NLMISC::CBitmap::releaseMipMaps(), NLMISC::CBitmap::resample(), NL3D::sameDXTCFormat(), NL3D::CDriverGLStates::setTextureMode(), sint, NLMISC::CObjectVector< uint8 >::size(), size, NL3D::ITexture::supportSharing(), NL3D::ITexture::TextureDrvShare, NL3D::CTextureDrvInfosGL::TextureMemory, NL3D::ITexture::touched(), NL3D::translateMagFilterToGl(), NL3D::translateMinFilterToGl(), NL3D::translateWrapToGl(), uint, w, NLMISC::CRect::Width, NL3D::CTextureDrvInfosGL::WrapS, NL3D::CTextureDrvInfosGL::WrapT, NLMISC::CRect::X, and NLMISC::CRect::Y. +

+Referenced by setupTexture(). +

+

00362 {
+00363         bAllUploaded = false;
+00364         
+00365         if(tex.isTextureCube() && (!_Extensions.ARBTextureCubeMap))
+00366                 return true;
+00367 
+00368         // 0. Create/Retrieve the driver texture.
+00369         //=======================================
+00370         bool mustCreate = false;
+00371         if ( !tex.TextureDrvShare )
+00372         {
+00373                 // insert into driver list. (so it is deleted when driver is deleted).
+00374                 ItTexDrvSharePtrList    it= _TexDrvShares.insert(_TexDrvShares.end());
+00375                 // create and set iterator, for future deletion.
+00376                 *it= tex.TextureDrvShare= new CTextureDrvShare(this, it);
+00377 
+00378                 // Must (re)-create the texture.
+00379                 mustCreate = true;
+00380         }
+00381 
+00382         // Does the texture has been touched ?
+00383         if ( (!tex.touched()) && (!mustCreate) )
+00384                 return true; // Do not do anything
+00385 
+00386 
+00387         // 1. If modified, may (re)load texture part or all of the texture.
+00388         //=================================================================
+00389 
+00390 
+00391         bool    mustLoadAll= false;
+00392         bool    mustLoadPart= false;
+00393 
+00394 
+00395         // To avoid any delete/new ptr problem, disable all texturing.
+00396         /* If an old texture is deleted, _CurrentTexture[*] and _CurrentTextureInfoGL[*] are invalid. 
+00397                 But this is grave only if a new texture is created, with the same pointer (bad luck). 
+00398                 Since an newly allocated texture always pass here before use, we are sure to avoid any problems.
+00399         */
+00400         for(sint stage=0 ; stage<inlGetNumTextStages() ; stage++)
+00401         {
+00402                 activateTexture(stage, NULL);
+00403         }
+00404 
+00405 
+00406         // A. Share mgt.
+00407         //==============
+00408         if(tex.supportSharing())
+00409         {
+00410                 // Try to get the shared texture.
+00411 
+00412                 // Create the shared Name.
+00413                 std::string     name;
+00414                 getTextureShareName (tex, name);
+00415 
+00416                 // insert or get the texture.
+00417                 {
+00418                         CSynchronized<TTexDrvInfoPtrMap>::CAccessor access(&_SyncTexDrvInfos);
+00419                         TTexDrvInfoPtrMap &rTexDrvInfos = access.value();
+00420 
+00421                         ItTexDrvInfoPtrMap      itTex;
+00422                         itTex= rTexDrvInfos.find(name);
+00423 
+00424                         // texture not found?
+00425                         if( itTex==rTexDrvInfos.end() )
+00426                         {
+00427                                 // insert into driver map. (so it is deleted when driver is deleted).
+00428                                 itTex= (rTexDrvInfos.insert(make_pair(name, (ITextureDrvInfos*)NULL))).first;
+00429                                 // create and set iterator, for future deletion.
+00430                                 itTex->second= tex.TextureDrvShare->DrvTexture= new CTextureDrvInfosGL(this, itTex, this);
+00431 
+00432                                 // need to load ALL this texture.
+00433                                 mustLoadAll= true;
+00434                         }
+00435                         else
+00436                         {
+00437                                 tex.TextureDrvShare->DrvTexture= itTex->second;
+00438 
+00439                                 if(bMustRecreateSharedTexture)
+00440                                         // reload this shared texture (user request)
+00441                                         mustLoadAll= true;
+00442                                 else
+00443                                         // Do not need to reload this texture, even if the format/mipmap has changed, since we found this 
+00444                                         // couple in the map.
+00445                                         mustLoadAll= false;
+00446                         }
+00447                 }
+00448                 // Do not test if part of texture may need to be computed, because Rect invalidation is incompatible 
+00449                 // with texture sharing.
+00450         }
+00451         else
+00452         {
+00453                 // If texture not already created.
+00454                 if(!tex.TextureDrvShare->DrvTexture)
+00455                 {
+00456                         // Must create it. Create auto a GL id (in constructor).
+00457                         // Do not insert into the map. This un-shared texture will be deleted at deletion of the texture.
+00458                         // Inform ITextureDrvInfos by passing NULL _Driver.
+00459                         tex.TextureDrvShare->DrvTexture= new CTextureDrvInfosGL(NULL, ItTexDrvInfoPtrMap(), this);
+00460 
+00461                         // need to load ALL this texture.
+00462                         mustLoadAll= true;
+00463                 }
+00464                 else if(tex.isAllInvalidated())
+00465                         mustLoadAll= true;
+00466                 else if(tex.touched())
+00467                         mustLoadPart= true;
+00468         }
+00469 
+00470         // B. Setup texture.
+00471         //==================
+00472         if(mustLoadAll || mustLoadPart)
+00473         {
+00474                 CTextureDrvInfosGL*     gltext;
+00475                 gltext= getTextureGl(tex);
+00476 
+00477                 // system of "backup the previous binded texture" seems to not work with some drivers....
+00478                 _DriverGLStates.activeTextureARB(0);
+00479                 if(tex.isTextureCube())
+00480                 {
+00481                         _DriverGLStates.setTextureMode(CDriverGLStates::TextureCubeMap);
+00482                         // Bind this texture, for reload...
+00483                         glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, gltext->ID);                             
+00484                 }
+00485                 else
+00486                 {
+00487                         _DriverGLStates.setTextureMode(CDriverGLStates::Texture2D);
+00488                         // Bind this texture, for reload...
+00489                         glBindTexture(GL_TEXTURE_2D, gltext->ID);                               
+00490                 }
+00491 
+00492 
+00493                 glPixelStorei(GL_UNPACK_ALIGNMENT,1);
+00494 
+00495                 // a. Load All the texture case.
+00496                 //==============================
+00497                 if (mustLoadAll)
+00498                 {
+00499                         // profiling. sub old textre memory usage, and reset.
+00500                         _AllocatedTextureMemory-= gltext->TextureMemory;
+00501                         gltext->TextureMemory= 0;
+00502 
+00503 
+00504                         if(tex.isTextureCube())
+00505                         {
+00506                                 static GLenum face_map[6] = {   GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
+00507                                                                                                 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
+00508                                                                                                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
+00509                                                                                                 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
+00510                                                                                                 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
+00511                                                                                                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB };
+00512                                 CTextureCube *pTC = NLMISC::safe_cast<CTextureCube *>(&tex);
+00513                                 // Regenerate all the texture.
+00514                                 tex.generate();                                 
+00515                                 for(uint nText = 0; nText < 6; ++nText)
+00516                                 if(pTC->getTexture((CTextureCube::TFace)nText) != NULL)
+00517                                 {
+00518                                         ITexture *pTInTC = pTC->getTexture((CTextureCube::TFace)nText);
+00519                                         // Get the correct texture format from texture...
+00520                                         GLint   glfmt= getGlTextureFormat(*pTInTC, gltext->Compressed);
+00521                                         GLint   glSrcFmt= getGlSrcTextureFormat(*pTInTC, glfmt);
+00522                                         GLenum  glSrcType= getGlSrcTextureComponentType(glSrcFmt);
+00523 
+00524                                         sint    nMipMaps;
+00525                                         if(glSrcFmt==GL_RGBA && pTInTC->getPixelFormat()!=CBitmap::RGBA )
+00526                                                 pTInTC->convertToType(CBitmap::RGBA);
+00527                                         if(tex.mipMapOn())
+00528                                         {
+00529                                                 pTInTC->buildMipMaps();
+00530                                                 nMipMaps= pTInTC->getMipMapCount();
+00531                                         }
+00532                                         else
+00533                                                 nMipMaps= 1;
+00534 
+00535                                         // MipMap upload?
+00536                                         gltext->MipMap= nMipMaps>1;
+00537 
+00538                                         // Fill mipmaps.
+00539                                         for(sint i=0;i<nMipMaps;i++)
+00540                                         {
+00541                                                 void    *ptr= pTInTC->getPixels(i).getPtr();
+00542                                                 uint    w= pTInTC->getWidth(i);
+00543                                                 uint    h= pTInTC->getHeight(i);
+00544                                                 if (bUpload)
+00545                                                 {
+00546                                                         NEL_MEASURE_UPLOAD_TIME_START
+00547                                                         glTexImage2D (face_map[nText], i, glfmt, w, h, 0, glSrcFmt, glSrcType, ptr);
+00548                                                         bAllUploaded = true;
+00549                                                         NEL_MEASURE_UPLOAD_TIME_END
+00550                                                                 
+00551                                                 }
+00552                                                 else
+00553                                                 {
+00554                                                         NEL_MEASURE_UPLOAD_TIME_START
+00555                                                         glTexImage2D (face_map[nText], i, glfmt, w, h, 0, glSrcFmt, glSrcType, NULL);
+00556                                                         NEL_MEASURE_UPLOAD_TIME_END
+00557                                                 }
+00558                                                 // profiling: count TextureMemory usage.
+00559                                                 gltext->TextureMemory+= computeMipMapMemoryUsage(w, h, glfmt);
+00560                                         }
+00561                                 }
+00562                         }
+00563                         else
+00564                         {
+00565                                 // Regenerate all the texture.
+00566                                 tex.generate();
+00567 
+00568                                 if(tex.getSize()>0)
+00569                                 {
+00570                                         // Get the correct texture format from texture...
+00571                                         GLint   glfmt= getGlTextureFormat(tex, gltext->Compressed);
+00572                                         GLint   glSrcFmt= getGlSrcTextureFormat(tex, glfmt);
+00573                                         GLenum  glSrcType= getGlSrcTextureComponentType(glSrcFmt);
+00574 
+00575                                         // DXTC: if same format, and same mipmapOn/Off, use glTexCompressedImage*.
+00576                                         // We cannot build the mipmaps if they are not here.
+00577                                         if(_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt))
+00578                                         {
+00579                                                 sint    nMipMaps = 1;
+00580                                                 
+00581                                                 if(tex.mipMapOn())
+00582                                                         nMipMaps= tex.getMipMapCount();
+00583 
+00584                                                 // MipMap upload?
+00585                                                 gltext->MipMap= nMipMaps>1;
+00586 
+00587                                                 // Degradation in Size allowed only if DXTC texture are provided with mipmaps.
+00588                                                 // Because use them to resize !!!
+00589                                                 uint    decalMipMapResize= 0;
+00590                                                 if(_ForceTextureResizePower>0 && tex.allowDegradation() && nMipMaps>1)
+00591                                                 {
+00592                                                         decalMipMapResize= min(_ForceTextureResizePower, (uint)(nMipMaps-1));
+00593                                                 }
+00594 
+00595                                                 // Fill mipmaps.
+00596                                                 for(sint i=decalMipMapResize;i<nMipMaps;i++)
+00597                                                 {
+00598                                                         void    *ptr= tex.getPixels(i).getPtr();
+00599                                                         sint    size= tex.getPixels(i).size();
+00600                                                         if (bUpload)
+00601                                                         {
+00602                                                                 nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, 
+00603                                                                                                                         tex.getWidth(i),tex.getHeight(i), 0, size, ptr);
+00604                                                                 bAllUploaded = true;
+00605                                                         }
+00606                                                         else
+00607                                                         {
+00608                                                                 //nglCompressedTexImage2DARB (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, 
+00609                                                                 //                                                      tex.getWidth(i),tex.getHeight(i), 0, size, NULL);
+00610                                                                 NEL_MEASURE_UPLOAD_TIME_START
+00611                                                                 glTexImage2D (GL_TEXTURE_2D, i-decalMipMapResize, glfmt, tex.getWidth(i), tex.getHeight(i), 
+00612                                                                                                 0, glSrcFmt, glSrcType, NULL);
+00613                                                                 NEL_MEASURE_UPLOAD_TIME_END
+00614                                                         }
+00615 
+00616                                                         // profiling: count TextureMemory usage.
+00617                                                         gltext->TextureMemory+= tex.getPixels(i).size();
+00618                                                 }
+00619                                         }
+00620                                         else
+00621                                         {
+00622                                                 sint    nMipMaps;
+00623                                                 if(glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA )
+00624                                                 {
+00625                                                         bUpload = true; // Force all upload
+00626                                                         tex.convertToType(CBitmap::RGBA);
+00627                                                 }
+00628 
+00629                                                 // Degradation in Size.
+00630                                                 if(_ForceTextureResizePower>0 && tex.allowDegradation())
+00631                                                 {
+00632                                                         uint    w= tex.getWidth(0) >> _ForceTextureResizePower;
+00633                                                         uint    h= tex.getHeight(0) >> _ForceTextureResizePower;
+00634                                                         w= max(1U, w);
+00635                                                         h= max(1U, h);
+00636                                                         tex.resample(w, h);
+00637                                                 }
+00638 
+00639                                                 if(tex.mipMapOn())
+00640                                                 {
+00641                                                         tex.buildMipMaps();
+00642                                                         nMipMaps= tex.getMipMapCount();
+00643                                                 }
+00644                                                 else
+00645                                                         nMipMaps= 1;
+00646 
+00647                                                 // MipMap upload?
+00648                                                 gltext->MipMap= nMipMaps>1;
+00649 
+00650                                                 // Fill mipmaps.
+00651                                                 for(sint i=0;i<nMipMaps;i++)
+00652                                                 {
+00653                                                         void    *ptr= tex.getPixels(i).getPtr();
+00654                                                         uint    w= tex.getWidth(i);
+00655                                                         uint    h= tex.getHeight(i);
+00656 
+00657                                                         if (bUpload)
+00658                                                         {       
+00659                                                                 NEL_MEASURE_UPLOAD_TIME_START
+00660                                                                 glTexImage2D (GL_TEXTURE_2D, i, glfmt, w, h, 0,glSrcFmt, glSrcType, ptr);
+00661                                                                 NEL_MEASURE_UPLOAD_TIME_END
+00662                                                                 bAllUploaded = true;
+00663                                                         }
+00664                                                         else
+00665                                                         {       
+00666                                                                 NEL_MEASURE_UPLOAD_TIME_START
+00667                                                                 glTexImage2D (GL_TEXTURE_2D, i, glfmt, w, h, 0,glSrcFmt, glSrcType, NULL);                                                              
+00668                                                                 NEL_MEASURE_UPLOAD_TIME_END
+00669                                                         }
+00670                                                         // profiling: count TextureMemory usage.
+00671                                                         gltext->TextureMemory += computeMipMapMemoryUsage (w, h, glfmt);
+00672                                                 }
+00673                                         }
+00674                                 }
+00675                         }
+00676                         //printf("%d,%d,%d\n", tex.getMipMapCount(), tex.getWidth(0), tex.getHeight(0));
+00677 
+00678 
+00679                         // profiling. add new TextureMemory usage.
+00680                         _AllocatedTextureMemory+= gltext->TextureMemory;
+00681                 }
+00682                 // b. Load part of the texture case.
+00683                 //==================================
+00684                 // \todo yoyo: TODO_DXTC
+00685                 // Replace parts of a compressed image. Maybe don't work with the actual system of invalidateRect()...
+00686                 else if (mustLoadPart && !gltext->Compressed)
+00687                 {
+00688                         // Regenerate wanted part of the texture.
+00689                         tex.generate();
+00690 
+00691                         if(tex.getSize()>0)
+00692                         {
+00693                                 // Get the correct texture format from texture...
+00694                                 //===============================================
+00695                                 bool    dummy;
+00696                                 GLint   glfmt= getGlTextureFormat(tex, dummy);
+00697                                 GLint   glSrcFmt= getGlSrcTextureFormat(tex, glfmt);
+00698                                 GLenum  glSrcType= getGlSrcTextureComponentType(glSrcFmt);
+00699 
+00700                                 sint    nMipMaps;
+00701                                 if(glSrcFmt==GL_RGBA && tex.getPixelFormat()!=CBitmap::RGBA )
+00702                                         tex.convertToType(CBitmap::RGBA);
+00703                                 if(tex.mipMapOn())
+00704                                 {
+00705                                         bool    hadMipMap= tex.getMipMapCount()>1;
+00706                                         tex.buildMipMaps();
+00707                                         nMipMaps= tex.getMipMapCount();
+00708                                         // If the texture had no mipmap before, release them.
+00709                                         if(!hadMipMap)
+00710                                         {
+00711                                                 tex.releaseMipMaps();
+00712                                         }
+00713                                 }
+00714                                 else
+00715                                         nMipMaps= 1;
+00716 
+00717                                 // For all rect, update the texture/mipmap.
+00718                                 //===============================================
+00719                                 list<NLMISC::CRect>::iterator   itRect;
+00720                                 for(itRect=tex._ListInvalidRect.begin(); itRect!=tex._ListInvalidRect.end(); itRect++)
+00721                                 {
+00722                                         CRect   &rect= *itRect;
+00723                                         sint    x0= rect.X;
+00724                                         sint    y0= rect.Y;
+00725                                         sint    x1= rect.X+rect.Width;
+00726                                         sint    y1= rect.Y+rect.Height;
+00727 
+00728                                         // Fill mipmaps.
+00729                                         for(sint i=0;i<nMipMaps;i++)
+00730                                         {
+00731                                                 void    *ptr= tex.getPixels(i).getPtr();
+00732                                                 sint    w= tex.getWidth(i);
+00733                                                 sint    h= tex.getHeight(i);
+00734                                                 clamp(x0, 0, w);
+00735                                                 clamp(y0, 0, h);
+00736                                                 clamp(x1, x0, w);
+00737                                                 clamp(y1, y0, h);
+00738 
+00739                                                 glPixelStorei(GL_UNPACK_ROW_LENGTH, w);
+00740                                                 glPixelStorei(GL_UNPACK_SKIP_ROWS, y0);
+00741                                                 glPixelStorei(GL_UNPACK_SKIP_PIXELS, x0);
+00742                                                 if (bUpload)
+00743                                                         glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, ptr);
+00744                                                 else
+00745                                                         glTexSubImage2D (GL_TEXTURE_2D, i, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, NULL);
+00746 
+00747                                                 // Next mipmap!!
+00748                                                 // floor .
+00749                                                 x0= x0/2;
+00750                                                 y0= y0/2;
+00751                                                 // ceil.
+00752                                                 x1= (x1+1)/2;
+00753                                                 y1= (y1+1)/2;
+00754                                         }
+00755                                 }
+00756 
+00757                                 // Reset the transfer mode...
+00758                                 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+00759                                 glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+00760                                 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+00761                         }
+00762                 }
+00763 
+00764 
+00765                 // Release, if wanted.
+00766                 if(tex.getReleasable())
+00767                         tex.release();
+00768 
+00769                 // Basic parameters.
+00770                 //==================
+00771                 gltext->WrapS= tex.getWrapS();
+00772                 gltext->WrapT= tex.getWrapT();
+00773                 gltext->MagFilter= tex.getMagFilter();
+00774                 gltext->MinFilter= tex.getMinFilter();
+00775                 if(tex.isTextureCube())
+00776                 {
+00777                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_S, translateWrapToGl(ITexture::Clamp, _Extensions));
+00778                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_T, translateWrapToGl(ITexture::Clamp, _Extensions));
+00779                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_WRAP_R, translateWrapToGl(ITexture::Clamp, _Extensions));
+00780                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
+00781                         glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
+00782                 }
+00783                 else
+00784                 {
+00785                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, translateWrapToGl(gltext->WrapS, _Extensions));
+00786                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, translateWrapToGl(gltext->WrapT, _Extensions));
+00787                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, translateMagFilterToGl(gltext));
+00788                         glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, translateMinFilterToGl(gltext));
+00789                 }
+00790 
+00791 
+00792 
+00793                 // Disable texture 0
+00794                 _CurrentTexture[0]= NULL;
+00795                 _CurrentTextureInfoGL[0]= NULL;
+00796                 _DriverGLStates.setTextureMode(CDriverGLStates::TextureDisabled);
+00797         }
+00798 
+00799 
+00800         // The texture is correctly setuped.
+00801         tex.clearTouched();
+00802         return true;
+00803 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setupUserTextureMatrix uint  numStages,
CMaterial mat
+
+ + + + + +
+   + + +

+setup the texture matrix for a given number of stages (starting from 0) +

+check if matrix disabled +

+Definition at line 160 of file driver_opengl_material.cpp. +

+References _DriverGLStates, _UserTexMatEnabled, NL3D::CDriverGLStates::activeTextureARB(), NLMISC::CMatrix::get(), NL3D::CMaterial::getFlags(), NL3D::CMaterial::getUserTexMat(), NL3D::IDRV_MAT_USER_TEX_FIRST_BIT, NL3D::IDRV_MAT_USER_TEX_MAT_ALL, and uint. +

+Referenced by setupMaterial(). +

+

00161 { 
+00162         if (
+00163                 (_UserTexMatEnabled != 0 && (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) == 0)          
+00164                 || (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) != 0
+00165            )
+00166         {
+00167                 glMatrixMode(GL_TEXTURE);
+00168                 // for each stage, setup the texture matrix if needed
+00169                 uint newMask = (mat.getFlags() & IDRV_MAT_USER_TEX_MAT_ALL) >> IDRV_MAT_USER_TEX_FIRST_BIT;
+00170                 uint shiftMask = 1;
+00171                 for (uint k = 0; k < numStages ; ++k)
+00172                 {
+00173                         if (newMask & shiftMask) // user matrix for this stage
+00174                         {               
+00175                                 _DriverGLStates.activeTextureARB(k);
+00176                                 glLoadMatrixf(mat.getUserTexMat(k).get());
+00177                                 _UserTexMatEnabled |= shiftMask;
+00178                         }
+00179                         else
+00180                         {
+00182                                 if (
+00183                                         (newMask & shiftMask) != (_UserTexMatEnabled & shiftMask)
+00184                                    )
+00185                                 {
+00186                                         _DriverGLStates.activeTextureARB(k);
+00187                                         glLoadIdentity();
+00188                                         _UserTexMatEnabled &= ~shiftMask;
+00189                                 }                               
+00190                         }
+00191                         shiftMask <<= 1;
+00192                 }
+00193                 glMatrixMode(GL_MODELVIEW);
+00194         }
+00195 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setupUVPtr uint  stage,
CVertexBufferInfo VB,
uint  uvId
[private]
+
+ + + + + +
+   + + +

+setup a texture stage with an UV from VB. +

+ +

+Definition at line 449 of file driver_opengl_vertex.cpp. +

+References _DriverGLStates, _LastSetupGLArrayVertexProgram, NL3D::CVertexBufferInfo::ATIValueOffset, NL3D::CVertexBufferInfo::ATIVBHardMode, NL3D::CVertexBufferInfo::ATIVertexObjectId, NL3D::CDriverGLStates::clientActiveTextureARB(), NL3D::CDriverGLStates::enableTexCoordArray(), nglArrayObjectATI, nlassert, NL3D::CVertexBufferInfo::Type, uint, NL3D::CVertexBufferInfo::ValuePtr, NL3D::CVertexBufferInfo::VertexFormat, and NL3D::CVertexBufferInfo::VertexSize. +

+Referenced by mapTextureStageToUV(), resetLightMapVertexSetup(), setupGlArraysStd(), and setupLightMapPass(). +

+

00450 {
+00451         // sould not be called with vertex program Array setuped.
+00452         nlassert(!_LastSetupGLArrayVertexProgram);
+00453 
+00454         _DriverGLStates.clientActiveTextureARB(stage);
+00455         if (VB.VertexFormat & (CVertexBuffer::TexCoord0Flag<<uvId))
+00456         {
+00457                 // Check type, if not supported, just ignore
+00458                 if (VB.Type[CVertexBuffer::TexCoord0+uvId]==CVertexBuffer::Float2)
+00459                 {
+00460                         _DriverGLStates.enableTexCoordArray(true);
+00461                         // Setup ATI VBHard or std ptr.
+00462                         if(VB.ATIVBHardMode)
+00463                                 nglArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, VB.VertexSize, 
+00464                                         VB.ATIVertexObjectId, VB.ATIValueOffset[CVertexBuffer::TexCoord0+uvId]);
+00465                         else
+00466                                 glTexCoordPointer(2,GL_FLOAT,VB.VertexSize,VB.ValuePtr[CVertexBuffer::TexCoord0+uvId]);
+00467                 }
+00468                 else
+00469                 {
+00470                         _DriverGLStates.enableTexCoordArray(false);
+00471                 }
+00472         }
+00473         else
+00474                 _DriverGLStates.enableTexCoordArray(false);
+00475 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::setupVertexBuffer CVertexBuffer VB  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 60 of file driver_opengl_vertex.cpp. +

+References NL3D::CVertexBuffer::DrvInfos, NL3D::CVertexBuffer::getTouchFlags(), NL3D::ItVBDrvInfoPtrList, and NL3D::CVertexBuffer::resetTouchFlags(). +

+Referenced by activeVertexBuffer(). +

+

00061 {
+00062         // 1. Retrieve/Create driver shader.
+00063         //==================================
+00064         if (!VB.DrvInfos)
+00065         {
+00066                 // insert into driver list. (so it is deleted when driver is deleted).
+00067                 ItVBDrvInfoPtrList      it= _VBDrvInfos.insert(_VBDrvInfos.end());
+00068                 // create and set iterator, for future deletion.
+00069                 *it= VB.DrvInfos= new CVBDrvInfosGL(this, it);
+00070         }
+00071 
+00072         // 2. If necessary, do modifications.
+00073         //==================================
+00074         if( VB.getTouchFlags()!=0 )
+00075         {
+00076                 // nop
+00077                 // OK!
+00078                 VB.resetTouchFlags();
+00079         }
+00080 
+00081 
+00082         return true;
+00083 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupViewMatrix const CMatrix mtx  )  [virtual]
+
+ + + + + +
+   + + +

+setup the view matrix (inverse of camera matrix).

+NB: you must setupViewMatrix() BEFORE setupModelMatrix(), or else undefined results. +

+Implements NL3D::IDriver. +

+Definition at line 86 of file driver_opengl_matrix.cpp. +

+References _LightDirty, _LightSetupDirty, _ModelViewMatrixDirty, _PZBCameraPos, _RenderSetupDirty, _SpecularTexMtx, _UserViewMtx, _ViewMtx, NLMISC::CMatrix::identity(), NLMISC::CMatrix::invert(), MaxLight, NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), and uint. +

+

00087 {
+00088         _UserViewMtx= mtx;
+00089 
+00090         // Setup the matrix to transform the CScene basis in openGL basis.
+00091         CMatrix         changeBasis;
+00092         CVector         I(1,0,0);
+00093         CVector         J(0,0,-1);
+00094         CVector         K(0,1,0);
+00095 
+00096         changeBasis.identity();
+00097         changeBasis.setRot(I,J,K, true);
+00098         _ViewMtx=changeBasis*mtx;
+00099         // Just set the PZBCameraPos to 0.
+00100         _PZBCameraPos= CVector::Null;
+00101 
+00102         // Anything that depend on the view martix must be updated.
+00103         _LightSetupDirty= true;
+00104         _ModelViewMatrixDirty= true;
+00105         _RenderSetupDirty= true;
+00106         // All lights must be refresh.
+00107         for(uint i=0;i<MaxLight;i++)
+00108                 _LightDirty[i]= true;
+00109 
+00110         _SpecularTexMtx = _ViewMtx;
+00111         _SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f));
+00112         _SpecularTexMtx.invert();
+00113         _SpecularTexMtx = changeBasis * _SpecularTexMtx;
+00114 
+00115 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::setupViewMatrixEx const CMatrix mtx,
const CVector cameraPos
[virtual]
+
+ + + + + +
+   + + +

+setup the view matrix (inverse of camera matrix). Extended: give a cameraPos (mtx.Pos() is not taken into account but for getViewMatrix()), so the driver use it to remove translation from all ModelMatrixes (and lights pos). This approach improves greatly ZBuffer precision.

+This is transparent to user, and getViewMatrix() return mtx (as in setupViewMatrix()).

+NB: you must setupViewMatrixEx() BEFORE setupModelMatrix(), or else undefined results.

+

Parameters:
+ + + +
mtx the same view matrix (still with correct "inversed" camera position) as if passed in setupViewMatrix()
cameraPos position of the camera (before inversion, ie mtx.getPos()!=cameraPos ).
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 53 of file driver_opengl_matrix.cpp. +

+References _LightDirty, _LightSetupDirty, _ModelViewMatrixDirty, _PZBCameraPos, _RenderSetupDirty, _SpecularTexMtx, _UserViewMtx, _ViewMtx, NLMISC::CMatrix::identity(), NLMISC::CMatrix::invert(), MaxLight, NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), and uint. +

+

00054 {
+00055         _UserViewMtx= mtx;
+00056 
+00057         // Setup the matrix to transform the CScene basis in openGL basis.
+00058         CMatrix         changeBasis;
+00059         CVector         I(1,0,0);
+00060         CVector         J(0,0,-1);
+00061         CVector         K(0,1,0);
+00062 
+00063         changeBasis.identity();
+00064         changeBasis.setRot(I,J,K, true);
+00065         _ViewMtx=changeBasis*mtx;
+00066         // Reset the viewMtx position.
+00067         _ViewMtx.setPos(CVector::Null);
+00068         _PZBCameraPos= cameraPos;
+00069 
+00070         // Anything that depend on the view martix must be updated.
+00071         _LightSetupDirty= true;
+00072         _ModelViewMatrixDirty= true;
+00073         _RenderSetupDirty= true;
+00074         // All lights must be refresh.
+00075         for(uint i=0;i<MaxLight;i++)
+00076                 _LightDirty[i]= true;
+00077 
+00078         _SpecularTexMtx = _ViewMtx;
+00079         _SpecularTexMtx.setPos(CVector(0.0f,0.0f,0.0f));
+00080         _SpecularTexMtx.invert();
+00081         _SpecularTexMtx = changeBasis * _SpecularTexMtx;
+00082 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupViewport const class CViewport viewport  )  [virtual]
+
+ + + + + +
+   + + +

+Set the current viewport

+

Parameters:
+ + +
viewport is a viewport to setup as current viewport.
+
+ +

+Implements NL3D::IDriver. +

+Definition at line 1821 of file driver_opengl.cpp. +

+References _CurrViewport, NLMISC::clamp(), height, NL3D::CViewport::init(), width, x, and y. +

+

01822 {
+01823 #ifdef NL_OS_WINDOWS
+01824         if (_hWnd == NULL) return;
+01825 
+01826         // Setup gl viewport
+01827         int clientWidth = _WindowWidth;
+01828         int clientHeight = _WindowHeight;
+01829 
+01830 #else // NL_OS_WINDOWS
+01831 
+01832         XWindowAttributes win_attributes;
+01833         if (!XGetWindowAttributes(dpy, win, &win_attributes))
+01834                 throw EBadDisplay("Can't get window attributes.");
+01835 
+01836         // Setup gl viewport
+01837         int clientWidth=win_attributes.width;
+01838         int clientHeight=win_attributes.height;
+01839 
+01840 #endif // NL_OS_WINDOWS
+01841 
+01842         // Get viewport
+01843         float x;
+01844         float y;
+01845         float width;
+01846         float height;
+01847         viewport.getValues (x, y, width, height);
+01848 
+01849         // Setup gl viewport
+01850         int ix=(int)((float)clientWidth*x);
+01851         clamp (ix, 0, clientWidth);
+01852         int iy=(int)((float)clientHeight*y);
+01853         clamp (iy, 0, clientHeight);
+01854         int iwidth=(int)((float)clientWidth*width);
+01855         clamp (iwidth, 0, clientWidth-ix);
+01856         int iheight=(int)((float)clientHeight*height);
+01857         clamp (iheight, 0, clientHeight-iy);
+01858         glViewport (ix, iy, iwidth, iheight);
+01859 
+01860         _CurrViewport.init(ix / (float) clientWidth, iy / (float) clientHeight,
+01861                                            iwidth / (float) clientWidth, iheight / (float) clientHeight);
+01862                 
+01863 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupWaterPass uint  pass  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2155 of file driver_opengl_material.cpp. +

+References _CurrentMaterial, _Extensions, ARBWaterShader, ATIWaterShaderHandleNoDiffuseMap, NL3D::CMaterial::getShader(), nlassert, NL3D::CGlExtensions::NVTextureShader, setupWaterPassARB(), setupWaterPassNV20(), setupWaterPassR200(), and uint. +

+Referenced by setupPass(). +

+

02156 {
+02157         nlassert (_CurrentMaterial);
+02158         CMaterial &mat = *_CurrentMaterial;
+02159         nlassert(_CurrentMaterial->getShader() == CMaterial::Water);
+02160 
+02161         if (_Extensions.NVTextureShader)
+02162         {
+02163                 setupWaterPassNV20(mat);
+02164         }
+02165         else
+02166         if (ARBWaterShader[0])  
+02167         {
+02168                 setupWaterPassARB(mat); 
+02169         }
+02170         else
+02171         if (ATIWaterShaderHandleNoDiffuseMap)   
+02172         {
+02173                 setupWaterPassR200(mat);
+02174         }       
+02175         
+02176 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupWaterPassARB const CMaterial mat  )  [private]
+
+ + + + + +
+   + + +

+water setup for ARB_fragment_program +

+Unfortunately, the EXT_vertex_shader extension has to output the fog values in the [0, 1] range to work with the standard pipeline. So we must add a special path for this case, where the fog coordinate is 'unscaled' again. NB : this is fixed in later drivers (from 6.14.10.6343), so chek this +

+Definition at line 1956 of file driver_opengl_material.cpp. +

+References _ATIFogRangeFixed, _Extensions, _FogEnabled, _FogEnd, _FogStart, activateTexture(), ARBWaterShader, NL3D::CGlExtensions::EXTVertexShader, NL3D::CMaterial::getTexture(), GL_FRAGMENT_PROGRAM_ARB, inlGetNumTextStages(), NL3D::ITexture::isBumpMap(), nglBindProgramARB, nglProgramEnvParameter4fARB, NL3D::ITexture::setUploadFormat(), setupTexture(), and uint. +

+Referenced by setupWaterPass(). +

+

01957 {
+01958         uint k;         
+01959         ITexture *tex = mat.getTexture(0);
+01960         if (tex) 
+01961         {       
+01962                 tex->setUploadFormat(ITexture::RGBA8888);
+01963                 setupTexture(*tex);
+01964                 activateTexture(0, tex);
+01965         }
+01966         tex = mat.getTexture(1);
+01967         if (tex) 
+01968         {                                       
+01969                 tex->setUploadFormat(ITexture::RGBA8888);
+01970                 setupTexture(*tex);
+01971                 activateTexture(1, tex);
+01972         }
+01973         tex = mat.getTexture(2);
+01974         if (tex) 
+01975         {                                       
+01976                 setupTexture(*tex);
+01977                 activateTexture(2, tex);
+01978         }
+01979         tex = mat.getTexture(3);
+01980         if (tex) 
+01981         {                                       
+01982                 setupTexture(*tex);
+01983                 activateTexture(3, tex);
+01984         }               
+01985         for (k = 4; k < (uint) inlGetNumTextStages(); ++k)
+01986         {
+01987                 activateTexture(k, NULL);
+01988         }       
+01989         nglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ARBWaterShader[(_FogEnabled ? 1 : 0) | (mat.getTexture(3) != NULL ? 2 : 0)]);        
+01990         glEnable(GL_FRAGMENT_PROGRAM_ARB);
+01991         // setup the constant
+01992         if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap())
+01993         {
+01994                 float factor = 0.25f * NLMISC::safe_cast<CTextureBump *>(mat.getTexture(0))->getNormalizationFactor();
+01995                 nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 2.f * factor, -1.f * factor, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
+01996         }
+01997         else
+01998         {
+01999                 nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 2.f, -1.f, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
+02000         }
+02001 
+02002         // setup the constant
+02003         if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap())
+02004         {
+02005                 float factor = NLMISC::safe_cast<CTextureBump *>(mat.getTexture(1))->getNormalizationFactor();
+02006                 nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 2.f * factor, -1.f * factor, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
+02007         }
+02008         else
+02009         {
+02010                 nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 2.f, -1.f, 0.f, 0.f); // scale_bias from [0, 1] to [-1, 1] and factor applied
+02011         }
+02012 
+02013         if (_FogEnabled)
+02014         {               
+02015                 if (_FogStart == _FogEnd)
+02016                 {               
+02017                         nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, 0.f, 0.f, 0.f, 0.f);
+02018                 }
+02019                 else
+02020                 {
+02025                         if (_Extensions.EXTVertexShader && !_ATIFogRangeFixed)
+02026                         {
+02027                                 nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, 1.f, 0.f, 0.f, 0.f);
+02028                         }
+02029                         else
+02030                         {
+02031                                 //\TODO nico: test this pass when we got hardware to test it
+02032                                 nglProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2, - 1.f/  (_FogEnd - _FogStart), _FogEnd / (_FogEnd - _FogStart), 0.f, 0.f);
+02033                         }                                               
+02034                 }                               
+02035         }
+02036         
+02037 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupWaterPassNV20 const CMaterial mat  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2064 of file driver_opengl_material.cpp. +

+References _DriverGLStates, NL3D::CMaterial::_Textures, activateTexEnvMode(), activateTexture(), NL3D::CDriverGLStates::activeTextureARB(), enableNVTextureShader(), NL3D::CMaterial::CTexEnv::Env, NL3D::CTextureBump::getNormalizationFactor(), NL3D::CMaterial::getTexture(), GL_OFFSET_TEXTURE_MATRIX_NV, GL_TEXTURE_SHADER_NV, NL3D::IdentityTexMat, NL3D::IDRV_MAT_MAXTEXTURES, inlGetNumTextStages(), NL3D::ITexture::isBumpMap(), nlctassert, setTextureShaders(), setupTexture(), uint, NL3D::WaterNoDiffuseTexAddrMode, and NL3D::WaterTexAddrMode. +

+Referenced by setupWaterPass(). +

+

02065 {
+02066         
+02067         static bool setupDone = false;
+02068         static CMaterial::CTexEnv texEnvReplace;
+02069         static CMaterial::CTexEnv texEnvModulate;
+02070 
+02071         if (!setupDone)
+02072         {
+02073                 texEnvReplace.Env.OpRGB   = CMaterial::Replace;
+02074                 texEnvReplace.Env.OpAlpha = CMaterial::Replace;
+02075                 // use default setup for texenv modulate
+02076                 setupDone = true;
+02077         }
+02078 
+02079         // activate the textures & set the matrixs
+02080         ITexture *tex = mat.getTexture(0);
+02081         if (tex) 
+02082         {                       
+02083                 setupTexture(*tex);
+02084                 activateTexture(0, tex);
+02085                 _DriverGLStates.activeTextureARB(1);
+02086                 if (tex->isBumpMap())
+02087                 {
+02088                         CTextureBump *tb = static_cast<CTextureBump *>(tex);                    
+02089                         // set the matrix for the texture shader
+02090                         float factor = tb->getNormalizationFactor();
+02091                         float tsMatrix[4] = { 0.25f * factor, 0.f, 0.f, 0.25f * factor };                       
+02092                         glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, tsMatrix);
+02093                 }
+02094                 else
+02095                 {
+02096                         glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, IdentityTexMat);
+02097                 }
+02098         }
+02099         tex = mat.getTexture(1);
+02100         if (tex) 
+02101         {                               
+02102                 setupTexture(*tex);
+02103                 activateTexture(1, tex);
+02104                 _DriverGLStates.activeTextureARB(2);
+02105                 if (tex->isBumpMap())
+02106                 {
+02107                         CTextureBump *tb = static_cast<CTextureBump *>(tex);
+02108                         // set the matrix for the texture shader
+02109                         float factor = tb->getNormalizationFactor();
+02110                         float tsMatrix[4] = { factor, 0.f, 0.f, factor };                       
+02111                         glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, tsMatrix);
+02112                 }
+02113                 else
+02114                 {
+02115                         glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, IdentityTexMat);
+02116                 }
+02117         }
+02118         tex = mat.getTexture(2);
+02119         if (tex) 
+02120         {                                       
+02121                 setupTexture(*tex);
+02122                 activateTexture(2, tex);
+02123         }
+02124         tex = mat.getTexture(3);
+02125         if (tex) 
+02126         {                                       
+02127                 setupTexture(*tex);
+02128                 activateTexture(3, tex);
+02129         }               
+02130         for (uint k = 4; k < (uint) inlGetNumTextStages(); ++k)
+02131         {
+02132                 activateTexture(k, NULL);
+02133         }
+02134 
+02135 
+02136         // setup the texture shaders
+02137         enableNVTextureShader(true);
+02138         activateTexEnvMode(0, texEnvReplace);
+02139         activateTexEnvMode(1, texEnvReplace);
+02140         nlctassert(IDRV_MAT_MAXTEXTURES == 4); // if this value changes, may have to change the arrays WaterNoDiffuseTexAddrMode & WaterTexAddrMode
+02141         if (mat.getTexture(3) == NULL)
+02142         {       
+02143                 setTextureShaders(WaterNoDiffuseTexAddrMode, mat._Textures);            
+02144                 activateTexEnvMode(2, texEnvReplace);
+02145         }
+02146         else
+02147         {
+02148                 setTextureShaders(WaterTexAddrMode, mat._Textures);
+02149                 activateTexEnvMode(2, texEnvReplace);
+02150                 activateTexEnvMode(3, texEnvModulate);
+02151         }
+02152 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::setupWaterPassR200 const CMaterial mat  )  [private]
+
+ + + + + +
+   + + +

+water setup for ATI +

+Definition at line 1876 of file driver_opengl_material.cpp. +

+References activateTexture(), ATIWaterShaderHandle, ATIWaterShaderHandleNoDiffuseMap, NL3D::CMaterial::getTexture(), GL_CON_0_ATI, GL_CON_1_ATI, GL_FRAGMENT_SHADER_ATI, inlGetNumTextStages(), NL3D::ITexture::isBumpMap(), nglBindFragmentShaderATI, nglSetFragmentShaderConstantATI, NL3D::CTextureBump::setSignedFormat(), setupTexture(), and uint. +

+Referenced by setupWaterPass(). +

+

01877 {
+01878         uint k;         
+01879         ITexture *tex = mat.getTexture(0);
+01880         if (tex) 
+01881         {       
+01882                 if (tex->isBumpMap())
+01883                 {
+01884                         CTextureBump *tb = static_cast<CTextureBump *>(tex);
+01885                         tb->setSignedFormat(false);
+01886                 }               
+01887                 setupTexture(*tex);
+01888                 activateTexture(0, tex);
+01889         }
+01890         tex = mat.getTexture(1);
+01891         if (tex) 
+01892         {                                       
+01893                 if (tex->isBumpMap())
+01894                 {
+01895                         CTextureBump *tb = static_cast<CTextureBump *>(tex);
+01896                         tb->setSignedFormat(false);
+01897                 }
+01898                 setupTexture(*tex);
+01899                 activateTexture(1, tex);
+01900         }
+01901         tex = mat.getTexture(2);
+01902         if (tex) 
+01903         {                                       
+01904                 setupTexture(*tex);
+01905                 activateTexture(2, tex);
+01906         }
+01907         tex = mat.getTexture(3);
+01908         if (tex) 
+01909         {                                       
+01910                 setupTexture(*tex);
+01911                 activateTexture(3, tex);
+01912         }               
+01913         for (k = 4; k < (uint) inlGetNumTextStages(); ++k)
+01914         {
+01915                 activateTexture(k, NULL);
+01916         }
+01917         if (mat.getTexture(3) != NULL) // is there a diffuse map ?
+01918         {
+01919                 nglBindFragmentShaderATI(ATIWaterShaderHandle);
+01920         }
+01921         else
+01922         {
+01923                 nglBindFragmentShaderATI(ATIWaterShaderHandleNoDiffuseMap);
+01924         }
+01925         glEnable(GL_FRAGMENT_SHADER_ATI);
+01926         // set constants
+01927         if (mat.getTexture(0) && mat.getTexture(0)->isBumpMap())
+01928         {
+01929                 float factor = NLMISC::safe_cast<CTextureBump *>(mat.getTexture(0))->getNormalizationFactor();
+01930                 float cst[4] = { factor, factor, factor, 0.f };
+01931                 nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
+01932         }
+01933         else
+01934         {
+01935                 float cst[4] = { 1.f, 1.f, 1.f, 0.f };
+01936                 nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
+01937         }
+01938         //
+01939         if (mat.getTexture(1) && mat.getTexture(1)->isBumpMap())
+01940         {
+01941                 float factor = NLMISC::safe_cast<CTextureBump *>(mat.getTexture(1))->getNormalizationFactor();
+01942                 float cst[4] = { factor, factor, factor, 0.f };
+01943                 nglSetFragmentShaderConstantATI(GL_CON_1_ATI, cst);
+01944         }
+01945         else
+01946         {
+01947                 float cst[4] = { 1.f, 1.f, 1.f, 0.f };
+01948                 nglSetFragmentShaderConstantATI(GL_CON_0_ATI, cst);
+01949         }
+01950 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CDriverGL::showCursor bool  b  )  [virtual]
+
+ + + + + +
+   + + +

+show cursor if b is true, or hide it if b is false +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1925 of file driver_opengl.cpp. +

+

01926 {
+01927 #ifdef NL_OS_WINDOWS
+01928         if (b)
+01929         {
+01930                 while (ShowCursor(b) < 0) {};
+01931         }
+01932         else
+01933         {
+01934                 while (ShowCursor(b) >= 0) {};
+01935         }
+01936 #elif defined (NL_OS_UNIX)
+01937 
+01938         if (b)
+01939         {
+01940                 if (cursor != None)
+01941                 {
+01942                         XFreeCursor(dpy, cursor);
+01943                         cursor = None;
+01944                 }
+01945                 XUndefineCursor(dpy, win);
+01946         }
+01947         else
+01948         {
+01949                 if (cursor == None)
+01950                 {
+01951                         char bm_no_data[] = { 0,0,0,0, 0,0,0,0 };
+01952                         Pixmap pixmap_no_data = XCreateBitmapFromData (dpy, win, bm_no_data, 8, 8);
+01953                         XColor black;
+01954                         memset(&black, 0, sizeof (XColor));
+01955                         black.flags = DoRed | DoGreen | DoBlue;
+01956                         cursor = XCreatePixmapCursor (dpy, pixmap_no_data, pixmap_no_data, &black, &black, 0, 0);
+01957                         XFreePixmap(dpy, pixmap_no_data);
+01958                 }
+01959                 XDefineCursor(dpy, win, cursor);
+01960         }
+01961 #endif // NL_OS_UNIX
+01962 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::slowUnlockVertexBufferHard  )  const [virtual]
+
+ + + + + +
+   + + +

+return true if driver support VertexBufferHard, but vbHard->unlock() are slow (ATI-openGL). +

+Implements NL3D::IDriver. +

+Definition at line 502 of file driver_opengl_vertex.cpp. +

+References _SlowUnlockVBHard. +

+

00503 {
+00504         return _SlowUnlockVBHard;
+00505 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::startProfileVBHardLock  )  [virtual]
+
+ + + + + +
+   + + +

+If the driver support it, enable profile VBHard locks. No-Op if already profiling +

+Implements NL3D::IDriver. +

+Definition at line 3079 of file driver_opengl.cpp. +

+References _CurVBHardLockCount, _NumVBHardProfileFrame, _VBHardProfiles, and _VBHardProfiling. +

+

03080 {
+03081         if(_VBHardProfiling)
+03082                 return;
+03083 
+03084         // start
+03085         _VBHardProfiles.clear();
+03086         _VBHardProfiles.reserve(50);
+03087         _VBHardProfiling= true;
+03088         _CurVBHardLockCount= 0;
+03089         _NumVBHardProfileFrame= 0;
+03090 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::startSpecularBatch  )  [virtual]
+
+ + + + + +
+   + + +

+Special for Faster Specular Setup. Call this between lot of primitives rendered with Specular Materials. Visual Errors may arise if you don't correclty call endSpecularBatch(). +

+Implements NL3D::IDriver. +

+Definition at line 969 of file driver_opengl_material.cpp. +

+References _SpecularBatchOn, and setupSpecularBegin(). +

+

00970 {
+00971         _SpecularBatchOn= true;
+00972 
+00973         setupSpecularBegin();
+00974 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::supportBlendConstantColor  )  const [virtual]
+
+ + + + + +
+   + + +

+Does the driver support Blend Constant Color ??? If yes CMaterial::blendConstant* enum can be used for blend Src ord Dst factor. If no, using these enum will have undefined results. +

+Implements NL3D::IDriver. +

+Definition at line 2559 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::EXTBlendColor. +

+

02560 {
+02561         return _Extensions.EXTBlendColor;
+02562 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::supportCloudRenderSinglePass  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 3193 of file driver_opengl.cpp. +

+References _Extensions, NL3D::CGlExtensions::ATIXTextureEnvRoute, NL3D::CGlExtensions::EXTTextureEnvCombine, and NL3D::CGlExtensions::NVTextureEnvCombine4. +

+

03194 {
+03195         return _Extensions.NVTextureEnvCombine4 || (_Extensions.ATIXTextureEnvRoute && _Extensions.EXTTextureEnvCombine);
+03196 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::supportEMBM  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2657 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::ATIEnvMapBumpMap. +

+Referenced by initEMBM(), isEMBMSupportedAtStage(), and setEMBMMatrix(). +

+

02658 {
+02659         // For now, supported via ATI extension
+02660         return _Extensions.ATIEnvMapBumpMap;
+02661 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CDriverGL::supportPerPixelLighting bool  specular  )  const [virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2445 of file driver_opengl.cpp. +

+References _SupportPerPixelShader, and _SupportPerPixelShaderNoSpec. +

+Referenced by beginPPLMultiPass(), and beginPPLNoSpecMultiPass(). +

+

02446 {
+02447         return specular ? _SupportPerPixelShader : _SupportPerPixelShaderNoSpec;        
+02448 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::supportTextureShaders  )  const [virtual]
+
+ + + + + +
+   + + +

+test wether the device supports some form of texture shader. (could be limited to DX6 EMBM for example) +

+ +

+Implements NL3D::IDriver. +

+Definition at line 2369 of file driver_opengl.cpp. +

+References _Extensions, and NL3D::CGlExtensions::NVTextureShader. +

+Referenced by setMatrix2DForTextureOffsetAddrMode(). +

+

02370 {
+02371         // fully supported by NV_TEXTURE_SHADER 
+02372         return _Extensions.NVTextureShader;
+02373 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::supportVertexBufferHard  )  const [virtual]
+
+ + + + + +
+   + + +

+return true if driver support VertexBufferHard. +

+Implements NL3D::IDriver. +

+Definition at line 495 of file driver_opengl_vertex.cpp. +

+References _SupportVBHard. +

+Referenced by initVertexArrayRange(). +

+

00496 {
+00497         return _SupportVBHard;
+00498 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::supportVertexProgramDoubleSidedColor  )  const [private, virtual]
+
+ + + + + +
+   + + +

+Check if the driver support double sided colors vertex programs. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1442 of file driver_opengl_vertex_program.cpp. +

+References _Extensions, and NL3D::CGlExtensions::NVVertexProgram. +

+

01443 {
+01444         // currenlty only supported by NV_VERTEX_PROGRAM
+01445         return _Extensions.NVVertexProgram;
+01446 }
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CDriverGL::swapBuffers  )  [virtual]
+
+ + + + + +
+   + + +

+Swap the back and front buffers. +

+ +

+Implements NL3D::IDriver. +

+Definition at line 1536 of file driver_opengl.cpp. +

+References _CurrentMaterial, _CurrentTexture, _CurrentTextureInfoGL, _CurrentVertexBufferHard, _CurVBHardLockCount, _DriverGLStates, _NbSetupMaterialCall, _NbSetupModelMatrixCall, _NumVBHardProfileFrame, _NVTextureShaderEnabled, _PrimitiveProfileIn, _PrimitiveProfileOut, _TextureUsed, _VBHardProfiling, _VertexBufferHardSet, activeVertexBuffer(), NL3D::CMaterial::CTexEnv::ConstantColor, forceActivateTexEnvColor(), forceActivateTexEnvMode(), NL3D::CDriverGLStates::forceDefaults(), GL_TEXTURE_SHADER_NV, inlGetNumTextStages(), NL3D::CVertexBufferHardGLNVidia::isFenceSet(), nlassert, NL3D::CPrimitiveProfile::reset(), NLMISC::CRGBA::set(), NL3D::CPtrSet< IVertexBufferHardGL >::Set, NL3D::CVertexBuffer::setNumVertices(), NL3D::CVertexBuffer::setVertexFormat(), sint, and NL3D::CVertexBufferHardGLNVidia::testFence(). +

+

01537 {       
+01538         // Reset texture shaders
+01539         //resetTextureShaders();
+01540 
+01541 
+01542         /* Yoyo: must do this (GeForce bug ??) esle weird results if end render with a VBHard.
+01543                 Setup a std vertex buffer to ensure NVidia synchronisation.
+01544         */
+01545         static  CVertexBuffer   dummyVB;
+01546         static  bool                    dummyVBinit= false; 
+01547         if(!dummyVBinit)
+01548         {
+01549                 dummyVBinit= true;
+01550                 // setup a full feature VB (maybe not usefull ... :( ).
+01551                 dummyVB.setVertexFormat(CVertexBuffer::PositionFlag|CVertexBuffer::NormalFlag|
+01552                         CVertexBuffer::PrimaryColorFlag|CVertexBuffer::SecondaryColorFlag|
+01553                         CVertexBuffer::TexCoord0Flag|CVertexBuffer::TexCoord1Flag|
+01554                         CVertexBuffer::TexCoord2Flag|CVertexBuffer::TexCoord3Flag
+01555                         );
+01556                 // some vertices.
+01557                 dummyVB.setNumVertices(10);
+01558         }
+01559         /* activate each frame to close VBHard rendering. 
+01560                 NVidia: This also force a SetFence on if last VB was a VBHard, "closing" it before swap.
+01561         */
+01562         activeVertexBuffer(dummyVB);
+01563         nlassert(_CurrentVertexBufferHard==NULL);
+01564 
+01565 
+01566         /* PATCH For Possible NVidia Synchronisation.
+01567         /*/
+01568         // Because of Bug with GeForce, must finishFence() for all VBHard.
+01569         /*set<IVertexBufferHardGL*>::iterator           itVBHard= _VertexBufferHardSet.Set.begin();
+01570         while(itVBHard != _VertexBufferHardSet.Set.end() )
+01571         {
+01572                 // Need only to do it for NVidia VB ones.
+01573                 if((*itVBHard)->NVidiaVertexBufferHard)
+01574                 {
+01575                         CVertexBufferHardGLNVidia       *vbHardNV= static_cast<CVertexBufferHardGLNVidia*>(*itVBHard);
+01576                         // If needed, "flush" these VB.
+01577                         vbHardNV->finishFence();
+01578                 }
+01579                 itVBHard++;
+01580         }*/
+01581         /* Need to Do this code only if Synchronisation PATCH before not done!
+01582                 AS NV_Fence GeForce Implementation says. Test each frame the NVFence, until completion. 
+01583                 NB: finish is not required here. Just test. This is like a "non block synchronisation"
+01584          */
+01585         set<IVertexBufferHardGL*>::iterator             itVBHard= _VertexBufferHardSet.Set.begin();
+01586         while(itVBHard != _VertexBufferHardSet.Set.end() )
+01587         {
+01588                 if((*itVBHard)->VBType == IVertexBufferHardGL::NVidiaVB)
+01589                 {
+01590                         CVertexBufferHardGLNVidia       *vbHardNV= static_cast<CVertexBufferHardGLNVidia*>(*itVBHard);
+01591                         if(vbHardNV->isFenceSet())
+01592                         {
+01593                                 // update Fence Cache.
+01594                                 vbHardNV->testFence();
+01595                         }
+01596                 }
+01597                 itVBHard++;
+01598         }
+01599 
+01600 
+01601 #ifdef NL_OS_WINDOWS
+01602         if (_EventEmitter.getNumEmitters() > 1) // is direct input running ?
+01603         {
+01604                 // flush direct input messages if any
+01605                 NLMISC::safe_cast<NLMISC::CDIEventEmitter *>(_EventEmitter.getEmitter(1))->poll();
+01606         }
+01607 #endif
+01608 
+01609 
+01610 #ifdef NL_OS_WINDOWS
+01611         SwapBuffers(_hDC);
+01612 #else // NL_OS_WINDOWS
+01613         glXSwapBuffers(dpy, win);
+01614 #endif // NL_OS_WINDOWS
+01615         
+01616         // Activate the default texture environnments for all stages.
+01617         //===========================================================
+01618         // This is not a requirement, but it ensure a more stable state each frame.
+01619         // (well, maybe the good reason is "it hides much more the bugs"  :o) ).
+01620         for(sint stage=0;stage<inlGetNumTextStages(); stage++)
+01621         {
+01622                 // init no texture.
+01623                 _CurrentTexture[stage]= NULL;
+01624                 _CurrentTextureInfoGL[stage]= NULL;
+01625                 // texture are disabled in DriverGLStates.forceDefaults().
+01626                 
+01627                 // init default env.
+01628                 CMaterial::CTexEnv      env;    // envmode init to default.
+01629                 env.ConstantColor.set(255,255,255,255);
+01630                 forceActivateTexEnvMode(stage, env);
+01631                 forceActivateTexEnvColor(stage, env);
+01632         }
+01633         
+01634 
+01635         // Activate the default material.
+01636         //===========================================================
+01637         // Same reasoning as textures :)
+01638         _DriverGLStates.forceDefaults(inlGetNumTextStages());
+01639         if (_NVTextureShaderEnabled)
+01640         {
+01641                 glDisable(GL_TEXTURE_SHADER_NV);
+01642                 _NVTextureShaderEnabled = false;
+01643         }
+01644         _CurrentMaterial= NULL;
+01645 
+01646         // Reset the profiling counter.
+01647         _PrimitiveProfileIn.reset();
+01648         _PrimitiveProfileOut.reset();
+01649         _NbSetupMaterialCall= 0;
+01650         _NbSetupModelMatrixCall= 0;
+01651 
+01652         // Reset the texture set
+01653         _TextureUsed.clear();
+01654 
+01655         // Reset Profile VBHardLock
+01656         if(_VBHardProfiling)
+01657         {
+01658                 _CurVBHardLockCount= 0;
+01659                 _NumVBHardProfileFrame++;
+01660         }
+01661 
+01662         return true;
+01663 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CDriverGL::swapTextureHandle ITexture tex0,
ITexture tex1
[virtual]
+
+ + + + + +
+   + + +

+Special method to internally swap the Driver handle of 2 textures. USE IT WITH CARE (eg: may have Size problems, mipmap problems, format problems ...) Actually, it is used only by CAsyncTextureManager, to manage Lods of DXTC CTextureFile. NB: internally, all textures slots are disabled. +

+Implements NL3D::IDriver. +

+Definition at line 1185 of file driver_opengl_texture.cpp. +

+References activateTexture(), NL3D::CTextureDrvInfosGL::Compressed, NL3D::getTextureGl(), NL3D::CTextureDrvInfosGL::ID, inlGetNumTextStages(), NL3D::CTextureDrvInfosGL::MagFilter, NL3D::CTextureDrvInfosGL::MinFilter, NL3D::CTextureDrvInfosGL::MipMap, setupTexture(), sint, NL3D::CTextureDrvInfosGL::TextureMemory, NL3D::CTextureDrvInfosGL::WrapS, and NL3D::CTextureDrvInfosGL::WrapT. +

+

01186 {
+01187         // ensure creation of both texture
+01188         setupTexture(tex0);
+01189         setupTexture(tex1);
+01190 
+01191         // avoid any problem, disable all textures
+01192         for(sint stage=0; stage<inlGetNumTextStages() ; stage++)
+01193         {
+01194                 activateTexture(stage, NULL);
+01195         }
+01196 
+01197         // get the handle.
+01198         CTextureDrvInfosGL      *t0= getTextureGl(tex0);
+01199         CTextureDrvInfosGL      *t1= getTextureGl(tex1);
+01200 
+01201         /* Swap contents. Can't swap directly the pointers cause would have to change all CTextureDrvShare which point on
+01202                 Can't do swap(*t0, *t1), because must keep the correct _DriverIterator
+01203         */
+01204         swap(t0->ID, t1->ID);
+01205         swap(t0->MipMap, t1->MipMap);
+01206         swap(t0->Compressed, t1->Compressed);
+01207         swap(t0->TextureMemory, t1->TextureMemory);
+01208         swap(t0->WrapS, t1->WrapS);
+01209         swap(t0->WrapT, t1->WrapT);
+01210         swap(t0->MagFilter, t1->MagFilter);
+01211         swap(t0->MinFilter, t1->MinFilter);
+01212 
+01213 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
virtual TMessageBoxId NL3D::CDriverGL::systemMessageBox const char *  message,
const char *  title,
TMessageBoxType  type = okType,
TMessageBoxIcon  icon = noIcon
[virtual]
+
+ + + + + +
+   + + +

+Output a system message box and print a message with an icon. This method can be call even if the driver is not initialized. This method is used to return internal driver problem when string can't be displayed in the driver window. If the driver can't open a messageBox, it should not override this method and let the IDriver class manage it with the ASCII console.

+

Parameters:
+ + + + + +
message This is the message to display in the message box.
title This is the title of the message box.
type This is the type of the message box, ie number of button and label of buttons.
icon This is the icon of the message box should use like warning, error etc...
+
+ +

+Reimplemented from NL3D::IDriver.

+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::toggleGlArraysForEXTVertexShader  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 792 of file driver_opengl_vertex.cpp. +

+References _DriverGLStates, NL3D::CVertexProgram::_DrvInfo, _LastSetupGLArrayVertexProgram, _LastSetuppedVP, NL3D::CDriverGLStates::clientActiveTextureARB(), NL3D::CDriverGLStates::enableColorArray(), NL3D::CDriverGLStates::enableNormalArray(), NL3D::CDriverGLStates::enableTexCoordArray(), NL3D::CDriverGLStates::enableVertexArray(), NL3D::CDriverGLStates::enableVertexAttribArrayForEXTVertexShader(), inlGetNumTextStages(), isVertexProgramEnabled(), sint, uint, value, and NL3D::CVertexProgamDrvInfosGL::Variants. +

+Referenced by setupGlArrays(). +

+

00793 {
+00794         // If change of setup type, must disable olds.
+00795         //=======================
+00796 
+00797 
+00798         // If last was a VertexProgram setup, and now it is a standard GL array setup.
+00799         if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
+00800         {
+00801                 CVertexProgram *vp = _LastSetuppedVP;
+00802                 if (vp)
+00803                 {               
+00804                         CVertexProgamDrvInfosGL *drvInfo = NLMISC::safe_cast<CVertexProgamDrvInfosGL *>((IVertexProgramDrvInfos *) vp->_DrvInfo);
+00805                         if (drvInfo)
+00806                         {
+00807                                 // Disable all VertexAttribs.
+00808                                 for (uint value=0; value<CVertexBuffer::NumValue; value++)
+00809                                 {
+00810                                         _DriverGLStates.enableVertexAttribArrayForEXTVertexShader(value, false, drvInfo->Variants);
+00811                                 }
+00812                         }                                                                               
+00813                 }
+00814                 // no more a vertex program setup.
+00815                 _LastSetupGLArrayVertexProgram= false;
+00816         }
+00817 
+00818         // If last was a standard GL array setup, and now it is a VertexProgram setup.
+00819         if( !_LastSetupGLArrayVertexProgram && isVertexProgramEnabled () )
+00820         {
+00821                 // Disable all standards ptrs.
+00822                 _DriverGLStates.enableVertexArray(false);
+00823                 _DriverGLStates.enableNormalArray(false);
+00824                 _DriverGLStates.enableColorArray(false);
+00825                 for(sint i=0; i<inlGetNumTextStages(); i++)
+00826                 {
+00827                         _DriverGLStates.clientActiveTextureARB(i);
+00828                         _DriverGLStates.enableTexCoordArray(false);
+00829                 }
+00830 
+00831 
+00832                 // now, vertex program setup.
+00833                 _LastSetupGLArrayVertexProgram= true;
+00834         }
+00835 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::toggleGlArraysForNVVertexProgram  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 748 of file driver_opengl_vertex.cpp. +

+References _DriverGLStates, _LastSetupGLArrayVertexProgram, NL3D::CDriverGLStates::clientActiveTextureARB(), NL3D::CDriverGLStates::enableColorArray(), NL3D::CDriverGLStates::enableNormalArray(), NL3D::CDriverGLStates::enableSecondaryColorArray(), NL3D::CDriverGLStates::enableTexCoordArray(), NL3D::CDriverGLStates::enableVertexArray(), NL3D::CDriverGLStates::enableVertexAttribArray(), GLVertexAttribIndex, inlGetNumTextStages(), isVertexProgramEnabled(), sint, uint, and value. +

+Referenced by setupGlArrays(). +

+

00749 {
+00750         // If change of setup type, must disable olds.
+00751         //=======================
+00752 
+00753         // If last was a VertexProgram setup, and now it is a standard GL array setup.
+00754         if( _LastSetupGLArrayVertexProgram && !isVertexProgramEnabled () )
+00755         {
+00756                                 
+00757                 // Disable all VertexAttribs.
+00758                 for (uint value=0; value<CVertexBuffer::NumValue; value++)
+00759                 {
+00760                         // Index
+00761                         uint glIndex=GLVertexAttribIndex[value];
+00762                         _DriverGLStates.enableVertexAttribArray(glIndex, false);
+00763                 }
+00764                 _DriverGLStates.enableColorArray(false);
+00765                 _DriverGLStates.enableSecondaryColorArray(false);               
+00766 
+00767                 // no more a vertex program setup.
+00768                 _LastSetupGLArrayVertexProgram= false;
+00769         }
+00770 
+00771         // If last was a standard GL array setup, and now it is a VertexProgram setup.
+00772         if( !_LastSetupGLArrayVertexProgram && isVertexProgramEnabled () )
+00773         {
+00774                 // Disable all standards ptrs.
+00775                 _DriverGLStates.enableVertexArray(false);
+00776                 _DriverGLStates.enableNormalArray(false);
+00777                 _DriverGLStates.enableColorArray(false);
+00778                 for(sint i=0; i<inlGetNumTextStages(); i++)
+00779                 {
+00780                         _DriverGLStates.clientActiveTextureARB(i);
+00781                         _DriverGLStates.enableTexCoordArray(false);
+00782                 }
+00783 
+00784 
+00785                 // now, vertex program setup.
+00786                 _LastSetupGLArrayVertexProgram= true;
+00787         }
+00788 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::uploadTexture ITexture tex,
NLMISC::CRect rect,
uint8  nNumMipMap
[virtual]
+
+ + + + + +
+   + + +

+The texture must be created or uploadTexture do nothing. These function can be used to upload piece by piece a texture. Use it in conjunction with setupTextureEx(..., false); +

+Implements NL3D::IDriver. +

+Definition at line 807 of file driver_opengl_texture.cpp. +

+References _CurrentTexture, _CurrentTextureInfoGL, _DriverGLStates, _Extensions, _ForceTextureResizePower, NL3D::CDriverGLStates::activeTextureARB(), NL3D::ITexture::allowDegradation(), NLMISC::clamp(), NL3D::CGlExtensions::EXTTextureCompressionS3TC, NL3D::getGlSrcTextureComponentType(), NL3D::getGlSrcTextureFormat(), getGlTextureFormat(), NLMISC::CBitmap::getHeight(), NLMISC::CBitmap::getMipMapCount(), NLMISC::CBitmap::getPixelFormat(), NLMISC::CBitmap::getPixels(), NLMISC::CObjectVector< uint8 >::getPtr(), NL3D::getTextureGl(), NLMISC::CBitmap::getWidth(), NLMISC::CRect::Height, NL3D::CTextureDrvInfosGL::ID, imageSize, NL3D::ITexture::isTextureCube(), min, NL3D::ITexture::mipMapOn(), nglCompressedTexImage2DARB, nglCompressedTexSubImage2DARB, nlassert, NL3D::sameDXTCFormat(), NL3D::CDriverGLStates::setTextureMode(), sint, NLMISC::CObjectVector< uint8 >::size(), NL3D::ITexture::TextureDrvShare, uint, uint8, w, NLMISC::CRect::Width, NLMISC::CRect::X, and NLMISC::CRect::Y. +

+

00808 {
+00809         if (tex.TextureDrvShare == NULL)
+00810                 return false; // Texture not created
+00811         if (tex.TextureDrvShare->DrvTexture == NULL)
+00812                 return false; // Texture not created
+00813         if (tex.isTextureCube())
+00814                 return false;
+00815 
+00816         nlassert(nNumMipMap<(uint8)tex.getMipMapCount());
+00817 
+00818         // validate rect.
+00819         sint x0 = rect.X;
+00820         sint y0 = rect.Y;
+00821         sint x1 = rect.X+rect.Width;
+00822         sint y1 = rect.Y+rect.Height;
+00823         sint w = tex.getWidth (nNumMipMap);
+00824         sint h = tex.getHeight (nNumMipMap);
+00825         clamp (x0, 0, w);
+00826         clamp (y0, 0, h);
+00827         clamp (x1, x0, w);
+00828         clamp (y1, y0, h);
+00829 
+00830         // bind the texture to upload 
+00831         CTextureDrvInfosGL*     gltext;
+00832         gltext = getTextureGl (tex);
+00833 
+00834         // system of "backup the previous binded texture" seems to not work with some drivers....
+00835         _DriverGLStates.activeTextureARB (0);
+00836         _DriverGLStates.setTextureMode (CDriverGLStates::Texture2D);
+00837         // Bind this texture, for reload...
+00838         glBindTexture (GL_TEXTURE_2D, gltext->ID);
+00839 
+00840         glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+00841 
+00842         bool dummy;
+00843         GLint glfmt = getGlTextureFormat (tex, dummy);
+00844         GLint glSrcFmt = getGlSrcTextureFormat (tex, glfmt);
+00845         GLenum  glSrcType= getGlSrcTextureComponentType(glSrcFmt);
+00846         // If DXTC format
+00847         if (_Extensions.EXTTextureCompressionS3TC && sameDXTCFormat(tex, glfmt))
+00848         {
+00849 
+00850                 sint nUploadMipMaps;
+00851                 if (tex.mipMapOn())
+00852                         nUploadMipMaps = tex.getMipMapCount();
+00853                 else
+00854                         nUploadMipMaps = 1;
+00855 
+00856                 uint decalMipMapResize = 0;
+00857                 if (_ForceTextureResizePower>0 && tex.allowDegradation() && nUploadMipMaps>1)
+00858                 {
+00859                         decalMipMapResize = min(_ForceTextureResizePower, (uint)(nUploadMipMaps-1));
+00860                 }
+00861 
+00862                 // Compute src compressed size and location
+00863                 sint imageSize = (x1-x0)*(y1-y0);
+00864                 void *ptr = tex.getPixels(nNumMipMap).getPtr();
+00865 
+00866                 // If DXTC1 or DXTC1A, then 4 bits/texel else 8 bits/texel
+00867                 if (glfmt == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || glfmt == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
+00868                 {
+00869                         imageSize /= 2;
+00870                         ptr = (uint8*)ptr + y0*w/2 + x0/2;
+00871                 }
+00872                 else
+00873                 {
+00874                         ptr = (uint8*)ptr + y0*w + x0;
+00875                 }
+00876 
+00877                 // Upload
+00878 
+00879                 if (decalMipMapResize > nNumMipMap)
+00880                 {
+00881                         _CurrentTexture[0]= NULL;
+00882                         _CurrentTextureInfoGL[0]= NULL;
+00883                         _DriverGLStates.setTextureMode (CDriverGLStates::TextureDisabled);
+00884                         return false;
+00885                 }
+00886                         
+00887 
+00888                 nlassert (((x0&3) == 0) && ((y0&3) == 0));
+00889                 if ((w>=4) && (h>=4))
+00890                 {
+00891                         nglCompressedTexSubImage2DARB ( GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, 
+00892                                                                                         x0, y0, (x1-x0), (y1-y0), glfmt, imageSize, ptr );
+00893                 }
+00894                 else
+00895                 {
+00896                         // The CompressedTexSubImage2DARB function do not functionnate properly if width or height
+00897                         // of the mipmap is less than 4 pixel so we use the other form. (its not really time critical
+00898                         // to upload 16 bytes so we can do it twice if texture is cut)
+00899                         imageSize = tex.getPixels(nNumMipMap).size();
+00900                         nglCompressedTexImage2DARB (GL_TEXTURE_2D, nNumMipMap-decalMipMapResize, 
+00901                                                                                 glfmt, w, h, 0, imageSize, ptr);
+00902                 }
+00903         }
+00904         else
+00905         {
+00906                 // glSrcFmt and ITexture format must be identical
+00907                 nlassert (glSrcFmt!=GL_RGBA || tex.getPixelFormat()==CBitmap::RGBA);
+00908 
+00909                 void    *ptr= tex.getPixels(nNumMipMap).getPtr();
+00910                 glPixelStorei (GL_UNPACK_ROW_LENGTH, w);
+00911                 glPixelStorei (GL_UNPACK_SKIP_ROWS, y0);
+00912                 glPixelStorei (GL_UNPACK_SKIP_PIXELS, x0);
+00913                 glTexSubImage2D (GL_TEXTURE_2D, nNumMipMap, x0, y0, x1-x0, y1-y0, glSrcFmt,glSrcType, ptr);
+00914 
+00915                 // Reset the transfer mode...
+00916                 glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+00917                 glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+00918                 glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+00919         }
+00920 
+00921         // Disable texture 0
+00922         _CurrentTexture[0]= NULL;
+00923         _CurrentTextureInfoGL[0]= NULL;
+00924         _DriverGLStates.setTextureMode (CDriverGLStates::TextureDisabled);
+00925 
+00926         return true;
+00927 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
bool NL3D::CDriverGL::uploadTextureCube ITexture tex,
NLMISC::CRect rect,
uint8  nNumMipMap,
uint8  nNumFace
[virtual]
+
+ + + + + +
+   + + +

+ +

+Implements NL3D::IDriver. +

+Definition at line 930 of file driver_opengl_texture.cpp. +

+References NL3D::ITexture::isTextureCube(), NL3D::ITexture::TextureDrvShare, and uint8. +

+

00931 {
+00932         if (tex.TextureDrvShare == NULL)
+00933                 return false; // Texture not created
+00934         if (!tex.isTextureCube())
+00935                 return false;
+00936 
+00937         return true;
+00938 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CDriverGL::verifyNVTextureShaderConfig  )  [private]
+
+ + + + + +
+   + + +

+

+


Friends And Related Function Documentation

+

+ + + + +
+ + +
friend struct CPtrInfo [friend, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 67 of file smart_ptr.h.

+

+ + + + +
+ + +
friend class CTextureDrvInfosGL [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 515 of file driver_opengl.h. +

+Referenced by setupTextureEx().

+

+ + + + +
+ + +
friend class CTextureDrvShare [friend, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 993 of file driver.h. +

+Referenced by setupTextureEx().

+

+ + + + +
+ + +
friend class CVertexArrayRangeATI [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 881 of file driver_opengl.h.

+

+ + + + +
+ + +
friend class CVertexArrayRangeMapObjectATI [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 883 of file driver_opengl.h.

+

+ + + + +
+ + +
friend class CVertexArrayRangeNVidia [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 879 of file driver_opengl.h.

+

+ + + + +
+ + +
friend class CVertexBufferHardGLATI [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 882 of file driver_opengl.h.

+

+ + + + +
+ + +
friend class CVertexBufferHardGLMapObjectATI [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 884 of file driver_opengl.h.

+

+ + + + +
+ + +
friend class CVertexBufferHardGLNVidia [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 880 of file driver_opengl.h.

+

+ + + + +
+ + +
friend class CVertexProgamDrvInfosGL [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 516 of file driver_opengl.h. +

+Referenced by activeEXTVertexShader(), and activeNVVertexProgram().

+

+ + + + +
+ + +
friend class IShader [friend, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 995 of file driver.h.

+

+ + + + +
+ + +
friend class ITextureDrvInfos [friend, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 994 of file driver.h.

+

+ + + + +
+ + +
friend class IVBDrvInfos [friend, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 992 of file driver.h.

+

+ + + + +
+ + +
friend class IVertexProgramDrvInfos [friend, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 996 of file driver.h.

+


Field Documentation

+

+ + + + +
+ + +
IVertexArrayRange* NL3D::CDriverGL::_AGPVertexArrayRange [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 900 of file driver_opengl.h. +

+Referenced by CDriverGL(), createVertexBufferHard(), getAvailableVertexAGPMemory(), initVertexArrayRange(), release(), and resetVertexArrayRange().

+

+ + + + +
+ + +
uint32 NL3D::CDriverGL::_AllocatedTextureMemory [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 917 of file driver_opengl.h. +

+Referenced by CDriverGL(), profileAllocatedTextureMemory(), setupTextureEx(), and NL3D::CTextureDrvInfosGL::~CTextureDrvInfosGL().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_ATIDriverVersion [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1079 of file driver_opengl.h. +

+Referenced by CDriverGL(), and retrieveATIDriverVersion().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_ATIFogRangeFixed [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1080 of file driver_opengl.h. +

+Referenced by CDriverGL(), retrieveATIDriverVersion(), setupEXTVertexShader(), setupFog(), and setupWaterPassARB().

+

+ + + + +
+ + +
NLMISC::CSmartPtr<CTextureCube> NL3D::CDriverGL::_CausticCubeMap [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1012 of file driver_opengl.h.

+

+ + + + +
+ + +
NLMISC::CRGBA NL3D::CDriverGL::_CurrentBlendConstantColor [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1020 of file driver_opengl.h. +

+Referenced by getBlendConstantColor(), and setBlendConstantColor().

+

+ + + + +
+ + +
GLfloat NL3D::CDriverGL::_CurrentFogColor[4] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 611 of file driver_opengl.h. +

+Referenced by CDriverGL(), endLightMapMultiPass(), getFogColor(), and setupFog().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_CurrentGlNormalize [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 684 of file driver_opengl.h. +

+Referenced by CDriverGL(), and enableGlNormalize().

+

+ + + + +
+ + +
CMaterial* NL3D::CDriverGL::_CurrentMaterial [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 653 of file driver_opengl.h. +

+Referenced by beginCloudMultiPass(), beginLightMapMultiPass(), beginSpecularMultiPass(), beginWaterMultiPass(), CDriverGL(), endCloudMultiPass(), endLightMapMultiPass(), endWaterMultiPass(), setupCloudPass(), setupLightMapPass(), setupMaterial(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularPass(), setupWaterPass(), and swapBuffers().

+

+ + + + +
+ + +
CMaterial::TShader NL3D::CDriverGL::_CurrentMaterialSupportedShader [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 654 of file driver_opengl.h. +

+Referenced by beginMultiPass(), endMultiPass(), setupMaterial(), and setupPass().

+

+ + + + +
+ + +
GLenum NL3D::CDriverGL::_CurrentTexAddrMode[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 665 of file driver_opengl.h. +

+Referenced by CDriverGL(), resetTextureShaders(), and setTextureShaders().

+

+ + + + +
+ + +
CMaterial::CTexEnv NL3D::CDriverGL::_CurrentTexEnv[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 661 of file driver_opengl.h. +

+Referenced by activateTexEnvColor(), activateTexEnvMode(), forceActivateTexEnvColor(), and forceActivateTexEnvMode().

+

+ + + + +
+ + +
CTexEnvSpecial NL3D::CDriverGL::_CurrentTexEnvSpecial[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 663 of file driver_opengl.h. +

+Referenced by activateTexEnvMode(), forceActivateTexEnvMode(), setupCloudPass(), setupLightMapPass(), setupPPLNoSpecPass(), setupPPLPass(), and setupSpecularPass().

+

+ + + + +
+ + +
ITexture* NL3D::CDriverGL::_CurrentTexture[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 658 of file driver_opengl.h. +

+Referenced by activateTexture(), copyFrameBufferToTexture(), setupTextureEx(), swapBuffers(), and uploadTexture().

+

+ + + + +
+ + +
CTextureDrvInfosGL* NL3D::CDriverGL::_CurrentTextureInfoGL[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 660 of file driver_opengl.h. +

+Referenced by activateTexture(), copyFrameBufferToTexture(), setupTextureEx(), swapBuffers(), and uploadTexture().

+

+ + + + +
+ + +
IVertexArrayRange* NL3D::CDriverGL::_CurrentVertexArrayRange [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 887 of file driver_opengl.h. +

+Referenced by CDriverGL(), NL3D::CVertexArrayRangeATI::disable(), NL3D::CVertexArrayRangeNVidia::disable(), NL3D::CVertexArrayRangeATI::enable(), and NL3D::CVertexArrayRangeNVidia::enable().

+

+ + + + +
+ + +
IVertexBufferHardGL* NL3D::CDriverGL::_CurrentVertexBufferHard [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 889 of file driver_opengl.h. +

+Referenced by activeVertexBuffer(), CDriverGL(), deleteVertexBufferHard(), NL3D::CVertexBufferHardGLMapObjectATI::disable(), NL3D::CVertexBufferHardGLATI::disable(), NL3D::CVertexBufferHardGLNVidia::disable(), NL3D::CVertexBufferHardGLMapObjectATI::enable(), NL3D::CVertexBufferHardGLATI::enable(), NL3D::CVertexBufferHardGLNVidia::enable(), fenceOnCurVBHardIfNeeded(), render(), renderOrientedQuads(), renderPoints(), renderQuads(), renderSimpleTriangles(), renderTriangles(), resetVertexArrayRange(), and swapBuffers().

+

+ + + + +
+ + +
CViewport NL3D::CDriverGL::_CurrViewport [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 614 of file driver_opengl.h. +

+Referenced by getViewport(), and setupViewport().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_CurVBHardLockCount [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 940 of file driver_opengl.h. +

+Referenced by appendVBHardLockProfile(), CDriverGL(), startProfileVBHardLock(), and swapBuffers().

+

+ + + + +
+ + +
uint8 NL3D::CDriverGL::_Depth [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 569 of file driver_opengl.h.

+

+ + + + +
+ + +
CDriverGLStates NL3D::CDriverGL::_DriverGLStates [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 678 of file driver_opengl.h. +

+Referenced by activateTexture(), beginLightMapMultiPass(), clearZBuffer(), copyFrameBufferToTexture(), disableUserTextureMatrix(), enableFog(), endLightMapMultiPass(), forceActivateTexEnvColor(), forceActivateTexEnvMode(), initEMBM(), resetLightMapVertexSetup(), resetTextureShaders(), setEMBMMatrix(), setMatrix2DForTextureOffsetAddrMode(), setTextureEnvFunction(), setTextureShaders(), setupCloudPass(), setupGlArraysForEXTVertexShader(), setupGlArraysForNVVertexProgram(), setupGlArraysStd(), setupLightMapPass(), setupMaterial(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularBegin(), setupSpecularEnd(), setupSpecularPass(), setupTextureEx(), setupUserTextureMatrix(), setupUVPtr(), setupWaterPassNV20(), swapBuffers(), toggleGlArraysForEXTVertexShader(), toggleGlArraysForNVVertexProgram(), and uploadTexture().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::_EVSColorHandle [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1036 of file driver_opengl.h. +

+Referenced by setupEXTVertexShader().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::_EVSConstantHandle [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1039 of file driver_opengl.h. +

+Referenced by setConstant(), setConstantMatrix(), and setupEXTVertexShader().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::_EVSNormalHandle [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1035 of file driver_opengl.h. +

+Referenced by setupEXTVertexShader().

+

+ + + + +
+ + +
const uint NL3D::CDriverGL::_EVSNumConstant = 97 [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 99 of file driver_opengl.cpp. +

+Referenced by setupEXTVertexShader(), and setupFog().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::_EVSPositionHandle [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1034 of file driver_opengl.h. +

+Referenced by setupEXTVertexShader().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::_EVSTexHandle[8] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1037 of file driver_opengl.h. +

+Referenced by setupEXTVertexShader().

+

+ + + + +
+ + +
CGlExtensions NL3D::CDriverGL::_Extensions [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 564 of file driver_opengl.h. +

+Referenced by activateTexture(), activeVertexProgram(), beginSpecularMultiPass(), checkForPerPixelLightingSupport(), computeLightMapInfos(), NL3D::CVertexProgamDrvInfosGL::CVertexProgamDrvInfosGL(), NL3D::CVertexArrayRangeNVidia::disable(), disableHardwareTextureShader(), disableHardwareVertexArrayAGP(), disableHardwareVertexProgram(), NL3D::CVertexArrayRangeNVidia::enable(), enableVertexProgramDoubleSidedColor(), endWaterMultiPass(), forceActivateTexEnvMode(), getGlTextureFormat(), getSwapVBLInterval(), initEMBM(), initFragmentShaders(), inlGetNumTextStages(), isTextureAddrModeSupported(), isVertexProgramEmulated(), isVertexProgramSupported(), isWaterShaderSupported(), resetTextureShaders(), setBlendConstantColor(), setConstant(), setConstantMatrix(), setEMBMMatrix(), setSwapVBLInterval(), setupCloudPass(), setupFog(), setupGlArrays(), setupLightMapPass(), setupMaterial(), setupPPLNoSpecPass(), setupPPLPass(), setupSpecularPass(), setupTextureEx(), setupWaterPass(), setupWaterPassARB(), supportBlendConstantColor(), supportCloudRenderSinglePass(), supportEMBM(), supportTextureShaders(), supportVertexProgramDoubleSidedColor(), and uploadTexture().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_FogEnabled [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 609 of file driver_opengl.h. +

+Referenced by CDriverGL(), enableFog(), endLightMapMultiPass(), fogEnabled(), setupLightMapPass(), setupMaterial(), and setupWaterPassARB().

+

+ + + + +
+ + +
float NL3D::CDriverGL::_FogEnd [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 610 of file driver_opengl.h. +

+Referenced by CDriverGL(), getFogEnd(), setupFog(), and setupWaterPassARB().

+

+ + + + +
+ + +
float NL3D::CDriverGL::_FogStart [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 610 of file driver_opengl.h. +

+Referenced by CDriverGL(), getFogStart(), setupFog(), and setupWaterPassARB().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_ForceDXTCCompression [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 993 of file driver_opengl.h. +

+Referenced by CDriverGL(), forceDXTCCompression(), and getGlTextureFormat().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_ForceNormalize [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 572 of file driver_opengl.h. +

+Referenced by CDriverGL(), doRefreshRenderSetup(), forceNormalize(), and isForceNormalize().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_ForceTextureResizePower [private] +
+
+ + + + + +
+   + + +

+Divisor for textureResize (power). +

+ +

+Definition at line 995 of file driver_opengl.h. +

+Referenced by CDriverGL(), forceTextureResize(), setupTextureEx(), and uploadTexture().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_FullScreen [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 523 of file driver_opengl.h. +

+Referenced by CDriverGL(), release(), and setMode().

+

+ + + + +
+ + +
NLMISC::CMatrix NL3D::CDriverGL::_GLProjMat [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 584 of file driver_opengl.h. +

+Referenced by refreshProjMatrixFromGL(), and setConstantMatrix().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_Initialized [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 559 of file driver_opengl.h. +

+Referenced by CDriverGL(), getVideocardInformation(), and release().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_LastSetupGLArrayVertexProgram [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 988 of file driver_opengl.h. +

+Referenced by setupUVPtr(), toggleGlArraysForEXTVertexShader(), and toggleGlArraysForNVVertexProgram().

+

+ + + + +
+ + +
NLMISC::CRefPtr<CVertexProgram> NL3D::CDriverGL::_LastSetuppedVP [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 991 of file driver_opengl.h. +

+Referenced by activeEXTVertexShader(), activeNVVertexProgram(), setupGlArraysForEXTVertexShader(), and toggleGlArraysForEXTVertexShader().

+

+ + + + +
+ + +
CVertexBufferInfo NL3D::CDriverGL::_LastVB [private] +
+
+ + + + + +
+   + + +

+LastVB for UV setup. +

+ +

+Definition at line 748 of file driver_opengl.h. +

+Referenced by activeVertexBuffer(), activeVertexBufferHard(), beginLightMapMultiPass(), mapTextureStageToUV(), resetLightMapVertexSetup(), and setupLightMapPass().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_LastVertexSetupIsLightMap [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 774 of file driver_opengl.h. +

+Referenced by CDriverGL(), endLightMapMultiPass(), resetLightMapVertexSetup(), setupGlArrays(), setupLightMapPass(), and setupMaterial().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_LightDirty[MaxLight] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 623 of file driver_opengl.h. +

+Referenced by CDriverGL(), cleanLightSetup(), enableLight(), setLight(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_LightEnable[MaxLight] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 619 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), and enableLight().

+

+ + + + +
+ + +
CMaterial::CTexEnv NL3D::CDriverGL::_LightMapLastStageEnv [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 771 of file driver_opengl.h. +

+Referenced by CDriverGL(), and setupLightMapPass().

+

+ + + + +
+ + +
std::vector<uint> NL3D::CDriverGL::_LightMapLUT [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 768 of file driver_opengl.h. +

+Referenced by CDriverGL(), computeLightMapInfos(), and setupLightMapPass().

+

+ + + + +
+ + +
sint8 NL3D::CDriverGL::_LightMapUVMap[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 775 of file driver_opengl.h. +

+Referenced by CDriverGL(), resetLightMapVertexSetup(), and setupLightMapPass().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_LightMode[MaxLight] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 620 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), and setLight().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_LightSetupDirty [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 575 of file driver_opengl.h. +

+Referenced by CDriverGL(), cleanLightSetup(), doRefreshRenderSetup(), enableLight(), setLight(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
uint32 NL3D::CDriverGL::_MaterialAllTextureTouchedFlag [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 680 of file driver_opengl.h. +

+Referenced by CDriverGL(), and setupMaterial().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_MaxDriverLight [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 618 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), enableLight(), getMaxLight(), and setLight().

+

+ + + + +
+ + +
uint32 NL3D::CDriverGL::_MaxVerticesByVBHard [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 897 of file driver_opengl.h. +

+Referenced by CDriverGL(), createVertexBufferHard(), getMaxVerticesByVertexBufferHard(), and initVertexArrayRange().

+

+ + + + +
+ + +
CMatrix NL3D::CDriverGL::_ModelViewMatrix [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 606 of file driver_opengl.h. +

+Referenced by doRefreshRenderSetup(), multiplyModelMatrix(), setConstantMatrix(), and setupModelMatrix().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_ModelViewMatrixDirty [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 578 of file driver_opengl.h. +

+Referenced by CDriverGL(), doRefreshRenderSetup(), multiplyModelMatrix(), setupModelMatrix(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
uint32 NL3D::CDriverGL::_NbSetupMaterialCall [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 918 of file driver_opengl.h. +

+Referenced by profileSetupedMaterials(), setupMaterial(), and swapBuffers().

+

+ + + + +
+ + +
uint32 NL3D::CDriverGL::_NbSetupModelMatrixCall [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 919 of file driver_opengl.h. +

+Referenced by profileSetupedModelMatrix(), setupModelMatrix(), and swapBuffers().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_NLightMapPass [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 766 of file driver_opengl.h. +

+Referenced by beginLightMapMultiPass(), computeLightMapInfos(), endLightMapMultiPass(), and setupLightMapPass().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_NLightMapPerPass [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 765 of file driver_opengl.h. +

+Referenced by computeLightMapInfos(), endLightMapMultiPass(), and setupLightMapPass().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_NLightMaps [private] +
+
+ + + + + +
+   + + +

+Temp Variables computed in beginLightMapMultiPass(). Reused in setupLightMapPass(). +

+ +

+Definition at line 764 of file driver_opengl.h. +

+Referenced by computeLightMapInfos(), and setupLightMapPass().

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_NumVBHardProfileFrame [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 941 of file driver_opengl.h. +

+Referenced by CDriverGL(), endProfileVBHardLock(), startProfileVBHardLock(), and swapBuffers().

+

+ + + + +
+ + +
void* NL3D::CDriverGL::_NVCurrentVARPtr [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 891 of file driver_opengl.h. +

+Referenced by CDriverGL(), and NL3D::CVertexArrayRangeNVidia::enable().

+

+ + + + +
+ + +
uint32 NL3D::CDriverGL::_NVCurrentVARSize [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 892 of file driver_opengl.h. +

+Referenced by CDriverGL(), and NL3D::CVertexArrayRangeNVidia::enable().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_NVTextureShaderEnabled [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 673 of file driver_opengl.h. +

+Referenced by CDriverGL(), enableNVTextureShader(), resetTextureShaders(), and swapBuffers().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_OffScreen [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 524 of file driver_opengl.h. +

+Referenced by CDriverGL(), getWindowPos(), getWindowSize(), and release().

+

+ + + + +
+ + +
float NL3D::CDriverGL::_OODeltaZ [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 590 of file driver_opengl.h. +

+Referenced by setFrustum(), and setupMaterial().

+

+ + + + +
+ + +
TPolygonMode NL3D::IDriver::_PolygonMode [protected, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 165 of file driver.h. +

+Referenced by NL3D::IDriver::getPolygonMode(), NL3D::IDriver::IDriver(), and NL3D::IDriver::setPolygonMode().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_PolygonSmooth [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1076 of file driver_opengl.h. +

+Referenced by CDriverGL(), enablePolygonSmoothing(), and isPolygonSmoothingEnabled().

+

+ + + + +
+ + +
float NL3D::CDriverGL::_PPLExponent [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 630 of file driver_opengl.h. +

+Referenced by setPerPixelLightingLight().

+

+ + + + +
+ + +
NLMISC::CRGBA NL3D::CDriverGL::_PPLightDiffuseColor [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 631 of file driver_opengl.h. +

+Referenced by setPerPixelLightingLight(), setupPPLNoSpecPass(), and setupPPLPass().

+

+ + + + +
+ + +
NLMISC::CRGBA NL3D::CDriverGL::_PPLightSpecularColor [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 632 of file driver_opengl.h. +

+Referenced by setPerPixelLightingLight(), and setupPPLPass().

+

+ + + + +
+ + +
CPrimitiveProfile NL3D::CDriverGL::_PrimitiveProfileIn [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 915 of file driver_opengl.h. +

+Referenced by profileRenderedPrimitives(), render(), renderOrientedQuads(), renderPoints(), renderQuads(), renderSimpleTriangles(), renderTriangles(), and swapBuffers().

+

+ + + + +
+ + +
CPrimitiveProfile NL3D::CDriverGL::_PrimitiveProfileOut [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 916 of file driver_opengl.h. +

+Referenced by profileRenderedPrimitives(), render(), renderOrientedQuads(), renderPoints(), renderQuads(), renderSimpleTriangles(), renderTriangles(), and swapBuffers().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_ProjMatDirty [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 581 of file driver_opengl.h. +

+Referenced by CDriverGL(), refreshProjMatrixFromGL(), and setFrustum().

+

+ + + + +
+ + +
CVector NL3D::CDriverGL::_PZBCameraPos [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 600 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), setupModelMatrix(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_RenderSetupDirty [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 587 of file driver_opengl.h. +

+Referenced by CDriverGL(), doRefreshRenderSetup(), enableLight(), multiplyModelMatrix(), refreshRenderSetup(), setLight(), setupModelMatrix(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
TShaderPtrList NL3D::IDriver::_Shaders [protected, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 163 of file driver.h. +

+Referenced by NL3D::IDriver::release(), NL3D::IDriver::removeShaderPtr(), and NL3D::IDriver::~IDriver().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_SlowUnlockVBHard [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 896 of file driver_opengl.h. +

+Referenced by CDriverGL(), and slowUnlockVertexBufferHard().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_SpecularBatchOn [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 789 of file driver_opengl.h. +

+Referenced by beginSpecularMultiPass(), CDriverGL(), endSpecularBatch(), endSpecularMultiPass(), and startSpecularBatch().

+

+ + + + +
+ + +
CMatrix NL3D::CDriverGL::_SpecularTexMtx [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 598 of file driver_opengl.h. +

+Referenced by setupSpecularBegin(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
TTexCubeVect NL3D::CDriverGL::_SpecularTextureCubes [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 814 of file driver_opengl.h. +

+Referenced by getSpecularCubeMap().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_StageSupportEMBM[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 675 of file driver_opengl.h. +

+Referenced by CDriverGL(), initEMBM(), and isEMBMSupportedAtStage().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_SumTextureMemoryUsed [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 920 of file driver_opengl.h. +

+Referenced by activateTexture(), CDriverGL(), and enableUsedTextureMemorySum().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_SupportPerPixelShader [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 628 of file driver_opengl.h. +

+Referenced by checkForPerPixelLightingSupport(), getSupportedShader(), and supportPerPixelLighting().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_SupportPerPixelShaderNoSpec [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 629 of file driver_opengl.h. +

+Referenced by checkForPerPixelLightingSupport(), getSupportedShader(), and supportPerPixelLighting().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_SupportVBHard [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 895 of file driver_opengl.h. +

+Referenced by CDriverGL(), and supportVertexBufferHard().

+

+ + + + +
+ + +
CSynchronized<TTexDrvInfoPtrMap> NL3D::IDriver::_SyncTexDrvInfos [protected, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 160 of file driver.h. +

+Referenced by NL3D::IDriver::invalidateShareTexture(), NL3D::IDriver::release(), NL3D::IDriver::removeTextureDrvInfoPtr(), and NL3D::IDriver::~IDriver().

+

+ + + + +
+ + +
TTexDrvSharePtrList NL3D::IDriver::_TexDrvShares [protected, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 162 of file driver.h. +

+Referenced by NL3D::IDriver::invalidateShareTexture(), NL3D::IDriver::release(), NL3D::IDriver::removeTextureDrvSharePtr(), and NL3D::IDriver::~IDriver().

+

+ + + + +
+ + +
std::set<CTextureDrvInfosGL*> NL3D::CDriverGL::_TextureUsed [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 921 of file driver_opengl.h. +

+Referenced by activateTexture(), getUsedTextureMemory(), swapBuffers(), and NL3D::CTextureDrvInfosGL::~CTextureDrvInfosGL().

+

+ + + + +
+ + +
NLMISC::CMatrix NL3D::CDriverGL::_UserTexMat[IDRV_MAT_MAXTEXTURES] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 999 of file driver_opengl.h.

+

+ + + + +
+ + +
uint NL3D::CDriverGL::_UserTexMatEnabled [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1000 of file driver_opengl.h. +

+Referenced by CDriverGL(), disableUserTextureMatrix(), and setupUserTextureMatrix().

+

+ + + + +
+ + +
CMatrix NL3D::CDriverGL::_UserViewMtx [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 593 of file driver_opengl.h. +

+Referenced by getViewMatrix(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
TVBDrvInfoPtrList NL3D::IDriver::_VBDrvInfos [protected, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 164 of file driver.h. +

+Referenced by NL3D::IDriver::release(), NL3D::IDriver::removeVBDrvInfoPtr(), and NL3D::IDriver::~IDriver().

+

+ + + + +
+ + +
std::vector<CVBHardProfile> NL3D::CDriverGL::_VBHardProfiles [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 939 of file driver_opengl.h. +

+Referenced by appendVBHardLockProfile(), endProfileVBHardLock(), and startProfileVBHardLock().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_VBHardProfiling [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 938 of file driver_opengl.h. +

+Referenced by CDriverGL(), endProfileVBHardLock(), NL3D::CVertexBufferHardGLNVidia::lock(), startProfileVBHardLock(), and swapBuffers().

+

+ + + + +
+ + +
CPtrSet<IVertexBufferHardGL> NL3D::CDriverGL::_VertexBufferHardSet [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 878 of file driver_opengl.h. +

+Referenced by createVertexBufferHard(), deleteVertexBufferHard(), profileVBHardAllocation(), resetVertexArrayRange(), and swapBuffers().

+

+ + + + +
+ + +
bool NL3D::CDriverGL::_VertexProgramEnabled [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 986 of file driver_opengl.h. +

+Referenced by activeEXTVertexShader(), activeNVVertexProgram(), and isVertexProgramEnabled().

+

+ + + + +
+ + +
CMatrix NL3D::CDriverGL::_ViewMtx [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 596 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), setupModelMatrix(), setupViewMatrix(), and setupViewMatrixEx().

+

+ + + + +
+ + +
IVertexArrayRange* NL3D::CDriverGL::_VRAMVertexArrayRange [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 902 of file driver_opengl.h. +

+Referenced by CDriverGL(), createVertexBufferHard(), getAvailableVertexVRAMMemory(), initVertexArrayRange(), release(), and resetVertexArrayRange().

+

+ + + + +
+ + +
TVtxPrgDrvInfoPtrList NL3D::IDriver::_VtxPrgDrvInfos [protected, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 166 of file driver.h. +

+Referenced by NL3D::IDriver::release(), NL3D::IDriver::removeVtxPrgDrvInfoPtr(), and NL3D::IDriver::~IDriver().

+

+ + + + +
+ + +
CVector NL3D::CDriverGL::_WorldLightDirection[MaxLight] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 622 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), and setLight().

+

+ + + + +
+ + +
CVector NL3D::CDriverGL::_WorldLightPos[MaxLight] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 621 of file driver_opengl.h. +

+Referenced by cleanLightSetup(), and setLight().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::ARBWaterShader[4] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1063 of file driver_opengl.h. +

+Referenced by CDriverGL(), deleteARBFragmentPrograms(), endWaterMultiPass(), initFragmentShaders(), setupWaterPass(), and setupWaterPassARB().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::ATIWaterShaderHandle [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1061 of file driver_opengl.h. +

+Referenced by CDriverGL(), deleteFragmentShaders(), initFragmentShaders(), and setupWaterPassR200().

+

+ + + + +
+ + +
GLuint NL3D::CDriverGL::ATIWaterShaderHandleNoDiffuseMap [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1060 of file driver_opengl.h. +

+Referenced by CDriverGL(), deleteFragmentShaders(), endWaterMultiPass(), initFragmentShaders(), setupWaterPass(), and setupWaterPassR200().

+

+ + + + +
+ + +
sint NLMISC::CRefCount::crefs [mutable, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 79 of file smart_ptr.h. +

+Referenced by NLMISC::CRefCount::CRefCount(), NLMISC::CRefCount::getRefCount(), and NLMISC::CRefCount::~CRefCount().

+

+ + + + +
+ + +
const uint NL3D::CDriverGL::GLMatrix [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

+{
+        GL_MODELVIEW,
+        GL_PROJECTION,
+         0x8629 
+}
+
+

+Definition at line 1345 of file driver_opengl_vertex_program.cpp. +

+Referenced by setConstantMatrix().

+

+ + + + +
+ + +
const uint NL3D::CDriverGL::GLTransform [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

+{
+         0x862A ,
+         0x862B ,
+         0x862C ,
+         0x862D 
+}
+
+

+Definition at line 1355 of file driver_opengl_vertex_program.cpp. +

+Referenced by setConstantMatrix().

+

+ + + + +
+ + +
const uint NL3D::CDriverGL::GLType [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

+{
+        GL_DOUBLE,      
+        GL_FLOAT,       
+        GL_SHORT,       
+        GL_DOUBLE,      
+        GL_FLOAT,       
+        GL_SHORT,       
+        GL_DOUBLE,      
+        GL_FLOAT,       
+        GL_SHORT,       
+        GL_DOUBLE,      
+        GL_FLOAT,       
+        GL_SHORT,       
+        GL_UNSIGNED_BYTE        
+}
+
+

+Definition at line 634 of file driver_opengl_vertex.cpp. +

+Referenced by setupGlArraysForEXTVertexShader(), and setupGlArraysForNVVertexProgram().

+

+ + + + +
+ + +
const uint NL3D::CDriverGL::GLVertexAttribIndex [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

+{
+        0,      
+        2,      
+        8,      
+        9,      
+        10,     
+        11,     
+        12,     
+        13,     
+        14,     
+        15,     
+        3,      
+        4,      
+        1,      
+        6,      
+        5,      
+        7,      
+}
+
+

+Definition at line 653 of file driver_opengl_vertex.cpp. +

+Referenced by setupGlArraysForEXTVertexShader(), setupGlArraysForNVVertexProgram(), and toggleGlArraysForNVVertexProgram().

+

+ + + + +
+ + +
const uint32 NL3D::IDriver::InterfaceVersion = 0x4e [static, inherited] +
+
+ + + + + +
+   + + +

+Version of the driver interface. To increment when the interface change. +

+ +

+Definition at line 46 of file driver.cpp.

+

+ + + + +
+ + +
CRefCount::CPtrInfo NLMISC::CRefCount::NullPtrInfo [static, inherited] +
+
+ + + + + +
+   + + +

+ +

+Referenced by NLMISC::CRefCount::CRefCount().

+

+ + + + +
+ + +
const uint NL3D::CDriverGL::NumCoordinatesType [static, private] +
+
+ + + + + +
+   + + +

+Initial value:

+{
+        1,      
+        1,      
+        1,      
+        2,      
+        2,      
+        2,      
+        3,      
+        3,      
+        3,      
+        4,      
+        4,      
+        4,      
+        4       
+}
+
+

+Definition at line 615 of file driver_opengl_vertex.cpp. +

+Referenced by setupGlArraysForEXTVertexShader(), and setupGlArraysForNVVertexProgram().

+

+ + + + +
+ + +
CPtrInfo* NLMISC::CRefCount::pinfo [mutable, inherited] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 80 of file smart_ptr.h. +

+Referenced by NLMISC::CRefCount::CRefCount(), and NLMISC::CRefCount::~CRefCount().

+

+ + + + +
+ + +
const uint32 NL3D::CDriverGL::ReleaseVersion = 0xa [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 96 of file driver_opengl.cpp. +

+Referenced by getImplementationVersion().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 06:45:53 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1