From 04f9aab10bebe32ffb304e0867b5fadce3a8bc0b Mon Sep 17 00:00:00 2001 From: Harrison Date: Sat, 4 Apr 2020 17:35:06 -0500 Subject: [PATCH] Added documentation. Added more documentation. Corrected doc. --- RecrownedGTK/Graphics/Camera.cs | 21 +++++++++++ .../Graphics/ElementBufferArrayHandle.cs | 1 + RecrownedGTK/Graphics/TextureData.cs | 36 +++++++++++++++++++ .../Graphics/VertexAttributesArrayHandle.cs | 11 ++++++ .../Graphics/VertexBufferArrayHandle.cs | 3 ++ RecrownedGTK/Graphics/VertexInformation.cs | 3 ++ RecrownedGTK/Persistence/PreferencesInfo.cs | 21 +++++++++++ 7 files changed, 96 insertions(+) diff --git a/RecrownedGTK/Graphics/Camera.cs b/RecrownedGTK/Graphics/Camera.cs index 27cf939..0568c38 100644 --- a/RecrownedGTK/Graphics/Camera.cs +++ b/RecrownedGTK/Graphics/Camera.cs @@ -1,8 +1,16 @@ using OpenTK; namespace RecrownedGTK.Graphics { + /// + /// Basic camera handling up to x, y and z axis. + /// public class Camera { private Vector3 scale = new Vector3(1f), translate, rotation; + + /// + /// Scale factor multiplied to the camera coordinates. + /// + /// The value to be multiplied. public Vector3 Scale { get { return scale; @@ -12,12 +20,21 @@ namespace RecrownedGTK.Graphics { scale = value; } } + + /// + /// The translation applied after scaling and rotating. + /// + /// public Vector3 Translate { set { updated = true; translate = value; } } + /// + /// Rotation applied before translation. + /// + /// public Vector3 Rotation { set { updated = true; @@ -29,6 +46,10 @@ namespace RecrownedGTK.Graphics { } private Matrix4 transform; + /// + /// If values have updated, recalculate transformation matrix. + /// + /// The transformation matrix. public Matrix4 Transform { get { if (!updated) return transform; diff --git a/RecrownedGTK/Graphics/ElementBufferArrayHandle.cs b/RecrownedGTK/Graphics/ElementBufferArrayHandle.cs index e772a7f..8c196d9 100644 --- a/RecrownedGTK/Graphics/ElementBufferArrayHandle.cs +++ b/RecrownedGTK/Graphics/ElementBufferArrayHandle.cs @@ -11,6 +11,7 @@ namespace RecrownedGTK.Graphics { public void Bind() { GL.BindBuffer(BufferTarget.ElementArrayBuffer, handle); } + public void Buffer(uint[] indices, BufferUsageHint hint = BufferUsageHint.DynamicDraw) { Bind(); GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, hint); diff --git a/RecrownedGTK/Graphics/TextureData.cs b/RecrownedGTK/Graphics/TextureData.cs index f158247..4cd5351 100644 --- a/RecrownedGTK/Graphics/TextureData.cs +++ b/RecrownedGTK/Graphics/TextureData.cs @@ -4,6 +4,10 @@ using OpenTK.Graphics.OpenGL; using OpenTK.Graphics; using System; namespace RecrownedGTK.Graphics { + /// + /// Represents the texture for any given vertice. + /// Contains bytes that form the texture. + /// public class TextureData : IDisposable { private bool disposed; int handle; @@ -13,6 +17,10 @@ namespace RecrownedGTK.Graphics { public TextureMinFilter textureMinFilter; public TextureMagFilter textureMagFilter; + /// + /// Generates a texture data with a png. + /// + /// A path to a texture represented in PNG format. public TextureData(string path) { int width; int height; @@ -20,6 +28,12 @@ namespace RecrownedGTK.Graphics { GenerateTexture(textureData, width, height); } + /// + /// Generates a texture using a byte array of the texture data. + /// + /// The byte array representing the texture. + /// The width of the texture. + /// The height of the texture. public TextureData(byte[] textureData, int width, int height) { textureWrapModeHeight = TextureWrapMode.ClampToBorder; textureWrapModeWidth = TextureWrapMode.ClampToBorder; @@ -30,6 +44,15 @@ namespace RecrownedGTK.Graphics { GenerateTexture(textureData, width, height); } + /// + ///Load PNG data to this texture representation. + /// + /// Decodes the PNG into a byte array to be stored. + /// + /// The path to the PNG file to be represented. + /// Outputs the width of the PNG file. + /// Outputs the height of the PNG file. + /// A byte array representing the PNG. private byte[] LoadPNG(string path, out int width, out int height) { byte[] textureData = null; using (FileStream file = new FileStream(path, FileMode.Open)) { @@ -43,6 +66,12 @@ namespace RecrownedGTK.Graphics { return textureData; } + /// + /// Generates a texture in the OpenGL context. + /// + /// Byte array representing the texture. + /// Width of the texture. + /// Height of the texture. private void GenerateTexture(byte[] textureData, int width, int height) { if (handle != 0) throw new InvalidOperationException("This texture data already holds a texture."); handle = GL.GenTexture(); @@ -51,9 +80,16 @@ namespace RecrownedGTK.Graphics { GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); } + /// + /// Binds the OpenGL texture. + /// internal void Use() { GL.BindTexture(TextureTarget.Texture2D, handle); } + + /// + /// Removes texture data from memory. + /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); diff --git a/RecrownedGTK/Graphics/VertexAttributesArrayHandle.cs b/RecrownedGTK/Graphics/VertexAttributesArrayHandle.cs index 6839449..14c4f68 100644 --- a/RecrownedGTK/Graphics/VertexAttributesArrayHandle.cs +++ b/RecrownedGTK/Graphics/VertexAttributesArrayHandle.cs @@ -3,13 +3,24 @@ using OpenTK.Graphics.OpenGL; using OpenTK; using RecrownedGTK.Graphics.Render.Shaders; namespace RecrownedGTK.Graphics { + /// + /// The attributes of the vertex. + /// Handle for openGL. + /// public class VertexAttributesArrayHandle : IDisposable { private bool disposed; private int handle; + + /// + /// Generates an openGL vertex array. + /// public VertexAttributesArrayHandle() { handle = GL.GenVertexArray(); } + /// + /// Tells openGL to bind this vertex attributes array. + /// public void Bind() { GL.BindVertexArray(handle); } diff --git a/RecrownedGTK/Graphics/VertexBufferArrayHandle.cs b/RecrownedGTK/Graphics/VertexBufferArrayHandle.cs index 9a90b7c..78dbb1e 100644 --- a/RecrownedGTK/Graphics/VertexBufferArrayHandle.cs +++ b/RecrownedGTK/Graphics/VertexBufferArrayHandle.cs @@ -1,6 +1,9 @@ using System; using OpenTK.Graphics.OpenGL; namespace RecrownedGTK.Graphics { + /// + /// Handles the openGL vertex buffer. + /// public class VertexBufferArrayHandle : IDisposable { private bool disposed; private int handle; diff --git a/RecrownedGTK/Graphics/VertexInformation.cs b/RecrownedGTK/Graphics/VertexInformation.cs index fe86793..8c8b78b 100644 --- a/RecrownedGTK/Graphics/VertexInformation.cs +++ b/RecrownedGTK/Graphics/VertexInformation.cs @@ -1,6 +1,9 @@ using OpenTK; using OpenTK.Graphics; namespace RecrownedGTK.Graphics { + /// + /// Stores the information that is required per vertex. + /// public struct VertexInformation { public Vector3 coords; public Vector2 textureCoords; diff --git a/RecrownedGTK/Persistence/PreferencesInfo.cs b/RecrownedGTK/Persistence/PreferencesInfo.cs index f663bde..82091ae 100644 --- a/RecrownedGTK/Persistence/PreferencesInfo.cs +++ b/RecrownedGTK/Persistence/PreferencesInfo.cs @@ -1,7 +1,18 @@ using System.Collections.Generic; namespace RecrownedGTK.Persistence { + /// + /// Serializable preferences. + /// public struct PreferencesInfo { + /// + /// Array of preferences. + /// public PreferenceInfo[] preferences; + + /// + /// Sets the serializable preference with a string string value pair dictionary. + /// + /// A dictionary of string and string pair. public void SetPreferences(Dictionary preferences) { this.preferences = new PreferenceInfo[preferences.Count]; @@ -13,6 +24,10 @@ namespace RecrownedGTK.Persistence { } } + /// + /// Return a dictionary containing a string string key value pair. + /// + /// Dictionary with a string value and string key representing a preference option. public Dictionary GetPreferences() { Dictionary res = new Dictionary(); for (int prefID = 0; prefID < preferences.Length; prefID++) { @@ -21,7 +36,13 @@ namespace RecrownedGTK.Persistence { return res; } + /// + /// Serializable preference option. + /// public struct PreferenceInfo { + /// + /// The key and value of the option in the preferences. + /// public string key, value; public PreferenceInfo(string key, string value) {