public RenderTargetViewControl( ) { InitializeComponent( ); m_Sampler = Graphics.Factory.CreateTexture2dSampler( ); m_Sampler.WrapS = TextureWrap.Repeat; m_Sampler.WrapT = TextureWrap.Repeat; }
/// <summary> /// Default constructor /// </summary> public SpherePlanetRingRenderer( ) { ITexture2d texture = ( ITexture2d )AssetManager.Instance.Load( "Rings\\ring1.jpg" ); m_Texture = Graphics.Factory.CreateTexture2dSampler( ); m_Texture.Texture = texture; m_State = Graphics.Factory.CreateRenderState( ); m_State.Enable2dTextures = true; }
/// <summary> /// Builds this font from a System.Drawing.Font object /// </summary> /// <param name="font">Font to build from</param> /// <param name="characters">Set of characters to build the font texture from</param> /// <returns>Returns this</returns> public void Setup( Font font, FontData.CharacterSet characters ) { Bitmap img = BuildFontImage( font, characters ); img.Save( string.Format( "{0}{1}.png", font.Name, font.Size ), ImageFormat.Png ); m_FontTextureSampler = Graphics.Factory.CreateTexture2dSampler( ); m_FontTextureSampler.Texture = Graphics.Factory.CreateTexture2d( ); m_FontTextureSampler.Texture.Create( img, false ); m_FontTextureSampler.Mode = TextureMode.Modulate; m_FontTextureSampler.MinFilter = TextureFilter.NearestTexel; m_FontTextureSampler.MagFilter = TextureFilter.NearestTexel; }
/// <summary> /// Renders the grid as a texture /// </summary> private void RenderTexture( ) { if ( m_TextureState == null ) { m_TextureState = Graphics.Factory.CreateRenderState( ); m_TextureState.Lighting = false; m_TextureState.Enable2dTextures = true; m_TextureState.Enable2dTextureUnit(0, true ); ITexture2d texture = Graphics.Factory.CreateTexture2d( ); texture.Load( GridSquareBitmap, true, TextureUsage.Normal ); m_Sampler = Graphics.Factory.CreateTexture2dSampler( ); m_Sampler.Texture = texture; m_Sampler.Mode = TextureMode.Replace; m_Sampler.MinFilter = TextureFilter.NearestTexelLinearMipMap; m_Sampler.MagFilter = TextureFilter.NearestTexelLinearMipMap; m_Sampler.WrapS = TextureWrap.Repeat; m_Sampler.WrapT = TextureWrap.Repeat; } // For the moment, let's just render a giant quad with a texture :( // TODO: AP: Render a grid of quads centered on the camera position projected onto the ground plane Graphics.Renderer.PushRenderState( m_TextureState ); m_Sampler.Begin( ); Gl.glBegin( Gl.GL_QUADS ); Gl.glTexCoord2f( MinU, MinV ); Gl.glVertex3f( MinX, Y, MinZ ); Gl.glTexCoord2f( MaxU, MinV ); Gl.glVertex3f( MaxX, Y, MinZ ); Gl.glTexCoord2f( MaxU, MaxV ); Gl.glVertex3f( MaxX, Y, MaxZ ); Gl.glTexCoord2f( MinU, MaxV ); Gl.glVertex3f( MinX, Y, MaxZ ); Gl.glEnd( ); m_Sampler.End( ); Graphics.Renderer.PopRenderState( ); }
public SimpleSpriteRenderer( ) { m_Texture = Graphics.Factory.CreateTexture2dSampler( ); m_Texture.WrapS = TextureWrap.Repeat; m_Texture.WrapT = TextureWrap.Repeat; }
private void TextureForm_Shown( object sender, System.EventArgs e ) { ITexture2d texture; try { TextureLoadParameters parameters = new TextureLoadParameters( true ); texture = ( ITexture2d )AssetManager.Instance.Load( m_FilePath, parameters ); //texture.ToBitmap( false )[ 0 ].Save( "output.png" ); } catch ( Exception ex ) { string msg = string.Format( "Error occurred opening \"{0}\" - {1}", Path.GetFileName( m_FilePath ), ex.Message ); MessageBox.Show( this, msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); Close( ); return; } m_Sampler = Graphics.Factory.CreateTexture2dSampler( ); m_Sampler.Texture = texture; m_Sampler.Mode = TextureMode.Modulate; }