mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-12 06:30:39 +00:00
[WIP] Updated Renderer3D
This commit is contained in:
@@ -60,9 +60,7 @@
|
||||
this.comboParent = new System.Windows.Forms.ComboBox();
|
||||
this.buttonEXPORT = new System.Windows.Forms.Button();
|
||||
this.buttonIMPORT = new System.Windows.Forms.Button();
|
||||
this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox();
|
||||
this.buttonImportModel = new System.Windows.Forms.Button();
|
||||
this.displayBox = new System.Windows.Forms.PictureBox();
|
||||
this.buttonExportModel = new System.Windows.Forms.Button();
|
||||
this.OpenJSONButton = new System.Windows.Forms.Button();
|
||||
this.buttonTemplate = new MetroFramework.Controls.MetroButton();
|
||||
@@ -87,6 +85,8 @@
|
||||
this.U = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.V = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.listViewBoxes = new System.Windows.Forms.ListView();
|
||||
this.renderer3D1 = new PckStudio.Rendering.Renderer3D();
|
||||
this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox();
|
||||
label6 = new System.Windows.Forms.Label();
|
||||
label5 = new System.Windows.Forms.Label();
|
||||
label3 = new System.Windows.Forms.Label();
|
||||
@@ -97,8 +97,6 @@
|
||||
this.tabBody.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.myTablePanel2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.displayBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SizeXUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SizeYUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SizeZUpDown)).BeginInit();
|
||||
@@ -107,6 +105,7 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.PosZUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PosYUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PosXUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label6
|
||||
@@ -325,14 +324,6 @@
|
||||
this.buttonIMPORT.UseVisualStyleBackColor = true;
|
||||
this.buttonIMPORT.Click += new System.EventHandler(this.buttonIMPORT_Click);
|
||||
//
|
||||
// uvPictureBox
|
||||
//
|
||||
this.uvPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
resources.ApplyResources(this.uvPictureBox, "uvPictureBox");
|
||||
this.uvPictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
this.uvPictureBox.Name = "uvPictureBox";
|
||||
this.uvPictureBox.TabStop = false;
|
||||
//
|
||||
// buttonImportModel
|
||||
//
|
||||
resources.ApplyResources(this.buttonImportModel, "buttonImportModel");
|
||||
@@ -341,14 +332,6 @@
|
||||
this.buttonImportModel.UseVisualStyleBackColor = true;
|
||||
this.buttonImportModel.Click += new System.EventHandler(this.buttonImportModel_Click);
|
||||
//
|
||||
// displayBox
|
||||
//
|
||||
this.displayBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50)))));
|
||||
this.displayBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
resources.ApplyResources(this.displayBox, "displayBox");
|
||||
this.displayBox.Name = "displayBox";
|
||||
this.displayBox.TabStop = false;
|
||||
//
|
||||
// buttonExportModel
|
||||
//
|
||||
resources.ApplyResources(this.buttonExportModel, "buttonExportModel");
|
||||
@@ -555,10 +538,44 @@
|
||||
this.listViewBoxes.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
|
||||
this.listViewBoxes.KeyDown += new System.Windows.Forms.KeyEventHandler(this.delStuffUsingDelKey);
|
||||
//
|
||||
// renderer3D1
|
||||
//
|
||||
resources.ApplyResources(this.renderer3D1, "renderer3D1");
|
||||
this.renderer3D1.BackColor = System.Drawing.Color.DarkGray;
|
||||
this.renderer3D1.CameraDistance = 72F;
|
||||
this.renderer3D1.LookAngle = ((OpenTK.Vector2)(resources.GetObject("renderer3D1.LookAngle")));
|
||||
this.renderer3D1.Model = PckStudio.Rendering.Renderer3D.Models.Steve;
|
||||
this.renderer3D1.Name = "renderer3D1";
|
||||
this.renderer3D1.Rotation = ((OpenTK.Vector2)(resources.GetObject("renderer3D1.Rotation")));
|
||||
this.renderer3D1.ShowBody = true;
|
||||
this.renderer3D1.ShowBodyOverlay = true;
|
||||
this.renderer3D1.ShowHead = true;
|
||||
this.renderer3D1.ShowHeadOverlay = true;
|
||||
this.renderer3D1.ShowLeftArm = true;
|
||||
this.renderer3D1.ShowLeftArmOverlay = true;
|
||||
this.renderer3D1.ShowLeftLeg = true;
|
||||
this.renderer3D1.ShowLeftLegOverlay = true;
|
||||
this.renderer3D1.ShowRightArm = true;
|
||||
this.renderer3D1.ShowRightArmOverlay = true;
|
||||
this.renderer3D1.ShowRightLeg = true;
|
||||
this.renderer3D1.ShowRightLegOverlay = true;
|
||||
this.renderer3D1.Texture = null;
|
||||
this.renderer3D1.VSync = true;
|
||||
this.renderer3D1.FieldOfView = 1D;
|
||||
//
|
||||
// uvPictureBox
|
||||
//
|
||||
this.uvPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
resources.ApplyResources(this.uvPictureBox, "uvPictureBox");
|
||||
this.uvPictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
this.uvPictureBox.Name = "uvPictureBox";
|
||||
this.uvPictureBox.TabStop = false;
|
||||
//
|
||||
// generateModel
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.renderer3D1);
|
||||
this.Controls.Add(this.PosZUpDown);
|
||||
this.Controls.Add(this.PosYUpDown);
|
||||
this.Controls.Add(this.PosXUpDown);
|
||||
@@ -571,7 +588,6 @@
|
||||
this.Controls.Add(this.checkGuide);
|
||||
this.Controls.Add(this.generateTextureCheckBox);
|
||||
this.Controls.Add(this.buttonTemplate);
|
||||
this.Controls.Add(this.displayBox);
|
||||
this.Controls.Add(this.listViewBoxes);
|
||||
this.Controls.Add(this.OpenJSONButton);
|
||||
this.Controls.Add(this.buttonExportModel);
|
||||
@@ -603,8 +619,6 @@
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.myTablePanel2.ResumeLayout(false);
|
||||
this.myTablePanel2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.displayBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SizeXUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SizeYUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SizeZUpDown)).EndInit();
|
||||
@@ -613,6 +627,7 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.PosZUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PosYUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PosXUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -627,7 +642,6 @@
|
||||
private System.Windows.Forms.Button buttonDone;
|
||||
private System.Windows.Forms.Button OpenJSONButton;
|
||||
private System.Windows.Forms.Button buttonExportModel;
|
||||
private System.Windows.Forms.PictureBox displayBox;
|
||||
private System.Windows.Forms.Button buttonImportModel;
|
||||
private PckStudio.ToolboxItems.InterpolationPictureBox uvPictureBox;
|
||||
private System.Windows.Forms.Button buttonIMPORT;
|
||||
@@ -671,5 +685,6 @@
|
||||
private System.Windows.Forms.ColumnHeader U;
|
||||
private System.Windows.Forms.ColumnHeader V;
|
||||
private System.Windows.Forms.ListView listViewBoxes;
|
||||
private Rendering.Renderer3D renderer3D1;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -960,33 +960,6 @@
|
||||
<data name=">>buttonIMPORT.ZOrder" xml:space="preserve">
|
||||
<value>23</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>655, 72</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>128, 128</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
|
||||
<value>Zoom</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>112</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.Name" xml:space="preserve">
|
||||
<value>uvPictureBox</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.Type" xml:space="preserve">
|
||||
<value>PckStudio.PictureBoxWithInterpolationMode, PCK-Studio, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.ZOrder" xml:space="preserve">
|
||||
<value>20</value>
|
||||
</data>
|
||||
<data name="buttonImportModel.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
|
||||
<value>Flat</value>
|
||||
</data>
|
||||
@@ -1017,33 +990,6 @@
|
||||
<data name=">>buttonImportModel.ZOrder" xml:space="preserve">
|
||||
<value>17</value>
|
||||
</data>
|
||||
<data name="displayBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="displayBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>194, 56</value>
|
||||
</data>
|
||||
<data name="displayBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>449, 580</value>
|
||||
</data>
|
||||
<data name="displayBox.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
|
||||
<value>StretchImage</value>
|
||||
</data>
|
||||
<data name="displayBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>98</value>
|
||||
</data>
|
||||
<data name=">>displayBox.Name" xml:space="preserve">
|
||||
<value>displayBox</value>
|
||||
</data>
|
||||
<data name=">>displayBox.Type" xml:space="preserve">
|
||||
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name=">>displayBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>displayBox.ZOrder" xml:space="preserve">
|
||||
<value>13</value>
|
||||
</data>
|
||||
<data name="buttonExportModel.FlatStyle" type="System.Windows.Forms.FlatStyle, System.Windows.Forms">
|
||||
<value>Flat</value>
|
||||
</data>
|
||||
@@ -1126,7 +1072,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>buttonTemplate.ZOrder" xml:space="preserve">
|
||||
<value>12</value>
|
||||
<value>13</value>
|
||||
</data>
|
||||
<data name="generateTextureCheckBox.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
@@ -1153,7 +1099,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>generateTextureCheckBox.ZOrder" xml:space="preserve">
|
||||
<value>11</value>
|
||||
<value>12</value>
|
||||
</data>
|
||||
<data name="checkGuide.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
@@ -1180,7 +1126,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>checkGuide.ZOrder" xml:space="preserve">
|
||||
<value>10</value>
|
||||
<value>11</value>
|
||||
</data>
|
||||
<data name="checkBoxArmor.AutoSize" type="System.Boolean, mscorlib">
|
||||
<value>True</value>
|
||||
@@ -1207,7 +1153,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>checkBoxArmor.ZOrder" xml:space="preserve">
|
||||
<value>9</value>
|
||||
<value>10</value>
|
||||
</data>
|
||||
<data name="SizeXUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>658, 275</value>
|
||||
@@ -1231,7 +1177,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>SizeXUpDown.ZOrder" xml:space="preserve">
|
||||
<value>8</value>
|
||||
<value>9</value>
|
||||
</data>
|
||||
<data name="SizeYUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>658, 301</value>
|
||||
@@ -1255,7 +1201,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>SizeYUpDown.ZOrder" xml:space="preserve">
|
||||
<value>7</value>
|
||||
<value>8</value>
|
||||
</data>
|
||||
<data name="SizeZUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>658, 327</value>
|
||||
@@ -1279,7 +1225,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>SizeZUpDown.ZOrder" xml:space="preserve">
|
||||
<value>6</value>
|
||||
<value>7</value>
|
||||
</data>
|
||||
<data name="TextureXUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>682, 233</value>
|
||||
@@ -1300,7 +1246,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>TextureXUpDown.ZOrder" xml:space="preserve">
|
||||
<value>5</value>
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="TextureYUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>731, 234</value>
|
||||
@@ -1321,7 +1267,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>TextureYUpDown.ZOrder" xml:space="preserve">
|
||||
<value>4</value>
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="PosZUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>657, 425</value>
|
||||
@@ -1345,7 +1291,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>PosZUpDown.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="PosYUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>658, 399</value>
|
||||
@@ -1369,7 +1315,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>PosYUpDown.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="PosXUpDown.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>658, 373</value>
|
||||
@@ -1393,7 +1339,7 @@
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>PosXUpDown.ZOrder" xml:space="preserve">
|
||||
<value>3</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="Part.Text" xml:space="preserve">
|
||||
<value>Part</value>
|
||||
@@ -1485,6 +1431,71 @@
|
||||
<data name=">>listViewBoxes.ZOrder" xml:space="preserve">
|
||||
<value>14</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top, Bottom, Left, Right</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>194, 59</value>
|
||||
</data>
|
||||
<data name="renderer3D1.LookAngle" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAElPcGVuVEssIFZlcnNpb249My4zLjMuMCwgQ3VsdHVyZT1uZXV0
|
||||
cmFsLCBQdWJsaWNLZXlUb2tlbj1iYWQxOTlmZTg0ZWIzZGY0BQEAAAAOT3BlblRLLlZlY3RvcjICAAAA
|
||||
AVgBWQAACwsCAAAAAAAAAAAAAAAL
|
||||
</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Rotation" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAElPcGVuVEssIFZlcnNpb249My4zLjMuMCwgQ3VsdHVyZT1uZXV0
|
||||
cmFsLCBQdWJsaWNLZXlUb2tlbj1iYWQxOTlmZTg0ZWIzZGY0BQEAAAAOT3BlblRLLlZlY3RvcjICAAAA
|
||||
AVgBWQAACwsCAAAAAAAAAAAAAAAL
|
||||
</value>
|
||||
</data>
|
||||
<data name="renderer3D1.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>449, 574</value>
|
||||
</data>
|
||||
<data name="renderer3D1.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<data name=">>renderer3D1.Name" xml:space="preserve">
|
||||
<value>renderer3D1</value>
|
||||
</data>
|
||||
<data name=">>renderer3D1.Type" xml:space="preserve">
|
||||
<value>PckStudio.Rendering.Renderer3D, PCK-Studio, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>renderer3D1.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>renderer3D1.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>655, 72</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>128, 128</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
|
||||
<value>Zoom</value>
|
||||
</data>
|
||||
<data name="uvPictureBox.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>112</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.Name" xml:space="preserve">
|
||||
<value>uvPictureBox</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.Type" xml:space="preserve">
|
||||
<value>PckStudio.ToolboxItems.InterpolationPictureBox, PCK-Studio, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
</data>
|
||||
<data name=">>uvPictureBox.ZOrder" xml:space="preserve">
|
||||
<value>20</value>
|
||||
</data>
|
||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
@@ -4003,6 +4014,9 @@
|
||||
AP//AAA=
|
||||
</value>
|
||||
</data>
|
||||
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>1114, 1000</value>
|
||||
</data>
|
||||
|
||||
4
PCK-Studio/Forms/TestGL.Designer.cs
generated
4
PCK-Studio/Forms/TestGL.Designer.cs
generated
@@ -38,8 +38,6 @@
|
||||
this.renderer3D1.Location = new System.Drawing.Point(0, 0);
|
||||
this.renderer3D1.Model = PckStudio.Rendering.Renderer3D.Models.Steve;
|
||||
this.renderer3D1.Name = "renderer3D1";
|
||||
this.renderer3D1.RotationX = 0;
|
||||
this.renderer3D1.RotationY = 0;
|
||||
this.renderer3D1.ShowBodyOverlay = true;
|
||||
this.renderer3D1.ShowHeadOverlay = true;
|
||||
this.renderer3D1.ShowLeftArmOverlay = true;
|
||||
@@ -55,7 +53,7 @@
|
||||
this.renderer3D1.Size = new System.Drawing.Size(426, 428);
|
||||
this.renderer3D1.Texture = global::PckStudio.Properties.Resources.classic_template;
|
||||
this.renderer3D1.TabIndex = 8;
|
||||
this.renderer3D1.Zoom = 1D;
|
||||
this.renderer3D1.FieldOfView = 1D;
|
||||
//
|
||||
// TestGL
|
||||
//
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -13,33 +14,23 @@ namespace PckStudio.Forms
|
||||
{
|
||||
public partial class TestGL : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.Run(new TestGL());
|
||||
}
|
||||
|
||||
public TestGL()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
internal Bitmap Skin = Resources.classic_template;
|
||||
internal void UpdateImage()
|
||||
{
|
||||
var Image = new Bitmap(Skin.Width, Skin.Height); // Create the skin preview bitmao
|
||||
if (!(Skin.Width == 64 && Skin.Height == 64)) // Check the skin resolution
|
||||
{
|
||||
MessageBox.Show("Skin isn't valid.", "Error");
|
||||
return;
|
||||
}
|
||||
// ****************Writing pixels to the preview****************
|
||||
for (byte Y = 0, loopTo = (byte)(Skin.Height - 1); Y <= loopTo; Y++)
|
||||
{
|
||||
for (byte X = 0, loopTo1 = (byte)(Skin.Width - 1); X <= loopTo1; X++)
|
||||
Image.SetPixel(X, Y, Skin.GetPixel(X / 2, Y / 2));
|
||||
}
|
||||
// *************************************************************
|
||||
renderer3D1.Texture = Skin;
|
||||
renderer3D1.Refresh(); // Render
|
||||
}
|
||||
private void TestGL_Load(object sender, EventArgs e)
|
||||
{
|
||||
UpdateImage(); // Load preview
|
||||
renderer3D1.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<PropertyGroup>
|
||||
<StartupObject>PckStudio.Program</StartupObject>
|
||||
<StartupObject>PckStudio.Forms.TestGL</StartupObject>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup />
|
||||
<PropertyGroup>
|
||||
@@ -151,6 +151,13 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Rendering\IndexBuffer.cs" />
|
||||
<Compile Include="Rendering\Renderer.cs" />
|
||||
<Compile Include="Rendering\Shader.cs" />
|
||||
<Compile Include="Rendering\Texture2D.cs" />
|
||||
<Compile Include="Rendering\VertexArray.cs" />
|
||||
<Compile Include="Rendering\VertexBuffer.cs" />
|
||||
<Compile Include="Rendering\VertexBufferLayout.cs" />
|
||||
<Compile Include="ToolboxItems\BlendPictureBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
@@ -621,7 +628,7 @@
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\steve.png" />
|
||||
<None Include="Resources\vertexShader.glsl" />
|
||||
<None Include="Resources\entityData.json" />
|
||||
<None Include="Resources\TexturePackIcon.png" />
|
||||
<None Include="Resources\binka\binkawin.asi" />
|
||||
@@ -674,6 +681,7 @@
|
||||
<None Include="Resources\iconImageList\ENTITY MATERIALS ICON.png" />
|
||||
<None Include="Resources\iconImageList\blank.png" />
|
||||
<None Include="Resources\entities.png" />
|
||||
<None Include="Resources\fragment.glsl" />
|
||||
<Content Include="Resources\icons\file_delete.png" />
|
||||
<Content Include="Resources\icons\file_empty.png" />
|
||||
<None Include="Resources\icons\file_export.png" />
|
||||
|
||||
42
PCK-Studio/Properties/Resources.Designer.cs
generated
42
PCK-Studio/Properties/Resources.Designer.cs
generated
@@ -334,6 +334,22 @@ namespace PckStudio.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to #version 330 core
|
||||
///
|
||||
///layout(location = 0) out vec4 color;
|
||||
///
|
||||
///void main()
|
||||
///{
|
||||
/// color = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
///};.
|
||||
/// </summary>
|
||||
public static string fragmentShader {
|
||||
get {
|
||||
return ResourceManager.GetString("fragmentShader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@@ -584,16 +600,6 @@ namespace PckStudio.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
public static System.Drawing.Bitmap steve {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("steve", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@@ -775,6 +781,22 @@ namespace PckStudio.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to #version 330 core
|
||||
///
|
||||
///layout(location = 0) in vec2 position;
|
||||
///
|
||||
///void main()
|
||||
///{
|
||||
/// gl_Position = vec4(position.xy, 0.0, 0.0);
|
||||
///};.
|
||||
/// </summary>
|
||||
public static string vertexShader {
|
||||
get {
|
||||
return ResourceManager.GetString("vertexShader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
||||
@@ -328,7 +328,10 @@
|
||||
<data name="ProjectLogo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\..\ProjectLogo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="steve" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\steve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="vertexShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\vertexShader.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="fragmentShader" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\fragment.glsl;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
</root>
|
||||
42
PCK-Studio/Rendering/IndexBuffer.cs
Normal file
42
PCK-Studio/Rendering/IndexBuffer.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal class IndexBuffer : IDisposable
|
||||
{
|
||||
private int _id;
|
||||
private int _count;
|
||||
|
||||
public IndexBuffer(params uint[] indecies)
|
||||
{
|
||||
_id = GL.GenBuffer();
|
||||
Bind();
|
||||
_count = indecies.Length;
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, indecies.Length * sizeof(uint), indecies, BufferUsageHint.StaticDraw);
|
||||
}
|
||||
|
||||
public int GetCount() => _count;
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _id);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GL.DeleteBuffer(_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
PCK-Studio/Rendering/Renderer.cs
Normal file
27
PCK-Studio/Rendering/Renderer.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal static class Renderer
|
||||
{
|
||||
public static void Draw(VertexArray va, IndexBuffer ib, Shader shader)
|
||||
{
|
||||
shader.Bind();
|
||||
va.Bind();
|
||||
ib.Bind();
|
||||
GL.DrawElements(PrimitiveType.Triangles, ib.GetCount(), DrawElementsType.UnsignedInt, 0);
|
||||
}
|
||||
|
||||
public static void Draw(VertexArray va, Shader shader)
|
||||
{
|
||||
shader.Bind();
|
||||
va.Bind();
|
||||
GL.DrawArrays(PrimitiveType.Triangles, 0, 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
PCK-Studio/Rendering/Renderer3D.Designer.cs
generated
32
PCK-Studio/Rendering/Renderer3D.Designer.cs
generated
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
@@ -33,43 +31,43 @@ namespace PckStudio.Rendering
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
timMove = new Timer(components);
|
||||
timMove.Tick += new EventHandler(Move_Tick);
|
||||
moveTimer = new System.Windows.Forms.Timer(components);
|
||||
moveTimer.Tick += new EventHandler(Move_Tick);
|
||||
SuspendLayout();
|
||||
//
|
||||
// timMove
|
||||
//
|
||||
timMove.Enabled = true;
|
||||
timMove.Interval = 20;
|
||||
moveTimer.Enabled = true;
|
||||
moveTimer.Interval = 20;
|
||||
#if DEBUG
|
||||
//
|
||||
// debugLabel
|
||||
//
|
||||
debugLabel = new System.Windows.Forms.Label();
|
||||
debugLabel.Enabled = true;
|
||||
debugLabel.Visible = true;
|
||||
debugLabel.Visible = false;
|
||||
debugLabel.AutoSize = true;
|
||||
debugLabel.Location = new Point(0, 0);
|
||||
debugLabel.BackColor = Color.Transparent;
|
||||
Controls.Add(debugLabel);
|
||||
debugLabel.Location = new System.Drawing.Point(0, 0);
|
||||
debugLabel.BackColor = System.Drawing.Color.Transparent;
|
||||
Controls.Add(debugLabel);;
|
||||
#endif
|
||||
//
|
||||
// Renderer3D
|
||||
//
|
||||
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
BackColor = Color.Transparent;
|
||||
Location = new Point(0, 0);
|
||||
Size = new Size(150, 150);
|
||||
Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
BackColor = System.Drawing.Color.LightGray;
|
||||
Location = new System.Drawing.Point(0, 0);
|
||||
Size = new System.Drawing.Size(150, 150);
|
||||
TabIndex = 0;
|
||||
VSync = true;
|
||||
AutoScaleDimensions = new SizeF(6.0f, 13.0f);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(6.0f, 13.0f);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
Name = "Renderer3D";
|
||||
ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
private Timer timMove;
|
||||
private System.Windows.Forms.Timer moveTimer;
|
||||
#if DEBUG
|
||||
private System.Windows.Forms.Label debugLabel;
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
107
PCK-Studio/Rendering/Shader.cs
Normal file
107
PCK-Studio/Rendering/Shader.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal class Shader
|
||||
{
|
||||
private int _programId;
|
||||
private Dictionary<string, int> locationCache = new Dictionary<string, int>();
|
||||
|
||||
private Shader(int programId)
|
||||
{
|
||||
_programId = programId;
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
GL.UseProgram(_programId);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.UseProgram(0);
|
||||
}
|
||||
|
||||
public void SetUniform1(string name, int value)
|
||||
{
|
||||
int location = GetUniformLocation(name);
|
||||
GL.Uniform1(location, value);
|
||||
}
|
||||
|
||||
public void SetUniform4(string name, Vector4 value)
|
||||
{
|
||||
int location = GetUniformLocation(name);
|
||||
GL.Uniform4(location, value);
|
||||
}
|
||||
|
||||
public void SetUniform4(string name, Color color)
|
||||
{
|
||||
int location = GetUniformLocation(name);
|
||||
GL.Uniform4(location, color);
|
||||
}
|
||||
|
||||
public void SetUniformMat4(string name, ref Matrix4 matrix)
|
||||
{
|
||||
int location = GetUniformLocation(name);
|
||||
GL.UniformMatrix4(location, false, ref matrix);
|
||||
}
|
||||
|
||||
private int GetUniformLocation(string name)
|
||||
{
|
||||
if (locationCache.ContainsKey(name))
|
||||
return locationCache[name];
|
||||
int location = GL.GetUniformLocation(_programId, name);
|
||||
locationCache.Add(name, location);
|
||||
return location;
|
||||
}
|
||||
|
||||
private static int CompileShader(ShaderType type, string shaderSource)
|
||||
{
|
||||
int shaderId = GL.CreateShader(type);
|
||||
GL.ShaderSource(shaderId, shaderSource);
|
||||
GL.CompileShader(shaderId);
|
||||
|
||||
GL.GetShader(shaderId, ShaderParameter.CompileStatus, out int status);
|
||||
|
||||
if (status == 0)
|
||||
{
|
||||
GL.GetShader(shaderId, ShaderParameter.InfoLogLength, out int length);
|
||||
GL.GetShaderInfoLog(shaderId, length, out _, out string infoLog);
|
||||
Trace.TraceError(infoLog);
|
||||
GL.DeleteShader(shaderId);
|
||||
return 0;
|
||||
}
|
||||
return shaderId;
|
||||
}
|
||||
|
||||
public static Shader Create(string vertexSource, string fragmentSource)
|
||||
{
|
||||
int programId = GL.CreateProgram();
|
||||
|
||||
int vertexShader = CompileShader(ShaderType.VertexShader, vertexSource);
|
||||
int fragmentShader = CompileShader(ShaderType.FragmentShader, fragmentSource);
|
||||
|
||||
GL.AttachShader(programId, vertexShader);
|
||||
GL.AttachShader(programId, fragmentShader);
|
||||
|
||||
GL.LinkProgram(programId);
|
||||
GL.ValidateProgram(programId);
|
||||
|
||||
Trace.TraceInformation(GL.GetProgramInfoLog(programId));
|
||||
|
||||
GL.DeleteShader(vertexShader);
|
||||
GL.DeleteShader(fragmentShader);
|
||||
return new Shader(programId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
71
PCK-Studio/Rendering/Texture2D.cs
Normal file
71
PCK-Studio/Rendering/Texture2D.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal class Texture2D : IDisposable
|
||||
{
|
||||
private int _id;
|
||||
|
||||
public Texture2D(string filepath)
|
||||
: this(Image.FromFile(filepath))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Texture2D(Image image)
|
||||
: this(new Bitmap(image))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private Texture2D(Bitmap bitmap)
|
||||
{
|
||||
_id = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, _id);
|
||||
|
||||
GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToBorder);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToBorder);
|
||||
|
||||
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, bitmap.Width, bitmap.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
|
||||
bitmap.UnlockBits(data);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
public void Bind(int slot)
|
||||
{
|
||||
GL.ActiveTexture(TextureUnit.Texture0 + slot);
|
||||
GL.BindTexture(TextureTarget.Texture2D, _id);
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
Bind(0);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GL.DeleteTexture(_id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
51
PCK-Studio/Rendering/VertexArray.cs
Normal file
51
PCK-Studio/Rendering/VertexArray.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal class VertexArray : IDisposable
|
||||
{
|
||||
private int _id;
|
||||
|
||||
public VertexArray()
|
||||
{
|
||||
_id = GL.GenVertexArray();
|
||||
}
|
||||
|
||||
public void AddBuffer<T>(VertexBuffer<T> buffer, VertexBufferLayout layout) where T : struct
|
||||
{
|
||||
Bind();
|
||||
buffer.Bind();
|
||||
var elements = layout.GetElements();
|
||||
int offset = 0;
|
||||
for (int i = 0; i < elements.Count; i++)
|
||||
{
|
||||
var element = elements[i];
|
||||
GL.EnableVertexAttribArray(i);
|
||||
GL.VertexAttribPointer(i, element.Count, element.Type, element.Normalize, layout.GetStride(), offset);
|
||||
offset += layout.GetStride();
|
||||
}
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
GL.BindVertexArray(_id);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindVertexArray(0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GL.DeleteVertexArray(_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
PCK-Studio/Rendering/VertexBuffer.cs
Normal file
40
PCK-Studio/Rendering/VertexBuffer.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal class VertexBuffer<T> : IDisposable where T : struct
|
||||
{
|
||||
private int _id;
|
||||
|
||||
public VertexBuffer(T[] data, int size)
|
||||
{
|
||||
_id = GL.GenBuffer();
|
||||
Bind();
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, size, data, BufferUsageHint.StaticDraw);
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, _id);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GL.DeleteBuffer(_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
77
PCK-Studio/Rendering/VertexBufferLayout.cs
Normal file
77
PCK-Studio/Rendering/VertexBufferLayout.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
struct VertexBufferElement
|
||||
{
|
||||
public readonly VertexAttribPointerType Type;
|
||||
public readonly int Count;
|
||||
public readonly bool Normalize;
|
||||
|
||||
public static int GetStrideSize(VertexAttribPointerType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
VertexAttribPointerType.Int => 4,
|
||||
VertexAttribPointerType.UnsignedInt => 4,
|
||||
VertexAttribPointerType.Float => 4,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
public VertexBufferElement(VertexAttribPointerType type, int count, bool normalize)
|
||||
{
|
||||
Type = type;
|
||||
Count = count;
|
||||
Normalize = normalize;
|
||||
}
|
||||
}
|
||||
|
||||
internal class VertexBufferLayout
|
||||
{
|
||||
private List<VertexBufferElement> elements;
|
||||
private int stride;
|
||||
|
||||
|
||||
public VertexBufferLayout()
|
||||
{
|
||||
elements = new List<VertexBufferElement>();
|
||||
stride = 0;
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<VertexBufferElement> GetElements()
|
||||
{
|
||||
return elements.AsReadOnly();
|
||||
}
|
||||
|
||||
public void Add<T>(int count)
|
||||
{
|
||||
if (typeof(T).Equals(typeof(float)))
|
||||
{
|
||||
elements.Add(new VertexBufferElement(VertexAttribPointerType.Float, count, false));
|
||||
stride += count * VertexBufferElement.GetStrideSize(VertexAttribPointerType.Float);
|
||||
}
|
||||
if (typeof(T).Equals(typeof(int)))
|
||||
{
|
||||
elements.Add(new VertexBufferElement(VertexAttribPointerType.Int, count, false));
|
||||
stride += count * VertexBufferElement.GetStrideSize(VertexAttribPointerType.Int);
|
||||
}
|
||||
if (typeof(T).Equals(typeof(uint)))
|
||||
{
|
||||
elements.Add(new VertexBufferElement(VertexAttribPointerType.UnsignedInt, count, false));
|
||||
stride += count * VertexBufferElement.GetStrideSize(VertexAttribPointerType.UnsignedInt);
|
||||
}
|
||||
}
|
||||
|
||||
internal int GetStride()
|
||||
{
|
||||
return stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
PCK-Studio/Resources/fragment.glsl
Normal file
15
PCK-Studio/Resources/fragment.glsl
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
uniform vec4 u_Color;
|
||||
uniform sampler2D u_Texture;
|
||||
|
||||
in vec2 v_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texColor = texture(u_Texture, v_TexCoord);
|
||||
color = u_Color;
|
||||
color = texColor;
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
14
PCK-Studio/Resources/vertexShader.glsl
Normal file
14
PCK-Studio/Resources/vertexShader.glsl
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec4 vertexPosition;
|
||||
layout(location = 1) in vec2 texCoord;
|
||||
|
||||
uniform mat4 u_MVP;
|
||||
|
||||
out vec2 v_TexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_MVP * vertexPosition;
|
||||
v_TexCoord = texCoord;
|
||||
};
|
||||
Reference in New Issue
Block a user