Archived
Private
Public Access
1
0

Removed Subrepository

This commit is contained in:
2022-09-04 13:23:45 +02:00
parent f4a01d6a69
commit 2cdae71f61
109 changed files with 12072 additions and 1 deletions

Submodule C#/OpenGLTutorial deleted from ad686dae1d

View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
/.idea.OpenGLTutorial.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectDictionaryState">
<dictionary name="leon" />
</component>
</project>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="com.jetbrains.rider.android.RiderAndroidMiscFileCreationComponent">
<option name="ENSURE_MISC_FILE_EXISTS" value="true" />
</component>
</project>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

10000
C#/OpenGLTutorial/GL.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,111 @@
using System.IO;
using GLFW;
using OpenGLTutorial.Rendering.Display;
namespace OpenGLTutorial.GameLoop {
public abstract class Game {
/// <summary>
/// Initializes the Game and starts the GameLoop
/// </summary>
/// <param name="width">The initial width of the game window</param>
/// <param name="height">The initial height of the game window</param>
/// <param name="title">The title of the game window</param>
/// <param name="vsync">Sync the game FPS to the Monitor FPS</param>
public void Run(int width, int height, string title, bool vsync = false) {
Initialize();
DisplayManager.CreateWindow(width, height, title, vsync);
LoadContent();
while (!DisplayManager.Window.IsClosing) {
GameTime.DeltaTime = (float)Glfw.Time - GameTime.TotalElapsedSeconds;
GameTime.TotalElapsedSeconds = (float)Glfw.Time;
Glfw.PollEvents();
Input.Update();
Update();
Render();
Input.MouseScroll = 0.0f;
}
Destroy();
DisplayManager.Window.Close();
}
/// <summary>
/// Gets called at the very start of the GameLoop
/// </summary>
protected abstract void Initialize();
/// <summary>
/// Gets called after the GLFW Window inititalizes
/// </summary>
protected abstract void LoadContent();
/// <summary>
/// Gets called every frame before Render
/// </summary>
protected abstract void Update();
/// <summary>
/// Gets called every frame after Update
/// </summary>
protected abstract void Render();
/// <summary>
/// Gets called right before the Game ends
/// </summary>
protected abstract void Destroy();
/// <summary>
/// Copys a folder to the Game output (DEBUG ONLY)
/// </summary>
/// <param name="folder">The folder to copy</param>
protected void DEBUG_CopyFolderToOutput(string folder) {
#if DEBUG
var info = new DirectoryInfo(folder);
info.CopyTo(Directory.GetCurrentDirectory() + "/" + info.Name, true, true);
#endif
}
/// <summary>
/// Copys a file to the Game output (DEBUG ONLY)
/// </summary>
/// <param name="file">The file to copy</param>
protected void DEBUG_CopyFileToOutput(string file) {
#if DEBUG
var info = new FileInfo(file);
info.CopyTo(Directory.GetCurrentDirectory() + "/" + info.Name, true);
#endif
}
}
public static class DirectoryExtensions {
public static void CopyTo(this DirectoryInfo dir, string destinationDir, bool overwrite, bool recursive) {
if (overwrite && Directory.Exists(destinationDir))
Directory.Delete(destinationDir, true);
if (!dir.Exists)
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
DirectoryInfo[] dirs = dir.GetDirectories();
Directory.CreateDirectory(destinationDir);
foreach (FileInfo file in dir.GetFiles()) {
string targetFilePath = Path.Combine(destinationDir, file.Name);
file.CopyTo(targetFilePath);
}
if (recursive) {
foreach (DirectoryInfo subDir in dirs) {
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
CopyTo(subDir, newDestinationDir, true, overwrite);
}
}
}
}
}

View File

@@ -0,0 +1,15 @@
namespace OpenGLTutorial.GameLoop {
public static class GameTime {
/// <summary>
/// The time in seconds that passed between frames
/// </summary>
public static float DeltaTime { get; set; }
/// <summary>
/// The total elapsed time sinse the game started
/// </summary>
public static float TotalElapsedSeconds { get; set; }
}
}

