Skip to content

Instantly share code, notes, and snippets.

@arxae

arxae/Program.cs Secret

Last active December 24, 2015 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arxae/71ff6c188162d8b2c0d8 to your computer and use it in GitHub Desktop.
Save arxae/71ff6c188162d8b2c0d8 to your computer and use it in GitHub Desktop.
uniform sampler2D texture;
void main()
{
vec4 pixel = texture2D(texture, gl_TexCoord[0].st);
gl_FragColor = gl_Color * pixel;
}
//gl_Position = ftransform();
void main()
{
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
}
using System;
using System.Diagnostics;
using System.IO;
using SFML.Graphics;
using SFML.Window;
using Color = SFML.Graphics.Color;
namespace ArxGame
{
public static class Program
{
private static readonly Color CornflowerBlue = new Color( 100, 149, 237 );
public static void Main(string[] args)
{
RenderWindow window = new RenderWindow( new VideoMode( 800, 600 ), "SFML Window" );
window.SetVerticalSyncEnabled( true );
window.Closed += (sender, eventArgs) => window.Close();
Texture texture = new Texture( "media/dude.png" );
Sprite _spr = new Sprite( texture );
uint tWidth = texture.Size.X;
uint tHeight = texture.Size.Y;
Vertex v1 = new Vertex( new Vector2f( 0, 0 ) );
Vertex v2 = new Vertex( new Vector2f( tWidth, 0 ) );
Vertex v3 = new Vertex( new Vector2f( tWidth, tHeight ) );
Vertex v4 = new Vertex( new Vector2f( 0, tHeight ) );
v1.TexCoords = new Vector2f( 0, 0 );
v2.TexCoords = new Vector2f( tWidth, 0 );
v3.TexCoords = new Vector2f( tWidth, tHeight );
v4.TexCoords = new Vector2f( 0, tHeight );
VertexArray varr = new VertexArray( PrimitiveType.Quads );
varr.Append( v1 );
varr.Append( v2 );
varr.Append( v3 );
varr.Append( v4 );
Shader shader = new Shader( "media/shaders/basic.vert", "media/shaders/basic.frag" );
shader.SetParameter( "texture", texture );
RenderStates rState = new RenderStates( shader );
while ( window.IsOpen() )
{
window.DispatchEvents();
window.Clear(CornflowerBlue);
window.Draw( varr, rState );
window.Display();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment