From fd8bc506d3f3ed986edec0200dd2b592ba6fe807 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 25 Feb 2004 21:07:55 +0000 Subject: [PATCH] build on windows with new PreparedGraphicsObjects --- panda/metalibs/panda/Sources.pp | 1 - panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx | 37 ++---------------- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 37 ++---------------- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 39 ++----------------- panda/src/wgldisplay/wglGraphicsBuffer.cxx | 3 +- 5 files changed, 11 insertions(+), 106 deletions(-) diff --git a/panda/metalibs/panda/Sources.pp b/panda/metalibs/panda/Sources.pp index 724d8ef504..6c4b3ea1e2 100644 --- a/panda/metalibs/panda/Sources.pp +++ b/panda/metalibs/panda/Sources.pp @@ -7,7 +7,6 @@ #define DIR_TYPE metalib #define BUILDING_DLL BUILDING_PANDA #define USE_PACKAGES net -#define WIN_SYS_LIBS $[WIN_SYS_LIBS] Ws2_32.lib #define COMPONENT_LIBS \ recorder pgraph \ diff --git a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx index a9a0864d05..b49e3e4a47 100644 --- a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx +++ b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx @@ -3309,15 +3309,6 @@ TextureContext *DXGraphicsStateGuardian7:: prepare_texture(Texture *tex) { DXTextureContext7 *dtc = new DXTextureContext7(tex); -#ifdef WBD_GL_MODE - glGenTextures(1, >c->_index); - - bind_texture(gtc); - glPrioritizeTextures(1, >c->_index, >c->_priority); - specify_texture(tex); - apply_texture_immediate(tex); -#else - #ifdef USE_TEXFMTVEC if (dtc->CreateTexture(_pScrn->pD3DDevice,_pScrn->TexPixFmts,&_pScrn->D3DDevDesc) == NULL) { #else @@ -3326,14 +3317,6 @@ prepare_texture(Texture *tex) { delete dtc; return NULL; } -#endif // WBD_GL_MODE - - bool inserted = mark_prepared_texture(dtc); - - // If this assertion fails, the same texture was prepared twice, - // which shouldn't be possible, since the texture itself should - // detect this. - nassertr(inserted, NULL); return dtc; } @@ -3503,17 +3486,7 @@ apply_texture(TextureContext *tc) { void DXGraphicsStateGuardian7:: release_texture(TextureContext *tc) { DXTextureContext7 *gtc = DCAST(DXTextureContext7, tc); - Texture *tex = tc->_texture; - gtc->DeleteTexture(); - bool erased = unmark_prepared_texture(gtc); - - // If this assertion fails, a texture was released that hadn't been - // prepared (or a texture was released twice). - nassertv(erased); - - tex->clear_gsg(this); - delete gtc; } @@ -3913,7 +3886,9 @@ issue_texture(const TextureAttrib *attrib) { enable_texturing(true); Texture *tex = attrib->get_texture(); nassertv(tex != (Texture *)NULL); - tex->apply(this); + + TextureContext *tc = tex->prepare_now(_prepared_objects, this); + apply_texture(tc); } } @@ -4835,12 +4810,6 @@ dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled) { PRINTREFCNT(_pScrn->pDD,"exit start IDirectDraw7"); - // these 2 calls release ddraw surfaces and vbuffers. unsafe unless not on exit - release_all_textures(); - release_all_geoms(); - - PRINTREFCNT(_pScrn->pDD,"after release_all_textures IDirectDraw7"); - // Do a safe check for releasing the D3DDEVICE. RefCount should be zero. // if we're called from exit(), _pScrn->pD3DDevice may already have been released if (_pScrn->pD3DDevice!=NULL) { diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index b75d1e492e..c9bda34d1f 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -3004,27 +3004,10 @@ TextureContext *DXGraphicsStateGuardian8:: prepare_texture(Texture *tex) { DXTextureContext8 *dtc = new DXTextureContext8(tex); -#ifdef WBD_GL_MODE - glGenTextures(1, >c->_index); - - bind_texture(gtc); - glPrioritizeTextures(1, >c->_index, >c->_priority); - specify_texture(tex); - apply_texture_immediate(tex); -#else - if (dtc->CreateTexture(*_pScrn) == NULL) { delete dtc; return NULL; } -#endif // WBD_GL_MODE - - bool inserted = mark_prepared_texture(dtc); - - // If this assertion fails, the same texture was prepared twice, - // which shouldn't be possible, since the texture itself should - // detect this. - nassertr(inserted, NULL); return dtc; } @@ -3199,17 +3182,7 @@ apply_texture(TextureContext *tc) { void DXGraphicsStateGuardian8:: release_texture(TextureContext *tc) { DXTextureContext8 *gtc = DCAST(DXTextureContext8, tc); - Texture *tex = tc->_texture; - gtc->DeleteTexture(); - bool erased = unmark_prepared_texture(gtc); - - // If this assertion fails, a texture was released that hadn't been - // prepared (or a texture was released twice). - nassertv(erased); - - tex->clear_gsg(this); - delete gtc; } @@ -3673,7 +3646,9 @@ issue_texture(const TextureAttrib *attrib) { enable_texturing(true); Texture *tex = attrib->get_texture(); nassertv(tex != (Texture *)NULL); - tex->apply(this); + + TextureContext *tc = tex->prepare_now(_prepared_objects, this); + apply_texture(tc); } } @@ -4578,12 +4553,6 @@ dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled) { PRINT_REFCNT(dxgsg8,_pD3DDevice); - // these 2 calls release ddraw surfaces and vbuffers. unsafe unless not on exit - release_all_textures(); - release_all_geoms(); - - PRINT_REFCNT(dxgsg8,_pD3DDevice); - // delete non-panda-texture/geom DX objects (VBs/textures/shaders) SAFE_DELSHADER(Vertex,_CurVertexShader,_pD3DDevice); SAFE_DELSHADER(Pixel,_CurPixelShader,_pD3DDevice); diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index bd7c8e8cd8..a0f0e22f07 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3020,30 +3020,11 @@ draw_sphere(GeomSphere *geom, GeomContext *gc) { //////////////////////////////////////////////////////////////////// TextureContext *DXGraphicsStateGuardian9:: prepare_texture(Texture *tex) { - DXTextureContext9 *dtc = new DXTextureContext9(tex); -#ifdef WBD_GL_MODE - glGenTextures(1, >c->_index); - - bind_texture(gtc); - glPrioritizeTextures(1, >c->_index, >c->_priority); - specify_texture(tex); - apply_texture_immediate(tex); -#else - if (dtc->CreateTexture(*_pScrn) == NULL) { delete dtc; return NULL; } -#endif // WBD_GL_MODE - - bool inserted = mark_prepared_texture(dtc); - - // If this assertion fails, the same texture was prepared twice, - // which shouldn't be possible, since the texture itself should - // detect this. - nassertr(inserted, NULL); - return dtc; } @@ -3217,17 +3198,7 @@ apply_texture(TextureContext *tc) { void DXGraphicsStateGuardian9:: release_texture(TextureContext *tc) { DXTextureContext9 *gtc = DCAST(DXTextureContext9, tc); - Texture *tex = tc->_texture; - gtc->DeleteTexture(); - bool erased = unmark_prepared_texture(gtc); - - // If this assertion fails, a texture was released that hadn't been - // prepared (or a texture was released twice). - nassertv(erased); - - tex->clear_gsg(this); - delete gtc; } @@ -3692,7 +3663,9 @@ issue_texture(const TextureAttrib *attrib) { enable_texturing(true); Texture *tex = attrib->get_texture(); nassertv(tex != (Texture *)NULL); - tex->apply(this); + + TextureContext *tc = tex->prepare_now(_prepared_objects, this); + apply_texture(tc); } } @@ -4597,12 +4570,6 @@ dx_cleanup(bool bRestoreDisplayMode,bool bAtExitFnCalled) { PRINT_REFCNT(dxgsg9,_pD3DDevice); - // these 2 calls release ddraw surfaces and vbuffers. unsafe unless not on exit - release_all_textures(); - release_all_geoms(); - - PRINT_REFCNT(dxgsg9,_pD3DDevice); - // delete non-panda-texture/geom DX objects (VBs/textures/shaders) //SAFE_DELSHADER(Vertex,_CurVertexShader,_pD3DDevice); //SAFE_DELSHADER(Pixel,_CurPixelShader,_pD3DDevice); diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index 49f37e2d59..510763f597 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -134,7 +134,8 @@ end_frame() { DisplayRegion dr(this, _x_size, _y_size); RenderBuffer buffer = _gsg->get_render_buffer(get_draw_buffer_type()); - get_texture()->copy(_gsg, &dr, buffer); + TextureContext *tc = get_texture()->prepare_now(_gsg->get_prepared_objects(), _gsg); + _gsg->copy_texture(tc, &dr, buffer); // It appears that the nVidia graphics driver 5.3.0.3, dated // 11/17/2003 will get confused with the above copy operation and