Compare commits
No commits in common. "9991b991abca371e2d1efcf9b919322f76541e08" and "8c7e3edf86d4a85ea4683d74e959e838cd4d3d00" have entirely different histories.
9991b991ab
...
8c7e3edf86
1
Makefile
1
Makefile
@ -14,7 +14,6 @@ CFLAGS += -fpic
|
|||||||
CFLAGS += -I./include
|
CFLAGS += -I./include
|
||||||
CFLAGS += -Wall -Werror -Wfatal-errors -Wno-error=unused-variable -Wno-error=unused-but-set-variable
|
CFLAGS += -Wall -Werror -Wfatal-errors -Wno-error=unused-variable -Wno-error=unused-but-set-variable
|
||||||
CFLAGS += -Wno-error=unknown-pragmas -Wno-unknown-pragmas
|
CFLAGS += -Wno-error=unknown-pragmas -Wno-unknown-pragmas
|
||||||
CFLAGS += -Wno-error=unused-function
|
|
||||||
CFLAGS += -fno-strict-aliasing
|
CFLAGS += -fno-strict-aliasing
|
||||||
ifdef READ_PACK_FILE
|
ifdef READ_PACK_FILE
|
||||||
CFLAGS += -DREAD_PACK_FILE
|
CFLAGS += -DREAD_PACK_FILE
|
||||||
|
|||||||
@ -13,8 +13,7 @@ extern "C" {
|
|||||||
EXPORT void DECL update_keyboard(int up, int down, int left, int right,
|
EXPORT void DECL 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,
|
||||||
int i, int k, int j, int l,
|
int i, int k, int j, int l);
|
||||||
int q, int e);
|
|
||||||
EXPORT void DECL update_mouse(int x, int y);
|
EXPORT void DECL update_mouse(int x, int y);
|
||||||
EXPORT void DECL update_joystick(int joystick_index,
|
EXPORT void DECL update_joystick(int joystick_index,
|
||||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||||
|
|||||||
25
main.lua
25
main.lua
@ -1,17 +1,11 @@
|
|||||||
local ffi = require 'ffi'
|
local ffi = require 'ffi'
|
||||||
local joysticks
|
local joysticks
|
||||||
|
|
||||||
function init_joysticks()
|
|
||||||
joysticks = {}
|
|
||||||
for i, joystick in ipairs(love.joystick.getJoysticks()) do
|
|
||||||
if joystick:isGamepad() then
|
|
||||||
table.insert(joysticks, joystick)
|
|
||||||
print(#joysticks, joystick:getName())
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
|
joysticks = love.joystick.getJoysticks()
|
||||||
|
for i, joystick in ipairs(joysticks) do
|
||||||
|
print(i, joystick:getName())
|
||||||
|
end
|
||||||
|
|
||||||
ffi.cdef[[
|
ffi.cdef[[
|
||||||
void load(const char * source_path);
|
void load(const char * source_path);
|
||||||
@ -20,8 +14,7 @@ void draw();
|
|||||||
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,
|
||||||
int i, int k, int j, int l,
|
int i, int k, int j, int l);
|
||||||
int q, int e);
|
|
||||||
void update_mouse(int x, int y);
|
void update_mouse(int x, int y);
|
||||||
void update_joystick(int joystick_index,
|
void update_joystick(int joystick_index,
|
||||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||||
@ -130,13 +123,10 @@ local update = function(time)
|
|||||||
local k = love.keyboard.isDown("k")
|
local k = love.keyboard.isDown("k")
|
||||||
local j = love.keyboard.isDown("j")
|
local j = love.keyboard.isDown("j")
|
||||||
local l = love.keyboard.isDown("l")
|
local l = love.keyboard.isDown("l")
|
||||||
local q = love.keyboard.isDown("q")
|
|
||||||
local e = love.keyboard.isDown("e")
|
|
||||||
test.update_keyboard(up, down, left, right,
|
test.update_keyboard(up, down, left, right,
|
||||||
w, s, a, d,
|
w, s, a, d,
|
||||||
t, g, f, h,
|
t, g, f, h,
|
||||||
i, k, j, l,
|
i, k, j, l);
|
||||||
q, e)
|
|
||||||
|
|
||||||
test.update(time)
|
test.update(time)
|
||||||
end
|
end
|
||||||
@ -239,9 +229,6 @@ function love.run()
|
|||||||
return function()
|
return function()
|
||||||
love.event.pump()
|
love.event.pump()
|
||||||
for name, a,b,c,d,e,f,g,h in love.event.poll() do
|
for name, a,b,c,d,e,f,g,h in love.event.poll() do
|
||||||
if name == "joystickadded" or name == "joystickremoved" then
|
|
||||||
init_joysticks()
|
|
||||||
end
|
|
||||||
if name == "quit" then
|
if name == "quit" then
|
||||||
if c or not love.quit or not love.quit() then
|
if c or not love.quit or not love.quit() then
|
||||||
return a or 0, b
|
return a or 0, b
|
||||||
|
|||||||
41
src/hud.cpp
41
src/hud.cpp
@ -2,15 +2,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "directxmath/directxmath.h"
|
#include "directxmath/directxmath.h"
|
||||||
#include "glad/gl.h"
|
|
||||||
|
|
||||||
#include "font/bitmap.h"
|
#include "font/bitmap.h"
|
||||||
#include "font/outline.h"
|
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
extern font::bitmap::font * terminus_fonts;
|
extern font::bitmap::font * terminus_fonts;
|
||||||
extern font::outline::font * uncial_antiqua_fonts;
|
|
||||||
extern unsigned int empty_vertex_array_object;
|
extern unsigned int empty_vertex_array_object;
|
||||||
extern unsigned int quad_index_buffer;
|
extern unsigned int quad_index_buffer;
|
||||||
|
|
||||||
@ -84,8 +80,6 @@ namespace hud {
|
|||||||
return y + font.desc->glyph_height;
|
return y + font.desc->glyph_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int frame = 0;
|
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
static char buf[512];
|
static char buf[512];
|
||||||
@ -96,41 +90,14 @@ namespace hud {
|
|||||||
font::bitmap::font const& ter_best = terminus_fonts[font_ix];
|
font::bitmap::font const& ter_best = terminus_fonts[font_ix];
|
||||||
font::bitmap::draw_start(ter_best, empty_vertex_array_object, quad_index_buffer);
|
font::bitmap::draw_start(ter_best, empty_vertex_array_object, quad_index_buffer);
|
||||||
|
|
||||||
//y = draw_label<float>(ter_best, buf, 10, y, "fov: ", "%.3f", view::state.fov);
|
y = draw_label<float>(ter_best, buf, 10, y, "fov: ", "%.3f", view::state.fov);
|
||||||
//y = draw_label<int>(ter_best, buf, 10, y, "font_height: ", "%d", ter_best.desc->glyph_height);
|
y = draw_label<int>(ter_best, buf, 10, y, "font_height: ", "%d", ter_best.desc->glyph_height);
|
||||||
|
|
||||||
font::bitmap::draw_string(ter_best, "keyboard:", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, " move: w/a/s/d", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, " look: up/down/left/right", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, " elevate: q/e", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, "gamepad:", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, " move: right stick", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, " look: left stick", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
font::bitmap::draw_string(ter_best, " elevate: trigger left/right", 10, y); y += ter_best.desc->glyph_height;
|
|
||||||
|
|
||||||
if (frame++ > 60 * 10)
|
|
||||||
return;
|
|
||||||
|
|
||||||
font::outline::draw_start(uncial_antiqua_fonts[0], empty_vertex_array_object, quad_index_buffer);
|
|
||||||
char const * title = "Technical demo: Bibliotheca";
|
|
||||||
int const title_length = strlen(title);
|
|
||||||
int title_width = 563;
|
|
||||||
int title_height = 31;
|
|
||||||
int title_x = (window::width - title_width) / 2.0;
|
|
||||||
int title_y = (window::height - title_height) / 2.0;
|
|
||||||
|
|
||||||
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
font::outline::draw_string(uncial_antiqua_fonts[0], title, title_x + 3, title_y + 3);
|
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
font::outline::draw_string(uncial_antiqua_fonts[0], title, title_x + 0, title_y + 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
y = draw_label<float>(ter_best, buf, 10, y, "lighting.quadratic: ", "%.2f", lighting.quadratic);
|
y = draw_label<float>(ter_best, buf, 10, y, "lighting.quadratic: ", "%.2f", lighting.quadratic);
|
||||||
y = draw_label<float>(ter_best, buf, 10, y, "lighting.linear: ", "%.2f", lighting.linear);
|
y = draw_label<float>(ter_best, buf, 10, y, "lighting.linear: ", "%.2f", lighting.linear);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
y = draw_vector(ter_best, buf, y, "eye", XMVectorSetW(view::state.eye, 0));
|
y = draw_vector(ter_best, buf, y, "eye", XMVectorSetW(view::state.eye, 0));
|
||||||
y = draw_vector(ter_best, buf, y, "at", XMVectorSetW(view::state.at, 0));
|
y = draw_vector(ter_best, buf, y, "at", XMVectorSetW(view::state.at, 0));
|
||||||
y = draw_vector(ter_best, buf, y, "forward", XMVectorSetW(view::state.forward, 0));
|
y = draw_vector(ter_best, buf, y, "forward", XMVectorSetW(view::state.forward, 0));
|
||||||
@ -138,10 +105,10 @@ namespace hud {
|
|||||||
y = draw_label<float>(ter_best, buf, 10, y, "pitch: ", "%.4f", view::state.pitch);
|
y = draw_label<float>(ter_best, buf, 10, y, "pitch: ", "%.4f", view::state.pitch);
|
||||||
y = draw_label<float>(ter_best, buf, 10, y, "frame_rate_avg: ", "%.2f", 1.0f / update_average(current_time - last_frame_time));
|
y = draw_label<float>(ter_best, buf, 10, y, "frame_rate_avg: ", "%.2f", 1.0f / update_average(current_time - last_frame_time));
|
||||||
|
|
||||||
font::bitmap::draw_string(ter_best, "mouse:", 10, y); y += ter_best.desc->glyph_height;
|
font::bitmap::draw_string(ter_best, "mouse:", 10, y);
|
||||||
|
y += ter_best.desc->glyph_height;
|
||||||
|
|
||||||
y = draw_vector(ter_best, buf, y, " position", XMLoadFloat4((XMFLOAT4*)mouse_position));
|
y = draw_vector(ter_best, buf, y, " position", XMLoadFloat4((XMFLOAT4*)mouse_position));
|
||||||
y = draw_vector(ter_best, buf, y, " block", XMLoadFloat4((XMFLOAT4*)mouse_block));
|
y = draw_vector(ter_best, buf, y, " block", XMLoadFloat4((XMFLOAT4*)mouse_block));
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
57
src/test.cpp
57
src/test.cpp
@ -215,6 +215,26 @@ void load(const char * source_path)
|
|||||||
flame::load_texture();
|
flame::load_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void update_keyboard(int up, int down, int left, int right,
|
||||||
|
int w, int s, int a, int d,
|
||||||
|
int t, int g, int f, int h,
|
||||||
|
int i, int k, int j, int l)
|
||||||
|
{
|
||||||
|
//float forward = (0.1f * up + -0.1f * down);
|
||||||
|
//float strafe = (-0.1f * left + 0.1f * right);
|
||||||
|
//view::third_person::apply_translation(forward, strafe, 0);
|
||||||
|
/*
|
||||||
|
collision_scene::update(up, down, left, right,
|
||||||
|
w, s, a, d,
|
||||||
|
t, g, f, h,
|
||||||
|
i, k, j, l);
|
||||||
|
*/
|
||||||
|
boids_scene::update(up, down, left, right,
|
||||||
|
w, s, a, d,
|
||||||
|
t, g, f, h,
|
||||||
|
i, k, j, l);
|
||||||
|
}
|
||||||
|
|
||||||
void check_collisions(collision::Sphere const & sphere, XMVECTOR const & direction,
|
void check_collisions(collision::Sphere const & sphere, XMVECTOR const & direction,
|
||||||
collision::state & state)
|
collision::state & state)
|
||||||
{
|
{
|
||||||
@ -292,43 +312,6 @@ void minecraft_view_update(XMVECTOR direction)
|
|||||||
view::state.eye = view::state.at - view::state.direction * view::at_distance;
|
view::state.eye = view::state.at - view::state.direction * view::at_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_keyboard(int up, int down, int left, int right,
|
|
||||||
int w, int s, int a, int d,
|
|
||||||
int t, int g, int f, int h,
|
|
||||||
int i, int k, int j, int l,
|
|
||||||
int q, int e)
|
|
||||||
{
|
|
||||||
//float forward = (0.1f * up + -0.1f * down);
|
|
||||||
//float strafe = (-0.1f * left + 0.1f * right);
|
|
||||||
//view::third_person::apply_translation(forward, strafe, 0);
|
|
||||||
/*
|
|
||||||
collision_scene::update(up, down, left, right,
|
|
||||||
w, s, a, d,
|
|
||||||
t, g, f, h,
|
|
||||||
i, k, j, l);
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
boids_scene::update(up, down, left, right,
|
|
||||||
w, s, a, d,
|
|
||||||
t, g, f, h,
|
|
||||||
i, k, j, l);
|
|
||||||
*/
|
|
||||||
|
|
||||||
float forward = (w - s) * 0.5;
|
|
||||||
float strafe = (d - a) * 0.5;
|
|
||||||
float elevation = (q - e) * 0.5;
|
|
||||||
float delta_yaw = (left - right) * -0.035;
|
|
||||||
float delta_pitch = (down - up) * -0.035;
|
|
||||||
|
|
||||||
XMVECTOR direction = view::third_person::apply_transform(forward, strafe, elevation,
|
|
||||||
delta_yaw, delta_pitch);
|
|
||||||
view::apply_fov(0.01 * up + -0.01 * down);
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
minecraft_view_update(direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_joystick(int joystick_index,
|
void update_joystick(int joystick_index,
|
||||||
float lx, float ly, float rx, float ry, float tl, float tr,
|
float lx, float ly, float rx, float ry, float tl, float tr,
|
||||||
int up, int down, int left, int right,
|
int up, int down, int left, int right,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user