protected override void OnLoad() { base.OnLoad(); string vertexShader = "#version 330\n" + "uniform mat4 mvp;\n" + "in vec3 in_pos;\n" + "layout (location = 0) in vec3 aPosition;\n" + "void main() { gl_Position = mvp * vec4(in_pos, 1.0); \n}"; string fragmentShader = "#version 330\n" + "void main() { gl_FragColor = vec4(0.2, 0.2, 0.2, 1.0); }\n"; for (int i = 0; i < 20; i++) { objects[i] = new GameObject[10]; } for (int i = 0; i < 10; i++) { for (int x = 0; x < 10; x++) { objects[i][x] = new GameObject(); } } int pass = 1; var source = objects; for (int i = 0; i < source.Count(); i++) { for (int x = 0; x < source[pass - 1].Count(); x++) { //Console.WriteLine(i); //Console.WriteLine(x); var tri = objects[i][x]; tri = new GameObject(vertexShader, fragmentShader, vertices_cube); tri.Position = new Vector3(-2.0f * (i), Convert.ToSingle(rnd.NextDouble() * 1.0), -2.0f * (x + 1)); objects[i][x] = tri; } pass++; } Console.WriteLine(objects); for (int x = 0; x < objects_pyramid.Count(); x++) { var tri = objects_pyramid[x]; tri = new GameObject(vertexShader, fragmentShader, vertices_pyramid); tri.Position = new Vector3(0, 2, -3.0f * (x + 1)); objects_pyramid[x] = tri; } cam = new Camera(); player = new Player(); base.CursorGrabbed = true; Size = new OpenTK.Mathematics.Vector2i(1280, 720); }
private void Init(WindowProperties props) { data.Title = props.Title; data.Width = props.Width; data.Height = props.Height; Title = props.Title; Size = new OpenTK.Mathematics.Vector2i(props.Width, props.Height); GL.Viewport(0, 0, Width, Height); Resize += e => { data.Width = e.Width; data.Height = e.Height; data.EventCallback(new WindowResizeEvent(e.Width, e.Height)); }; Closing += e => { data.EventCallback(new WindowCloseEvent()); }; KeyDown += e => { data.EventCallback(new KeyPressedEvent((int)e.Key, e.Control, e.Alt, e.Shift)); }; KeyUp += e => { data.EventCallback(new KeyReleasedEvent((int)e.Key, e.Control, e.Alt, e.Shift)); }; TextInput += e => { data.EventCallback(new TextInputEvent(e.Unicode)); }; MouseDown += e => { data.EventCallback(new MouseButtonPressedEvent(e.Button)); }; MouseUp += e => { data.EventCallback(new MouseButtonReleasedEvent(e.Button)); }; MouseWheel += e => { data.EventCallback(new MouseScrolledEvent(e.OffsetX, e.OffsetY)); }; MouseMove += e => { data.EventCallback(new MouseMovedEvent(e.X, e.Y)); }; }
public bool InitialiseGameWindow() { GC.AddMemoryPressure(33554432); FullscreenToggle = new ToggleButton((isToggled) => { if (isToggled) { WindowState = WindowState.Fullscreen; } else { WindowState = WindowState.Normal; } }); CursorGrappedToggle = new ToggleButton((isToggled) => { if (isToggled) { CursorVisible = true; CursorGrabbed = false; } else { CursorVisible = false; CursorGrabbed = true; } }); Size = new OpenTK.Mathematics.Vector2i(1280, 720); IsRunning = false; UtilityLauncher.PreOpenGLLaunch(); if (InitialiseOpenGL()) { UtilityLauncher.AfterOpenGLLaunch(); LogManager.OpenGLLogger.Log("Successfully initialised Game Engine"); return(true); } else { LogManager.OpenGLLogger.Log("Failed to initialise Game Engine"); return(false); } }
// Called first after the Run() function is called, i think. // or after the constructor completes. basically, it only runs once. protected override void OnLoad() { base.OnLoad(); string vertexShader = "#version 330\n" + "uniform mat4 mvp;\n" + "in vec3 in_pos;\n" + "void main() { gl_Position = mvp * vec4(in_pos, 1.0); }"; string fragmentShader = "#version 330\n" + "void main() { gl_FragColor = vec4(0.8, 0.2, 1.0, 1.0); }\n"; tri = new GameObject(vertexShader, fragmentShader, vertices); tri.Position = new Vector3(0, 0, -5.0f); cam = new Camera(); player = new Player(); base.CursorGrabbed = true; Size = new OpenTK.Mathematics.Vector2i(1280, 720); }
public static unsafe Layer.Mathematics.Vector2i Vector2i(OpenTK.Mathematics.Vector2i vector2i) { return(*(Layer.Mathematics.Vector2i *) & vector2i); }