View File

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using GLFW;
namespace OpenGLTutorial.GameLoop {
public class Input {
/// <summary>
/// Get the state of a key
/// Usage: Input.Keys[Keys.W]
/// </summary>
public static Dict<Keys, bool> Keys { get; } = new (false);
/// <summary>
/// Get the state of a mouse button
/// Usage: Input.MouseButtons[MouseButton.Button1]
/// </summary>
public static Dict<MouseButton, bool> MouseButtons { get; } = new (false);
/// <summary>
/// The screen position of the Mouse
/// </summary>
public static Point MousePosition { get; set; } = new (0, 0);
/// <summary>
/// The relative scroll offset from last frame
/// </summary>
public static float MouseScroll { get; set; } = 0.0f;
/// <summary>
/// Get the state of a joystick button
/// Usage: Input.JoystickButtons[Joystick.Joystick1][JoystickButton.A]
/// </summary>
public static Dict<Joystick, Dict<JoystickButton, bool>> JoystickButtons { get; } = new(new Dict<JoystickButton, bool>(false));
/// <summary>
/// Get the state of a joystick axis
/// Usage: JoystickAxis[Joystick.Joystick1][JoystickAxis.LeftJoystickX]
/// </summary>
public static Dict<Joystick, Dict<JoystickAxis, float>> JoystickAxis { get; } = new(new Dict<JoystickAxis, float>(0.0f));
/// <summary>
/// Get the state of the given axis
/// </summary>
/// <param name="axis">The axis</param>
/// <param name="joystick">(OPTIONAL) The joystick to use</param>
/// <returns>A value between -1 and 1</returns>
/// <exception cref="GLFW.Exception">Throws an exception if the given axis does not exist</exception>
public static float GetAxis(Axis axis, Joystick joystick = Joystick.Joystick1) {
switch (axis) {
case Axis.Horizontal:
float x = JoystickAxis[joystick][GameLoop.JoystickAxis.LeftJoystickX];
if (Keys[GLFW.Keys.A]) x += -1.0f;
if (Keys[GLFW.Keys.D]) x += 1.0f;
return Math.Clamp(x, -1, 1);
case Axis.Vertical:
float y = JoystickAxis[joystick][GameLoop.JoystickAxis.LeftJoystickY];
if (Keys[GLFW.Keys.S]) y += -1.0f;
if (Keys[GLFW.Keys.W]) y += 1.0f;
return Math.Clamp(y, -1, 1);
case Axis.Junp:
float jump = JoystickButtons[joystick][JoystickButton.A] ? 1.0f : 0.0f;
if (Keys[GLFW.Keys.Space]) jump = 1.0f;
return jump;
default:
throw new System.Exception("Unexpected Token: '" + axis + "'. That Axis does not exist");
}
}
/// <summary>
/// SYSTEM INTERNAL
/// </summary>
public static void Update() {
UpdateJoystick(Joystick.Joystick1);
UpdateJoystick(Joystick.Joystick2);
UpdateJoystick(Joystick.Joystick3);
UpdateJoystick(Joystick.Joystick4);
UpdateJoystick(Joystick.Joystick5);
UpdateJoystick(Joystick.Joystick6);
UpdateJoystick(Joystick.Joystick7);
UpdateJoystick(Joystick.Joystick8);
UpdateJoystick(Joystick.Joystick9);
UpdateJoystick(Joystick.Joystick10);
UpdateJoystick(Joystick.Joystick11);
UpdateJoystick(Joystick.Joystick12);
UpdateJoystick(Joystick.Joystick13);
UpdateJoystick(Joystick.Joystick14);
UpdateJoystick(Joystick.Joystick15);
UpdateJoystick(Joystick.Joystick16);
}
private static void UpdateJoystick(Joystick joystick) {
if (!Glfw.JoystickPresent(joystick)) return;
float[] axis = Glfw.GetJoystickAxes(joystick);
JoystickAxis[joystick][GameLoop.JoystickAxis.LeftJoystickX] = ClampAxis(axis[0]);
JoystickAxis[joystick][GameLoop.JoystickAxis.LeftJoystickY] = -ClampAxis(axis[1]);
JoystickAxis[joystick][GameLoop.JoystickAxis.RightJoystickX] = ClampAxis(axis[2]);
JoystickAxis[joystick][GameLoop.JoystickAxis.RightJoystickY] = -ClampAxis(axis[3]);
JoystickAxis[joystick][GameLoop.JoystickAxis.LeftTrigger] = ClampAxis(axis[4]);
JoystickAxis[joystick][GameLoop.JoystickAxis.RightTrigger] = ClampAxis(axis[5]);
InputState[] buttons = Glfw.GetJoystickButtons(joystick);
JoystickButtons[joystick][JoystickButton.A] = buttons[0] != InputState.Release;
JoystickButtons[joystick][JoystickButton.B] = buttons[1] != InputState.Release;
JoystickButtons[joystick][JoystickButton.X] = buttons[2] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Y] = buttons[3] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Lb] = buttons[4] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Rb] = buttons[5] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Back] = buttons[6] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Start] = buttons[7] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Left] = buttons[8] != InputState.Release;
JoystickButtons[joystick][JoystickButton.Right] = buttons[9] != InputState.Release;
JoystickButtons[joystick][JoystickButton.DpadUp] = buttons[10] != InputState.Release;
JoystickButtons[joystick][JoystickButton.DpadRight] = buttons[11] != InputState.Release;
JoystickButtons[joystick][JoystickButton.DpadDown] = buttons[12] != InputState.Release;
JoystickButtons[joystick][JoystickButton.DpadLeft] = buttons[13] != InputState.Release;
}
private static float ClampAxis(float value) {
if (value < 0.15f && value > -0.15f)
value = 0;
return value;
}
}
public class Dict<TKey, TValue> : Dictionary<TKey, TValue> {
public TValue DefaultValue { get; set; }
public Dict(TValue defaultValue) => DefaultValue = defaultValue;
public new TValue this[TKey key] {
get => TryGetValue(key, out TValue t) ? t : DefaultValue;
set => base[key] = value;
}
}
public enum JoystickButton {
A,
B,
X,
Y,
Start,
Back,
Lb,
Rb,
Left,
Right,
DpadUp,
DpadDown,
DpadRight,
DpadLeft
}
public enum JoystickAxis {
LeftJoystickX,
LeftJoystickY,
RightJoystickX,
RightJoystickY,
LeftTrigger,
RightTrigger
}
public enum Axis {
Horizontal,
Vertical,
Junp
}
}

View File

@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="GLFW.NET, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\.Librarys\GLFW.NET.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StbiSharp" Version="1.2.1" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\bricks.png" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGLTutorial", "OpenGLTutorial.csproj", "{2322DD0D-7B9A-4C17-B8C9-63232B734E5A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2322DD0D-7B9A-4C17-B8C9-63232B734E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2322DD0D-7B9A-4C17-B8C9-63232B734E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2322DD0D-7B9A-4C17-B8C9-63232B734E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2322DD0D-7B9A-4C17-B8C9-63232B734E5A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,9 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=D_003A_005CProgrammierstuff_005C_002ELibrarys_005Cglfw3_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=D_003A_005CProgrammierstuff_005C_002ELibrarys_005CGLFW_002ENET_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=D_003A_005CProgrammierstuff_005C_002ELibrarys_005CGLFW_002ENET_005CGLFW_002ENET_002Edll/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=D_003A_005CProgrammierstuff_005C_002ELibrarys_005CGLFW_002ENET_005CGLFW_002ENET_002Exml/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=D_003A_005CProgrammierstuff_005C_002ELibrarys_005CGLFW_005Clib_002Dvc2022_005Cglfw3_002Elib/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="D:\Programmierstuff\.Librarys\GLFW.NET.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>

View File

@@ -0,0 +1,10 @@
using OpenGLTutorial.GameLoop;
namespace OpenGLTutorial {
class Program {
public static void Main(string[] args) {
Game game = new TestGame();
game.Run(800, 600, "Test Game", true);
}
}
}

View File

