00001
00002
00003 This file is subject to the terms and conditions of the GNU Lesser
00004 General Public License Version 2.1. See the file "COPYING" in the
00005 main directory of this archive for more details. */
00006
00007 #include "ps2gl/texture.h"
00008
00009 #include "GL/ps2gl.h"
00010
00011 #include "ps2gl/debug.h"
00012 #include "ps2gl/glcontext.h"
00013 #include "ps2gl/dlist.h"
00014 #include "ps2gl/immgmanager.h"
00015 #include "ps2gl/dlgmanager.h"
00016 #include "ps2gl/metrics.h"
00017
00018
00019 * CTexManager
00020 */
00021
00022 CTexManager::CTexManager( CGLContext &context )
00023 : GLContext(context), IsTexEnabled(false), InsideDListDef(false),
00024 Cursor(0), LastTexSent(NULL),
00025 CurClut(NULL),
00026 TexMode(GS::TexMode::kModulate)
00027 {
00028
00029 for ( int i = 0; i < NumTexNames; i++ )
00030 TexNames[i] = NULL;
00031
00032
00033 DefaultTex = new CMMTexture( GS::kContext1 );
00034 CurTexture = DefaultTex;
00035 }
00036
00037 CTexManager::~CTexManager()
00038 {
00039 delete DefaultTex;
00040 if ( CurClut ) delete CurClut;
00041
00042 for ( int i = 0; i < NumTexNames; i++ ) {
00043 if (TexNames[i]) delete TexNames[i];
00044 }
00045 }
00046
00047 class CSetTexEnabledCmd : public CDListCmd {
00048 bool IsEnabled;
00049 public:
00050 CSetTexEnabledCmd( bool enabled ) : IsEnabled(enabled) {}
00051 CDListCmd* Play() {
00052 pGLContext->GetTexManager().SetTexEnabled(IsEnabled);
00053 return CDListCmd::GetNextCmd(this);
00054 }
00055 };
00056
00057 void
00058 CTexManager::SetTexEnabled( bool yesNo )
00059 {
00060 if (! InsideDListDef) {
00061 if ( IsTexEnabled != yesNo ) {
00062 GLContext.TexEnabledChanged();
00063 GLContext.GetImmGeomManager().GetRendererManager().TexEnabledChanged(yesNo);
00064 IsTexEnabled = yesNo;
00065 }
00066 }
00067 else {
00068 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00069 dlist += CSetTexEnabledCmd( yesNo );
00070 GLContext.TexEnabledChanged();
00071 }
00072 }
00073
00074 class CSetTexModeCmd : public CDListCmd {
00075 GS::tTexMode Mode;
00076 public:
00077 CSetTexModeCmd( GS::tTexMode mode ) : Mode(mode) {}
00078 CDListCmd* Play() {
00079 pGLContext->GetTexManager().SetTexMode(Mode);
00080 return CDListCmd::GetNextCmd(this);
00081 }
00082 };
00083
00084 void
00085 CTexManager::SetTexMode( GS::tTexMode mode )
00086 {
00087 if ( ! InsideDListDef )
00088 TexMode = mode;
00089 else {
00090 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00091 dlist += CSetTexModeCmd( mode );
00092 }
00093 }
00094
00095 void
00096 CTexManager::GenTextures( GLsizei numNewTexNames, GLuint *newTexNames )
00097 {
00098 for ( int curTexName = 0; curTexName < numNewTexNames; curTexName++ ) {
00099
00100 int i;
00101 for ( i = 0; i < NumTexNames; i++ ) {
00102
00103 if ( Cursor != 0 && TexNames[Cursor] == NULL ) break;
00104
00105 IncCursor();
00106 }
00107
00108 if ( i == NumTexNames ) {
00109 mError("No free texture names. Time to write a less braindead tex manager.");
00110
00111
00112 while(i < NumTexNames) {
00113 newTexNames[i] = 0;
00114 ++i;
00115 }
00116 } else {
00117 newTexNames[curTexName] = Cursor;
00118 IncCursor();
00119 }
00120 }
00121 }
00122
00123 void
00124 CTexManager::UseCurTexture( CVifSCDmaPacket &renderPacket )
00125 {
00126 if ( IsTexEnabled ) {
00127 GS::tPSM psm = CurTexture->GetPSM();
00128
00129 if ( psm == GS::kPsm8 || psm == GS::kPsm8h ) {
00130 mErrorIf( CurClut == NULL,
00131 "Trying to use an indexed-color texture with no color table given!" );
00132 CurClut->Load( renderPacket );
00133 }
00134
00135 CurTexture->SetTexMode( TexMode );
00136 if ( CurTexture->GetPSM() == GS::kPsm8
00137 || CurTexture->GetPSM() == GS::kPsm8h )
00138 CurTexture->SetClut( *CurClut );
00139 CurTexture->Use( renderPacket );
00140 }
00141 }
00142
00143 class CBindTextureCmd : public CDListCmd {
00144 unsigned int TexName;
00145 public:
00146 CBindTextureCmd( unsigned int name ) : TexName(name) {}
00147 CDListCmd* Play() {
00148 pGLContext->GetTexManager().BindTexture(TexName);
00149 return CDListCmd::GetNextCmd(this);
00150 }
00151 };
00152
00153 void
00154 CTexManager::BindTexture( GLuint texNameToBind )
00155 {
00156 GLContext.TextureChanged();
00157
00158 if ( ! InsideDListDef ) {
00159 if ( texNameToBind == 0 ) {
00160
00161 CurTexture = DefaultTex;
00162 }
00163 else {
00164 if ( TexNames[texNameToBind] == NULL )
00165 TexNames[texNameToBind] = new CMMTexture( GS::kContext1 );
00166 CurTexture = TexNames[texNameToBind];
00167 }
00168
00169 pglAddToMetric(kMetricsBindTexture);
00170 }
00171 else {
00172 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00173 dlist += CBindTextureCmd( texNameToBind );
00174 }
00175 }
00176
00177 void
00178 CTexManager::DeleteTextures( GLsizei numToDelete, const GLuint *texNames )
00179 {
00180 for ( int i = 0; i < numToDelete; i++ ) {
00181 mErrorIf( TexNames[texNames[i]] == NULL,
00182 "Trying to delete a texture that doesn't exist!" );
00183 GLuint texName = texNames[i];
00184 if ( CurTexture == TexNames[texName] )
00185 CurTexture = DefaultTex;
00186 delete TexNames[texName];
00187 TexNames[texName] = NULL;
00188 }
00189 }
00190
00191 class CSetCurTexParamCmd : public CDListCmd {
00192 GLenum PName;
00193 int Param;
00194 public:
00195 CSetCurTexParamCmd( GLenum pname, int param ) : PName(pname), Param(param) {}
00196 CDListCmd* Play() {
00197 pGLContext->GetTexManager().SetCurTexParam(PName, Param);
00198 return CDListCmd::GetNextCmd(this);
00199 }
00200 };
00201
00202 void
00203 CTexManager::SetCurTexParam( GLenum pname, GLint param )
00204 {
00205 if ( ! InsideDListDef ) {
00206 CMMTexture &tex = *CurTexture;
00207
00208 switch( pname ) {
00209 case GL_TEXTURE_MIN_FILTER:
00210 tex.SetMinMode( (GS::tMinMode)(param & 0xf) );
00211 break;
00212 case GL_TEXTURE_MAG_FILTER:
00213 tex.SetMagMode( (GS::tMagMode)(param & 0xf) );
00214 break;
00215 case GL_TEXTURE_MIN_LOD:
00216 case GL_TEXTURE_MAX_LOD:
00217 case GL_TEXTURE_BASE_LEVEL:
00218 case GL_TEXTURE_MAX_LEVEL:
00219 case GL_TEXTURE_PRIORITY:
00220 case GL_TEXTURE_BORDER_COLOR:
00221 mNotImplemented( );
00222 break;
00223 case GL_TEXTURE_WRAP_S:
00224 tex.SetWrapModeS( (GS::tTexWrapMode)(param & 0xf) );
00225 break;
00226 case GL_TEXTURE_WRAP_T:
00227 tex.SetWrapModeT( (GS::tTexWrapMode)(param & 0xf) );
00228 break;
00229 case GL_TEXTURE_WRAP_R:
00230 mNotImplemented( "Sorry, only 2d textures." );
00231 break;
00232 }
00233 }
00234 else {
00235 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00236 dlist += CSetCurTexParamCmd(pname, param);
00237 }
00238 }
00239
00240 class CSetCurTexImageCmd : public CDListCmd {
00241 tU128 *Image;
00242 unsigned int Width, Height;
00243 GS::tPSM Psm;
00244 public:
00245 CSetCurTexImageCmd( tU128 *image, unsigned int w, unsigned int h,
00246 GS::tPSM psm )
00247 : Image(image), Width(w), Height(h), Psm(psm) {}
00248 CDListCmd* Play() {
00249 pGLContext->GetTexManager().SetCurTexImage( Image, Width, Height, Psm );
00250 return CDListCmd::GetNextCmd(this);
00251 }
00252 };
00253
00254 void
00255 CTexManager::SetCurTexImage( tU128* imagePtr, tU32 w, tU32 h,
00256 GS::tPSM psm )
00257 {
00258 GLContext.TextureChanged();
00259
00260 if ( ! InsideDListDef ) {
00261 CurTexture->SetImage( imagePtr, w, h, psm );
00262 if ( psm != GS::kPsm24 )
00263 CurTexture->SetUseTexAlpha( true );
00264 else
00265 CurTexture->SetUseTexAlpha( false );
00266
00267 CurTexture->Free();
00268 }
00269 else {
00270 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00271 dlist += CSetCurTexImageCmd( imagePtr, w, h, psm );
00272 }
00273 }
00274
00275 class CSetCurClutCmd : public CDListCmd {
00276 const void *Clut;
00277 int NumEntries;
00278 public:
00279 CSetCurClutCmd( const void *clut, int numEntries )
00280 : Clut(clut), NumEntries(numEntries) {}
00281 CDListCmd* Play() {
00282 pGLContext->GetTexManager().SetCurClut(Clut, NumEntries);
00283 return CDListCmd::GetNextCmd(this);
00284 }
00285 };
00286
00287 void
00288 CTexManager::SetCurClut( const void *clut, int numEntries )
00289 {
00290 GLContext.TextureChanged();
00291
00292 if ( ! InsideDListDef ) {
00293 CMMClut *temp = CurClut;
00294 CurClut = new CMMClut( clut );
00295 if ( temp ) delete temp;
00296 }
00297 else {
00298 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00299 dlist += CSetCurClutCmd( clut, numEntries );
00300 }
00301 }
00302
00303 class CSetGsTextureCmd : public CDListCmd {
00304 GS::CMemArea &Texture;
00305 public:
00306 CSetGsTextureCmd(GS::CMemArea &tex) : Texture(tex) {}
00307 CDListCmd* Play() {
00308 pGLContext->GetTexManager().SetGsTexture(Texture);
00309 return CDListCmd::GetNextCmd(this);
00310 }
00311 };
00312
00313 void
00314 CTexManager::SetGsTexture( GS::CMemArea &area )
00315 {
00316 GLContext.TextureChanged();
00317
00318 if ( ! InsideDListDef )
00319 CurTexture->SetImage( area );
00320 else {
00321 CDList &dlist = GLContext.GetDListManager().GetOpenDList();
00322 dlist += CSetGsTextureCmd(area);
00323 }
00324 }
00325
00326
00327 * CMMTexture methods
00328 */
00329
00330 CMMTexture::CMMTexture( GS::tContext context )
00331 : CTexture( context ), pImageMem(NULL), XferImage(false), IsResident(false)
00332 {
00333
00334
00335
00336
00337 SetClutLoadConditions(1);
00338 }
00339
00340 CMMTexture::~CMMTexture()
00341 {
00342 delete pImageMem;
00343 }
00344
00348 void
00349 CMMTexture::SetImage( tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm )
00350 {
00351 if ( pImageMem ) {
00352
00353 delete pImageMem;
00354 CTexture::Reset();
00355 }
00356
00357 CTexture::SetImage( imagePtr, w, h, psm, NULL );
00358
00359
00360 tU32 bufWidth = gsrTex0.TBW * 64;
00361 pImageMem = new GS::CMemArea( bufWidth, h, psm, GS::kAlignBlock );
00362
00363 XferImage = true;
00364 }
00365
00370 void
00371 CMMTexture::SetImage( const GS::CMemArea &area )
00372 {
00373 CTexEnv::SetPSM( area.GetPixFormat() );
00374 CTexEnv::SetDimensions( area.GetWidth(), area.GetHeight() );
00375 SetImageGsAddr( area.GetWordAddr() );
00376
00377 XferImage = false;
00378 }
00379
00380 void
00381 CMMTexture::ChangePsm( GS::tPSM psm )
00382 {
00383
00384
00385 using namespace GS;
00386
00387
00388
00389 if ( GS::GetBitsPerPixel(psm) == GS::GetBitsPerPixel(GetPSM()) ) {
00390
00391 CTexEnv::SetPSM(psm);
00392 pImageUploadPkt->ChangePsm(psm);
00393 }
00394 else {
00395
00396
00397 int bpp = GS::GetBitsPerPixel(GetPSM());
00398 if ( bpp == 8 && GetPSM() == GS::kPsm8h ) {
00399
00400 ChangePsm(GS::kPsm8);
00401 }
00402 else if ( bpp == 4 && GetPSM() != GS::kPsm4 ) {
00403
00404 ChangePsm(GS::kPsm4);
00405 }
00406 else {
00407
00408 }
00409 }
00410 }
00411
00412 void
00413 CMMTexture::Load( bool waitForEnd = true )
00414 {
00415 mErrorIf( pImageMem == NULL,
00416 "Trying to load a texture that hasn't been defined!" );
00417
00418 if ( ! pImageMem->IsAllocated() ) {
00419 pImageMem->Alloc();
00420 if ( GetPSM() != pImageMem->GetPixFormat() )
00421 ChangePsm(pImageMem->GetPixFormat());
00422 SetImageGsAddr( pImageMem->GetWordAddr() );
00423 IsResident = false;
00424 }
00425 if ( ! IsResident ) {
00426 #ifndef PS2_LINUX
00427 FlushCache(0);
00428 #endif
00429
00430 SendImage( waitForEnd, Packet::kDontFlushCache );
00431 IsResident = true;
00432
00433 pglAddToMetric(kMetricsTextureUploadCount);
00434 }
00435 }
00436
00437
00438
00439 void
00440 CMMTexture::Load( CSCDmaPacket& packet )
00441 {
00442 mErrorIf( pImageMem == NULL,
00443 "Trying to load a texture that hasn't been defined!" );
00444 if ( ! pImageMem->IsAllocated() ) {
00445 pImageMem->Alloc();
00446 if ( GetPSM() != pImageMem->GetPixFormat() )
00447 ChangePsm(pImageMem->GetPixFormat());
00448 SetImageGsAddr( pImageMem->GetWordAddr() );
00449 IsResident = false;
00450 }
00451 if ( ! IsResident ) {
00452 SendImage( packet );
00453 IsResident = true;
00454
00455 pglAddToMetric(kMetricsTextureUploadCount);
00456 }
00457 }
00458 void
00459 CMMTexture::Load( CVifSCDmaPacket& packet )
00460 {
00461 mErrorIf( pImageMem == NULL,
00462 "Trying to load a texture that hasn't been defined!" );
00463 if ( ! pImageMem->IsAllocated() ) {
00464 pImageMem->Alloc();
00465 if ( GetPSM() != pImageMem->GetPixFormat() )
00466 ChangePsm(pImageMem->GetPixFormat());
00467 SetImageGsAddr( pImageMem->GetWordAddr() );
00468 IsResident = false;
00469 }
00470 if ( ! IsResident ) {
00471
00472
00473
00474 SendImage( packet );
00475 IsResident = true;
00476
00477 pglAddToMetric(kMetricsTextureUploadCount);
00478 }
00479 }
00480
00481
00482
00483 void
00484 CMMTexture::Use( bool waitForEnd = false )
00485 {
00486 if ( XferImage ) Load();
00487 SendSettings( waitForEnd, Packet::kDontFlushCache );
00488 }
00489 void
00490 CMMTexture::Use( CSCDmaPacket& packet )
00491 {
00492 if ( XferImage ) Load( packet );
00493 SendSettings( packet );
00494 }
00495 void
00496 CMMTexture::Use( CVifSCDmaPacket& packet )
00497 {
00498 if ( XferImage ) Load( packet );
00499 SendSettings( packet );
00500 }
00501
00502 void
00503 CMMTexture::Free( void )
00504 {
00505 pImageMem->Free();
00506 IsResident = false;
00507 }
00508
00509 void
00510 CMMTexture::BindToSlot( GS::CMemSlot &slot )
00511 {
00512
00513
00514
00515
00516
00517 }
00518
00519
00520 * CMMClut
00521 */
00522
00523 void
00524 CMMClut::Load( CVifSCDmaPacket &packet )
00525 {
00526 if ( ! GsMem.IsAllocated() ) {
00527 GsMem.Alloc();
00528 SetGsAddr( GsMem.GetWordAddr() );
00529 Send(packet);
00530
00531 pglAddToMetric(kMetricsClutUploadCount);
00532 }
00533 }
00534
00535
00536 * gl api
00537 */
00538
00539 void glGenTextures( GLsizei numNewTexNames, GLuint *newTexNames )
00540 {
00541 CTexManager &texManager = pGLContext->GetTexManager();
00542 texManager.GenTextures( numNewTexNames, newTexNames );
00543 }
00544
00545 void glBindTexture( GLenum target, GLuint texName )
00546 {
00547 mErrorIf( target != GL_TEXTURE_2D, "There are only 2D textures in ps2gl" );
00548
00549 CTexManager &texManager = pGLContext->GetTexManager();
00550 texManager.BindTexture( texName );
00551 }
00552
00553 void glDeleteTextures( GLsizei numToDelete, const GLuint *texNames )
00554 {
00555 CTexManager &texManager = pGLContext->GetTexManager();
00556 texManager.DeleteTextures( numToDelete, texNames );
00557 }
00558
00559 void glTexImage2D( GLenum target,
00560 GLint level,
00561 GLint internalFormat,
00562 GLsizei width,
00563 GLsizei height,
00564 GLint border,
00565 GLenum format,
00566 GLenum type,
00567 const GLvoid *pixels )
00568 {
00569 if ( target == GL_PROXY_TEXTURE_2D ) {
00570 mNotImplemented( );
00571 return;
00572 }
00573 if ( level > 0 ) {
00574 mNotImplemented("mipmapping");
00575 return;
00576 }
00577 if ( border > 0 ) {
00578 mNotImplemented("texture borders");
00579 return;
00580 }
00581 if ( (unsigned int)pixels & 0xf ) {
00582 mNotImplemented( "texture data needs to be aligned to at least 16 bytes, "
00583 "preferably 9 quads" );
00584 }
00585
00586 GS::tPSM psm = GS::kInvalidPsm;
00587 switch (format) {
00588 case GL_RGBA:
00589 if ( type == GL_UNSIGNED_BYTE ||
00590 type == GL_UNSIGNED_INT_8_8_8_8 )
00591 psm = GS::kPsm32;
00592 else if ( type == GL_UNSIGNED_SHORT_5_5_5_1 )
00593 psm = GS::kPsm16;
00594 else {
00595 mNotImplemented( "RGBA textures should have a type of GL_UNSIGNED_BYTE, "
00596 "GL_UNSIGNED_INT_8_8_8_8, or GL_UNSIGNED_SHORT_5_5_5_1" );
00597 }
00598 break;
00599 case GL_RGB:
00600 if ( type == GL_UNSIGNED_BYTE )
00601 psm = GS::kPsm24;
00602 else {
00603 mNotImplemented( "RGB textures should have a type of GL_UNSIGNED_BYTE" );
00604 }
00605 break;
00606 case GL_COLOR_INDEX:
00607 if ( type == GL_UNSIGNED_BYTE )
00608 psm = GS::kPsm8;
00609 else {
00610 mNotImplemented( "indexed textures should have a type of GL_UNSIGNED_BYTE" );
00611 }
00612 break;
00613 default:
00614 mError( "Unknown texture format" );
00615 }
00616
00617 if ( psm != GS::kInvalidPsm ) {
00618 CTexManager& tm = pGLContext->GetTexManager();
00619 tm.SetCurTexImage( (tU128*)pixels, width, height, psm );
00620 }
00621 }
00622
00623 void glColorTable( GLenum target, GLenum internalFormat,
00624 GLsizei width, GLenum format, GLenum type,
00625 const GLvoid *table )
00626 {
00627 mWarnIf( target != GL_COLOR_TABLE,
00628 "glColorTable only supports GL_COLOR_TABLE" );
00629
00630 mErrorIf( width != 16 && width != 256,
00631 "A color table must contain either 16 or 256 entries" );
00632 mErrorIf( format != GL_RGB && format != GL_RGBA,
00633 "The pixel format of color tables must be either GL_RGB or GL_RGBA" );
00634 mWarnIf( type != GL_UNSIGNED_INT && type != GL_UNSIGNED_INT_8_8_8_8,
00635 "The type of color table data must be either GL_UNSIGNED_INT or"
00636 "GL_UNSIGNED_INT_8_8_8_8" );
00637 mErrorIf( (unsigned int)table & (16-1),
00638 "Color tables in ps2gl need to be 16-byte aligned in memory.." );
00639
00640 CTexManager& tm = pGLContext->GetTexManager();
00641 tm.SetCurClut( table, width );
00642 }
00643
00644 void glTexParameteri( GLenum target, GLenum pname, GLint param )
00645 {
00646 if ( target != GL_TEXTURE_2D ) {
00647 mNotImplemented( "Sorry, only 2d textures." );
00648 return;
00649 }
00650
00651 pGLContext->GetTexManager().SetCurTexParam( pname, param );
00652 }
00653
00654 void glTexParameterf( GLenum target, GLenum pname, GLfloat param )
00655 {
00656 glTexParameteri( target, pname, (GLint)param );
00657 }
00658
00659 void glTexParameteriv( GLenum target, GLenum pname, GLint *param )
00660 {
00661 glTexParameteri( target, pname, *param );
00662 }
00663
00664 void glTexParameterfv( GLenum target, GLenum pname, const GLfloat *param )
00665 {
00666 glTexParameteri( target, pname, (GLint)*param );
00667 }
00668
00669 void glTexEnvi( GLenum target, GLenum pname, GLint param )
00670 {
00671 CTexManager &tm = pGLContext->GetTexManager();
00672
00673 switch( param ) {
00674 case GL_MODULATE:
00675 tm.SetTexMode( (GS::tTexMode)(param & 0xf) );
00676 break;
00677 case GL_DECAL:
00678 mWarn( "GL_DECAL functions exactly as GL_REPLACE right now." );
00679 case GL_REPLACE:
00680 tm.SetTexMode( (GS::tTexMode)(param & 0xf) );
00681 break;
00682 case GL_BLEND:
00683 mNotImplemented( );
00684 break;
00685 }
00686 }
00687
00688 void glTexEnvf( GLenum target, GLenum pname, GLfloat param )
00689 {
00690 glTexEnvi( target, pname, (GLint)param );
00691 }
00692
00693 void glTexEnvfv( GLenum target, GLenum pname, GLfloat *param )
00694 {
00695 glTexEnvi( target, pname, (GLint)*param );
00696 }
00697
00698 void glTexEnviv( GLenum target, GLenum pname, GLint *param )
00699 {
00700 glTexEnvi( target, pname, *param );
00701 }
00702
00703 void glTexSubImage2D( GLenum target, int level,
00704 int xoffset, int yoffset, int width, int height,
00705 GLenum format, GLenum type,
00706 const void* pixels )
00707 {
00708 mNotImplemented( );
00709 }
00710
00711 void glCopyTexImage2D( GLenum target, int level,
00712 GLenum iformat,
00713 int x, int y, int width, int height,
00714 int border )
00715 {
00716 mNotImplemented( );
00717 }
00718
00719 void glCopyTexSubImage2D( GLenum target, int level,
00720 int xoffset, int yoffset, int x, int y,
00721 int width, int height )
00722 {
00723 mNotImplemented( );
00724 }
00725
00726
00727 * ps2gl C interface
00728 */
00729
00739 void
00740 pglFreeTexture( GLuint texId )
00741 {
00742 CTexManager &texManager = pGLContext->GetTexManager();
00743 CMMTexture &texture = texManager.GetNamedTexture(texId);
00744 texture.Free();
00745 }
00746
00752 void
00753 pglBindTextureToSlot( GLuint texId, pgl_slot_handle_t mem_slot )
00754 {
00755 CTexManager &texManager = pGLContext->GetTexManager();
00756 CMMTexture &texture = texManager.GetNamedTexture(texId);
00757 texture.BindToSlot( *reinterpret_cast<GS::CMemSlot*>(mem_slot) );
00758 }
00759
00765 void pglTextureFromGsMemArea( pgl_area_handle_t tex_area_handle )
00766 {
00767 CTexManager &texManager = pGLContext->GetTexManager();
00768 GS::CMemArea *texArea = reinterpret_cast<GS::CMemArea*>(tex_area_handle);
00769 texManager.SetGsTexture( *texArea );
00770 }
00771