added issue_tex_gen for spheremap

This commit is contained in:
Asad M. Zaman 2004-07-02 00:13:20 +00:00
parent b05e24e913
commit 7fbec02238
6 changed files with 1724 additions and 1630 deletions

View File

@ -16,6 +16,79 @@
//
////////////////////////////////////////////////////////////////////
#if defined(_DEBUG) || defined(COUNT_DRAWPRIMS)
typedef enum {DrawPrim,DrawIndexedPrim} DP_Type;
static const char *DP_Type_Strs[3] = {"DrawPrimitive","DrawIndexedPrimitive"};
void INLINE TestDrawPrimFailure(DP_Type dptype,HRESULT hr,IDirect3DDevice8 *pD3DDevice,DWORD nVerts,DWORD nTris) {
if(FAILED(hr)) {
// loss of exclusive mode is not a real DrawPrim problem, ignore it
HRESULT testcooplvl_hr = pD3DDevice->TestCooperativeLevel();
if((testcooplvl_hr != D3DERR_DEVICELOST)||(testcooplvl_hr != D3DERR_DEVICENOTRESET)) {
dxgsg8_cat.fatal() << DP_Type_Strs[dptype] << "() failed: result = " << D3DERRORSTRING(hr);
exit(1);
}
}
CountDPs(nVerts,nTris);
}
#else
#define TestDrawPrimFailure(a,b,c,nVerts,nTris) CountDPs(nVerts,nTris);
#endif
INLINE DWORD
Colorf_to_D3DCOLOR(const Colorf &cColorf) {
// MS VC defines _M_IX86 for x86. gcc should define _X86_
#if defined(_M_IX86) || defined(_X86_)
DWORD d3dcolor,tempcolorval=255;
// note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode
// dont think this makes much difference
__asm {
push ebx ; want to save this in case this fn is inlined
push ecx
mov ecx, cColorf
fild tempcolorval
fld DWORD PTR [ecx]
fmul ST(0),ST(1)
fistp tempcolorval ; no way to store directly to int register
mov eax, tempcolorval
shl eax, 16
fld DWORD PTR [ecx+4] ;grn
fmul ST(0),ST(1)
fistp tempcolorval
mov ebx,tempcolorval
shl ebx, 8
or eax,ebx
fld DWORD PTR [ecx+8] ;blue
fmul ST(0),ST(1)
fistp tempcolorval
or eax,tempcolorval
fld DWORD PTR [ecx+12] ;alpha
fmul ST(0),ST(1)
fistp tempcolorval
; simulate pop 255.0 off FP stack w/o store, mark top as empty and increment stk ptr
ffree ST(0)
fincstp
mov ebx,tempcolorval
shl ebx, 24
or eax,ebx
mov d3dcolor,eax
pop ecx
pop ebx
}
// dxgsg8_cat.debug() << (void*)d3dcolor << endl;
return d3dcolor;
#else //!_X86_
return MY_D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
#endif //!_X86_
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::enable_line_smooth
@ -97,6 +170,24 @@ enable_blend(bool val) {
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::enable_texturing
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian8::
enable_texturing(bool val) {
_texturing_enabled = val;
if (!val) {
_pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE);
} else {
nassertv(_pCurTexContext!=NULL);
SetTextureBlendMode(_CurTexBlendMode,true);
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::set_color_writemask
// Access:
@ -151,6 +242,17 @@ enable_fog(bool val) {
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::add_to_FVFBuf
// Access: Private
// Description: This adds data to the flexible vertex format
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian8::
add_to_FVFBuf(void *data, size_t bytes) {
memcpy(_pCurFvfBufPtr, data, bytes);
_pCurFvfBufPtr += bytes;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::set_vertex_format
// Access:
@ -366,6 +468,112 @@ enable_zwritemask(bool val) {
}
}
INLINE void DXGraphicsStateGuardian8::
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
Colorf transformed
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
}
/*
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::wants_normals
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian8::
wants_normals() const {
return (_lighting_enabled || _normals_enabled);
}
*/
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::wants_texcoords
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian8::
wants_texcoords() const {
return _texturing_enabled;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::compute_distance_to
// Access: Public, Virtual
// Description: This function may only be called during a render
// traversal; it will compute the distance to the
// indicated point, assumed to be in modelview
// coordinates, from the camera plane.
////////////////////////////////////////////////////////////////////
INLINE float DXGraphicsStateGuardian8::
compute_distance_to(const LPoint3f &point) const {
// In the case of a DXGraphicsStateGuardian8, we know that the
// modelview matrix already includes the relative transform from the
// camera, as well as a to-y-up conversion. Thus, the distance to
// the camera plane is simply the +z distance. (negative of gl compute_distance_to,
// since d3d uses left-hand coords)
return point[2];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::get_texture_wrap_mode
// Access: Protected
// Description: Maps from the Texture's internal wrap mode symbols to
// GL's.
////////////////////////////////////////////////////////////////////
INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian8::
get_texture_wrap_mode(Texture::WrapMode wm) const {
static D3DTEXTUREADDRESS PandaTexWrapMode_to_D3DTexWrapMode[Texture::WM_invalid] = {
D3DTADDRESS_CLAMP,D3DTADDRESS_WRAP,D3DTADDRESS_MIRROR,D3DTADDRESS_MIRRORONCE,D3DTADDRESS_BORDER};
return PandaTexWrapMode_to_D3DTexWrapMode[wm];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::get_fog_mode_type
// Access: Protected
// Description: Maps from the fog types to gl version
////////////////////////////////////////////////////////////////////
INLINE D3DFOGMODE DXGraphicsStateGuardian8::
get_fog_mode_type(Fog::Mode m) const {
switch (m) {
case Fog::M_linear:
return D3DFOG_LINEAR;
case Fog::M_exponential:
return D3DFOG_EXP;
case Fog::M_exponential_squared:
return D3DFOG_EXP2;
}
dxgsg8_cat.error() << "Invalid Fog::Mode value" << endl;
return D3DFOG_EXP;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::enable_clip_plane
// Access: Protected, Virtual
// Description: Intended to be overridden by a derived class to
// enable the indicated clip_plane id. A specific
// PlaneNode will already have been bound to this id via
// bind_clip_plane().
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian8::
enable_clip_plane(int plane_id, bool enable) {
assert(plane_id < D3DMAXUSERCLIPPLANES);
DWORD bitflag = ((DWORD)1 << plane_id);
if (enable) {
_clip_plane_bits |= bitflag;
} else {
_clip_plane_bits &= ~bitflag;
}
_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, _clip_plane_bits);
}
/** unimplemented
////////////////////////////////////////////////////////////////////

View File

@ -33,6 +33,7 @@
#include "pointLight.h"
#include "spotlight.h"
#include "textureAttrib.h"
#include "texGenAttrib.h"
#include "lightAttrib.h"
#include "cullFaceAttrib.h"
#include "transparencyAttrib.h"
@ -129,59 +130,6 @@ static bool bTexStatsRetrievalImpossible=false;
//#define Colorf_to_D3DCOLOR(out_color) (MY_D3DRGBA((out_color)[0], (out_color)[1], (out_color)[2], (out_color)[3]))
INLINE DWORD
Colorf_to_D3DCOLOR(const Colorf &cColorf) {
// MS VC defines _M_IX86 for x86. gcc should define _X86_
#if defined(_M_IX86) || defined(_X86_)
DWORD d3dcolor,tempcolorval=255;
// note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode
// dont think this makes much difference
__asm {
push ebx ; want to save this in case this fn is inlined
push ecx
mov ecx, cColorf
fild tempcolorval
fld DWORD PTR [ecx]
fmul ST(0),ST(1)
fistp tempcolorval ; no way to store directly to int register
mov eax, tempcolorval
shl eax, 16
fld DWORD PTR [ecx+4] ;grn
fmul ST(0),ST(1)
fistp tempcolorval
mov ebx,tempcolorval
shl ebx, 8
or eax,ebx
fld DWORD PTR [ecx+8] ;blue
fmul ST(0),ST(1)
fistp tempcolorval
or eax,tempcolorval
fld DWORD PTR [ecx+12] ;alpha
fmul ST(0),ST(1)
fistp tempcolorval
; simulate pop 255.0 off FP stack w/o store, mark top as empty and increment stk ptr
ffree ST(0)
fincstp
mov ebx,tempcolorval
shl ebx, 24
or eax,ebx
mov d3dcolor,eax
pop ecx
pop ebx
}
// dxgsg8_cat.debug() << (void*)d3dcolor << endl;
return d3dcolor;
#else //!_X86_
return MY_D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
#endif //!_X86_
}
void DXGraphicsStateGuardian8::
set_color_clear_value(const Colorf& value) {
_color_clear_value = value;
@ -1124,26 +1072,6 @@ void DXGraphicsStateGuardian8::set_clipper(RECT cliprect) {
}
#endif
#if defined(_DEBUG) || defined(COUNT_DRAWPRIMS)
typedef enum {DrawPrim,DrawIndexedPrim} DP_Type;
static const char *DP_Type_Strs[3] = {"DrawPrimitive","DrawIndexedPrimitive"};
void INLINE TestDrawPrimFailure(DP_Type dptype,HRESULT hr,IDirect3DDevice8 *pD3DDevice,DWORD nVerts,DWORD nTris) {
if(FAILED(hr)) {
// loss of exclusive mode is not a real DrawPrim problem, ignore it
HRESULT testcooplvl_hr = pD3DDevice->TestCooperativeLevel();
if((testcooplvl_hr != D3DERR_DEVICELOST)||(testcooplvl_hr != D3DERR_DEVICENOTRESET)) {
dxgsg8_cat.fatal() << DP_Type_Strs[dptype] << "() failed: result = " << D3DERRORSTRING(hr);
exit(1);
}
}
CountDPs(nVerts,nTris);
}
#else
#define TestDrawPrimFailure(a,b,c,nVerts,nTris) CountDPs(nVerts,nTris);
#endif
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::report_texmgr_stats
// Access: Protected
@ -1281,17 +1209,6 @@ report_texmgr_stats() {
#endif
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::add_to_FVFBuf
// Access: Private
// Description: This adds data to the flexible vertex format
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian8::
add_to_FVFBuf(void *data, size_t bytes) {
memcpy(_pCurFvfBufPtr, data, bytes);
_pCurFvfBufPtr += bytes;
}
// generates slightly fewer instrs
#define add_DWORD_to_FVFBuf(data) { *((DWORD *)_pCurFvfBufPtr) = (DWORD) data; _pCurFvfBufPtr += sizeof(DWORD);}
@ -1300,16 +1217,6 @@ typedef enum {
} GeomVertFormat;
INLINE void DXGraphicsStateGuardian8::
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
Colorf transformed
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::draw_prim_setup
// Access: Private
@ -1323,9 +1230,9 @@ draw_prim_setup(const Geom *geom) {
// (especially for shademode). maybe should change this, since we usually
// get attr info anyway)
#ifdef _DEBUG
#ifdef _DEBUG
assert(geom->get_binding(G_COORD) != G_OFF);
#endif
#endif
#define GET_NEXT_VERTEX(NEXTVERT) { NEXTVERT = geom->get_next_vertex(vi); }
#define GET_NEXT_NORMAL() { p_normal = geom->get_next_normal(ni); }
@ -1339,7 +1246,7 @@ draw_prim_setup(const Geom *geom) {
transform_color(tempcolor,_curD3Dcolor); \
}}
////////
////////
// this stuff should eventually replace the iterators below
PTA_Vertexf coords;
@ -1690,7 +1597,7 @@ draw_line(GeomLine* geom, GeomContext *gc) {
BYTE *_tmp_fvfOverrunBuf = NULL;
nassertv(_pCurFvfBufPtr == NULL); // make sure the storage pointer is clean.
// nassertv(nPrims * 2 * vertex_size < VERT_BUFFER_SIZE);
// nassertv(nPrims * 2 * vertex_size < VERT_BUFFER_SIZE);
if (nPrims * 2 * vertex_size > VERT_BUFFER_SIZE) {
// bugbug: need cleaner way to handle tmp buffer size overruns (malloc/realloc?)
@ -2100,11 +2007,11 @@ draw_sprite(GeomSprite *geom, GeomContext *gc) {
enable_gouraud_shading(_fog_enabled);
set_vertex_format(FVFType);
#ifdef _DEBUG
#ifdef _DEBUG
nassertv(_pCurFvfBufPtr == NULL); // make sure the storage pointer is clean.
nassertv(nPrims * 4 * vertex_size < VERT_BUFFER_SIZE);
nassertv(nPrims * 6 < PANDA_MAXNUMVERTS );
#endif
#endif
_pCurFvfBufPtr = _pFvfBufBasePtr; // _pCurFvfBufPtr changes, _pFvfBufBasePtr doesn't
@ -2354,7 +2261,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
// recheck this flag here!
bPerPrimColor=(_perPrim & PER_COLOR)!=0x0;
#ifdef _DEBUG
#ifdef _DEBUG
// is it Ok not to recompute bUseTexCoordOnlyLoop even if draw_prim_setup unsets color flags?
// add this check to make sure
bool bNewUseTexCoordOnlyLoop = (((_perVertex & PER_COLOR)==0x0) &&
@ -2371,7 +2278,7 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
DebugBreak();
assert(0);
}
#endif
#endif
nassertv(_pCurFvfBufPtr == NULL); // make sure the storage pointer is clean.
nassertv(nPrims * 3 * vertex_size < VERT_BUFFER_SIZE);
@ -2471,9 +2378,9 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
HRESULT hr;
if(nPrims==0) {
#ifdef _DEBUG
#ifdef _DEBUG
dxgsg8_cat.warning() << "draw_multitri() called with ZERO vertices!!" << endl;
#endif
#endif
return;
}
@ -2547,7 +2454,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
// recheck this flag here!
bPerPrimColor=(_perPrim & PER_COLOR)!=0;
#ifdef _DEBUG
#ifdef _DEBUG
// is it Ok not to recompute bUseTexCoordOnlyLoop even if draw_prim_setup unsets color flags?
// add this check to make sure. texcoordonly needs input that with unchanging color, except per-prim
bool bNewUseTexCoordOnlyLoop = ((((_perComp|_perVertex) & PER_COLOR)==0x0) &&
@ -2566,7 +2473,7 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
assert(0);
}
#endif
#endif
// iterate through the triangle primitives
@ -2636,7 +2543,6 @@ draw_multitri(Geom *geom, D3DPRIMITIVETYPE trilisttype) {
_pCurFvfBufPtr = NULL;
}
}
}
//-----------------------------------------------------------------------------
@ -2656,7 +2562,7 @@ GenerateSphere(void *pVertexSpace,DWORD dwVertSpaceByteSize,
float x, y, z, rsintheta;
D3DXVECTOR3 vPoint;
//#define DBG_GENSPHERE
//#define DBG_GENSPHERE
#define M_PI 3.1415926f // probably should get this from mathNumbers.h instead
nassertv(wNumRings>=2 && wNumSections>=2);
@ -2684,7 +2590,7 @@ GenerateSphere(void *pVertexSpace,DWORD dwVertSpaceByteSize,
dwNumIndices = dwNumTriangles*3;
*pNumTris = dwNumTriangles;
// D3DVERTEX* pvVertices = (D3DVERTEX*) pVertexSpace;
// D3DVERTEX* pvVertices = (D3DVERTEX*) pVertexSpace;
WORD *pwIndices = (WORD *) pIndexSpace;
nassertv(dwNumVertices*dwVertSize < VERT_BUFFER_SIZE);
@ -2886,7 +2792,6 @@ GenerateSphere(void *pVertexSpace,DWORD dwVertSpaceByteSize,
#endif
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::draw_sphere
// Access: Public, Virtual
@ -2963,7 +2868,6 @@ draw_sphere(GeomSphere *geom, GeomContext *gc) {
////////////////////////////////////////////////////////////////////
TextureContext *DXGraphicsStateGuardian8::
prepare_texture(Texture *tex) {
DXTextureContext8 *dtc = new DXTextureContext8(tex);
if (dtc->CreateTexture(*_pScrn) == NULL) {
delete dtc;
@ -2988,9 +2892,9 @@ apply_texture(TextureContext *tc) {
return;
}
#ifdef DO_PSTATS
#ifdef DO_PSTATS
add_to_texture_record(tc);
#endif
#endif
// Note: if this code changes, make sure to change initialization
// SetTSS code in dx_init as well so DX TSS renderstate matches
@ -3058,11 +2962,11 @@ apply_texture(TextureContext *tc) {
if (aniso_degree<=1) {
newMagFilter=((ft!=Texture::FT_nearest) ? D3DTEXF_LINEAR : D3DTEXF_POINT);
#ifdef _DEBUG
#ifdef _DEBUG
if((ft!=Texture::FT_linear)&&(ft!=Texture::FT_nearest)) {
dxgsg8_cat.error() << "MipMap filter type setting for texture magfilter makes no sense, texture: " << tex->get_name() << "\n";
}
#endif
#endif
} else {
newMagFilter=D3DTEXF_ANISOTROPIC;
}
@ -3075,11 +2979,11 @@ apply_texture(TextureContext *tc) {
#ifdef _DEBUG
assert(Texture::FT_linear_mipmap_linear < 8);
#endif
/*
/*
enum FilterType {
FT_nearest,FT_linear,FT_nearest_mipmap_nearest,FT_linear_mipmap_nearest,
FT_nearest_mipmap_linear, FT_linear_mipmap_linear, };
*/
*/
// map Panda composite min+mip filter types to d3d's separate min & mip filter types
static D3DTEXTUREFILTERTYPE PandaToD3DMinType[8] =
{D3DTEXF_POINT,D3DTEXF_LINEAR,D3DTEXF_POINT,D3DTEXF_LINEAR,D3DTEXF_POINT,D3DTEXF_LINEAR};
@ -3097,14 +3001,14 @@ apply_texture(TextureContext *tc) {
D3DTEXTUREFILTERTYPE newMipFilter = PandaToD3DMipType[(DWORD)ft];
#ifndef NDEBUG
#ifndef NDEBUG
// sanity check
extern char *PandaFilterNameStrs[];
if((!(dtc->_bHasMipMaps))&&(newMipFilter!=D3DTEXF_NONE)) {
dxgsg8_cat.error() << "Trying to set mipmap filtering for texture with no generated mipmaps!! texname[" << tex->get_name() << "], filter("<<PandaFilterNameStrs[ft]<<")\n";
newMipFilter=D3DTEXF_NONE;
}
#endif
#endif
D3DTEXTUREFILTERTYPE newMinFilter = PandaToD3DMinType[(DWORD)ft];
@ -3522,24 +3426,6 @@ void DXGraphicsStateGuardian8::SetTextureBlendMode(TextureApplyAttrib::Mode TexB
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::enable_texturing
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian8::
enable_texturing(bool val) {
_texturing_enabled = val;
if (!val) {
_pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE);
} else {
nassertv(_pCurTexContext!=NULL);
SetTextureBlendMode(_CurTexBlendMode,true);
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::issue_transform
// Access: Public, Virtual
@ -3595,6 +3481,49 @@ issue_tex_matrix(const TexMatrixAttrib *attrib) {
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::issue_tex_gen
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
void DXGraphicsStateGuardian8::
issue_tex_gen(const TexGenAttrib *attrib) {
/*
* Automatically generate texture coordinates for stage 0.
* Use the wrap mode from the texture coordinate set at index 1.
*/
DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1));
if (attrib->is_off()) {
//enable_texturing(false);
// reset the texcoordindex lookup to 0
//_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
} else if (attrib->get_mode() == TexGenAttrib::M_spherical) {
// We have set up the texture matrix to scale and translate the
// texture coordinates to get from camera space (-1, +1) to
// texture space (0,1)
LMatrix4f dm(0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.5f, 0.5f, 0.0f, 0.0f);
_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT2);
#if 0
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACENORMAL);
#else
_pD3DDevice->SetRenderState(D3DRS_LOCALVIEWER, TRUE);
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
#endif
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::issue_texture
// Access: Public, Virtual
@ -4064,17 +3993,6 @@ end_frame() {
GraphicsStateGuardian::end_frame();
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::wants_texcoords
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian8::
wants_texcoords() const {
return _texturing_enabled;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::depth_offset_decals
// Access: Public, Virtual
@ -4107,25 +4025,6 @@ get_internal_coordinate_system() const {
return CS_yup_left;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::compute_distance_to
// Access: Public, Virtual
// Description: This function may only be called during a render
// traversal; it will compute the distance to the
// indicated point, assumed to be in modelview
// coordinates, from the camera plane.
////////////////////////////////////////////////////////////////////
INLINE float DXGraphicsStateGuardian8::
compute_distance_to(const LPoint3f &point) const {
// In the case of a DXGraphicsStateGuardian8, we know that the
// modelview matrix already includes the relative transform from the
// camera, as well as a to-y-up conversion. Thus, the distance to
// the camera plane is simply the +z distance. (negative of gl compute_distance_to,
// since d3d uses left-hand coords)
return point[2];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::set_draw_buffer
// Access: Protected
@ -4197,39 +4096,6 @@ set_read_buffer(const RenderBuffer &rb) {
return;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::get_texture_wrap_mode
// Access: Protected
// Description: Maps from the Texture's internal wrap mode symbols to
// GL's.
////////////////////////////////////////////////////////////////////
INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian8::
get_texture_wrap_mode(Texture::WrapMode wm) const {
static D3DTEXTUREADDRESS PandaTexWrapMode_to_D3DTexWrapMode[Texture::WM_invalid] = {
D3DTADDRESS_CLAMP,D3DTADDRESS_WRAP,D3DTADDRESS_MIRROR,D3DTADDRESS_MIRRORONCE,D3DTADDRESS_BORDER};
return PandaTexWrapMode_to_D3DTexWrapMode[wm];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::get_fog_mode_type
// Access: Protected
// Description: Maps from the fog types to gl version
////////////////////////////////////////////////////////////////////
INLINE D3DFOGMODE DXGraphicsStateGuardian8::
get_fog_mode_type(Fog::Mode m) const {
switch (m) {
case Fog::M_linear:
return D3DFOG_LINEAR;
case Fog::M_exponential:
return D3DFOG_EXP;
case Fog::M_exponential_squared:
return D3DFOG_EXP2;
}
dxgsg8_cat.error() << "Invalid Fog::Mode value" << endl;
return D3DFOG_EXP;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::enable_lighting
// Access: Protected, Virtual
@ -4293,28 +4159,6 @@ slot_new_clip_plane(int plane_id) {
return (plane_id < D3DMAXUSERCLIPPLANES);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::enable_clip_plane
// Access: Protected, Virtual
// Description: Intended to be overridden by a derived class to
// enable the indicated clip_plane id. A specific
// PlaneNode will already have been bound to this id via
// bind_clip_plane().
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian8::
enable_clip_plane(int plane_id, bool enable) {
assert(plane_id < D3DMAXUSERCLIPPLANES);
DWORD bitflag = ((DWORD)1 << plane_id);
if (enable) {
_clip_plane_bits |= bitflag;
} else {
_clip_plane_bits &= ~bitflag;
}
_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, _clip_plane_bits);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::bind_clip_plane
// Access: Protected, Virtual

View File

@ -124,6 +124,7 @@ public:
virtual void issue_cull_face(const CullFaceAttrib *attrib);
virtual void issue_fog(const FogAttrib *attrib);
virtual void issue_depth_offset(const DepthOffsetAttrib *attrib);
virtual void issue_tex_gen(const TexGenAttrib *attrib);
virtual void bind_light(PointLight *light, int light_id);
virtual void bind_light(DirectionalLight *light, int light_id);

View File

@ -866,8 +866,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
wdxdisplay8_cat.warning() << "pPresParams->BackBufferCount : " << pPresParams->BackBufferCount << endl;
wdxdisplay8_cat.warning() << "D3D CreateDevice failed for device #" << Display.CardIDNum << D3DERRORSTRING(hr);
goto Fallback_to_16bpp_buffers;
//exit(1);
return false;
}
} // end create windowed buffers

View File

@ -38,6 +38,7 @@
#include "depthWriteAttrib.h"
#include "colorWriteAttrib.h"
#include "texMatrixAttrib.h"
#include "texGenAttrib.h"
#include "materialAttrib.h"
#include "renderModeAttrib.h"
#include "fogAttrib.h"
@ -2191,6 +2192,48 @@ issue_tex_matrix(const TexMatrixAttrib *attrib) {
report_my_gl_errors();
}
////////////////////////////////////////////////////////////////////
// Function: CLP(GraphicsStateGuardian)::issue_tex_gen
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian)::
issue_tex_gen(const TexGenAttrib *attrib) {
DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1));
static bool forced_normal = false;
if (attrib->is_off()) {
//enable_texturing(false);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
if (forced_normal) {
undo_force_normals();
forced_normal = false;
}
}
else if (attrib->get_mode() == TexGenAttrib::M_spherical) {
#if 0
Texture *tex = attrib->get_texture();
nassertv(tex != (Texture *)NULL);
TextureContext *tc = tex->prepare_now(_prepared_objects, this);
apply_texture(tc);
#else
// Set The Texture Generation Mode For S To Sphere Mapping
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
// Set The Texture Generation Mode For T To Sphere Mapping
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glEnable(GL_TEXTURE_GEN_S); //Enable Texture Coord Generation For S
glEnable(GL_TEXTURE_GEN_T); // Enable Texture Coord Generation For T
if (!forced_normal) {
force_normals();
forced_normal = true;
}
#endif
}
report_my_gl_errors();
}
////////////////////////////////////////////////////////////////////
// Function: CLP(GraphicsStateGuardian)::issue_texture
// Access: Public, Virtual

View File

@ -103,7 +103,7 @@ public:
virtual void issue_cull_face(const CullFaceAttrib *attrib);
virtual void issue_fog(const FogAttrib *attrib);
virtual void issue_depth_offset(const DepthOffsetAttrib *attrib);
// virtual void issue_tex_gen(const TexGenAttrib *attrib);
virtual void issue_tex_gen(const TexGenAttrib *attrib);
// virtual void issue_stencil(const StencilAttrib *attrib);
virtual void bind_light(PointLight *light, int light_id);