Updates to Level. More functionality, but also very unstable.

This commit is contained in:
2017-02-27 23:11:14 -05:00
parent 8566105158
commit 1824de6842
10 changed files with 756 additions and 429 deletions

View File

@@ -15,11 +15,10 @@ namespace hexworld
#region GLObjects
private Program _objPgm;
private Texture _grass;
private Texture _stone;
private Texture _gray;
private Texture _door;
private Level _level;
@@ -27,13 +26,12 @@ namespace hexworld
{
base.OnClosed(e);
_objPgm?.Dispose();
_grass?.Dispose();
_stone?.Dispose();
_gray?.Dispose();
_door?.Dispose();
// _level?.Dispose();
_level?.Dispose();
}
#endregion
@@ -47,7 +45,7 @@ namespace hexworld
public HexRender(int width, int height)
: base(width, height, new GraphicsMode(32, 24, 0, 8))
: base(width, height, new GraphicsMode(32, 24, 0, 0))
{
Width = width;
Height = Height;
@@ -59,13 +57,12 @@ namespace hexworld
{
base.OnLoad(e);
_objPgm = Program.FromFiles(@"res\obj.vs.glsl", @"res\obj.fs.glsl");
_level = Level.LoadLevel(@"res\level.json");
_grass = Texture.FromBitmap(new Bitmap(@"res\grass.png"));
_stone = Texture.FromBitmap(new Bitmap(@"res\stone.png"));
_gray = Texture.FromBitmap(new Bitmap(@"res\gray.png"));
_door = Texture.FromBitmap(new Bitmap(@"res\door.png"));
}
protected override void OnUpdateFrame(FrameEventArgs e)
@@ -92,23 +89,19 @@ namespace hexworld
GL.DepthFunc(DepthFunction.Lequal);
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
GL.Enable(EnableCap.CullFace);
GL.CullFace(CullFaceMode.Back);
if (_objPgm.Linked)
{
_objPgm.Use();
_grass.Bind(0);
_stone.Bind(1);
_gray.Bind(2);
_door.Bind(3);
_grass.Bind(0);
_stone.Bind(1);
_gray.Bind(2);
GL.Uniform1(_objPgm.GetUniform("tex"), 2);
GL.UniformMatrix4(_objPgm.GetUniform("view"), false, ref _view);
GL.UniformMatrix4(_objPgm.GetUniform("proj"), false, ref _proj);
_level.Draw();
}
var pgm = _level.Programs["textured"];
pgm.Use();
GL.Uniform1(pgm.GetUniform("tex"), 0);
GL.UniformMatrix4(pgm.GetUniform("view"), false, ref _view);
GL.UniformMatrix4(pgm.GetUniform("proj"), false, ref _proj);
_level.Draw();
SwapBuffers();
}

View File

@@ -59,6 +59,9 @@
<None Include="App.config" />
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
<None Include="res\cube.obj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="res\door.obj">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -77,6 +80,9 @@
</None>
</ItemGroup>
<ItemGroup>
<Content Include="res\door.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="res\grass.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

52
hexworld/res/cube.obj Normal file
View File

@@ -0,0 +1,52 @@
# Blender v2.78 (sub 0) OBJ File: ''
# www.blender.org
o Cube
v 0.500050 -0.500050 -0.500050
v 0.500050 -0.500050 0.500050
v -0.500050 -0.500050 -0.500050
v -0.500050 -0.500050 0.500050
v 0.500050 0.500050 -0.500050
v 0.500050 0.500050 0.500050
v -0.500050 0.500050 -0.500050
v -0.500050 0.500050 0.500050
vt 1.0000 1.0000
vt 0.5000 0.5000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.5000 0.5000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.5000 0.5000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.5000 0.5000
vt 1.0000 0.5000
vt 0.0000 -0.0000
vt 0.5000 0.0000
vt 0.5000 1.0000
vt -0.0000 0.5000
vt 0.5000 0.5000
vt 0.5000 1.0000
vt 0.5000 1.0000
vt 0.5000 1.0000
vt -0.0000 0.5000
vt -0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.0000 0.0000 1.0000
s off
f 2/1/1 3/2/1 1/3/1
f 4/4/2 7/5/2 3/6/2
f 8/7/3 5/8/3 7/9/3
f 6/10/4 1/11/4 5/12/4
f 7/5/5 1/13/5 3/14/5
f 4/15/6 6/16/6 8/17/6
f 2/1/1 4/15/1 3/2/1
f 4/4/2 8/18/2 7/5/2
f 8/7/3 6/19/3 5/8/3
f 6/10/4 2/20/4 1/11/4
f 7/5/5 5/21/5 1/13/5
f 4/15/6 2/22/6 6/16/6

