本文整理匯總了C#中OpenTK.OpenTK類的典型用法代碼示例。如果您正苦於以下問題:C# OpenTK類的具體用法?C# OpenTK怎麽用?C# OpenTK使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OpenTK類屬於OpenTK命名空間,在下文中一共展示了OpenTK類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Draw
public static void Draw(OpenTK.Graphics.Color4 color, Vector3 position, bool cpupiece)
{
if(!Loaded)
Load();
GL.PushMatrix();
Matrix4 translation = Matrix4.CreateTranslation(position) * LotusWindow.me.view * LotusWindow.me.proj;
GL.LoadMatrix(ref translation);
GL.Enable(EnableCap.Texture2D);
if(!cpupiece)
GL.BindTexture(TextureTarget.Texture2D, TextureLoader.get().getTexture("piece"));
else
GL.BindTexture(TextureTarget.Texture2D, TextureLoader.get().getTexture("aipiece"));
GL.Begin(BeginMode.TriangleStrip);
GL.Color4(color);
GL.TexCoord2(new OpenTK.Vector2d(1, 0));
GL.Vertex3(0, 0, 0);
GL.TexCoord2(new OpenTK.Vector2d(0, 0));
GL.Vertex3(32, 0, 0);
GL.TexCoord2(new OpenTK.Vector2d(1, 1f));
GL.Vertex3(0, 32, 0);
GL.TexCoord2(new OpenTK.Vector2d(0, 1f));
GL.Vertex3(32, 32, 0);
GL.End();
GL.PopMatrix();
}
示例2: mouse_ButtonUp
void mouse_ButtonUp(object sender, OpenTK.Input.MouseButtonEventArgs e)
{
MouseButton button = (MouseButton)e.Button;
Vector2 position = new Vector2(e.X, e.Y);
root.OnMouseUpEvent(new MouseButtonEventArgs(button, position, GetModifierKeys()));
}
示例3: draw
public override void draw(OpenTK.Matrix4 cam)
{
base.draw(cam);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, this.frameBuffer);
GL.Viewport(0, 0, (int)bufferResolution.X, (int)bufferResolution.Y);
GL.Clear(ClearBufferMask.ColorBufferBit);
coronaShader.Use();
coronaShader.setUniform("iResolution", this.bufferResolution.X, this.bufferResolution.Y);
coronaShader.setUniform("iGlobalTime", this.frameBufferTime);
coronaShader.bindBufferToShaderAttrib<float>(bufferVerts, "vertIn");
bufferElems.bind();
GL.DrawElements(PrimitiveType.Quads, bufferElems.Size, DrawElementsType.UnsignedShort, 0);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
GL.Viewport(0, 0, (int)Form1.resolution.X, (int)Form1.resolution.Y);
billboardShader.Use();
billboardShader.setUniform("view", cam);
billboardShader.setUniform("proj", Form1.projectionMatrix);
billboardShader.setUniform("model", this.transform);
billboardShader.setUniform("scale", this.Scale * scaleFactor);
billboardShader.setUniform("center", this.Position);
billboardShader.setUniform("up", new Vector3(0,1,0));
billboardShader.bindBufferToShaderAttrib<float>(squareVerts, "vertIn");
billboardShader.bindBufferToShaderAttrib<float>(squareUvs, "uvIn", 2);
squareElems.bind();
GL.BindTexture(TextureTarget.Texture2D, this.bufferTexture);
GL.DrawElements(PrimitiveType.Quads, squareElems.Size, DrawElementsType.UnsignedShort, 0);
this.frameBufferTime += .005f;
}
示例4: OnRenderFrame
public override void OnRenderFrame(OpenTK.FrameEventArgs e, GameWindow window)
{
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, 1280, 0,720,0,1);
GL.Disable(EnableCap.DepthTest);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.ClearColor(0.2f , 0.2f, 0.2f, 0);
GL.Clear(ClearBufferMask.ColorBufferBit);
for (int y=0;y<720;y++)
{
for (int x = 0; x < 1280; x++)
{
var c = (int) (Math.Floor(Math.Sin(x/35d)*128 + Math.Sin(y/28d)*32f + Math.Sin((x + y)/16d)*64));
c = mod(c, 256);
var r = cols[0, c] % 256;
var g = cols[1, c] % 256;
var b = cols[2, c] % 256;
GL.Color3(r/256, g/256, b/256);
GL.Begin(BeginMode.Points);
GL.Vertex2(x, y);
GL.End();
}
}
window.SwapBuffers();
}
示例5: Move
//Methods
//-Public
public bool Move(OpenTK.Input.KeyboardState ks)
{
bool ret = false;
//Move camera
//if(Keyboard[Key.Left] && cameraCAM != null) {
if(ks[OpenTK.Input.Key.Left]) {
X -= 2f; ret = true;
}
else if(ks[OpenTK.Input.Key.Right]) {
X += 2f; ret = true;
}
if(ks[OpenTK.Input.Key.Up]) {
Y += 2f; ret = true;
}
else if(ks[OpenTK.Input.Key.Down]) {
Y -= 2f; ret = true;
}
if((ks[OpenTK.Input.Key.Plus] || ks[OpenTK.Input.Key.KeypadPlus])) {
Z += 1f; ret = true;
}
else if((ks[OpenTK.Input.Key.Minus] || ks[OpenTK.Input.Key.KeypadMinus])) {
Z -= 1f; ret = true;
}
return ret;
}
示例6: LoadModel
public override ModelBase LoadModel(OpenTK.Vector3 scale)
{
List<ModelBase.BoneDef> flatBoneList = m_Model.m_BoneTree.GetAsList();
for (int i = 0; i < m_BCA.m_AnimationData.Length; i++)
{
string boneID = flatBoneList[i].m_ID;
BCA.SRTContainer[] boneTransformations = m_BCA.GetAllLocalSRTValuesForBone(i);
Dictionary<ModelBase.AnimationComponentType, ModelBase.AnimationComponentDataDef> animationComponentDataDefs =
new Dictionary<ModelBase.AnimationComponentType, ModelBase.AnimationComponentDataDef>();
float[] valuesSx = new float[boneTransformations.Length];
float[] valuesSy = new float[boneTransformations.Length];
float[] valuesSz = new float[boneTransformations.Length];
float[] valuesRx = new float[boneTransformations.Length];
float[] valuesRy = new float[boneTransformations.Length];
float[] valuesRz = new float[boneTransformations.Length];
float[] valuesTx = new float[boneTransformations.Length];
float[] valuesTy = new float[boneTransformations.Length];
float[] valuesTz = new float[boneTransformations.Length];
for (int j = 0; j < boneTransformations.Length; j++)
{
valuesSx[j] = boneTransformations[j].m_Scale.X;
valuesSy[j] = boneTransformations[j].m_Scale.Y;
valuesSz[j] = boneTransformations[j].m_Scale.Z;
valuesRx[j] = boneTransformations[j].m_Rotation.X;
valuesRy[j] = boneTransformations[j].m_Rotation.Y;
valuesRz[j] = boneTransformations[j].m_Rotation.Z;
valuesTx[j] = boneTransformations[j].m_Translation.X;
valuesTy[j] = boneTransformations[j].m_Translation.Y;
valuesTz[j] = boneTransformations[j].m_Translation.Z;
}
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.ScaleX,
new ModelBase.AnimationComponentDataDef(valuesSx, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.ScaleX));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.ScaleY,
new ModelBase.AnimationComponentDataDef(valuesSy, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.ScaleY));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.ScaleZ,
new ModelBase.AnimationComponentDataDef(valuesSz, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.ScaleZ));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.RotateX,
new ModelBase.AnimationComponentDataDef(valuesRx, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.RotateX));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.RotateY,
new ModelBase.AnimationComponentDataDef(valuesRy, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.RotateY));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.RotateZ,
new ModelBase.AnimationComponentDataDef(valuesRz, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.RotateZ));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.TranslateX,
new ModelBase.AnimationComponentDataDef(valuesTx, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.TranslateX));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.TranslateY,
new ModelBase.AnimationComponentDataDef(valuesTy, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.TranslateY));
animationComponentDataDefs.Add(ModelBase.AnimationComponentType.TranslateZ,
new ModelBase.AnimationComponentDataDef(valuesTz, m_BCA.m_NumFrames, false, 1, false, ModelBase.AnimationComponentType.TranslateZ));
ModelBase.AnimationDef animation = new ModelBase.AnimationDef(boneID + "-animation", boneID, m_BCA.m_NumFrames,
animationComponentDataDefs);
m_Model.m_Animations.Add(animation.m_ID, animation);
}
return m_Model;
}
示例7: OpenTKGLContext
public OpenTKGLContext( OpenTK.Platform.IWindowInfo windowInfo )
{
// setup created glcontrol / gtk control
this.windowInfo = windowInfo;
this.graphicsContext = new GraphicsContext( GraphicsMode.Default, this.windowInfo );
Initialized = true;
}
示例8: SetCornerColors
public void SetCornerColors(OpenTK.Graphics.Color4[] colors)
{
Flush(); //dont really need to flush with current implementation. we might as well roll modulate color into it too.
if (colors.Length != 4) throw new ArgumentException("array must be size 4", "colors");
for (int i = 0; i < 4; i++)
CornerColors[i] = colors[i];
}
示例9: OnRenderFrame
protected override void OnRenderFrame( OpenTK.FrameEventArgs e )
{
base.OnRenderFrame( e );
base.MakeCurrent();
if ( !_initialized )
{
Initialize();
_initialized = true;
}
try
{
if ( _engine != null )
{
_engine.RenderOneFrame();
}
}
catch ( Exception ex )
{
Console.WriteLine( "An exception has occurred. See below for details:" );
Console.WriteLine( BuildExceptionString( ex ) );
}
//base.SwapBuffers();
}
示例10: GameContext
/// <summary>
/// Initializes a new instance of the <see cref="GameContext" /> class.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="requestedWidth">Width of the requested.</param>
/// <param name="requestedHeight">Height of the requested.</param>
public GameContext(OpenTK.GameWindow control, int requestedWidth = 0, int requestedHeight = 0)
{
var creationFlags = GraphicsContextFlags.Default;
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
creationFlags |= GraphicsContextFlags.Embedded;
#endif
if (requestedWidth == 0 || requestedHeight == 0)
{
requestedWidth = 1280;
requestedHeight = 720;
}
// force the stencil buffer to be not null.
var defaultMode = GraphicsMode.Default;
var graphicMode = new GraphicsMode(defaultMode.ColorFormat, defaultMode.Depth, 8, defaultMode.Samples, defaultMode.AccumulatorFormat, defaultMode.Buffers, defaultMode.Stereo);
GraphicsContext.ShareContexts = true;
if (control == null)
{
int versionMajor, versionMinor;
if (RequestedGraphicsProfile == null || RequestedGraphicsProfile.Length == 0)
{
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
versionMajor = 3;
versionMinor = 0;
#else
// PC: 4.3 is commonly available (= compute shaders)
// MacOS X: 4.1 maximum
versionMajor = 4;
versionMinor = 1;
#endif
Control = TryGameWindow(requestedWidth, requestedHeight, graphicMode, versionMajor, versionMinor, creationFlags);
}
else
{
foreach (var profile in RequestedGraphicsProfile)
{
OpenGLUtils.GetGLVersion(profile, out versionMajor, out versionMinor);
var gameWindow = TryGameWindow(requestedWidth, requestedHeight, graphicMode, versionMajor, versionMinor, creationFlags);
if (gameWindow != null)
{
Control = gameWindow;
break;
}
}
}
}
else
Control = control;
if (Control == null)
throw new Exception("Unable to initialize graphics context.");
RequestedWidth = requestedWidth;
RequestedHeight = requestedHeight;
ContextType = AppContextType.DesktopOpenTK;
}
示例11: Mouse_Move
internal void Mouse_Move(object sender, OpenTK.Input.MouseMoveEventArgs e)
{
if (DragMode)
{
Yaw += e.XDelta;
Pitch += e.YDelta;
}
}
示例12: Initialize
public void Initialize(OpenTK.GameWindow window)
{
Window = window;
window.ClientSize = new Size(mapLayout[0].Length * 30, mapLayout.Length * 30);
TextureManager.Instance.UseNearestFiltering = true;
map = GenerateMap(mapLayout, spriteSheets, spriteSources);
hero = new PlayerCharacter(heroSheet, new Point(spawnTile.X * 30, spawnTile.Y * 30));
}
示例13: OnKeyDown
public override void OnKeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs args)
{
base.OnKeyDown(sender, args);
if (args.Key == OpenTK.Input.Key.Escape)
{
StateHandler.Push(new GuiState(Graphics.RenderMode.Ortho, true));
}
}
示例14: Clear
public void Clear(OpenTK.Graphics.OpenGL.ClearBufferMask mask)
{
var g = GetCurrentGraphics();
if((mask & ClearBufferMask.ColorBufferBit) != 0)
{
g.Clear(_currentClearColor);
}
}
示例15: Keyboard_KeyDown
void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
if (e.Key == OpenTK.Input.Key.F1)
{
shouldDraw = !shouldDraw;
DepthScreen.IsVisible = shouldDraw;
}
}