@@ -0,0 +1,26 @@
using System.Numerics;
using OpenGLTutorial.Rendering.Display;
namespace OpenGLTutorial.Rendering.Cameras {
public class Camera2D {
public Vector2 FocusPosition { get; set; }
public float Zoom { get; set; }
public Camera2D(Vector2 focusPosition, float zoom) {
FocusPosition = focusPosition;
Zoom = zoom;
}
public Matrix4x4 GetProjectionMatrix() {
float left = FocusPosition.X - DisplayManager.WindowSize.Width / 2f;
float right = FocusPosition.X + DisplayManager.WindowSize.Width / 2f;
float top = FocusPosition.Y - DisplayManager.WindowSize.Height / 2f;
float bottom = FocusPosition.Y + DisplayManager.WindowSize.Height / 2f;
Matrix4x4 orthoMatrix = Matrix4x4.CreateOrthographicOffCenter(left, right, bottom, top, 0.01f, 100.0f);
Matrix4x4 zoomMatrix = Matrix4x4.CreateScale(Zoom);
return orthoMatrix * zoomMatrix;
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using GLFW;
using OpenGLTutorial.GameLoop;
using StbiSharp;
using static OpenGL.GL;
using Image = GLFW.Image;
namespace OpenGLTutorial.Rendering.Display {
public static class DisplayManager {
public static NativeWindow Window { get; set; }
public static Size WindowSize { get; set; }
public static void CreateWindow(int width, int height, string title, bool vsync) {
WindowSize = new Size(width, height);
Glfw.Init();
Glfw.WindowHint(Hint.ContextVersionMajor, 3);
Glfw.WindowHint(Hint.ContextVersionMinor, 3);
Glfw.WindowHint(Hint.OpenglProfile, Profile.Core);
Glfw.WindowHint(Hint.Focused, true);
Glfw.WindowHint(Hint.Resizable, true);
Window = new NativeWindow(width, height, title);
Window.CenterOnScreen();
Window.MakeCurrent();
Import(Glfw.GetProcAddress);
glViewport(0, 0, width, height);
Glfw.SwapInterval(vsync ? 1 : 0);
Window.SizeChanged += OnResize;
Window.KeyAction += OnKey;
Window.MouseButton += OnMouse;
Window.MouseMoved += OnMouseMove;
Window.MouseScroll += OnMouseScroll;
}
private static void OnResize(object sender, SizeChangeEventArgs e) {
WindowSize = e.Size;
glViewport(0, 0, WindowSize.Width, WindowSize.Height);
}
private static void OnKey(object sender, KeyEventArgs e) => Input.Keys[e.Key] = e.State != InputState.Release;
private static void OnMouse(object sender, MouseButtonEventArgs e) => Input.MouseButtons[e.Button] = e.Action != InputState.Release;
private static void OnMouseMove(object sender, MouseMoveEventArgs e) => Input.MousePosition = e.Position;
private static void OnMouseScroll(object sender, MouseMoveEventArgs e) => Input.MouseScroll = e.Position.Y;
public static unsafe void SetWindowIcon(this NativeWindow window, string file) {
using var stream = File.OpenRead(file);
using var memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
StbiImage image = Stbi.LoadFromMemory(memoryStream, 0);
fixed (byte* data = &image.Data[0]) {
window.SetIcons(new Image(image.Width, image.Height, new IntPtr(data)));
}
}
}
}

View File

@@ -0,0 +1,154 @@
using System.Drawing;
using static OpenGL.GL;
namespace OpenGLTutorial.Rendering.Display {
public class Shape {
public int Mode { get; set; }
public uint Vao { get; private set; }
private uint Vbo { get; set; }
private float[] Vertices { get; set; }
private bool _loaded = false;
public Shape(float[] vertices, int mode = GL_STATIC_DRAW) {
Vertices = vertices;
Mode = mode;
}
public unsafe void Load() {
if (_loaded || Vertices.Length == 0) return;
_loaded = true;
Vao = glGenVertexArray();
Vbo = glGenBuffer();
glBindVertexArray(Vao);
glBindBuffer(GL_ARRAY_BUFFER, Vbo);
fixed (float* v = &Vertices[0]) {
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * Vertices.Length, v, Mode);
}
glVertexAttribPointer(0, 2, GL_FLOAT, false, 8 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 4, GL_FLOAT, false, 8 * sizeof(float), (void*)(2 * sizeof(float)));
glEnableVertexAttribArray(1);
glVertexAttribPointer(2, 2, GL_FLOAT, false, 8 * sizeof(float), (void*)(6 * sizeof(float)));
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
public void Delete() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
glDeleteBuffer(Vbo);
glDeleteVertexArray(Vao);
}
public unsafe void SetVertices(float[] vertices) {
Vertices = vertices;
if (vertices.Length == 0) return;
glBindVertexArray(Vao);
glBindBuffer(GL_ARRAY_BUFFER, Vbo);
fixed (float* v = &Vertices[0]) {
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * Vertices.Length, v, Mode);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
public int GetVertexCount() => Vertices.Length / 8;
}
public static class Shapes {
public static float[] Rectangle => new[] {
-0.5f, 0.5f, 1f, 1f, 1f, 1f, 0.0f, 1.0f, // top left
0.5f, 0.5f, 1f, 1f, 1f, 1f, 1.0f, 1.0f, // top right
-0.5f, -0.5f, 1f, 1f, 1f, 1f, 0.0f, 0.0f, // bottom left
0.5f, 0.5f, 1f, 1f, 1f, 1f, 1.0f, 1.0f, // top right
0.5f, -0.5f, 1f, 1f, 1f, 1f, 1.0f, 0.0f, // bottom right
-0.5f, -0.5f, 1f, 1f, 1f, 1f, 0.0f, 0.0f, // bottom left
};
public static float[] Triangle => new[] {
0.0f, -0.5f, 1f, 1f, 1f, 1f, 0.5f, 1.0f, // top center
0.5f, 0.5f, 1f, 1f, 1f, 1f, 1.0f, 0.0f, // bottom right
-0.5f, 0.5f, 1f, 1f, 1f, 1f, 0.0f, 0.0f, // bottom left
};
public static float[] CreateRectangle(Dimensions position, Color color, Dimensions uv) => new[] {
position.X, position.MaxY, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.X, uv.MaxY, // top left
position.MaxX, position.MaxY, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.MaxX, uv.MaxY, // top right
position.X, position.Y, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.X, uv.Y, // bottom left
position.MaxX, position.MaxY, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.MaxX, uv.MaxY, // top right
position.MaxX, position.Y, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.MaxX, uv.Y, // bottom right
position.X, position.Y, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.X, uv.Y, // bottom left
};
public static float[] CreateTriangle(Dimensions position, Color color, Dimensions uv) => new[] {
position.CenterX, position.Y, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.CenterX, uv.MaxY, // top center
position.MaxX, position.MaxY, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.MaxX, uv.Y, // bottom right
position.X, position.MaxY, color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha(), uv.X, uv.Y, // bottom left
};
}
public readonly struct Dimensions {
public static Dimensions Identity => new (0.0f, 0.0f, 1.0f, 1.0f);
public static Dimensions Centered => new (-0.5f, -0.5f, 1.0f, 1.0f);
public float X { get; }
public float Y { get; }
public float Width { get; }
public float Height { get; }
public Dimensions(float x, float y, float width, float height) {
X = x;
Y = y;
Width = width;
Height = height;
}
public float MaxX => X + Width;
public float MaxY => Y + Height;
public float CenterX => X + (Width / 2.0f);
public float CenterY => Y + (Height / 2.0f);
}
public static class ColorExtensions {
private static float Map(float value, float min, float max, float mMin, float mMax) {
float norm = (value - min) / (max - min);
return (mMax - mMin) * norm + mMin;
}
public static float GetRed(this Color color) {
return Map(color.R, 0, 255, 0, 1);
}
public static float GetGreen(this Color color) {
return Map(color.G, 0, 255, 0, 1);
}
public static float GetBlue(this Color color) {
return Map(color.B, 0, 255, 0, 1);
}
public static float GetAlpha(this Color color) {
return Map(color.A, 0, 255, 0, 1);
}
}
}

View File

@@ -0,0 +1,73 @@
using System.IO;
using StbiSharp;
using static OpenGL.GL;
namespace OpenGLTutorial.Rendering.Display {
public class Texture {
public static Texture Empty => new(null);
public int Width { get; private set; }
public int Height { get; private set; }
private uint Address { get; set; }
private string Path { get; }
private bool _loaded = false;
public Texture(string path) {
Path = path;
}
public unsafe void Load() {
if (_loaded) return;
_loaded = true;
Address = glGenTexture();
glBindTexture(GL_TEXTURE_2D, Address);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (string.IsNullOrEmpty(Path)) {
LoadEmpty();
return;
}
using var stream = File.OpenRead(Path);
using var memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
StbiImage image = Stbi.LoadFromMemory(memoryStream, 0);
int format = image.NumChannels == 3 ? GL_RGB : GL_RGBA;
fixed(byte* data = &image.Data[0])
glTexImage2D(GL_TEXTURE_2D, 0, format, image.Width, image.Height, 0, format, GL_UNSIGNED_BYTE, data);
Width = image.Width;
Height = image.Height;
glBindTexture(GL_TEXTURE_2D, 0);
}
private unsafe void LoadEmpty() {
byte[] pixels = {255, 255, 255, 255};
fixed (byte* data = &pixels[0]) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
Width = 1;
Height = 1;
glBindTexture(GL_TEXTURE_2D, 0);
}
public void Use() {
glBindTexture(GL_TEXTURE_2D, Address);
}
public void Delete() {
glBindTexture(GL_TEXTURE_2D, 0);
glDeleteTexture(Address);
}
}
}

View File

@@ -0,0 +1,8 @@
namespace OpenGLTutorial.Rendering.Objects.Components {
public interface IComponent {
public void Load(GameObject thisObject);
public void Update(GameObject thisObject);
public void Destroy(GameObject thisObject);
public void Render(GameObject thisObject);
}
}

View File

@@ -0,0 +1,173 @@
#pragma warning disable CA1416
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
using System.Numerics;
using System.Text;
using System.Text.Json;
using OpenGLTutorial.Rendering.Display;
using static OpenGL.GL;
namespace OpenGLTutorial.Rendering.Objects.Components {
[Serializable]
public class TextSettings {
public int GlyphsPerLine { get; set; } = 16;
public int GlyphLineCount { get; set; } = 16;
public int GlyphWidth { get; set; } = 30;
public int GlyphHeight { get; set; } = 48;
public float CharXSpacing { get; set; } = 0.0f;
// Used to offset rendering glyphs to bitmap
public int AtlasOffsetX { get; set; } = -3;
public int AtlasOffsetY { get; set; } = -1;
public int FontSize { get; set; } = 35;
public bool BitmapFont { get; set; } = false;
public float TexCoordOffset { get; set; } = 0.005f;
public void Save(string file) {
string json = JsonSerializer.Serialize(this, new JsonSerializerOptions {WriteIndented = true});
File.WriteAllText(file, json, Encoding.UTF8);
}
public static TextSettings Load(string file) {
string text = File.ReadAllText(file, Encoding.UTF8);
return JsonSerializer.Deserialize<TextSettings>(text);
}
}
public class TextComponent : IComponent {
public static TextSettings CompileFont(string fontNameOrUrl, string output, TextSettings settings = null) {
if (settings is null)
settings = new TextSettings();
int bitmapWidth = settings.GlyphsPerLine * settings.GlyphWidth;
int bitmapHeight = settings.GlyphLineCount * settings.GlyphHeight;
using Bitmap texture = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb);
Font font;
if (File.Exists(fontNameOrUrl))
{
var collection = new PrivateFontCollection();
collection.AddFontFile(fontNameOrUrl);
var fontFamily = new FontFamily(Path.GetFileNameWithoutExtension(fontNameOrUrl), collection);
font = new Font(fontFamily, settings.FontSize);
}
else {
font = new Font(new FontFamily(fontNameOrUrl), settings.FontSize);
}
using (var g = Graphics.FromImage(texture)) {
if (settings.BitmapFont) {
g.SmoothingMode = SmoothingMode.None;
g.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
}
else {
g.SmoothingMode = SmoothingMode.HighQuality;
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
}
for (int p = 0; p < settings.GlyphLineCount; p++) {
for (int n = 0; n < settings.GlyphsPerLine; n++) {
char c = (char)(n + p * settings.GlyphsPerLine);
g.DrawString(c.ToString(), font, Brushes.White,
n * settings.GlyphWidth + settings.AtlasOffsetX,
p * settings.GlyphHeight + settings.AtlasOffsetY);
}
}
}
texture.Save(output);
return settings;
}
public string Text { get; set; }
public Vector2 Size { get; private set; }
public Color TextColor { get; set; } = Color.White;
private Shape Shape { get; set; }
private Texture Texture { get; set; }
private TextSettings Settings { get; set; }
private string CurrentText { get; set; }
public TextComponent(string fontImage, string text, TextSettings settings = null, int renderingMode = GL_STATIC_DRAW) {
Texture = new Texture(fontImage);
Shape = new Shape(Shapes.Rectangle, renderingMode);
Settings = settings is not null ? settings : new TextSettings();
}
public void Load(GameObject thisObject) {
Texture.Load();
Shape.Load();
}
public void Update(GameObject thisObject) {
if (CurrentText == Text) return;
CurrentText = Text;
List<float> vertices = new List<float>();
float x = 0;
float y = 0;
float uW = Settings.GlyphWidth / (float)Texture.Width;
float vH = Settings.GlyphHeight / (float)Texture.Height;
float w = Settings.GlyphWidth / (float)Settings.GlyphHeight;
const float h = 1.0f;
for (int n = 0; n < Text.Length; n++) {
char idx = Text[n];
if (idx == '\n') {
y += 1;
x = 0;
continue;
}
if (idx == '\t') {
x += (w + Settings.CharXSpacing) * 4;
continue;
}
float u = (idx % Settings.GlyphsPerLine) * uW + Settings.TexCoordOffset;
float v = (idx / Settings.GlyphsPerLine) * vH + Settings.TexCoordOffset;
vertices.AddRange(new[] {
x, y + h, TextColor.R, TextColor.G, TextColor.B, TextColor.A, u, v + vH,
x + w, y + h, TextColor.R, TextColor.G, TextColor.B, TextColor.A, u + uW, v + vH,
x, y, TextColor.R, TextColor.G, TextColor.B, TextColor.A, u, v,
x + w, y, TextColor.R, TextColor.G, TextColor.B, TextColor.A, u + uW, v,
x + w, y + h, TextColor.R, TextColor.G, TextColor.B, TextColor.A, u + uW, v + vH,
x, y, TextColor.R, TextColor.G, TextColor.B, TextColor.A, u, v
});
x += w + Settings.CharXSpacing;
}
Shape.SetVertices(vertices.ToArray());
Size = new Vector2(x, y);
}
public void Destroy(GameObject thisObject) {
Shape.Delete();
Texture.Delete();
}
public void Render(GameObject thisObject) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Texture.Use();
glBindVertexArray(Shape.Vao);
glDrawArrays(GL_TRIANGLES, 0, Shape.GetVertexCount());
glBindVertexArray(0);
glBindTexture(GL_TEXTURE_2D, 0);
}
}
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using static OpenGL.GL;
using OpenGLTutorial.Rendering.Cameras;
using OpenGLTutorial.Rendering.Display;
using OpenGLTutorial.Rendering.Objects.Components;
using OpenGLTutorial.Rendering.Shaders;
namespace OpenGLTutorial.Rendering.Objects {
public class GameObject {
public Shader Shader { get; set; }
public Shape Shape { get; set; }
public Texture Texture { get; set; }
public Vector2 Position { get; set; }
public Vector2 Scale { get; set; }
public float Rotation { get; set; }
private List<IComponent> _components;
public GameObject(Shader shader, Shape shape, Texture texture) {
Position = Vector2.Zero;
Scale = Vector2.One;
Rotation = 0;
Shader = shader;
Shape = shape;
Texture = texture;
_components = new List<IComponent>();
}
public void Load() {
Shader?.Load();
Shape?.Load();
Texture?.Load();
_components.ForEach(component => component.Load(this));
}
public void Update() {
_components.ForEach(component => component.Update(this));
}
public void Render(Camera2D cam, int renderMode = GL_TRIANGLES) {
Matrix4x4 trans = Matrix4x4.CreateTranslation(Position.X, -Position.Y, 0);
Matrix4x4 sca = Matrix4x4.CreateScale(Scale.X, Scale.Y, 1);
Matrix4x4 rot = Matrix4x4.CreateRotationZ(Rotation);
Texture?.Use();
Shader?.Use();
Shader?.SetMatrix4X4("model", sca * rot * trans);
Shader?.SetMatrix4X4("projection", cam.GetProjectionMatrix());
if (Shape?.Vao != null) {
glBindVertexArray(Shape.Vao);
glDrawArrays(renderMode, 0, Shape.GetVertexCount());
glBindVertexArray(0);
}
_components.ForEach(component => component.Render(this));
}
public void Destroy() {
_components.ForEach(component => component.Destroy(this));
Shader?.Delete();
Shape?.Delete();
Texture?.Delete();
}
public void AddComponent(IComponent component) => _components.Add(component);
public T GetComponent<T>() {
foreach (var component in _components) {
if (component.GetType() == typeof(T)) return (T)component;
}
throw new NullReferenceException("Object does not contain a component of type " + typeof(T));
}
public void RemoveComponent<T>() {
foreach (var component in _components) {
if (component.GetType() == typeof(T)) {
_components.Remove(component);
return;
}
}
throw new NullReferenceException("Object does not contain a component of type " + typeof(T));
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.IO;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using static OpenGL.GL;
namespace OpenGLTutorial.Rendering.Shaders {
public class Shader {
private readonly string _vertexCode;
private readonly string _fragmentCode;
private bool _loaded = false;
public uint Program { get; private set; }
public Shader(string vertexPath, string fragmentPath) {
using (var vertexReader = new StreamReader(vertexPath, Encoding.UTF8))
_vertexCode = vertexReader.ReadToEnd();
using (var fragmentReader = new StreamReader(fragmentPath, Encoding.UTF8))
_fragmentCode = fragmentReader.ReadToEnd();
}
public Shader(string shader, bool isFile = true) {
using var reader = isFile ? new StreamReader(shader, Encoding.UTF8) : null;
string source = isFile ? reader.ReadToEnd() : shader;
string[] splitString = Regex.Split(source, "(#type [a-zA-Z]+)");
string firstPattern = splitString[1].Replace("#type ", "").Trim();
string secondPattern = splitString[3].Replace("#type ", "").Trim();
if (firstPattern.ToLower().Equals("vertex"))
_vertexCode = splitString[2];
else if (firstPattern.ToLower().Equals("fragment"))
_fragmentCode = splitString[2];
else throw new IOException("Unexpected token '" + firstPattern + "' in '" + shader + "'");
if (secondPattern.ToLower().Equals("vertex"))
_vertexCode = splitString[4];
else if (secondPattern.ToLower().Equals("fragment"))
_fragmentCode = splitString[4];
else throw new IOException("Unexpected token '" + secondPattern + "' in '" + shader + "'");
}
public void Load() {
if (_loaded) return;
_loaded = true;
uint vs = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vs, _vertexCode);
glCompileShader(vs);
int[] status = glGetShaderiv(vs, GL_COMPILE_STATUS, 1);
if (status[0] == 0) {
string error = glGetShaderInfoLog(vs);
throw new Exception("Error compiling vertex shader: " + error);
}
uint fs = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fs, _fragmentCode);
glCompileShader(fs);
status = glGetShaderiv(fs, GL_COMPILE_STATUS, 1);
if (status[0] == 0) {
string error = glGetShaderInfoLog(fs);
throw new Exception("Error compiling fragment shader: " + error);
}
Program = glCreateProgram();
glAttachShader(Program, vs);
glAttachShader(Program, fs);
glLinkProgram(Program);
glDetachShader(Program, vs);
glDetachShader(Program, fs);
glDeleteShader(vs);
glDeleteShader(fs);
}
public void Use() {
glUseProgram(Program);
}
public void Delete() {
glUseProgram(0);
glDeleteProgram(Program);
}
public void SetMatrix4X4(string uniformName, Matrix4x4 matrix) {
int location = glGetUniformLocation(Program, uniformName);
glUniformMatrix4fv(location, 1, false, GetMatrix4X4Values(matrix));
}
private float[] GetMatrix4X4Values(Matrix4x4 m) {
return new [] {
m.M11, m.M12, m.M13, m.M14,
m.M21, m.M22, m.M23, m.M24,
m.M31, m.M32, m.M33, m.M34,
m.M41, m.M42, m.M43, m.M44
};
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,12 @@
{
"GlyphsPerLine": 16,
"GlyphLineCount": 16,
"GlyphWidth": 30,
"GlyphHeight": 48,
"CharXSpacing": 0,
"AtlasOffsetX": -3,
"AtlasOffsetY": -1,
"FontSize": 35,
"BitmapFont": false,
"TexCoordOffset": 0.005
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -0,0 +1,28 @@
#type vertex
#version 330 core
layout (location = 0) in vec2 aPosition;
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec2 aUV;
out vec4 vertexColor;
out vec2 uv;
uniform mat4 projection;
uniform mat4 model;
void main() {
vertexColor = aColor;
uv = aUV;
gl_Position = projection * model * vec4(aPosition.xy, 0, 1.0);
}
#type fragment
#version 330 core
out vec4 FragColor;
in vec4 vertexColor;
in vec2 uv;
uniform sampler2D texture0;
void main() {
FragColor = texture(texture0, uv) * vertexColor;
}

View File

@@ -0,0 +1,75 @@
using System.Numerics;
using GLFW;
using static OpenGL.GL;
using OpenGLTutorial.GameLoop;
using OpenGLTutorial.Rendering.Cameras;
using OpenGLTutorial.Rendering.Display;
using OpenGLTutorial.Rendering.Objects;
using OpenGLTutorial.Rendering.Objects.Components;
using OpenGLTutorial.Rendering.Shaders;
namespace OpenGLTutorial {
public class TestGame : Game {
private Camera2D _camera;
private GameObject _text;
private GameObject _test;
protected override void Initialize() {
DEBUG_CopyFolderToOutput(@"D:\Programmierstuff\C#\OpenGLTutorial\Resources");
DEBUG_CopyFileToOutput(@"D:\Programmierstuff\C#\OpenGLTutorial\glfw.dll");
}
protected override void LoadContent() {
DisplayManager.Window.SetWindowIcon(@"Resources\logo.png");
Shader shader = new Shader(@"Resources\shader.glsl");
_text = new GameObject(shader, null, null);
_text.AddComponent(new TextComponent(@"Resources\font.png", "", null, GL_DYNAMIC_DRAW));
_text.Scale = new Vector2(0.2f, 0.2f);
_text.Position = new Vector2(-4, 3);
Texture texture = new Texture(@"Resources\bricks.png");
Shape shape = new Shape(Shapes.Rectangle);
_test = new GameObject(shader, shape, texture) { Scale = new Vector2(3, 3) };
_camera = new Camera2D(Vector2.Zero, 100.0f);
_text.Load();
_test.Load();
}
private float _fpsUpdate;
protected override void Update() {
if (_fpsUpdate >= 0.2f) {
_text.GetComponent<TextComponent>().Text = "FPS: " + (int)(1f / GameTime.DeltaTime);
_fpsUpdate = 0;
}
_fpsUpdate += GameTime.DeltaTime;
_text.Update();
const float speed = 2.0f;
float x = Input.GetAxis(Axis.Horizontal) * speed * GameTime.DeltaTime + _test.Position.X;
float y = Input.GetAxis(Axis.Vertical) * speed * GameTime.DeltaTime + _test.Position.Y;
_test.Position = new Vector2(x, y);
if (Input.Keys[Keys.Escape])
DisplayManager.Window.Close();
}
protected override void Render() {
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
_test.Render(_camera);
_text.Render(_camera);
DisplayManager.Window.SwapBuffers();
}
protected override void Destroy() {
_text.Destroy();
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,133 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"OpenGLTutorial/1.0.0": {
"dependencies": {
"StbiSharp": "1.2.1",
"System.Drawing.Common": "6.0.0",
"GLFW.NET": "1.0.1.0"
},
"runtime": {
"OpenGLTutorial.dll": {}
}
},
"Microsoft.Win32.SystemEvents/6.0.0": {
"runtime": {
"lib/netcoreapp3.1/Microsoft.Win32.SystemEvents.dll": {
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp3.1/Microsoft.Win32.SystemEvents.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
}
},
"StbiSharp/1.2.1": {
"runtime": {
"lib/netcoreapp3.0/StbiSharp.dll": {
"assemblyVersion": "1.2.1.0",
"fileVersion": "1.2.1.0"
}
},
"runtimeTargets": {
"runtimes/linux-x64/native/libstbi.so": {
"rid": "linux-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
},
"runtimes/osx-x64/native/libstbi.dylib": {
"rid": "osx-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
},
"runtimes/win-x64/native/stbi.dll": {
"rid": "win-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
},
"runtimes/win-x64/native/stbi.lib": {
"rid": "win-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
}
}
},
"System.Drawing.Common/6.0.0": {
"dependencies": {
"Microsoft.Win32.SystemEvents": "6.0.0"
},
"runtime": {
"lib/netcoreapp3.1/System.Drawing.Common.dll": {
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
},
"runtimeTargets": {
"runtimes/unix/lib/netcoreapp3.1/System.Drawing.Common.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
},
"runtimes/win/lib/netcoreapp3.1/System.Drawing.Common.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
}
},
"GLFW.NET/1.0.1.0": {
"runtime": {
"GLFW.NET.dll": {
"assemblyVersion": "1.0.1.0",
"fileVersion": "1.0.1.0"
}
}
}
}
},
"libraries": {
"OpenGLTutorial/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.Win32.SystemEvents/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A==",
"path": "microsoft.win32.systemevents/6.0.0",
"hashPath": "microsoft.win32.systemevents.6.0.0.nupkg.sha512"
},
"StbiSharp/1.2.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-jbi94g3UDVAC3vH6jKZmmADH4Z6tGqbcdlyGhT/WZN9UE8OjjvpGFE5zF+UCSmIdya6iJ+Zo5VvxdQywSKN0Uw==",
"path": "stbisharp/1.2.1",
"hashPath": "stbisharp.1.2.1.nupkg.sha512"
},
"System.Drawing.Common/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-NfuoKUiP2nUWwKZN6twGqXioIe1zVD0RIj2t976A+czLHr2nY454RwwXs6JU9Htc6mwqL6Dn/nEL3dpVf2jOhg==",
"path": "system.drawing.common/6.0.0",
"hashPath": "system.drawing.common.6.0.0.nupkg.sha512"
},
"GLFW.NET/1.0.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\leon\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\leon\\.nuget\\packages",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
]
}
}

View File

@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,12 @@
{
"GlyphsPerLine": 16,
"GlyphLineCount": 16,
"GlyphWidth": 30,
"GlyphHeight": 48,
"CharXSpacing": 0,
"AtlasOffsetX": -3,
"AtlasOffsetY": -1,
"FontSize": 35,
"BitmapFont": false,
"TexCoordOffset": 0.005
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -0,0 +1,28 @@
#type vertex
#version 330 core
layout (location = 0) in vec2 aPosition;
layout (location = 1) in vec4 aColor;
layout (location = 2) in vec2 aUV;
out vec4 vertexColor;
out vec2 uv;
uniform mat4 projection;
uniform mat4 model;
void main() {
vertexColor = aColor;
uv = aUV;
gl_Position = projection * model * vec4(aPosition.xy, 0, 1.0);
}
#type fragment
#version 330 core
out vec4 FragColor;
in vec4 vertexColor;
in vec2 uv;
uniform sampler2D texture0;
void main() {
FragColor = texture(texture0, uv) * vertexColor;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,133 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"OpenGLTutorial/1.0.0": {
"dependencies": {
"StbiSharp": "1.2.1",
"System.Drawing.Common": "6.0.0",
"GLFW.NET": "1.0.1.0"
},
"runtime": {
"OpenGLTutorial.dll": {}
}
},
"Microsoft.Win32.SystemEvents/6.0.0": {
"runtime": {
"lib/netcoreapp3.1/Microsoft.Win32.SystemEvents.dll": {
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
},
"runtimeTargets": {
"runtimes/win/lib/netcoreapp3.1/Microsoft.Win32.SystemEvents.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
}
},
"StbiSharp/1.2.1": {
"runtime": {
"lib/netcoreapp3.0/StbiSharp.dll": {
"assemblyVersion": "1.2.1.0",
"fileVersion": "1.2.1.0"
}
},
"runtimeTargets": {
"runtimes/linux-x64/native/libstbi.so": {
"rid": "linux-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
},
"runtimes/osx-x64/native/libstbi.dylib": {
"rid": "osx-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
},
"runtimes/win-x64/native/stbi.dll": {
"rid": "win-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
},
"runtimes/win-x64/native/stbi.lib": {
"rid": "win-x64",
"assetType": "native",
"fileVersion": "0.0.0.0"
}
}
},
"System.Drawing.Common/6.0.0": {
"dependencies": {
"Microsoft.Win32.SystemEvents": "6.0.0"
},
"runtime": {
"lib/netcoreapp3.1/System.Drawing.Common.dll": {
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
},
"runtimeTargets": {
"runtimes/unix/lib/netcoreapp3.1/System.Drawing.Common.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
},
"runtimes/win/lib/netcoreapp3.1/System.Drawing.Common.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "6.0.0.0",
"fileVersion": "6.0.21.52210"
}
}
},
"GLFW.NET/1.0.1.0": {
"runtime": {
"GLFW.NET.dll": {
"assemblyVersion": "1.0.1.0",
"fileVersion": "1.0.1.0"
}
}
}
}
},
"libraries": {
"OpenGLTutorial/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.Win32.SystemEvents/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A==",
"path": "microsoft.win32.systemevents/6.0.0",
"hashPath": "microsoft.win32.systemevents.6.0.0.nupkg.sha512"
},
"StbiSharp/1.2.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-jbi94g3UDVAC3vH6jKZmmADH4Z6tGqbcdlyGhT/WZN9UE8OjjvpGFE5zF+UCSmIdya6iJ+Zo5VvxdQywSKN0Uw==",
"path": "stbisharp/1.2.1",
"hashPath": "stbisharp.1.2.1.nupkg.sha512"
},
"System.Drawing.Common/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-NfuoKUiP2nUWwKZN6twGqXioIe1zVD0RIj2t976A+czLHr2nY454RwwXs6JU9Htc6mwqL6Dn/nEL3dpVf2jOhg==",
"path": "system.drawing.common/6.0.0",
"hashPath": "system.drawing.common.6.0.0.nupkg.sha512"
},
"GLFW.NET/1.0.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

View File

@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\leon\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\leon\\.nuget\\packages",
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
]
}
}

