public bool Resume() { if (_isSetup == false) { _ctx = new MGLContext(); _ctx.Clut = new MGLClut(this, _ctx); _ctx.TextureCache = new MGLTextureCache(this, _ctx); this.SetupGL(); this.SetupLists(); this.SetupWorker(); _isSetup = true; } //if( _thread == nullptr ) // this->StartThread(); //if( _props->HasChanged == false ) // return true; //Log::WriteLine( Verbosity::Normal, Feature::Video, "video mode change" ); //_currentProps = ( DisplayProperties^ )_props->Clone(); //_props->HasChanged = false; //_currentProps->HasChanged = false; return(true); }
public MGLClut( MGLDriver driver, MGLContext ctx ) { _driver = driver; _ctx = ctx; }
public MGLTextureCache(MGLDriver driver, MGLContext ctx) { _driver = driver; _ctx = ctx; _values = new FastLinkedList <MGLTexture>(); }
public MGLClut(MGLDriver driver, MGLContext ctx) { _driver = driver; _ctx = ctx; }
public MGLTextureCache( MGLDriver driver, MGLContext ctx ) { _driver = driver; _ctx = ctx; _values = new FastLinkedList<MGLTexture>(); }
public bool Resume() { if( _isSetup == false ) { _ctx = new MGLContext(); _ctx.Clut = new MGLClut( this, _ctx ); _ctx.TextureCache = new MGLTextureCache( this, _ctx ); this.SetupGL(); this.SetupLists(); this.SetupWorker(); _isSetup = true; } //if( _thread == nullptr ) // this->StartThread(); //if( _props->HasChanged == false ) // return true; //Log::WriteLine( Verbosity::Normal, Feature::Video, "video mode change" ); //_currentProps = ( DisplayProperties^ )_props->Clone(); //_props->HasChanged = false; //_currentProps->HasChanged = false; return true; }
public static MGLTexture LoadTexture(MGLDriver driver, MGLContext ctx, MGLTextureInfo info, uint checksum) { uint width = info.Width; uint lineWidth = info.LineWidth; uint height = info.Height; MGLTexture texture = new MGLTexture(); texture.PixelStorage = info.PixelStorage; texture.Address = info.Address; texture.LineWidth = lineWidth; texture.Width = width; texture.Height = height; texture.Checksum = checksum; texture.ClutPointer = ctx.Clut.Pointer; texture.ClutChecksum = ctx.Clut.Checksum; int textureId; Gl.glGenTextures(1, out textureId); Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureId); texture.TextureID = textureId; byte * address = driver.MemorySystem.Translate(info.Address); TextureFormat format = TextureFormats[( int )info.PixelStorage]; uint size = lineWidth * height * format.Size; fixed(byte *unswizzleBuffer = &_unswizzleBuffer[0]) fixed(byte *decodeBuffer = &_decodeBuffer[0]) { bool needRowLength = false; byte *buffer = address; if (ctx.TexturesSwizzled == true) { buffer = Unswizzle(format, buffer, unswizzleBuffer, lineWidth, height); } switch (texture.PixelStorage) { case TexturePixelStorage.BGR5650: texture.Checksum = ColorOperations.DecodeBGR5650(buffer, decodeBuffer, lineWidth * height); buffer = decodeBuffer; break; case TexturePixelStorage.ABGR5551: texture.Checksum = ColorOperations.DecodeABGR5551(buffer, decodeBuffer, lineWidth * height); buffer = decodeBuffer; break; case TexturePixelStorage.ABGR4444: texture.Checksum = ColorOperations.DecodeABGR4444(buffer, decodeBuffer, lineWidth * height); buffer = decodeBuffer; break; case TexturePixelStorage.ABGR8888: // Pass through needRowLength = true; break; case TexturePixelStorage.Indexed4: ctx.Clut.Decode4(buffer, decodeBuffer, width, height, lineWidth); buffer = decodeBuffer; break; case TexturePixelStorage.Indexed8: ctx.Clut.Decode8(buffer, decodeBuffer, width, height, lineWidth); buffer = decodeBuffer; break; case TexturePixelStorage.Indexed16: ctx.Clut.Decode16(buffer, decodeBuffer, width, height, lineWidth); buffer = decodeBuffer; break; case TexturePixelStorage.Indexed32: ctx.Clut.Decode32(buffer, decodeBuffer, width, height, lineWidth); buffer = decodeBuffer; break; case TexturePixelStorage.DXT1: case TexturePixelStorage.DXT3: case TexturePixelStorage.DXT5: // Not yet implemented Debug.Assert(false); break; } // TODO: eliminate these //Gl.glPixelStorei( Gl.GL_UNPACK_ALIGNMENT, 4 ); //if( needRowLength == true ) // Gl.glPixelStorei( Gl.GL_UNPACK_ROW_LENGTH, ( int )lineWidth ); //else // Gl.glPixelStorei( Gl.GL_UNPACK_ROW_LENGTH, ( int )width ); Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, ( int )width, ( int )height, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, ( IntPtr )buffer); // Set cookie //texture.CookieOriginal = *( ( uint* )address ); //texture.Cookie = ( uint )textureId; //*( ( uint* )address ) = ( uint )textureId; // Calculate checksum if needed if (texture.Checksum == 0) { texture.Checksum = MGLTexture.CalculateChecksum(address, width, height, texture.PixelStorage); } } return(texture); }