-
-
Save arxae/71ff6c188162d8b2c0d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform sampler2D texture; | |
void main() | |
{ | |
vec4 pixel = texture2D(texture, gl_TexCoord[0].st); | |
gl_FragColor = gl_Color * pixel; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//gl_Position = ftransform(); | |
void main() | |
{ | |
gl_Position = ftransform(); | |
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; | |
gl_FrontColor = gl_Color; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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