Compare commits
2 Commits
3facb17f90
...
c7df1ed578
| Author | SHA1 | Date | |
|---|---|---|---|
| c7df1ed578 | |||
| c21aed27c5 |
2
Makefile
2
Makefile
@ -59,8 +59,6 @@ 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, chunk_x, chunk_z, n_block_index)
|
n_block_data = decode_block_data(level_table, n_chunk_x, n_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.
1033305
minecraft/love2dworld/map.txt
1033305
minecraft/love2dworld/map.txt
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
#version 330 core
|
#version 430 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
vec3 Position; // world coordinates
|
vec3 Position; // world coordinates
|
||||||
@ -16,9 +16,7 @@ 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;
|
||||||
|
|
||||||
uniform sampler2D TerrainSampler;
|
layout (location = 1) uniform sampler2D TerrainSampler;
|
||||||
uniform vec3 MousePosition;
|
|
||||||
uniform vec3 MousePosition2;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
#version 330 core
|
#version 430 core
|
||||||
|
|
||||||
// per-vertex:
|
// per-vertex:
|
||||||
in vec3 Position;
|
layout (location = 0) in vec3 Position;
|
||||||
in vec3 Normal;
|
layout (location = 1) in vec3 Normal;
|
||||||
in vec2 Texture;
|
layout (location = 2) in vec2 Texture;
|
||||||
// per-instance:
|
// per-instance:
|
||||||
in vec3 BlockPosition;
|
layout (location = 3) in vec3 BlockPosition;
|
||||||
in int BlockID;
|
layout (location = 4) in int BlockID;
|
||||||
in int Data;
|
layout (location = 5) in int Data;
|
||||||
in int TextureID;
|
layout (location = 6) in int TextureID;
|
||||||
in int Special;
|
layout (location = 7) 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;
|
||||||
|
|
||||||
uniform mat4 Transform;
|
layout (location = 0) 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,13 +150,20 @@ 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 location {
|
struct layout {
|
||||||
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;
|
||||||
} attrib;
|
} attribute;
|
||||||
struct {
|
struct {
|
||||||
unsigned int transform;
|
unsigned int transform;
|
||||||
unsigned int terrain_sampler;
|
unsigned int terrain_sampler;
|
||||||
@ -33,7 +33,23 @@ namespace minecraft {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int program;
|
static unsigned int program;
|
||||||
static location location;
|
static layout const layout = {
|
||||||
|
.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;
|
||||||
@ -53,32 +69,6 @@ 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()
|
||||||
@ -89,37 +79,37 @@ namespace minecraft {
|
|||||||
glVertexBindingDivisor(0, 0);
|
glVertexBindingDivisor(0, 0);
|
||||||
glVertexBindingDivisor(1, 1);
|
glVertexBindingDivisor(1, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.position);
|
glEnableVertexAttribArray(layout.attribute.position);
|
||||||
glVertexAttribFormat(location.attrib.position, 3, GL_HALF_FLOAT, GL_FALSE, 0);
|
glVertexAttribFormat(layout.attribute.position, 3, GL_HALF_FLOAT, GL_FALSE, 0);
|
||||||
glVertexAttribBinding(location.attrib.position, 0);
|
glVertexAttribBinding(layout.attribute.position, 0);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.normal);
|
glEnableVertexAttribArray(layout.attribute.normal);
|
||||||
glVertexAttribFormat(location.attrib.normal, 3, GL_HALF_FLOAT, GL_FALSE, 6);
|
glVertexAttribFormat(layout.attribute.normal, 3, GL_HALF_FLOAT, GL_FALSE, 6);
|
||||||
glVertexAttribBinding(location.attrib.normal, 0);
|
glVertexAttribBinding(layout.attribute.normal, 0);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.texture);
|
glEnableVertexAttribArray(layout.attribute.texture);
|
||||||
glVertexAttribFormat(location.attrib.texture, 2, GL_HALF_FLOAT, GL_FALSE, 12);
|
glVertexAttribFormat(layout.attribute.texture, 2, GL_HALF_FLOAT, GL_FALSE, 12);
|
||||||
glVertexAttribBinding(location.attrib.texture, 0);
|
glVertexAttribBinding(layout.attribute.texture, 0);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.block_position);
|
glEnableVertexAttribArray(layout.attribute.block_position);
|
||||||
glVertexAttribFormat(location.attrib.block_position, 3, GL_SHORT, GL_FALSE, 0);
|
glVertexAttribFormat(layout.attribute.block_position, 3, GL_SHORT, GL_FALSE, 0);
|
||||||
glVertexAttribBinding(location.attrib.block_position, 1);
|
glVertexAttribBinding(layout.attribute.block_position, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.block_id);
|
glEnableVertexAttribArray(layout.attribute.block_id);
|
||||||
glVertexAttribIFormat(location.attrib.block_id, 1, GL_SHORT, 8);
|
glVertexAttribIFormat(layout.attribute.block_id, 1, GL_SHORT, 8);
|
||||||
glVertexAttribBinding(location.attrib.block_id, 1);
|
glVertexAttribBinding(layout.attribute.block_id, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.data);
|
glEnableVertexAttribArray(layout.attribute.data);
|
||||||
glVertexAttribIFormat(location.attrib.data, 1, GL_SHORT, 10);
|
glVertexAttribIFormat(layout.attribute.data, 1, GL_SHORT, 10);
|
||||||
glVertexAttribBinding(location.attrib.data, 1);
|
glVertexAttribBinding(layout.attribute.data, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.texture_id);
|
glEnableVertexAttribArray(layout.attribute.texture_id);
|
||||||
glVertexAttribIFormat(location.attrib.texture_id, 1, GL_SHORT, 12);
|
glVertexAttribIFormat(layout.attribute.texture_id, 1, GL_SHORT, 12);
|
||||||
glVertexAttribBinding(location.attrib.texture_id, 1);
|
glVertexAttribBinding(layout.attribute.texture_id, 1);
|
||||||
|
|
||||||
glEnableVertexAttribArray(location.attrib.special);
|
glEnableVertexAttribArray(layout.attribute.special);
|
||||||
glVertexAttribIFormat(location.attrib.special, 1, GL_SHORT, 14);
|
glVertexAttribIFormat(layout.attribute.special, 1, GL_SHORT, 14);
|
||||||
glVertexAttribBinding(location.attrib.special, 1);
|
glVertexAttribBinding(layout.attribute.special, 1);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
@ -289,8 +279,8 @@ namespace minecraft {
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
glUniformMatrix4fv(location.uniform.transform, 1, false, (float *)&view::state.float_transform);
|
glUniformMatrix4fv(layout.uniform.transform, 1, false, (float *)&view::state.float_transform);
|
||||||
glUniform1i(location.uniform.terrain_sampler, 0);
|
glUniform1i(layout.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