Update 3D
This commit is contained in:
parent
823092ad95
commit
1dc045cbed
@ -45,6 +45,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 \
|
||||||
data/scenes/ship20/ship20.o \
|
data/scenes/ship20/ship20.o \
|
||||||
data/scenes/noodle/noodle.o \
|
data/scenes/noodle/noodle.o \
|
||||||
data/scenes/shadow_test/shadow_test.o \
|
data/scenes/shadow_test/shadow_test.o \
|
||||||
|
|||||||
@ -64,5 +64,5 @@ namespace font {
|
|||||||
void load_fonts(font * const fonts, font_desc const * const descs, int length);
|
void load_fonts(font * const fonts, font_desc const * const descs, int length);
|
||||||
int best_font(font_desc const * const descs, int length);
|
int best_font(font_desc const * const descs, int length);
|
||||||
void draw_start(font const& font, unsigned int vertex_array_object, unsigned int index_buffer);
|
void draw_start(font const& font, unsigned int vertex_array_object, unsigned int index_buffer);
|
||||||
void draw_string(font const& font, char const * const s, int x, int y);
|
int draw_string(font const& font, char const * const s, int x, int y);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@ namespace lighting {
|
|||||||
|
|
||||||
extern light_parameters global;
|
extern light_parameters global;
|
||||||
|
|
||||||
void load_program();
|
void load();
|
||||||
void load_light_uniform_buffer();
|
void draw(unsigned int light_uniform_buffer, int light_count);
|
||||||
void draw();
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
game/include/lua_api.h
Normal file
18
game/include/lua_api.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int draw_font_start();
|
||||||
|
int draw_font(int font_ix, char const * text, int x, int y);
|
||||||
|
|
||||||
|
void draw_line_quad_start();
|
||||||
|
void draw_line(int x1, int y1, int x2, int y2);
|
||||||
|
void draw_set_color(float r, float g, float b);
|
||||||
|
void draw_quad(int x1, int y1, int x2, int y2,
|
||||||
|
int x3, int y3, int x4, int y4);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -8,13 +8,15 @@ short index_buffer_configuration_offsets[] = {
|
|||||||
768, 780, 798, 816, 840, 858, 882, 906,
|
768, 780, 798, 816, 840, 858, 882, 906,
|
||||||
936, 954, 978, 1002, 1032, 1056, 1086, 1116,
|
936, 954, 978, 1002, 1032, 1056, 1086, 1116,
|
||||||
};
|
};
|
||||||
|
// generated from
|
||||||
struct {
|
struct {
|
||||||
short offset;
|
short offset;
|
||||||
short count;
|
short count;
|
||||||
} index_buffer_custom_offsets[] = {
|
} index_buffer_custom_offsets[] = {
|
||||||
{1152, 12}, // tallgrass.obj
|
{1152, 3180}, // candle.obj
|
||||||
{1164, 36}, // fence.obj
|
{4332, 1584}, // custom_mushroom.obj
|
||||||
{1200, 36}, // torch.obj
|
{5916, 36}, // fence.obj
|
||||||
{1236, 24}, // wheat.obj
|
{5952, 24}, // stair.obj
|
||||||
{1260, 1584}, // custom-mushroom.obj
|
{5976, 12}, // tall_grass.obj
|
||||||
|
{5988, 2082}, // wall_torch.obj
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@ extern "C" {
|
|||||||
const char * geometry_path,
|
const char * geometry_path,
|
||||||
const char * fragment_path);
|
const char * fragment_path);
|
||||||
|
|
||||||
unsigned int load_uniform_buffer(char const * const path);
|
unsigned int load_uniform_buffer(char const * const path, int * out_size);
|
||||||
|
|
||||||
void load_dds_texture_2D(char const * const path);
|
void load_dds_texture_2D(char const * const path);
|
||||||
|
|
||||||
|
|||||||
12
game/include/pixel_line_art.h
Normal file
12
game/include/pixel_line_art.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace pixel_line_art {
|
||||||
|
|
||||||
|
void load();
|
||||||
|
|
||||||
|
void draw_line_quad_start();
|
||||||
|
void draw_line(int x1, int y1, int x2, int y2);
|
||||||
|
void draw_set_color(float r, float g, float b);
|
||||||
|
void draw_quad(int x1, int y1, int x2, int y2,
|
||||||
|
int x3, int y3, int x4, int y4);
|
||||||
|
}
|
||||||
@ -6,6 +6,8 @@ extern "C" {
|
|||||||
|
|
||||||
void load(const char * source_path);
|
void load(const char * source_path);
|
||||||
void draw();
|
void draw();
|
||||||
|
void love2d_state_load();
|
||||||
|
void love2d_state_restore();
|
||||||
void update_keyboard(int up, int down, int left, int right,
|
void update_keyboard(int up, int down, int left, int right,
|
||||||
int w, int s, int a, int d,
|
int w, int s, int a, int d,
|
||||||
int t, int g, int f, int h,
|
int t, int g, int f, int h,
|
||||||
|
|||||||
@ -25,8 +25,8 @@ namespace world {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// also update index_buffer_custom_offsets in data.inc
|
// also update index_buffer_custom_offsets in include/minecraft_data.inc
|
||||||
const int custom_block_types = 5;
|
const int custom_block_types = 6;
|
||||||
const int instance_cfg_length = 64 + custom_block_types;
|
const int instance_cfg_length = 64 + custom_block_types;
|
||||||
|
|
||||||
struct instance_cfg_entry {
|
struct instance_cfg_entry {
|
||||||
@ -42,8 +42,9 @@ namespace world {
|
|||||||
struct state {
|
struct state {
|
||||||
world::descriptor const * descriptor;
|
world::descriptor const * descriptor;
|
||||||
world::region * region; // malloc region_count
|
world::region * region; // malloc region_count
|
||||||
unsigned int light_uniform_buffer;
|
|
||||||
entry_table::global_entry_t * entry_table;
|
entry_table::global_entry_t * entry_table;
|
||||||
|
unsigned int light_uniform_buffer;
|
||||||
|
int light_count;
|
||||||
int entry_table_length;
|
int entry_table_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
228
game/main.lua
228
game/main.lua
@ -23,6 +23,15 @@ void update_joystick(int joystick_index,
|
|||||||
int leftshoulder, int rightshoulder,
|
int leftshoulder, int rightshoulder,
|
||||||
int start);
|
int start);
|
||||||
void update(float time);
|
void update(float time);
|
||||||
|
|
||||||
|
int draw_font_start();
|
||||||
|
int draw_font(int font_ix, char const * text, int x, int y);
|
||||||
|
|
||||||
|
void draw_line_quad_start();
|
||||||
|
void draw_line(int x1, int y1, int x2, int y2);
|
||||||
|
void draw_set_color(float r, float g, float b);
|
||||||
|
void draw_quad(int x1, int y1, int x2, int y2,
|
||||||
|
int x3, int y3, int x4, int y4);
|
||||||
]]
|
]]
|
||||||
local source_path = love.filesystem.getSource()
|
local source_path = love.filesystem.getSource()
|
||||||
test = ffi.load(source_path .. "/test.so")
|
test = ffi.load(source_path .. "/test.so")
|
||||||
@ -88,57 +97,130 @@ local draw = function()
|
|||||||
test.draw()
|
test.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local love_draw = function ()
|
local nico_draw = function()
|
||||||
love.graphics.setCanvas()
|
----------------------------------------------------------------------
|
||||||
love.graphics.setShader()
|
-- font drawing
|
||||||
love.graphics.push()
|
----------------------------------------------------------------------
|
||||||
love.graphics.setColor(1,0,0,1)
|
|
||||||
love.graphics.print("A", 100, 100)
|
-- call "draw_font_start()" prior each "group" of "draw_font()" calls
|
||||||
love.graphics.pop()
|
--
|
||||||
|
-- a "group" of draw_font() calls are back-to-back/consecutive,
|
||||||
|
-- with no non-font drawing between them.
|
||||||
|
--
|
||||||
|
-- For example:
|
||||||
|
|
||||||
|
local font_ix = test.draw_font_start()
|
||||||
|
local x = 512
|
||||||
|
local y = 50
|
||||||
|
y = y + test.draw_font(font_ix, "lua test", x, y)
|
||||||
|
y = y + test.draw_font(font_ix, "cool", x, y)
|
||||||
|
|
||||||
|
-- note that "font_ix" is the current "best font" as calculated
|
||||||
|
-- from the current window size, and might change next frame if the
|
||||||
|
-- window is resized.
|
||||||
|
--
|
||||||
|
-- Any of this of course could be changed to match your precise
|
||||||
|
-- requirements.
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
-- line drawing
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- call "draw_line_quad_start()" prior to each "group" of
|
||||||
|
-- "draw_line()" or "draw_quad()" calls
|
||||||
|
--
|
||||||
|
-- a "group" of draw_line()/draw_quad() calls are
|
||||||
|
-- back-to-back/consecutive, with no non-line/quad drawing between
|
||||||
|
-- them.
|
||||||
|
--
|
||||||
|
-- For example:
|
||||||
|
|
||||||
|
test.draw_line_quad_start()
|
||||||
|
test.draw_set_color(1.0, 0.0, 0.0) -- r, g, b (0.0 to 1.0)
|
||||||
|
test.draw_line(0, 0, 1024, 1024) -- x1, y1, x2, y2
|
||||||
|
test.draw_line(700, 300, 400, 500)
|
||||||
|
test.draw_set_color(0.0, 1.0, 0.0)
|
||||||
|
test.draw_line(700, 300, 400, 700)
|
||||||
|
|
||||||
|
-- x1, y1, x2, y2,
|
||||||
|
-- x3, y3, x4, y4,
|
||||||
|
--
|
||||||
|
-- vertices must be specified In "counter clockwise" order, as in:
|
||||||
|
--
|
||||||
|
-- 2──1
|
||||||
|
-- │ │ valid (counter clockwise)
|
||||||
|
-- 3──4
|
||||||
|
--
|
||||||
|
-- these can also be rotated, as in:
|
||||||
|
--
|
||||||
|
-- 3
|
||||||
|
-- ╱ ╲
|
||||||
|
-- 4 2 valid (counter clockwise)
|
||||||
|
-- ╲ ╱
|
||||||
|
-- 1
|
||||||
|
--
|
||||||
|
-- however "mirroring" is not valid, as in:
|
||||||
|
--
|
||||||
|
-- 1──2
|
||||||
|
-- │ │ not valid (clockwise)
|
||||||
|
-- 4──3
|
||||||
|
--
|
||||||
|
test.draw_set_color(0.0, 0.0, 1.0)
|
||||||
|
test.draw_quad(
|
||||||
|
600, 600, -- top right
|
||||||
|
500, 600, -- top left
|
||||||
|
500, 700, -- bottom left
|
||||||
|
600, 700 -- bottom right
|
||||||
|
)
|
||||||
|
test.draw_set_color(0.0, 0.5, 1.0)
|
||||||
|
test.draw_quad(
|
||||||
|
900, 900, -- bottom
|
||||||
|
950, 850, -- right
|
||||||
|
900, 800, -- top
|
||||||
|
850, 850 -- left
|
||||||
|
)
|
||||||
|
|
||||||
|
-- If you want to draw a large number of lines or quads in bulk
|
||||||
|
-- (e.g: 10,000+ lines/quads per frame), this interface might not be good
|
||||||
|
-- enough, and we should discuss this in more detail.
|
||||||
end
|
end
|
||||||
|
|
||||||
-- function love.run()
|
function love.run()
|
||||||
-- init()
|
init()
|
||||||
|
|
||||||
-- --love.timer.step()
|
return function()
|
||||||
|
love.event.pump()
|
||||||
|
for name, a,b,c,d,e,f,g,h in love.event.poll() do
|
||||||
|
if name == "quit" then
|
||||||
|
if c or not love.quit or not love.quit() then
|
||||||
|
return a or 0, b
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- return function()
|
local width
|
||||||
-- love.event.pump()
|
local height
|
||||||
-- for name, a,b,c,d,e,f,g,h in love.event.poll() do
|
local flags
|
||||||
-- if name == "quit" then
|
width, height, flags = love.window.getMode()
|
||||||
-- if c or not love.quit or not love.quit() then
|
test.update_window(width, height)
|
||||||
-- return a or 0, b
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local width
|
local time = love.timer.getTime()
|
||||||
-- local height
|
update(time)
|
||||||
-- local flags
|
|
||||||
-- width, height, flags = love.window.getMode()
|
|
||||||
-- test.update_window(width, height)
|
|
||||||
|
|
||||||
-- --local dt = love.timer.step()
|
draw()
|
||||||
-- local time = love.timer.getTime()
|
|
||||||
-- update(time)
|
|
||||||
|
|
||||||
-- draw()
|
local mouse_down = love.mouse.isDown(1)
|
||||||
|
if mouse_down then
|
||||||
|
local x, y = love.mouse.getPosition()
|
||||||
|
test.update_mouse(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
-- local mouse_down = love.mouse.isDown(1)
|
-- nico_draw()
|
||||||
-- if mouse_down then
|
|
||||||
-- local x, y = love.mouse.getPosition()
|
|
||||||
-- test.update_mouse(x, y)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- print(love)
|
love.graphics.present()
|
||||||
-- love_draw()
|
love.timer.sleep(0.001)
|
||||||
-- love.graphics.present()
|
end
|
||||||
-- love.timer.sleep(0.001)
|
end
|
||||||
-- --love.timer.sleep(0.1)
|
|
||||||
-- --local fps = love.timer.getFPS( )
|
|
||||||
-- --print(fps)
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function love.load(args)
|
-- function love.load(args)
|
||||||
-- init()
|
-- init()
|
||||||
@ -166,43 +248,43 @@ end
|
|||||||
|
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
local wm = require("world_map")
|
-- local wm = require("world_map")
|
||||||
|
|
||||||
world = {
|
-- world = {
|
||||||
["main_menu"] = require("love_src.src.world.main_menu")(),
|
-- ["main_menu"] = require("love_src.src.world.main_menu")(),
|
||||||
["1_intro"] = require("love_src.src.world.1_intro")(),
|
-- ["1_intro"] = require("love_src.src.world.1_intro")(),
|
||||||
["2_town_square"] = require("love_src.src.world.2_town_square")(),
|
-- ["2_town_square"] = require("love_src.src.world.2_town_square")(),
|
||||||
["race"] = require("love_src.src.world.race")(),
|
-- ["race"] = require("love_src.src.world.race")(),
|
||||||
["train"] = require("love_src.src.world.train")(),
|
-- ["train"] = require("love_src.src.world.train")(),
|
||||||
};
|
-- };
|
||||||
|
|
||||||
current = wm["2_town_square"]
|
-- current = wm["2_town_square"]
|
||||||
|
|
||||||
function load_world(world_to_load)
|
-- function load_world(world_to_load)
|
||||||
current = world_to_load
|
-- current = world_to_load
|
||||||
world[current]:reload()
|
-- world[current]:reload()
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function love.load()
|
-- function love.load()
|
||||||
world[current]:load()
|
-- world[current]:load()
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function love.update(dt)
|
-- function love.update(dt)
|
||||||
world[current]:update(dt)
|
-- world[current]:update(dt)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function love.draw()
|
-- function love.draw()
|
||||||
world[current]:draw()
|
-- world[current]:draw()
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function love.keyreleased(key, scancode)
|
-- function love.keyreleased(key, scancode)
|
||||||
world[current]:keyreleased(key, scancode)
|
-- world[current]:keyreleased(key, scancode)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function love.keypressed(key, scancode, isrepeat)
|
-- function love.keypressed(key, scancode, isrepeat)
|
||||||
world[current]:keypressed(key, scancode, isrepeat)
|
-- world[current]:keypressed(key, scancode, isrepeat)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function love.mousereleased(x, y, button, istouch, presses)
|
-- function love.mousereleased(x, y, button, istouch, presses)
|
||||||
world[current]:mousereleased(x, y, button, istouch, presses)
|
-- world[current]:mousereleased(x, y, button, istouch, presses)
|
||||||
end
|
-- end
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -5,16 +5,13 @@ Wooden Planks,5,,4,,,,"""linear texture index"" is invalid if unspecified"
|
|||||||
Trunk,17,,5,,,,"""properties"" is (empty) if unspecified"
|
Trunk,17,,5,,,,"""properties"" is (empty) if unspecified"
|
||||||
Trunk,17,1,5,,,,
|
Trunk,17,1,5,,,,
|
||||||
Birch Block,17,2,6,,,,
|
Birch Block,17,2,6,,,,
|
||||||
Leaves,18,,12,,,,
|
Leaves,18,"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15",12,,,,
|
||||||
Leaves,18,1,12,,,,
|
|
||||||
Leaves,18,2,12,,,,
|
|
||||||
Leaves,18,3,12,,,,
|
|
||||||
Unused,20,,11,,,,
|
Unused,20,,11,,,,
|
||||||
Door Bottom,21,,18,,,,
|
Door Bottom,21,,18,,,,
|
||||||
Door Top,22,,17,,,,
|
Door Top,22,,17,,,,
|
||||||
Tall Grass,31,"0,1",22,tall_grass,,,
|
Tall Grass,31,"0,1",22,tall_grass,two_sided,,
|
||||||
Tan Block 1,35,1,2,,,,
|
Tan Block 1,35,1,2,,,,
|
||||||
White Block 2,35,5,6,,,,if you say so
|
White Block 2,35,5,6,,,,
|
||||||
Arch Bottom,35,6,10,,,,
|
Arch Bottom,35,6,10,,,,
|
||||||
Tan Block 2,35,8,3,,,,
|
Tan Block 2,35,8,3,,,,
|
||||||
White Block 1,35,9,21,,,,
|
White Block 1,35,9,21,,,,
|
||||||
@ -23,13 +20,14 @@ Unused,35,10,,,,,
|
|||||||
Arch Top,35,14,9,,,,
|
Arch Top,35,14,9,,,,
|
||||||
Grey Bricks 1,35,15,8,,,,
|
Grey Bricks 1,35,15,8,,,,
|
||||||
White Block 3,35,,7,,,,
|
White Block 3,35,,7,,,,
|
||||||
Lilac Grass,37,,15,tall_grass,,,
|
Lilac Grass,37,,15,tall_grass,two_sided,,
|
||||||
Spider Plant,38,,13,tall_grass,,,
|
Spider Plant,38,,13,tall_grass,two_sided,,
|
||||||
Spider Plant,39,,13,tall_grass,,,
|
Spider Plant,39,,13,tall_grass,two_sided,,
|
||||||
Red Mushroom,40,,14,custom_mushroom,,,
|
Red Mushroom,40,,14,custom_mushroom,,,
|
||||||
Start/Finish Line,45,,16,,,,
|
Start/Finish Line,45,,16,,,,
|
||||||
Shadow Block,49,,20,,,,
|
Shadow Block,49,,20,,,,
|
||||||
Wall Torch,50,"1,2,3,4",,wall_torch,emits_light,,
|
Wall Torch,50,"1,2,3,4",62,wall_torch,"emits_light,torch_oriented",,
|
||||||
Candle,50,5,,candle,emits_light,,
|
Candle,50,5,61,candle,emits_light,,
|
||||||
|
Stair,53,"0,1,2,3,4,5,6,7",4,stair,stair_oriented,,
|
||||||
Fence,85,0,4,fence,,,
|
Fence,85,0,4,fence,,,
|
||||||
Lamp Block,89,,19,,,,
|
Lamp Block,89,,19,,,,
|
||||||
|
@ -77,5 +77,17 @@ def get_texture_id(block_id, block_data):
|
|||||||
decl = by_id_data.get((block_id, block_data), default_decl)
|
decl = by_id_data.get((block_id, block_data), default_decl)
|
||||||
return decl.linear_texture_index
|
return decl.linear_texture_index
|
||||||
|
|
||||||
|
def get_special(block_id, block_data):
|
||||||
|
decl = by_id_data.get((block_id, block_data), default_decl)
|
||||||
|
if "two_sided" in decl.properties:
|
||||||
|
return -1
|
||||||
|
if "torch_oriented" in decl.properties:
|
||||||
|
return 1
|
||||||
|
if "stair_oriented" in decl.properties:
|
||||||
|
return 2
|
||||||
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(sorted_custom_mesh)
|
from pprint import pprint
|
||||||
|
#print(sorted_custom_mesh)
|
||||||
|
pprint(sorted_decls)
|
||||||
|
|||||||
2639
game/minecraft/gen/candle.obj
Normal file
2639
game/minecraft/gen/candle.obj
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,20 +1,24 @@
|
|||||||
set -eux
|
set -eux
|
||||||
#cd ./minecraft/gen
|
#cd ./minecraft/gen
|
||||||
PYTHON=pypy3.11
|
PYTHON=pypy3.11
|
||||||
cat <<EOF > ../grandlecturn/all_regions.txt
|
|
||||||
|
CROP=-200,-150:300,200
|
||||||
|
ALL_REGIONS=../grandlecturn/all_regions.txt
|
||||||
|
|
||||||
|
cat <<EOF > $ALL_REGIONS
|
||||||
$HOME/GrandLecturn/region/r.0.0.mcr
|
$HOME/GrandLecturn/region/r.0.0.mcr
|
||||||
$HOME/GrandLecturn/region/r.-1.-1.mcr
|
$HOME/GrandLecturn/region/r.-1.-1.mcr
|
||||||
$HOME/GrandLecturn/region/r.0.-1.mcr
|
$HOME/GrandLecturn/region/r.0.-1.mcr
|
||||||
$HOME/GrandLecturn/region/r.-1.0.mcr
|
$HOME/GrandLecturn/region/r.-1.0.mcr
|
||||||
EOF
|
EOF
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.0.mcr ../grandlecturn/region.0.0 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.0.mcr ../grandlecturn/region.0.0 $ALL_REGIONS $CROP &
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.-1.mcr ../grandlecturn/region.-1.-1 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.-1.mcr ../grandlecturn/region.-1.-1 $ALL_REGIONS $CROP &
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.-1.mcr ../grandlecturn/region.0.-1 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.0.-1.mcr ../grandlecturn/region.0.-1 $ALL_REGIONS $CROP &
|
||||||
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.0.mcr ../grandlecturn/region.-1.0 ../grandlecturn/all_regions.txt &
|
$PYTHON mc.py $HOME/GrandLecturn/region/r.-1.0.mcr ../grandlecturn/region.-1.0 $ALL_REGIONS $CROP &
|
||||||
|
|
||||||
wait
|
wait
|
||||||
|
|
||||||
cat ../grandlecturn/region*.lights.vtx > ../grandlecturn/global.lights.vtx
|
cat ../grandlecturn/region*.lights.vtx > ../grandlecturn/global.lights.vtx
|
||||||
|
|
||||||
cat ../grandlecturn/region*.dump > ../grandlecturn/global.dump
|
cat ../grandlecturn/region*.dump > ../grandlecturn/global.dump
|
||||||
$PYTHON intkeys.py ../grandlecturn/global.dump | $HOME/nbperf/nbperf -n grandlecturn_hash -I -a bpz -c 1.26 -m ../love2dworld/map.txt > ../grandlecturn/inthash.c
|
$PYTHON intkeys.py ../grandlecturn/global.dump | $HOME/nbperf/nbperf -n grandlecturn_hash -I -a bpz -c 1.24 -m ../love2dworld/map.txt > ../grandlecturn/inthash.c
|
||||||
|
|||||||
@ -42,7 +42,15 @@ def neighbor_exists(level_table, chunk_x, chunk_z, nx, ny, nz):
|
|||||||
n_block_data = decode_block_data(level_table, chunk_x, 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 block_neighbors(level_table, chunk_x, chunk_z, block_index):
|
def outside_crop(position, crop):
|
||||||
|
return (
|
||||||
|
position[0] < crop[0][0] or
|
||||||
|
position[2] < crop[0][1] or
|
||||||
|
position[0] > crop[1][0] or
|
||||||
|
position[2] > crop[1][1]
|
||||||
|
)
|
||||||
|
|
||||||
|
def block_neighbors(level_table, chunk_x, chunk_z, block_index, crop):
|
||||||
block_id = level_table[(chunk_x, chunk_z)].blocks[block_index]
|
block_id = level_table[(chunk_x, chunk_z)].blocks[block_index]
|
||||||
if block_id == data.BlockID.AIR or block_id == data.BlockID.BEDROCK:
|
if block_id == data.BlockID.AIR or block_id == data.BlockID.BEDROCK:
|
||||||
return
|
return
|
||||||
@ -51,6 +59,8 @@ def block_neighbors(level_table, chunk_x, chunk_z, block_index):
|
|||||||
|
|
||||||
xyz = mcregion.xyz_from_block_index(block_index)
|
xyz = mcregion.xyz_from_block_index(block_index)
|
||||||
center_position = vec3.add(xyz, (chunk_x * 16, 0, chunk_z * 16))
|
center_position = vec3.add(xyz, (chunk_x * 16, 0, chunk_z * 16))
|
||||||
|
if outside_crop(center_position, crop):
|
||||||
|
return # block is cropped
|
||||||
|
|
||||||
if not block_ids.is_cube_block(block_id, block_data):
|
if not block_ids.is_cube_block(block_id, block_data):
|
||||||
yield center_position, block_id, block_data, None
|
yield center_position, block_id, block_data, None
|
||||||
@ -66,10 +76,10 @@ def block_neighbors(level_table, chunk_x, chunk_z, block_index):
|
|||||||
if normal_indices:
|
if normal_indices:
|
||||||
yield center_position, block_id, block_data, normal_indices
|
yield center_position, block_id, block_data, normal_indices
|
||||||
|
|
||||||
def devoxelize_region(level_table, level_table_keys):
|
def devoxelize_region(level_table, level_table_keys, crop):
|
||||||
for chunk_x, chunk_z in level_table_keys:
|
for chunk_x, chunk_z in level_table_keys:
|
||||||
for block_index in range(128 * 16 * 16):
|
for block_index in range(128 * 16 * 16):
|
||||||
yield from block_neighbors(level_table, chunk_x, chunk_z, block_index)
|
yield from block_neighbors(level_table, chunk_x, chunk_z, block_index, crop)
|
||||||
|
|
||||||
def build_level_table(level_table, mem, locations):
|
def build_level_table(level_table, mem, locations):
|
||||||
for location in locations:
|
for location in locations:
|
||||||
@ -96,9 +106,11 @@ def build_block_configuration_table():
|
|||||||
yield indices
|
yield indices
|
||||||
|
|
||||||
def pack_instance_data(position, block_id, block_data, texture_id):
|
def pack_instance_data(position, block_id, block_data, texture_id):
|
||||||
|
special = block_ids.get_special(block_id, block_data)
|
||||||
|
|
||||||
packed = struct.pack("<hhhhhhhh",
|
packed = struct.pack("<hhhhhhhh",
|
||||||
position[0], position[1], position[2], 0,
|
position[0], position[1], position[2], 0,
|
||||||
block_id, block_data, texture_id, 0)
|
block_id, block_data, texture_id, special)
|
||||||
return packed
|
return packed
|
||||||
|
|
||||||
def pack_light_data(position, block_id):
|
def pack_light_data(position, block_id):
|
||||||
@ -116,8 +128,8 @@ def build_block_instances(blocks):
|
|||||||
if block_ids.is_light_source(block_id, block_data):
|
if block_ids.is_light_source(block_id, block_data):
|
||||||
light_sources.append((position, block_id, block_data))
|
light_sources.append((position, block_id, block_data))
|
||||||
if not block_ids.is_cube_block(block_id, block_data):
|
if not block_ids.is_cube_block(block_id, block_data):
|
||||||
#custom_mesh_index = block_ids.get_custom_mesh_index(block_id, block_data)
|
custom_mesh_index = block_ids.get_custom_mesh_index(block_id, block_data)
|
||||||
#non_cube_blocks[custom_mesh_index].append((position, block_id, block_data))
|
non_cube_blocks[custom_mesh_index].append((position, block_id, block_data))
|
||||||
continue
|
continue
|
||||||
configuration = normal_indices_as_block_configuration(normal_indices)
|
configuration = normal_indices_as_block_configuration(normal_indices)
|
||||||
by_configuration[configuration].append((position, block_id, block_data))
|
by_configuration[configuration].append((position, block_id, block_data))
|
||||||
@ -210,8 +222,9 @@ def dump_blocks(blocks):
|
|||||||
assert(len(buf) == 8)
|
assert(len(buf) == 8)
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
|
|
||||||
def main2(level_table, level_table_keys):
|
def main2(level_table, level_table_keys, crop):
|
||||||
blocks = devoxelize_region(level_table, level_table_keys)
|
print("crop", crop)
|
||||||
|
blocks = devoxelize_region(level_table, level_table_keys, crop)
|
||||||
blocks = list(blocks)
|
blocks = list(blocks)
|
||||||
dump_blocks(blocks)
|
dump_blocks(blocks)
|
||||||
build_block_instances(blocks)
|
build_block_instances(blocks)
|
||||||
@ -222,7 +235,15 @@ def parse_all_paths(path):
|
|||||||
buf = f.read()
|
buf = f.read()
|
||||||
return set(l.strip() for l in buf.split('\n') if l.strip())
|
return set(l.strip() for l in buf.split('\n') if l.strip())
|
||||||
|
|
||||||
def main(mcr_path, data_path, all_paths_path):
|
def parse_crop(crop):
|
||||||
|
min_xz, max_xz = crop.strip().split(":")
|
||||||
|
min_xz = tuple(int(c) for c in min_xz.split(","))
|
||||||
|
max_xz = tuple(int(c) for c in max_xz.split(","))
|
||||||
|
assert min_xz[0] < max_xz[0], crop
|
||||||
|
assert min_xz[1] < max_xz[1], crop
|
||||||
|
return min_xz, max_xz
|
||||||
|
|
||||||
|
def main(mcr_path, data_path, all_paths_path, crop):
|
||||||
all_paths = parse_all_paths(all_paths_path)
|
all_paths = parse_all_paths(all_paths_path)
|
||||||
assert mcr_path in all_paths
|
assert mcr_path in all_paths
|
||||||
level_table = {}
|
level_table = {}
|
||||||
@ -232,10 +253,10 @@ def main(mcr_path, data_path, all_paths_path):
|
|||||||
if path == mcr_path:
|
if path == mcr_path:
|
||||||
continue
|
continue
|
||||||
level_table_from_path(level_table, path)
|
level_table_from_path(level_table, path)
|
||||||
|
main2(level_table, level_table_keys, parse_crop(crop))
|
||||||
main2(level_table, level_table_keys)
|
|
||||||
|
|
||||||
mcr_path = sys.argv[1]
|
mcr_path = sys.argv[1]
|
||||||
data_path = sys.argv[2]
|
data_path = sys.argv[2]
|
||||||
all_paths_path = sys.argv[3]
|
all_paths_path = sys.argv[3]
|
||||||
main(mcr_path, data_path, all_paths_path)
|
crop = sys.argv[4]
|
||||||
|
main(mcr_path, data_path, all_paths_path, crop)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# Blender 4.5.7 LTS
|
# Blender 5.0.0
|
||||||
# www.blender.org
|
# www.blender.org
|
||||||
o Cube
|
o Cube
|
||||||
v 1.000000 -1.000000 -1.000000
|
v 1.000000 -1.000000 -1.000000
|
||||||
@ -5,6 +5,8 @@ import obj_state
|
|||||||
import obj_write
|
import obj_write
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import block_ids
|
||||||
|
|
||||||
normals = [
|
normals = [
|
||||||
(-1.0, 0.0, 0.0),
|
(-1.0, 0.0, 0.0),
|
||||||
(0.0, -1.0, 0.0),
|
(0.0, -1.0, 0.0),
|
||||||
@ -49,11 +51,10 @@ def main():
|
|||||||
|
|
||||||
build_configuration_index_buffers(cube_faces_by_normal, index_buffer)
|
build_configuration_index_buffers(cube_faces_by_normal, index_buffer)
|
||||||
# check mc.py `custom_blocks` for model order
|
# check mc.py `custom_blocks` for model order
|
||||||
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "tallgrass.obj")
|
|
||||||
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "fence.obj")
|
mesh_order = block_ids.sorted_custom_mesh
|
||||||
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "torch.obj")
|
for mesh_name in mesh_order:
|
||||||
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "wheat.obj")
|
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, f"{mesh_name}.obj")
|
||||||
obj_write.write_obj(vertex_buffer, index_buffer, index_lookup, "custom-mushroom.obj")
|
|
||||||
|
|
||||||
with open("../configuration.idx", "wb") as f:
|
with open("../configuration.idx", "wb") as f:
|
||||||
obj_write.write_indices(f, "<H", index_buffer)
|
obj_write.write_indices(f, "<H", index_buffer)
|
||||||
|
|||||||
1507
game/minecraft/gen/wall_torch.obj
Normal file
1507
game/minecraft/gen/wall_torch.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -7,6 +7,7 @@ uniform sampler2D ColorSampler;
|
|||||||
uniform float Linear;
|
uniform float Linear;
|
||||||
uniform float Quadratic;
|
uniform float Quadratic;
|
||||||
uniform vec3 Eye;
|
uniform vec3 Eye;
|
||||||
|
uniform int LightCount;
|
||||||
|
|
||||||
layout (location = 0) out vec4 Color;
|
layout (location = 0) out vec4 Color;
|
||||||
|
|
||||||
@ -24,20 +25,21 @@ void main()
|
|||||||
vec4 color = texture(ColorSampler, PixelTexture.xy);
|
vec4 color = texture(ColorSampler, PixelTexture.xy);
|
||||||
|
|
||||||
vec3 out_color = color.xyz * 0.1;
|
vec3 out_color = color.xyz * 0.1;
|
||||||
for (int i = 0; i < 82; i++) {
|
for (int i = 0; i < LightCount; i++) {
|
||||||
vec3 light_position = light[i].xzy;
|
vec3 light_position = light[i].xzy + vec3(0, 0, 0.5);
|
||||||
float light_distance = length(light_position - position.xyz);
|
float light_distance = length(light_position - position.xyz);
|
||||||
vec3 light_direction = normalize(light_position - position.xyz);
|
vec3 light_direction = normalize(light_position - position.xyz);
|
||||||
float diffuse = max(dot(normal.xyz, light_direction), 0.0);
|
float diffuse = max(dot(normal.xyz, light_direction), 0.0);
|
||||||
|
if (normal.w == 1.0) // two-sided
|
||||||
|
diffuse = 1.0;
|
||||||
|
|
||||||
//float attenuation = 1.0 / (1.0 + Linear * light_distance + Quadratic * light_distance * light_distance);
|
//float attenuation = 1.0 / (1.0 + Linear * light_distance + Quadratic * light_distance * light_distance);
|
||||||
|
|
||||||
float attenuation = 1.0 / (1.0 + Quadratic * light_distance * light_distance);
|
float attenuation = 1.0 / (1.0 + Quadratic * light_distance * light_distance);
|
||||||
//out_color += color.xyz * attenuation * diffuse;
|
out_color += color.xyz * attenuation * diffuse;
|
||||||
//out_color = vec3(diffuse);
|
|
||||||
}
|
}
|
||||||
vec3 light_direction = normalize(Eye.xyz - position.xyz);
|
|
||||||
float diffuse = max(dot(normal.xyz, light_direction), 0.0);
|
|
||||||
|
|
||||||
out_color = color.xyz * diffuse;
|
//vec3 light_direction = normalize(Eye.xyz - position.xyz);
|
||||||
|
//float diffuse = max(dot(normal.xyz, light_direction), 0.0);
|
||||||
|
|
||||||
Color = vec4(out_color, 1.0);
|
Color = vec4(out_color, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,13 @@ in VS_OUT {
|
|||||||
flat int BlockID;
|
flat int BlockID;
|
||||||
flat int Data;
|
flat int Data;
|
||||||
flat int TextureID;
|
flat int TextureID;
|
||||||
|
flat int Special;
|
||||||
} fs_in;
|
} fs_in;
|
||||||
|
|
||||||
layout (location = 0) out vec3 Position;
|
layout (location = 0) out vec3 Position;
|
||||||
layout (location = 1) out vec3 Normal;
|
layout (location = 1) out vec4 Normal;
|
||||||
layout (location = 2) out vec3 Color;
|
layout (location = 2) out vec3 Color;
|
||||||
layout (location = 3) out vec3 Block;
|
layout (location = 3) out vec4 Block;
|
||||||
|
|
||||||
uniform sampler2D TerrainSampler;
|
uniform sampler2D TerrainSampler;
|
||||||
uniform vec3 MousePosition;
|
uniform vec3 MousePosition;
|
||||||
@ -22,16 +23,6 @@ uniform vec3 MousePosition2;
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
int texture_id = fs_in.TextureID;
|
int texture_id = fs_in.TextureID;
|
||||||
if (fs_in.BlockID == 2) // grass
|
|
||||||
texture_id = 0;
|
|
||||||
if (fs_in.BlockID == 50 && fs_in.Data == 0) // ?
|
|
||||||
texture_id = 61;
|
|
||||||
if (fs_in.BlockID == 18)
|
|
||||||
texture_id = 11;
|
|
||||||
if (fs_in.BlockID == 21)
|
|
||||||
texture_id = 17;
|
|
||||||
if (fs_in.BlockID == 22)
|
|
||||||
texture_id = 16;
|
|
||||||
|
|
||||||
int terrain_x = texture_id % 8;
|
int terrain_x = texture_id % 8;
|
||||||
int terrain_y = texture_id / 8;
|
int terrain_y = texture_id / 8;
|
||||||
@ -44,8 +35,11 @@ void main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position = fs_in.BlockPosition.xzy;
|
float two_sided = float(fs_in.Special == -1); // special
|
||||||
Normal = normalize(fs_in.Normal.xzy);
|
|
||||||
|
//Position = fs_in.BlockPosition.xzy;
|
||||||
|
Position = fs_in.Position.xzy;
|
||||||
|
Normal = vec4(normalize(fs_in.Normal.xzy), two_sided);
|
||||||
Color = texture_color.xyz;
|
Color = texture_color.xyz;
|
||||||
Block = vec3(fs_in.BlockID, fs_in.Data, fs_in.TextureID);
|
Block = vec4(fs_in.BlockID, fs_in.Data, fs_in.TextureID, fs_in.Special);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ in vec3 BlockPosition;
|
|||||||
in int BlockID;
|
in int BlockID;
|
||||||
in int Data;
|
in int Data;
|
||||||
in int TextureID;
|
in int TextureID;
|
||||||
|
in int Special;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
@ -18,13 +19,30 @@ out VS_OUT {
|
|||||||
flat int BlockID;
|
flat int BlockID;
|
||||||
flat int Data;
|
flat int Data;
|
||||||
flat int TextureID;
|
flat int TextureID;
|
||||||
|
flat int Special;
|
||||||
} vs_out;
|
} vs_out;
|
||||||
|
|
||||||
uniform mat4 Transform;
|
uniform mat4 Transform;
|
||||||
|
|
||||||
|
vec3 orientation(vec3 position)
|
||||||
|
{
|
||||||
|
if (Special == 1) { // oriented torch
|
||||||
|
if (Data == 1) // "facing east"
|
||||||
|
return vec3(position.z, position.y, -position.x);
|
||||||
|
else if (Data == 2) // "facing west"
|
||||||
|
return vec3(-position.z, position.y, position.x);
|
||||||
|
else if (Data == 4) // "facing north"
|
||||||
|
return vec3(position.x, position.y, -position.z);
|
||||||
|
else // "facing south"
|
||||||
|
return position;
|
||||||
|
} else {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 position = Position + BlockPosition; // world coordinates
|
vec3 position = orientation(Position) + BlockPosition; // world coordinates
|
||||||
|
|
||||||
vs_out.Position = position;
|
vs_out.Position = position;
|
||||||
vs_out.BlockPosition = BlockPosition;
|
vs_out.BlockPosition = BlockPosition;
|
||||||
@ -33,6 +51,7 @@ void main()
|
|||||||
vs_out.BlockID = BlockID;
|
vs_out.BlockID = BlockID;
|
||||||
vs_out.Data = Data;
|
vs_out.Data = Data;
|
||||||
vs_out.TextureID = TextureID;
|
vs_out.TextureID = TextureID;
|
||||||
|
vs_out.Special = Special;
|
||||||
|
|
||||||
gl_Position = Transform * vec4(position.xzy, 1.0);
|
gl_Position = Transform * vec4(position.xzy, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,12 +7,12 @@ in VS_OUT {
|
|||||||
} fs_in;
|
} fs_in;
|
||||||
|
|
||||||
layout (location = 0) out vec3 Position;
|
layout (location = 0) out vec3 Position;
|
||||||
layout (location = 1) out vec3 Normal;
|
layout (location = 1) out vec4 Normal;
|
||||||
layout (location = 2) out vec3 Color;
|
layout (location = 2) out vec3 Color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
Position = fs_in.Position;
|
Position = fs_in.Position;
|
||||||
Normal = normalize(fs_in.Normal);
|
Normal = vec4(normalize(fs_in.Normal), 0.0);
|
||||||
Color = vec3(0, 1, 1);
|
Color = vec3(0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
10
game/shader/pixel_line_art.frag
Normal file
10
game/shader/pixel_line_art.frag
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
out vec4 Color;
|
||||||
|
|
||||||
|
layout (location = 1) uniform vec3 BaseColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Color = vec4(BaseColor, 1);
|
||||||
|
}
|
||||||
10
game/shader/pixel_line_art.vert
Normal file
10
game/shader/pixel_line_art.vert
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
layout (location = 0) in vec2 Position;
|
||||||
|
|
||||||
|
layout (location = 0) uniform mat4 Transform;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = Transform * vec4(Position, 0, 1);
|
||||||
|
}
|
||||||
@ -123,8 +123,8 @@ namespace font {
|
|||||||
|
|
||||||
inline static XMFLOAT4X4 glyph_transform(font const& font, int x, int y)
|
inline static XMFLOAT4X4 glyph_transform(font const& font, int x, int y)
|
||||||
{
|
{
|
||||||
XMMATRIX transform =
|
XMMATRIX transform
|
||||||
XMMatrixScaling(font.desc->glyph_width, font.desc->glyph_height, 0)
|
= XMMatrixScaling(font.desc->glyph_width, font.desc->glyph_height, 0)
|
||||||
* XMMatrixTranslation(x, -y, 0)
|
* XMMatrixTranslation(x, -y, 0)
|
||||||
* XMMatrixScaling(2.0f / window::width, 2.0f / window::height, 0)
|
* XMMatrixScaling(2.0f / window::width, 2.0f / window::height, 0)
|
||||||
* XMMatrixTranslation(-1, 1, 0);
|
* XMMatrixTranslation(-1, 1, 0);
|
||||||
@ -148,7 +148,7 @@ namespace font {
|
|||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_string(font const& font, char const * const s, int x, int y)
|
int draw_string(font const& font, char const * const s, int x, int y)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (s[i] != 0) {
|
while (s[i] != 0) {
|
||||||
@ -164,5 +164,6 @@ namespace font {
|
|||||||
|
|
||||||
x += font.desc->glyph_width;
|
x += font.desc->glyph_width;
|
||||||
}
|
}
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace hud {
|
|||||||
|
|
||||||
inline static float draw_vector(font::font const& ter_best, char * const buf, float y, char const * const label, XMVECTOR vec)
|
inline static float draw_vector(font::font const& ter_best, char * const buf, float y, char const * const label, XMVECTOR vec)
|
||||||
{
|
{
|
||||||
labeled_value<float>(buf, label, ": %5.2f %5.2f %5.2f", XMVectorGetX(vec), XMVectorGetY(vec), XMVectorGetZ(vec));
|
labeled_value<float>(buf, label, ": %5.2f %5.2f %5.2f %5.2f", XMVectorGetX(vec), XMVectorGetY(vec), XMVectorGetZ(vec), XMVectorGetW(vec));
|
||||||
font::draw_string(ter_best, buf, 10, y);
|
font::draw_string(ter_best, buf, 10, y);
|
||||||
y += ter_best.desc->glyph_height;
|
y += ter_best.desc->glyph_height;
|
||||||
return y;
|
return y;
|
||||||
@ -81,7 +81,6 @@ namespace hud {
|
|||||||
|
|
||||||
int font_ix = font::best_font(font::terminus, font::terminus_length);
|
int font_ix = font::best_font(font::terminus, font::terminus_length);
|
||||||
font::font const& ter_best = terminus_fonts[font_ix];
|
font::font const& ter_best = terminus_fonts[font_ix];
|
||||||
|
|
||||||
font::draw_start(ter_best, empty_vertex_array_object, quad_index_buffer);
|
font::draw_start(ter_best, empty_vertex_array_object, quad_index_buffer);
|
||||||
|
|
||||||
labeled_value<float>(buf, "fov: ", "%.3f", view::state.fov);
|
labeled_value<float>(buf, "fov: ", "%.3f", view::state.fov);
|
||||||
@ -116,7 +115,7 @@ namespace hud {
|
|||||||
|
|
||||||
font::draw_string(ter_best, "mouse:", 10, y);
|
font::draw_string(ter_best, "mouse:", 10, y);
|
||||||
y += ter_best.desc->glyph_height;
|
y += ter_best.desc->glyph_height;
|
||||||
y = draw_vector(ter_best, buf, y, " position", XMLoadFloat3((XMFLOAT3*)mouse_position));
|
y = draw_vector(ter_best, buf, y, " position", XMLoadFloat4((XMFLOAT4*)mouse_position));
|
||||||
y = draw_vector(ter_best, buf, y, " block", XMLoadFloat3((XMFLOAT3*)mouse_block));
|
y = draw_vector(ter_best, buf, y, " block", XMLoadFloat4((XMFLOAT4*)mouse_block));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ namespace lighting {
|
|||||||
unsigned int quadratic;
|
unsigned int quadratic;
|
||||||
unsigned int linear;
|
unsigned int linear;
|
||||||
unsigned int eye;
|
unsigned int eye;
|
||||||
|
unsigned int light_count;
|
||||||
|
|
||||||
unsigned int lights;
|
unsigned int lights;
|
||||||
} uniform;
|
} uniform;
|
||||||
@ -38,7 +39,7 @@ namespace lighting {
|
|||||||
static unsigned int program;
|
static unsigned int program;
|
||||||
static location location;
|
static location location;
|
||||||
|
|
||||||
void load_program()
|
static void load_program()
|
||||||
{
|
{
|
||||||
program = compile_from_files("shader/quad.vert",
|
program = compile_from_files("shader/quad.vert",
|
||||||
NULL,
|
NULL,
|
||||||
@ -50,25 +51,35 @@ namespace lighting {
|
|||||||
location.uniform.quadratic = glGetUniformLocation(program, "Quadratic");
|
location.uniform.quadratic = glGetUniformLocation(program, "Quadratic");
|
||||||
location.uniform.linear = glGetUniformLocation(program, "Linear");
|
location.uniform.linear = glGetUniformLocation(program, "Linear");
|
||||||
location.uniform.eye = glGetUniformLocation(program, "Eye");
|
location.uniform.eye = glGetUniformLocation(program, "Eye");
|
||||||
|
location.uniform.light_count = glGetUniformLocation(program, "LightCount");
|
||||||
location.uniform.lights = glGetUniformBlockIndex(program, "Lights");
|
location.uniform.lights = glGetUniformBlockIndex(program, "Lights");
|
||||||
|
|
||||||
fprintf(stderr, "lighting program:\n");
|
fprintf(stderr, "lighting program:\n");
|
||||||
fprintf(stderr, " uniforms:\n position_sampler %u normal_sampler %u color_sampler %u lights %u\n",
|
fprintf(stderr, " uniforms:\n position_sampler %u normal_sampler %u color_sampler %u quadratic %u\n linear %u\n eye %u\n light_count %u\n lights %u\n",
|
||||||
location.uniform.position_sampler,
|
location.uniform.position_sampler,
|
||||||
location.uniform.normal_sampler,
|
location.uniform.normal_sampler,
|
||||||
location.uniform.color_sampler,
|
location.uniform.color_sampler,
|
||||||
|
location.uniform.quadratic,
|
||||||
|
location.uniform.linear,
|
||||||
|
location.uniform.eye,
|
||||||
|
location.uniform.light_count,
|
||||||
location.uniform.lights);
|
location.uniform.lights);
|
||||||
|
|
||||||
location.binding.lights = 0;
|
location.binding.lights = 0;
|
||||||
glUniformBlockBinding(program, location.uniform.lights, location.binding.lights);
|
glUniformBlockBinding(program, location.uniform.lights, location.binding.lights);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void load()
|
||||||
|
{
|
||||||
|
load_program();
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool near_zero(float a)
|
static inline bool near_zero(float a)
|
||||||
{
|
{
|
||||||
return (fabsf(a) < 0.00001f);
|
return (fabsf(a) < 0.00001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw()
|
void draw(unsigned int light_uniform_buffer, int light_count)
|
||||||
{
|
{
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
glDepthFunc(GL_ALWAYS);
|
glDepthFunc(GL_ALWAYS);
|
||||||
@ -89,12 +100,12 @@ namespace lighting {
|
|||||||
glUniform1f(location.uniform.quadratic, quadratic);
|
glUniform1f(location.uniform.quadratic, quadratic);
|
||||||
glUniform1f(location.uniform.linear, linear);
|
glUniform1f(location.uniform.linear, linear);
|
||||||
|
|
||||||
|
|
||||||
XMFLOAT3 eye;
|
XMFLOAT3 eye;
|
||||||
XMStoreFloat3(&eye, view::state.eye);
|
XMStoreFloat3(&eye, view::state.eye);
|
||||||
glUniform3fv(location.uniform.eye, 1, (float*)&eye);
|
glUniform3fv(location.uniform.eye, 1, (float*)&eye);
|
||||||
|
|
||||||
//glBindBufferBase(GL_UNIFORM_BUFFER, location.binding.lights, light_uniform_buffer);
|
glUniform1i(location.uniform.light_count, light_count);
|
||||||
|
glBindBufferBase(GL_UNIFORM_BUFFER, location.binding.lights, light_uniform_buffer);
|
||||||
|
|
||||||
glBindVertexArray(empty_vertex_array_object);
|
glBindVertexArray(empty_vertex_array_object);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_index_buffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_index_buffer);
|
||||||
|
|||||||
45
game/src/lua_api.cpp
Normal file
45
game/src/lua_api.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include "font.h"
|
||||||
|
#include "pixel_line_art.h"
|
||||||
|
|
||||||
|
#include "lua_api.h"
|
||||||
|
|
||||||
|
extern font::font * terminus_fonts;
|
||||||
|
extern unsigned int empty_vertex_array_object;
|
||||||
|
extern unsigned int quad_index_buffer;
|
||||||
|
|
||||||
|
int draw_font_start()
|
||||||
|
{
|
||||||
|
int font_ix = font::best_font(font::terminus, font::terminus_length);
|
||||||
|
font::font const& ter_best = terminus_fonts[font_ix];
|
||||||
|
font::draw_start(ter_best, empty_vertex_array_object, quad_index_buffer);
|
||||||
|
return font_ix;
|
||||||
|
}
|
||||||
|
|
||||||
|
int draw_font(int font_ix, char const * text, int x, int y)
|
||||||
|
{
|
||||||
|
font::font const& ter_best = terminus_fonts[font_ix];
|
||||||
|
font::draw_string(ter_best, text, x, y);
|
||||||
|
return ter_best.desc->glyph_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_line_quad_start()
|
||||||
|
{
|
||||||
|
pixel_line_art::draw_line_quad_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_line(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
pixel_line_art::draw_line(x1, y1, x2, y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_set_color(float r, float g, float b)
|
||||||
|
{
|
||||||
|
pixel_line_art::draw_set_color(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_quad(int x1, int y1, int x2, int y2,
|
||||||
|
int x3, int y3, int x4, int y4)
|
||||||
|
{
|
||||||
|
pixel_line_art::draw_quad(x1, y1, x2, y2,
|
||||||
|
x3, y3, x4, y4);
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ namespace minecraft {
|
|||||||
unsigned int block_id;
|
unsigned int block_id;
|
||||||
unsigned int data;
|
unsigned int data;
|
||||||
unsigned int texture_id;
|
unsigned int texture_id;
|
||||||
|
unsigned int special;
|
||||||
} attrib;
|
} attrib;
|
||||||
struct {
|
struct {
|
||||||
unsigned int transform;
|
unsigned int transform;
|
||||||
@ -61,15 +62,17 @@ namespace minecraft {
|
|||||||
location.attrib.block_id = glGetAttribLocation(program, "BlockID");
|
location.attrib.block_id = glGetAttribLocation(program, "BlockID");
|
||||||
location.attrib.data = glGetAttribLocation(program, "Data");
|
location.attrib.data = glGetAttribLocation(program, "Data");
|
||||||
location.attrib.texture_id = glGetAttribLocation(program, "TextureID");
|
location.attrib.texture_id = glGetAttribLocation(program, "TextureID");
|
||||||
|
location.attrib.special = glGetAttribLocation(program, "Special");
|
||||||
printf("minecraft program:\n");
|
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",
|
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.position,
|
||||||
location.attrib.normal,
|
location.attrib.normal,
|
||||||
location.attrib.texture,
|
location.attrib.texture,
|
||||||
location.attrib.block_position,
|
location.attrib.block_position,
|
||||||
location.attrib.block_id,
|
location.attrib.block_id,
|
||||||
location.attrib.data,
|
location.attrib.data,
|
||||||
location.attrib.texture_id);
|
location.attrib.texture_id,
|
||||||
|
location.attrib.special);
|
||||||
|
|
||||||
location.uniform.transform = glGetUniformLocation(program, "Transform");
|
location.uniform.transform = glGetUniformLocation(program, "Transform");
|
||||||
location.uniform.terrain_sampler = glGetUniformLocation(program, "TerrainSampler");
|
location.uniform.terrain_sampler = glGetUniformLocation(program, "TerrainSampler");
|
||||||
@ -114,6 +117,10 @@ namespace minecraft {
|
|||||||
glVertexAttribIFormat(location.attrib.texture_id, 1, GL_SHORT, 12);
|
glVertexAttribIFormat(location.attrib.texture_id, 1, GL_SHORT, 12);
|
||||||
glVertexAttribBinding(location.attrib.texture_id, 1);
|
glVertexAttribBinding(location.attrib.texture_id, 1);
|
||||||
|
|
||||||
|
glEnableVertexAttribArray(location.attrib.special);
|
||||||
|
glVertexAttribIFormat(location.attrib.special, 1, GL_SHORT, 14);
|
||||||
|
glVertexAttribBinding(location.attrib.special, 1);
|
||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +223,9 @@ namespace minecraft {
|
|||||||
state.region = New<world::region>(descriptor->region_count);
|
state.region = New<world::region>(descriptor->region_count);
|
||||||
load_regions(descriptor, state.region);
|
load_regions(descriptor, state.region);
|
||||||
|
|
||||||
state.light_uniform_buffer = load_uniform_buffer(descriptor->lights_path);
|
int light_buffer_size;
|
||||||
|
state.light_uniform_buffer = load_uniform_buffer(descriptor->lights_path, &light_buffer_size);
|
||||||
|
state.light_count = light_buffer_size / ((sizeof (float)) * 4);
|
||||||
|
|
||||||
// collision data
|
// collision data
|
||||||
world::entry_table::load_entry_table(descriptor->entry_table_path,
|
world::entry_table::load_entry_table(descriptor->entry_table_path,
|
||||||
@ -312,7 +321,6 @@ namespace minecraft {
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// custom blocks
|
// custom blocks
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
/*
|
|
||||||
for (int i = 0; i < world::custom_block_types; i++) {
|
for (int i = 0; i < world::custom_block_types; i++) {
|
||||||
int element_count = index_buffer_custom_offsets[i].count;
|
int element_count = index_buffer_custom_offsets[i].count;
|
||||||
const void * indices = (void *)(2 * (ptrdiff_t)index_buffer_custom_offsets[i].offset);
|
const void * indices = (void *)(2 * (ptrdiff_t)index_buffer_custom_offsets[i].offset);
|
||||||
@ -322,7 +330,6 @@ namespace minecraft {
|
|||||||
continue;
|
continue;
|
||||||
glDrawElementsInstancedBaseInstance(GL_TRIANGLES, element_count, GL_UNSIGNED_SHORT, indices, instance_count, base_instance);
|
glDrawElementsInstancedBaseInstance(GL_TRIANGLES, element_count, GL_UNSIGNED_SHORT, indices, instance_count, base_instance);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,7 +109,7 @@ unsigned int compile_from_files(char const * vertex_path,
|
|||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int load_uniform_buffer(char const * const path)
|
unsigned int load_uniform_buffer(char const * const path, int * out_size)
|
||||||
{
|
{
|
||||||
unsigned int buffer;
|
unsigned int buffer;
|
||||||
glGenBuffers(1, &buffer);
|
glGenBuffers(1, &buffer);
|
||||||
@ -124,6 +124,8 @@ unsigned int load_uniform_buffer(char const * const path)
|
|||||||
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||||
|
|
||||||
|
*out_size = data_size;
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
138
game/src/pixel_line_art.cpp
Normal file
138
game/src/pixel_line_art.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#include "glad/gl.h"
|
||||||
|
#include "directxmath/directxmath.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "opengl.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
|
#include "pixel_line_art.h"
|
||||||
|
|
||||||
|
extern unsigned int quad_index_buffer;
|
||||||
|
|
||||||
|
namespace pixel_line_art {
|
||||||
|
|
||||||
|
struct layout {
|
||||||
|
struct {
|
||||||
|
unsigned int position;
|
||||||
|
} attribute;
|
||||||
|
struct {
|
||||||
|
unsigned int transform;
|
||||||
|
unsigned int base_color;
|
||||||
|
} uniform;
|
||||||
|
};
|
||||||
|
|
||||||
|
const layout layout = {
|
||||||
|
.attribute = {
|
||||||
|
.position = 0,
|
||||||
|
},
|
||||||
|
.uniform = {
|
||||||
|
.transform = 0,
|
||||||
|
.base_color = 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static unsigned int program;
|
||||||
|
|
||||||
|
static unsigned int vertex_array_object;
|
||||||
|
static unsigned int per_vertex_buffer;
|
||||||
|
static int const per_vertex_size = (sizeof (float)) * 2;
|
||||||
|
|
||||||
|
static void load_program()
|
||||||
|
{
|
||||||
|
program = compile_from_files("shader/pixel_line_art.vert",
|
||||||
|
nullptr,
|
||||||
|
"shader/pixel_line_art.frag");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void load_vertex_attributes()
|
||||||
|
{
|
||||||
|
glGenVertexArrays(1, &vertex_array_object);
|
||||||
|
glBindVertexArray(vertex_array_object);
|
||||||
|
|
||||||
|
glVertexBindingDivisor(0, 0);
|
||||||
|
|
||||||
|
glEnableVertexAttribArray(layout.attribute.position);
|
||||||
|
glVertexAttribFormat(layout.attribute.position, 2, GL_FLOAT, GL_FALSE, 0);
|
||||||
|
glVertexAttribBinding(layout.attribute.position, 0);
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void load_per_vertex_buffer(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
float vertex_data[] = {
|
||||||
|
(float)x1, (float)y1, (float)x2, (float)y2,
|
||||||
|
};
|
||||||
|
int vertex_data_size = (sizeof (vertex_data));
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, per_vertex_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, vertex_data_size, vertex_data, GL_DYNAMIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void load_per_vertex_buffer2(int x1, int y1, int x2, int y2,
|
||||||
|
int x3, int y3, int x4, int y4)
|
||||||
|
{
|
||||||
|
float vertex_data[] = {
|
||||||
|
(float)x1, (float)y1, (float)x2, (float)y2,
|
||||||
|
(float)x3, (float)y3, (float)x4, (float)y4,
|
||||||
|
};
|
||||||
|
int vertex_data_size = (sizeof (vertex_data));
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, per_vertex_buffer);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, vertex_data_size, vertex_data, GL_DYNAMIC_DRAW);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void load()
|
||||||
|
{
|
||||||
|
load_program();
|
||||||
|
load_vertex_attributes();
|
||||||
|
|
||||||
|
glGenBuffers(1, &per_vertex_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_transform(XMMATRIX const & transform)
|
||||||
|
{
|
||||||
|
XMFLOAT4X4 float_transform;
|
||||||
|
XMStoreFloat4x4(&float_transform, transform);
|
||||||
|
glUniformMatrix4fv(layout.uniform.transform, 1, false, (float *)&float_transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_line_quad_start()
|
||||||
|
{
|
||||||
|
glUseProgram(program);
|
||||||
|
|
||||||
|
glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(GL_ALWAYS);
|
||||||
|
|
||||||
|
glBindVertexArray(vertex_array_object);
|
||||||
|
glBindVertexBuffer(0, per_vertex_buffer, 0, per_vertex_size);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_index_buffer);
|
||||||
|
|
||||||
|
XMMATRIX transform
|
||||||
|
= XMMatrixScaling(2.0f / window::width, -2.0f / window::height, 0)
|
||||||
|
* XMMatrixTranslation(-1, 1, 0);
|
||||||
|
set_transform(transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_line(int x1, int y1, int x2, int y2)
|
||||||
|
{
|
||||||
|
load_per_vertex_buffer(x1, y1, x2, y2);
|
||||||
|
glDrawArrays(GL_LINES, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_quad(int x1, int y1, int x2, int y2,
|
||||||
|
int x3, int y3, int x4, int y4)
|
||||||
|
{
|
||||||
|
load_per_vertex_buffer2(x1, y1, x2, y2,
|
||||||
|
x3, y3, x4, y4);
|
||||||
|
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, (void *)0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_set_color(float r, float g, float b)
|
||||||
|
{
|
||||||
|
glUniform3f(layout.uniform.base_color, r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,6 +24,7 @@
|
|||||||
#include "collada/scene.h"
|
#include "collada/scene.h"
|
||||||
#include "collada/types.h"
|
#include "collada/types.h"
|
||||||
#include "collada/instance_types.h"
|
#include "collada/instance_types.h"
|
||||||
|
#include "pixel_line_art.h"
|
||||||
|
|
||||||
#include "world/entry_table.h"
|
#include "world/entry_table.h"
|
||||||
#include "world/world.h"
|
#include "world/world.h"
|
||||||
@ -88,7 +89,6 @@ void load_quad_index_buffer()
|
|||||||
glGenBuffers(1, &quad_index_buffer);
|
glGenBuffers(1, &quad_index_buffer);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_index_buffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_index_buffer);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data_size, data, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data_size, data, GL_STATIC_DRAW);
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +119,12 @@ void load(const char * source_path)
|
|||||||
fprintf(stderr, "getproc %p\n", SDL_GL_GetProcAddress);
|
fprintf(stderr, "getproc %p\n", SDL_GL_GetProcAddress);
|
||||||
gladLoadGL((GLADloadfunc)SDL_GL_GetProcAddress);
|
gladLoadGL((GLADloadfunc)SDL_GL_GetProcAddress);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// minecraft (drawing data)
|
// minecraft (drawing data)
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -140,6 +146,12 @@ void load(const char * source_path)
|
|||||||
terminus_fonts = (font::font *)malloc((sizeof (font::font)) * font::terminus_length);
|
terminus_fonts = (font::font *)malloc((sizeof (font::font)) * font::terminus_length);
|
||||||
font::load_fonts(terminus_fonts, font::terminus, font::terminus_length);
|
font::load_fonts(terminus_fonts, font::terminus, font::terminus_length);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// pixel_line_art
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
pixel_line_art::load();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// quad
|
// quad
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -152,7 +164,7 @@ void load(const char * source_path)
|
|||||||
// lighting
|
// lighting
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
lighting::load_program();
|
lighting::load();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// non_block
|
// non_block
|
||||||
@ -365,12 +377,11 @@ int clamp(int n, int high)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
float mouse_position[3] = {};
|
float mouse_position[4] = {};
|
||||||
float mouse_block[3] = {};
|
float mouse_block[4] = {};
|
||||||
|
|
||||||
void update_mouse(int x, int y)
|
void update_mouse(int x, int y)
|
||||||
{
|
{
|
||||||
printf("update mouse %d %d\n", x, y);
|
|
||||||
x = clamp(x, geometry_buffer_pnc.width);
|
x = clamp(x, geometry_buffer_pnc.width);
|
||||||
y = clamp(y, geometry_buffer_pnc.height);
|
y = clamp(y, geometry_buffer_pnc.height);
|
||||||
|
|
||||||
@ -381,7 +392,7 @@ void update_mouse(int x, int y)
|
|||||||
geometry_buffer_pnc.height - y,
|
geometry_buffer_pnc.height - y,
|
||||||
1, // width
|
1, // width
|
||||||
1, // height
|
1, // height
|
||||||
GL_RGB,
|
GL_RGBA,
|
||||||
GL_FLOAT,
|
GL_FLOAT,
|
||||||
(void*)&mouse_position);
|
(void*)&mouse_position);
|
||||||
|
|
||||||
@ -390,7 +401,7 @@ void update_mouse(int x, int y)
|
|||||||
geometry_buffer_pnc.height - y,
|
geometry_buffer_pnc.height - y,
|
||||||
1, // width
|
1, // width
|
||||||
1, // height
|
1, // height
|
||||||
GL_RGB,
|
GL_RGBA,
|
||||||
GL_FLOAT,
|
GL_FLOAT,
|
||||||
(void*)&mouse_block);
|
(void*)&mouse_block);
|
||||||
}
|
}
|
||||||
@ -413,7 +424,9 @@ void draw()
|
|||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
lighting::draw();
|
|
||||||
|
lighting::draw(minecraft::current_world->light_uniform_buffer,
|
||||||
|
minecraft::current_world->light_count);
|
||||||
//draw_quad();
|
//draw_quad();
|
||||||
hud::draw();
|
hud::draw();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user