File diff suppressed because it is too large Load Diff

BIN
hexworld/res/door.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

View File

@@ -1,17 +1,52 @@
{
"models": [
"door.obj"
"door.obj",
"cube.obj"
],
"shaders": [
{
"name": "textured",
"files": [
"obj.fs.glsl",
"obj.vs.glsl",
]
}
],
"tiles": [
{ "mesh": "BaseLeft", "pos": { "x": -1, "y": 0, "z": 0 } },
{ "mesh": "BaseRight", "pos": { "x": 1, "y": 0, "z": 0 } },
{ "mesh": "Stairs", "pos": { "x": 0, "y": 0, "z": 0 } },
{ "mesh": "ColLeft", "pos": { "x": -1, "y": 0, "z": 1 } },
{ "mesh": "ColRight", "pos": { "x": 1, "y": 0, "z": 1 } },
{ "mesh": "ColLeft", "pos": { "x": -1, "y": 0, "z": 2 } },
{ "mesh": "ColRight", "pos": { "x": 1, "y": 0, "z": 2 } },
{ "mesh": "CapLeft", "pos": { "x": -1, "y": 0, "z": 3 } },
{ "mesh": "Lintel", "pos": { "x": 0, "y": 0, "z": 3 } },
{ "mesh": "CapRight", "pos": { "x": 1, "y": 0, "z": 3 } }
{ "mesh": "BaseLeft", "shader": "textured", "pos": { "x": -1, "y": 0, "z": 0 } },
{ "mesh": "BaseRight", "shader": "textured", "pos": { "x": 1, "y": 0, "z": 0 } },
{ "mesh": "Stairs", "shader": "textured", "pos": { "x": 0, "y": 0, "z": 0 } },
{ "mesh": "ColLeft", "shader": "textured", "pos": { "x": -1, "y": 0, "z": 1 } },
{ "mesh": "ColRight", "shader": "textured", "pos": { "x": 1, "y": 0, "z": 1 } },
{ "mesh": "ColLeft", "shader": "textured", "pos": { "x": -1, "y": 0, "z": 2 } },
{ "mesh": "ColRight", "shader": "textured", "pos": { "x": 1, "y": 0, "z": 2 } },
{ "mesh": "CapLeft", "shader": "textured", "pos": { "x": -1, "y": 0, "z": 3 } },
{ "mesh": "Lintel", "shader": "textured", "pos": { "x": 0, "y": 0, "z": 3 } },
{ "mesh": "CapRight", "shader": "textured", "pos": { "x": 1, "y": 0, "z": 3 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -2, "y": -2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -2, "y": -1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -2, "y": 0, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -2, "y": 1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -2, "y": 2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -1, "y": -2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -1, "y": -1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -1, "y": 0, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -1, "y": 1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": -1, "y": 2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 0, "y": -2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 0, "y": -1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 0, "y": 0, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 0, "y": 1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 0, "y": 2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 1, "y": -2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 1, "y": -1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 1, "y": 0, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 1, "y": 1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 1, "y": 2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 2, "y": -2, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 2, "y": -1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 2, "y": 0, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 2, "y": 1, "z": -1 } },
{ "mesh": "Cube", "shader": "textured", "pos": { "x": 2, "y": 2, "z": -1 } },
]
}