Compare commits
No commits in common. "c7df1ed578d141d4b703a6a28b7e958f95b039e4" and "3facb17f90145024d33fa43d0cb505324683a506" have entirely different histories.
c7df1ed578
...
3facb17f90
2
Makefile
2
Makefile
@ -59,6 +59,8 @@ OBJS = \
|
|||||||
src/collada/effect.o \
|
src/collada/effect.o \
|
||||||
src/collada/node_state.o \
|
src/collada/node_state.o \
|
||||||
src/collada/animate.o \
|
src/collada/animate.o \
|
||||||
|
src/lua_api.o \
|
||||||
|
src/pixel_line_art.o \
|
||||||
src/flame.o \
|
src/flame.o \
|
||||||
src/audio.o \
|
src/audio.o \
|
||||||
data/scenes/ship20/ship20.o \
|
data/scenes/ship20/ship20.o \
|
||||||
|
|||||||
@ -39,7 +39,7 @@ def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz):
|
|||||||
return True
|
return True
|
||||||
n_block_index = mcregion.block_index_from_xyz(nx, ny, nz)
|
n_block_index = mcregion.block_index_from_xyz(nx, ny, nz)
|
||||||
n_block_id = level_table[key].blocks[n_block_index]
|
n_block_id = level_table[key].blocks[n_block_index]
|
||||||
n_block_data = decode_block_data(level_table, n_chunk_x, n_chunk_z, n_block_index)
|
n_block_data = decode_block_data(level_table, chunk_x, chunk_z, n_block_index)
|
||||||
return block_ids.is_neighbor_block(n_block_id, n_block_data)
|
return block_ids.is_neighbor_block(n_block_id, n_block_data)
|
||||||
|
|
||||||
def outside_crop(position, crop):
|
def outside_crop(position, crop):
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1033309
minecraft/love2dworld/map.txt
1033309
minecraft/love2dworld/map.txt
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
#version 430 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
vec3 Position; // world coordinates
|
vec3 Position; // world coordinates
|
||||||
@ -16,7 +16,9 @@ layout (location = 1) out vec4 Normal;
|
|||||||
layout (location = 2) out vec3 Color;
|
layout (location = 2) out vec3 Color;
|
||||||
layout (location = 3) out vec4 Block;
|
layout (location = 3) out vec4 Block;
|
||||||
|
|
||||||
layout (location = 1) uniform sampler2D TerrainSampler;
|
uniform sampler2D TerrainSampler;
|
||||||
|
uniform vec3 MousePosition;
|
||||||
|
uniform vec3 MousePosition2;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
#version 430 core
|
#version 330 core
|
||||||
|
|
||||||
// per-vertex:
|
// per-vertex:
|
||||||
layout (location = 0) in vec3 Position;
|
in vec3 Position;
|
||||||
layout (location = 1) in vec3 Normal;
|
in vec3 Normal;
|
||||||
layout (location = 2) in vec2 Texture;
|
in vec2 Texture;
|
||||||
// per-instance:
|
// per-instance:
|
||||||
layout (location = 3) in vec3 BlockPosition;
|
in vec3 BlockPosition;
|
||||||
layout (location = 4) in int BlockID;
|
in int BlockID;
|
||||||
layout (location = 5) in int Data;
|
in int Data;
|
||||||
layout (location = 6) in int TextureID;
|
in int TextureID;
|
||||||
layout (location = 7) in int Special;
|
in int Special;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
@ -22,7 +22,7 @@ out VS_OUT {
|
|||||||
flat int Special;
|
flat int Special;
|
||||||
} vs_out;
|
} vs_out;
|
||||||
|
|
||||||
layout (location = 0) uniform mat4 Transform;
|
uniform mat4 Transform;
|
||||||
|
|
||||||
vec3 orientation(vec3 position)
|
vec3 orientation(vec3 position)
|
||||||
{
|
{
|
||||||
|
|||||||
13
src/main.cpp
13
src/main.cpp
@ -126,8 +126,8 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
load(".");
|
load(".");
|
||||||
//audio::init();
|
audio::init();
|
||||||
//audio::load();
|
audio::load();
|
||||||
|
|
||||||
update_window(1024, 1024);
|
update_window(1024, 1024);
|
||||||
|
|
||||||
@ -150,20 +150,13 @@ int main()
|
|||||||
case SDL_EVENT_GAMEPAD_REMOVED:
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
remove_gamepad(event.gdevice.which);
|
remove_gamepad(event.gdevice.which);
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
|
||||||
if (event.button.button == 1) {
|
|
||||||
update_mouse(event.button.x, event.button.y);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
//audio::update();
|
audio::update();
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
|
|
||||||
namespace minecraft {
|
namespace minecraft {
|
||||||
struct layout {
|
struct location {
|
||||||
struct {
|
struct {
|
||||||
unsigned int position;
|
unsigned int position;
|
||||||
unsigned int normal;
|
unsigned int normal;
|
||||||
@ -25,7 +25,7 @@ namespace minecraft {
|
|||||||
unsigned int data;
|
unsigned int data;
|
||||||
unsigned int texture_id;
|
unsigned int texture_id;
|
||||||
unsigned int special;
|
unsigned int special;
|
||||||
} attribute;
|
} attrib;
|
||||||
struct {
|
struct {
|
||||||
unsigned int transform;
|
unsigned int transform;
|
||||||
unsigned int terrain_sampler;
|
unsigned int terrain_sampler;
|
||||||
@ -33,23 +33,7 @@ namespace minecraft {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int program;
|
static unsigned int program;
|
||||||
static layout const layout = {
|
static location location;
|
||||||
.attribute = {
|
|
||||||
.position = 0,
|
|
||||||
.normal = 1,
|
|
||||||
.texture = 2,
|
|
||||||
|
|
||||||
.block_position = 3,
|
|
||||||
.block_id = 4,
|
|
||||||
.data = 5,
|
|
||||||
.texture_id = 6,
|
|
||||||
.special = 7,
|
|
||||||
},
|
|
||||||
.uniform = {
|
|
||||||
.transform = 0,
|
|
||||||
.terrain_sampler = 1,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int vertex_array_object;
|
static unsigned int vertex_array_object;
|
||||||
static unsigned int per_vertex_buffer;
|
static unsigned int per_vertex_buffer;
|
||||||
@ -69,6 +53,32 @@ namespace minecraft {
|
|||||||
program = compile_from_files("shader/minecraft.vert",
|
program = compile_from_files("shader/minecraft.vert",
|
||||||
NULL,
|
NULL,
|
||||||
"shader/minecraft.frag");
|
"shader/minecraft.frag");
|
||||||
|
|
||||||
|
location.attrib.position = glGetAttribLocation(program, "Position");
|
||||||
|
location.attrib.normal = glGetAttribLocation(program, "Normal");
|
||||||
|
location.attrib.texture = glGetAttribLocation(program, "Texture");
|
||||||
|
|
||||||
|
location.attrib.block_position = glGetAttribLocation(program, "BlockPosition");
|
||||||
|
location.attrib.block_id = glGetAttribLocation(program, "BlockID");
|
||||||
|
location.attrib.data = glGetAttribLocation(program, "Data");
|
||||||
|
location.attrib.texture_id = glGetAttribLocation(program, "TextureID");
|
||||||
|
location.attrib.special = glGetAttribLocation(program, "Special");
|
||||||
|
printf("minecraft program:\n");
|
||||||
|
printf(" attributes:\n position %u\n normal %u\n texture %u\n block_position %u\n block_id %u\n data %u\n texture_id %u\n special %u\n",
|
||||||
|
location.attrib.position,
|
||||||
|
location.attrib.normal,
|
||||||
|
location.attrib.texture,
|
||||||
|
location.attrib.block_position,
|
||||||
|
location.attrib.block_id,
|
||||||
|
location.attrib.data,
|
||||||
|
location.attrib.texture_id,
|
||||||
|
location.attrib.special);
|
||||||
|
|
||||||
|
location.uniform.transform = glGetUniformLocation(program, "Transform");
|
||||||
|
location.uniform.terrain_sampler = glGetUniformLocation(program, "TerrainSampler");
|
||||||
|
printf(" uniforms:\n transform %u\n terrain_sampler %u\n",
|
||||||
|
location.uniform.transform,
|
||||||
|
location.uniform.terrain_sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_vertex_attributes()
|
void load_vertex_attributes()
|
||||||
@ -79,37 +89,37 @@ namespace minecraft {
|
|||||||
glVertexBindingDivisor(0, 0);
|
glVertexBindingDivisor(0, 0);
|
||||||
glVertexBindingDivisor(1, 1);
|
glVertexBindingDivisor(1, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.position);
|
glEnableVertexAttribArray(location.attrib.position);
|
||||||
glVertexAttribFormat(layout.attribute.position, 3, GL_HALF_FLOAT, GL_FALSE, 0);
|
glVertexAttribFormat(location.attrib.position, 3, GL_HALF_FLOAT, GL_FALSE, 0);
|
||||||
glVertexAttribBinding(layout.attribute.position, 0);
|
glVertexAttribBinding(location.attrib.position, 0);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.normal);
|
glEnableVertexAttribArray(location.attrib.normal);
|
||||||
glVertexAttribFormat(layout.attribute.normal, 3, GL_HALF_FLOAT, GL_FALSE, 6);
|
glVertexAttribFormat(location.attrib.normal, 3, GL_HALF_FLOAT, GL_FALSE, 6);
|
||||||
glVertexAttribBinding(layout.attribute.normal, 0);
|
glVertexAttribBinding(location.attrib.normal, 0);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.texture);
|
glEnableVertexAttribArray(location.attrib.texture);
|
||||||
glVertexAttribFormat(layout.attribute.texture, 2, GL_HALF_FLOAT, GL_FALSE, 12);
|
glVertexAttribFormat(location.attrib.texture, 2, GL_HALF_FLOAT, GL_FALSE, 12);
|
||||||
glVertexAttribBinding(layout.attribute.texture, 0);
|
glVertexAttribBinding(location.attrib.texture, 0);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.block_position);
|
glEnableVertexAttribArray(location.attrib.block_position);
|
||||||
glVertexAttribFormat(layout.attribute.block_position, 3, GL_SHORT, GL_FALSE, 0);
|
glVertexAttribFormat(location.attrib.block_position, 3, GL_SHORT, GL_FALSE, 0);
|
||||||
glVertexAttribBinding(layout.attribute.block_position, 1);
|
glVertexAttribBinding(location.attrib.block_position, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.block_id);
|
glEnableVertexAttribArray(location.attrib.block_id);
|
||||||
glVertexAttribIFormat(layout.attribute.block_id, 1, GL_SHORT, 8);
|
glVertexAttribIFormat(location.attrib.block_id, 1, GL_SHORT, 8);
|
||||||
glVertexAttribBinding(layout.attribute.block_id, 1);
|
glVertexAttribBinding(location.attrib.block_id, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.data);
|
glEnableVertexAttribArray(location.attrib.data);
|
||||||
glVertexAttribIFormat(layout.attribute.data, 1, GL_SHORT, 10);
|
glVertexAttribIFormat(location.attrib.data, 1, GL_SHORT, 10);
|
||||||
glVertexAttribBinding(layout.attribute.data, 1);
|
glVertexAttribBinding(location.attrib.data, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.texture_id);
|
glEnableVertexAttribArray(location.attrib.texture_id);
|
||||||
glVertexAttribIFormat(layout.attribute.texture_id, 1, GL_SHORT, 12);
|
glVertexAttribIFormat(location.attrib.texture_id, 1, GL_SHORT, 12);
|
||||||
glVertexAttribBinding(layout.attribute.texture_id, 1);
|
glVertexAttribBinding(location.attrib.texture_id, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(layout.attribute.special);
|
glEnableVertexAttribArray(location.attrib.special);
|
||||||
glVertexAttribIFormat(layout.attribute.special, 1, GL_SHORT, 14);
|
glVertexAttribIFormat(location.attrib.special, 1, GL_SHORT, 14);
|
||||||
glVertexAttribBinding(layout.attribute.special, 1);
|
glVertexAttribBinding(location.attrib.special, 1);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
@ -279,8 +289,8 @@ namespace minecraft {
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
glUniformMatrix4fv(layout.uniform.transform, 1, false, (float *)&view::state.float_transform);
|
glUniformMatrix4fv(location.uniform.transform, 1, false, (float *)&view::state.float_transform);
|
||||||
glUniform1i(layout.uniform.terrain_sampler, 0);
|
glUniform1i(location.uniform.terrain_sampler, 0);
|
||||||
|
|
||||||
//glEnable(GL_CULL_FACE);
|
//glEnable(GL_CULL_FACE);
|
||||||
//glCullFace(GL_FRONT);
|
//glCullFace(GL_FRONT);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user