I worked about 2 weeks with OpenTK and I like to know how to texture triangles.
I like to give my program, the flexibility to make shapes like triangles, cubes, spheres and to give them different textures (or shaders).
I like to give my window a icon, but it says that I have this error:
"Exception Unhandled, System.ArgumentException: 'Argument 'picture' must be a picture that can be used as a icon.'".
This exception was originally thrown at this call stack:
System.Drawing.Icon.Initialize(int, int)
System.Drawing.Icon.Icon(string, int, int)
System.Drawing.Icon.Icon(string)
obamaExperimentingV1_14.ObamaBattlezCSharp.Main(string[]) in Program.cs
I am really thankfull if someone helps me or ask some questions at me or critisize my code, I know this is some multiple questions at one post.
But again, I am really thankfull for this.
Here are some tutorials (,but I can't really understand it fully):
https://github.com/opentk/LearnOpenTK
https://github.com/giawa/opengl4tutorials
https://www.youtube.com/playlist?list=PLWzp0Bbyy_3ggUK3XZjBmwnSjhbhJH3kp
https://github.com/eowind/dreamstatecoding
http://dreamstatecoding.blogspot.com/2017/01/opengl-4-with-opentk-in-c-part-1.html
https://opentk.net/learn/index.html
http://www.siltutorials.com/opentkbasicsindex
here are the things that I don't know what it is, here is a list what I don't know about:
- buffer;
- vector;
- matrix;
- buffertarget;
- bindbuffer;
- bufferdata;
- indices;
- clearbuffermask;
- colorbufferbit.
Here is a full code, there are just 2 classes in my project.
Program.cs
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
using System;
using System.Drawing;
namespace obamaExperimentingV1_14
{
public class ObamaBattlezCSharp : GameWindow
{
private static void Main(string[] args)
{
using (var window = new Window(1280, 720, GraphicsMode.Default, "Obama Battlez CSharp Version", GameWindowFlags.Default, DisplayDevice.Default)) {
window.Icon = new Icon("Resources/bruhstar (1).bmp");
window.Run(60.0f);
}
}
}
}
Window.cs
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
using System;
using System.Drawing;
namespace obamaExperimentingV1_14
{
class Window : GameWindow
{
public Window(int width, int height, GraphicsMode graphicsMode, string title, GameWindowFlags gameWindowFlags, DisplayDevice displayDevice)
: base(width, height, GraphicsMode.Default, title, GameWindowFlags.Default, displayDevice)
{
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
GL.ClearColor(0.5f, 0.6f, 0.7f, 1.0f);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
base.OnUpdateFrame(e);
var input = Keyboard.GetState();
if (input.IsKeyDown(Key.Escape)) {
Exit();
}
base.OnUpdateFrame(e);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
base.OnRenderFrame(e);
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.Color4(0.4, 0.6, 0.1, 1.0);
GL.Begin(PrimitiveType.Triangles);
GL.Vertex2(0, 0);
GL.Vertex2(1, 0);
GL.Vertex2(0, 1);
GL.End();
GL.Color4(0.4, 0.2, 0.1, 1.0);
GL.Begin(PrimitiveType.Triangles);
GL.Vertex2(0, 0);
GL.Vertex2(-1, 0);
GL.Vertex2(0, -1);
GL.End();
SwapBuffers();
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
GL.Viewport(0, 0, Width, Height);
}
protected override void OnUnload(EventArgs e)
{
base.OnUnload(e);
}
}
}