View File

@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
}
}
}

Binary file not shown.

BIN
C#/OpenGLTutorial/glfw.dll Normal file

Binary file not shown.

View File

@@ -0,0 +1,7 @@
{
"sdk": {
"version": "5.0",
"rollForward": "latestMajor",
"allowPrerelease": false
}
}

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("OpenGLTutorial")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("OpenGLTutorial")]
[assembly: System.Reflection.AssemblyTitleAttribute("OpenGLTutorial")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View File

@@ -0,0 +1 @@
e23398e549e482400cd2dfa9b5c58a3713ff2353

View File

@@ -0,0 +1,10 @@
is_global = true
build_property.TargetFramework = net5.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = OpenGLTutorial
build_property.ProjectDir = D:\Programmierstuff\C#\OpenGLTutorial\

View File

@@ -0,0 +1 @@
be806e03507d4ca29e1663d228ece7f9efae15fe

View File

@@ -0,0 +1,28 @@
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.csproj.AssemblyReference.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.GeneratedMSBuildEditorConfig.editorconfig
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.AssemblyInfoInputs.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.AssemblyInfo.cs
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.csproj.CoreCompileInputs.cache
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\OpenGLTutorial.exe
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\OpenGLTutorial.deps.json
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\OpenGLTutorial.runtimeconfig.json
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\OpenGLTutorial.runtimeconfig.dev.json
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\OpenGLTutorial.pdb
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\GLFW.NET.dll
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.csproj.CopyComplete
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\refint\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.pdb
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\OpenGLTutorial.genruntimeconfig.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Debug\net5.0\ref\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\Microsoft.Win32.SystemEvents.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\System.Drawing.Common.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\win\lib\netcoreapp3.1\Microsoft.Win32.SystemEvents.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\unix\lib\netcoreapp3.1\System.Drawing.Common.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\win\lib\netcoreapp3.1\System.Drawing.Common.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\StbiSharp.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\linux-x64\native\libstbi.so
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\osx-x64\native\libstbi.dylib
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\win-x64\native\stbi.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Debug\net5.0\runtimes\win-x64\native\stbi.lib

Binary file not shown.

View File

@@ -0,0 +1 @@
9d520c1efec991d500191924ddd0a63136a3d25f

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,76 @@
{
"format": 1,
"restore": {
"D:\\Programmierstuff\\C#\\OpenGLTutorial\\OpenGLTutorial.csproj": {}
},
"projects": {
"D:\\Programmierstuff\\C#\\OpenGLTutorial\\OpenGLTutorial.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\Programmierstuff\\C#\\OpenGLTutorial\\OpenGLTutorial.csproj",
"projectName": "OpenGLTutorial",
"projectPath": "D:\\Programmierstuff\\C#\\OpenGLTutorial\\OpenGLTutorial.csproj",
"packagesPath": "C:\\Users\\leon\\.nuget\\packages\\",
"outputPath": "D:\\Programmierstuff\\C#\\OpenGLTutorial\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\leon\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net5.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net5.0": {
"targetAlias": "net5.0",
"dependencies": {
"StbiSharp": {
"target": "Package",
"version": "[1.2.1, )"
},
"System.Drawing.Common": {
"target": "Package",
"version": "[6.0.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\leon\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.10.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\leon\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]

View File

@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("OpenGLTutorial")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("OpenGLTutorial")]
[assembly: System.Reflection.AssemblyTitleAttribute("OpenGLTutorial")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Von der MSBuild WriteCodeFragment-Klasse generiert.

View File

@@ -0,0 +1 @@
acc76bea0c290951aef98ca4acf42e9d4bab155c

View File

@@ -0,0 +1,10 @@
is_global = true
build_property.TargetFramework = net5.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = OpenGLTutorial
build_property.ProjectDir = D:\Programmierstuff\C#\OpenGLTutorial\

View File

@@ -0,0 +1 @@
036a76dd718810765f5c66a782be1036dea2dd1f

View File

@@ -0,0 +1,28 @@
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\OpenGLTutorial.exe
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\OpenGLTutorial.deps.json
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\OpenGLTutorial.runtimeconfig.json
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\OpenGLTutorial.runtimeconfig.dev.json
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\OpenGLTutorial.pdb
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\Microsoft.Win32.SystemEvents.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\StbiSharp.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\System.Drawing.Common.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\win\lib\netcoreapp3.1\Microsoft.Win32.SystemEvents.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\linux-x64\native\libstbi.so
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\osx-x64\native\libstbi.dylib
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\win-x64\native\stbi.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\win-x64\native\stbi.lib
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\unix\lib\netcoreapp3.1\System.Drawing.Common.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\runtimes\win\lib\netcoreapp3.1\System.Drawing.Common.dll
D:\Programmierstuff\C#\OpenGLTutorial\bin\Release\net5.0\GLFW.NET.dll
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.csproj.AssemblyReference.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.GeneratedMSBuildEditorConfig.editorconfig
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.AssemblyInfoInputs.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.AssemblyInfo.cs
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.csproj.CoreCompileInputs.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.csproj.CopyComplete
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\refint\OpenGLTutorial.dll
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.pdb
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\OpenGLTutorial.genruntimeconfig.cache
D:\Programmierstuff\C#\OpenGLTutorial\obj\Release\net5.0\ref\OpenGLTutorial.dll

Some files were not shown because too many files have changed in this diff Show More