本文整理汇总了C#中GraphicsContext类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsContext类的具体用法?C# GraphicsContext怎么用?C# GraphicsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsContext类属于命名空间,在下文中一共展示了GraphicsContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Filter
public void Filter( GraphicsContext graphics )
{
// Y軸方向へのガウス
// uniform
int idReciprocalTexHeight = shaderGaussianY.FindUniform( "ReciprocalTexHeight" );
if( idReciprocalTexHeight >= 0 ){
shaderGaussianY.SetUniformValue( idReciprocalTexHeight, 1.0f / texScene.Height );
}
int idWeight = shaderGaussianY.FindUniform( "Weight" );
if( idWeight >= 0 ){
shaderGaussianY.SetUniformValue( idWeight, 0, gaussianWeightTable );
}
int idOffset = shaderGaussianY.FindUniform( "Offset" );
if( idOffset >= 0 ){
Vector2 offset = new Vector2( 0.0f, 16.0f / texScene.Height );
shaderGaussianY.SetUniformValue( idOffset, ref offset );
}
// render
FrameBuffer oldBuffer = graphics.GetFrameBuffer();
if( this.Target != null ){
graphics.SetFrameBuffer( this.Target );
}
texRenderer.BindGraphicsContext( graphics );
texRenderer.Begin( shaderGaussianY );
texRenderer.Render( texScene );
texRenderer.End();
if( this.Target != null ){
graphics.SetFrameBuffer( oldBuffer );
}
}
示例2: Sprite
public Sprite(GraphicsContext graphics, Texture2D texture)
{
if(shaderProgram == null)
{
shaderProgram = new ShaderProgram("/Application/shaders/Sprite.cgx");
shaderProgram.SetUniformBinding(0, "u_WorldMatrix");
}
if (texture == null)
{
throw new Exception("ERROR: texture is null.");
}
this.graphics = graphics;
this.texture = texture;
this.width = texture.Width;
this.height = texture.Height;
indices = new ushort[indexSize];
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 3;
vertexBuffer = new VertexBuffer(4, indexSize, VertexFormat.Float3,
VertexFormat.Float2, VertexFormat.Float4);
}
示例3: Main
static void Main(string[] args)
{
graphics = new GraphicsContext(960,544,PixelFormat.Rgba,PixelFormat.Depth16,MultiSampleMode.None);
UISystem.Initialize(graphics);
MainScene scene = new MainScene();
SetupListNum(scene.RootWidget);
scene.SetWidgetLayout(LayoutOrientation.Horizontal);
UISystem.SetScene(scene);
for (; ; )
{
SystemEvents.CheckEvents();
// update
{
List<TouchData> touchDataList = Touch.GetData(0);
var gamePad = GamePad.GetData (0);
UISystem.Update(touchDataList, ref gamePad);
}
// draw
{
graphics.SetViewport(0, 0, graphics.Screen.Width, graphics.Screen.Height);
graphics.SetClearColor(
0xFF,
0xFF,
0xFF,
0xff);
graphics.Clear();
UISystem.Render();
graphics.SwapBuffers();
}
}
}
示例4: Saucer
public Saucer(GraphicsContext g, Texture2D t, Vector3 p, Player pl)
: base(g,t,p, pl)
{
player = pl;
vel= (new Vector3(.5f*(float)gen.Next(3,5),.7f*(float)gen.Next(3,5),0));
graphics=g;
}
示例5: RayTracerWindow
public RayTracerWindow(int width, int height)
{
_nativeWindow = new NativeWindow(width, height, "", GameWindowFlags.Default, GraphicsMode.Default, DisplayDevice.Default);
GraphicsContextFlags flags = GraphicsContextFlags.Default;
#if DEBUG
//flags |= GraphicsContextFlags.Debug;
#endif
_graphicsContext = new GraphicsContext(GraphicsMode.Default, _nativeWindow.WindowInfo, 3, 0, flags);
_graphicsContext.MakeCurrent(_nativeWindow.WindowInfo);
((IGraphicsContextInternal)_graphicsContext).LoadAll(); // wtf is this?
SetInitialStates();
SetViewport();
_nativeWindow.Resize += OnGameWindowResized;
_nativeWindow.Closing += OnWindowClosing;
_nativeWindow.KeyDown += OnKeyDown;
_scene = Scene.TwoPlanes;
_scene.Camera.ReflectionDepth = DefaultReflectionDepth;
SetTitle();
_renderTexture = new RenderTexture(_nativeWindow.Width, _nativeWindow.Height);
_scenes = typeof(Scene).GetProperties()
.Where(pi => pi.PropertyType == typeof(Scene))
.Select(pi => pi.GetValue(null))
.Cast<Scene>().ToList();
}
示例6: PaintVerticalBar
protected override void PaintVerticalBar(GraphicsContext context, SizeF size, SizeF knobSize)
{
var rect = new RectangleF (new PointF (), new SizeF (knobSize.Width, size.Height - knobSize.Height));
var brush = new LinearGradientBrush (rect, Color.Black, Color.Black,
LinearGradientMode.Vertical);
DrawBar (context, brush, rect);
}
示例7: GraphicsContextEventArgs
public GraphicsContextEventArgs(GraphicsContext context)
{
if (context == null)
throw new ArgumentNullException("context");
this.Graphics = context;
}
示例8: InitGL
private void InitGL()
{
windowInfo = Utilities.CreateWindowsWindowInfo(window.Handle);
context = new GraphicsContext(GraphicsMode.Default, windowInfo);
context.MakeCurrent(windowInfo);
context.LoadAll();
}
示例9: Claw
public Claw(GraphicsContext g, Texture2D t, Vector3 p)
: base(g,t,p)
{
graphics = g;
sprite.Position = p;
vel= (new Vector3(0, -1, 0));
}
示例10: DebugString
public DebugString(GraphicsContext graphics, Texture2D texture, int charaWidth, int charaHeight)
{
if(shaderProgram == null)
{
shaderProgram=CreateSimpleSpriteShader();
}
this.graphics = graphics;
this.texture = texture;
this.charaWidth = charaWidth;
this.charaHeight = charaHeight;
charaPositions = new float[maxNumOfCharactor * 4 * 3];
charaTexcoords = new float[maxNumOfCharactor * 4 * 2];
charaColors = new float[maxNumOfCharactor * 4 * 4];
charaIndices = new ushort[maxNumOfCharactor * indexSize];
vertices = new VertexBuffer(maxNumOfCharactor * 4, maxNumOfCharactor * indexSize,
VertexFormat.Float3, VertexFormat.Float2, VertexFormat.Float4);
PixelScreenPosition = new Vector3(0.0f, 0.0f, 0.0f);
ImageRect rectPixelScreen = graphics.GetViewport();
//@j ピクセルの座標系をスクリーンの座標系に変換する行列。
//@e Line to convert a pixel coordinate system into a screen coordinate system.
unitScreenMatrix = new Matrix4(
2.0f/rectPixelScreen.Width, 0.0f, 0.0f, 0.0f,
0.0f, -2.0f/rectPixelScreen.Height, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f
);
}
示例11: InitGraphicsContext
public static void InitGraphicsContext()
{
if (null != sm_GraphicsContext) {
return;
}
sm_GraphicsContext = new GraphicsContext();
}
示例12: Initialize
public static void Initialize()
{
// Set up the graphics system
graphics = new GraphicsContext ();
// Set up background sprite
ImageRect rectScreen = graphics.Screen.Rectangle;
Console.WriteLine("Screen size: " + rectScreen.Width + " x " + rectScreen.Height);
texture = new Texture2D("/Application/resources/bg.png", false);
bgSprite = new Sprite(graphics, texture);
bgSprite.Position.X = 0.0f; //rectScreen.Width/2.0f;
bgSprite.Position.Y = 0.0f; //rectScreen.Height/2.0f;
bgSprite.Position.Z = 0.0f;
patternGrid = new PatternGrid(graphics, texture, new Vector2(240.0f, 144.0f), new Vector2(720.0f, 400.0f));
patternGrid.Update(currentPattern);
textWriter = new Text(graphics, 16.0f);
m_song.Load("/Documents/songs/flowers1.xds");
// Start playback thread
//simStart = false;
playbackThread = new Thread(new ThreadStart(playbackThreadMain));
playbackThread.Start();
}
示例13: Initialize
public static void Initialize ()
{
// Set up the graphics system
graphics = new GraphicsContext ();
#if BUILD_FOR_PSV
program = new ShaderProgram("/Application/shaders/Texture.cgx");
#else
program = new ShaderProgram("/Application/shaders/Texture_sim.cgx");
#endif
program.SetUniformBinding(0, "WorldViewProj");
program.SetAttributeBinding(0, "a_Position");
program.SetAttributeBinding(1, "a_TexCoord");
vertices = new VertexBuffer(4, VertexFormat.Float3, VertexFormat.Float2);
float[] positions = {
-1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
};
float[] texcoords = {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 0.0f,
1.0f, 1.0f,
};
vertices.SetVertices(0, positions);
vertices.SetVertices(1, texcoords);
texture = new Texture2D(256, 224, false, PixelFormat.Rgb565);
SampleDraw.Init(graphics);
}
示例14: Initialize
public static void Initialize()
{
// Set up the graphics system
_graphics = new GraphicsContext ();
_texture = new Texture2D("/Application/32.png", false);
_spriteBatch = new MonoGameSpriteBatch(_graphics, 256);
//_spriteBatch = new MonoGameSpriteBatchNoIndex(_graphics, 256);
//_spriteBatch = new MonoGameSpriteBatchVector3(_graphics, 256);
//_spriteBatch = new MonoGameSpriteBatchUnpacked(_graphics, 256);
//_spriteBatch = new DoubleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256));
//_spriteBatch = new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256));
//_spriteBatch = new DoubleBufferedSpriteBatch(
// new DoubleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)),
// new DoubleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)));
//_spriteBatch = new TripleBufferedSpriteBatch(
// new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)),
// new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)),
// new TripleBufferedSpriteBatch(new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256), new MonoGameSpriteBatch(_graphics, 256)));
//_spriteBatch2 = new MonoGameSpriteBatch(_graphics, 256);
}
示例15: Filter
/// フィルタ処理の実行
public void Filter( GraphicsContext graphics )
{
texRenderer.BindGraphicsContext( graphics );
FrameBuffer oldBuffer = graphics.GetFrameBuffer();
bool isSwap = false;
int width = oldBuffer.Width;
int height = oldBuffer.Height;
if( this.Target != null ){
graphics.SetFrameBuffer( this.Target );
width = this.Target.Width;
height = this.Target.Height;
isSwap = true;
}
graphics.SetViewport( 0, 0, width, height );
texRenderer.Begin( shaderDOF );
graphics.SetTexture( 2, texDepth );
texRenderer.Render( texScene,
texBlur,
0, 0, 0, 0, width, height );
texRenderer.End();
if( isSwap ){
graphics.SetFrameBuffer( oldBuffer );
}
}