final commit for today - still searching to get the mouse_button
This commit is contained in:
parent
f840d51f4f
commit
fdf7714d11
6 changed files with 55 additions and 16 deletions
|
@ -3,7 +3,7 @@ set(scripts
|
||||||
${CMAKE_SOURCE_DIR}/src/scripts/demos/simple_000.lua
|
${CMAKE_SOURCE_DIR}/src/scripts/demos/simple_000.lua
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(pixwerx
|
add_executable(pixwerx WIN32 MACOSX_BUNDLE
|
||||||
pixwerx.cpp
|
pixwerx.cpp
|
||||||
${scripts}
|
${scripts}
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "pw/system/window.hpp"
|
#include "pw/system/window.hpp"
|
||||||
#include "pw/system/input.hpp"
|
#include "pw/system/input.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace pw {
|
namespace pw {
|
||||||
|
|
||||||
void script_system::load(sol::table &ns)
|
void script_system::load(sol::table &ns)
|
||||||
|
@ -11,14 +10,16 @@ void script_system::load(sol::table &ns)
|
||||||
ns.new_usertype<window>("window",
|
ns.new_usertype<window>("window",
|
||||||
"update",&window::update,
|
"update",&window::update,
|
||||||
"title",sol::writeonly_property(&window::set_title),
|
"title",sol::writeonly_property(&window::set_title),
|
||||||
"size",sol::property(&window::size,&window::set_size)
|
"size",sol::property(&window::size,&window::set_size),
|
||||||
|
"position",sol::property(&window::position,&window::set_position)
|
||||||
);
|
);
|
||||||
|
|
||||||
ns.new_usertype<input>("input",
|
ns.new_usertype<input>("input",
|
||||||
"new", sol::no_constructor,
|
"new", sol::no_constructor,
|
||||||
"get",&input::get
|
"get",&input::get,
|
||||||
|
"mouse_position",sol::readonly_property(&input::mouse_position),
|
||||||
|
"mouse_button",sol::readonly_property(&input::mouse_button)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ local q2 = pw.quaternion.new(0,0,0,1)
|
||||||
qm = pw.quaternion.lerp(q,qi,0.5)
|
qm = pw.quaternion.lerp(q,qi,0.5)
|
||||||
print("q.m",qm.x,qm.y,qm.z,qm.w)
|
print("q.m",qm.x,qm.y,qm.z,qm.w)
|
||||||
|
|
||||||
|
|
||||||
-- axis angle test
|
-- axis angle test
|
||||||
local aa = pw.axisangle.new(v1,0.707)
|
local aa = pw.axisangle.new(v1,0.707)
|
||||||
|
|
||||||
|
@ -56,6 +55,7 @@ n_1:add_child(pw.node.create()).name = "five"
|
||||||
|
|
||||||
print("node 1 - child count ",n_1.child_count)
|
print("node 1 - child count ",n_1.child_count)
|
||||||
|
|
||||||
|
-- stuff
|
||||||
for i = 1,n_1.child_count do
|
for i = 1,n_1.child_count do
|
||||||
print(i,n_1.children[i],n_1.children[i].name)
|
print(i,n_1.children[i],n_1.children[i].name)
|
||||||
end
|
end
|
||||||
|
@ -73,9 +73,15 @@ w.title = "pixwerx 0.1"
|
||||||
-- set size
|
-- set size
|
||||||
w.size = pw.size.new(1200,800)
|
w.size = pw.size.new(1200,800)
|
||||||
|
|
||||||
|
|
||||||
while w:update()
|
while w:update()
|
||||||
do
|
do
|
||||||
|
|
||||||
|
if (pw.input:get().mouse_button > 0) then
|
||||||
|
print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- print("update")
|
-- print("update")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ public:
|
||||||
static input& get();
|
static input& get();
|
||||||
|
|
||||||
point mouse_position() const { return _mouse_position; }
|
point mouse_position() const { return _mouse_position; }
|
||||||
|
int mouse_button() const { return _mouse_button; }
|
||||||
|
|
||||||
~input() = default;
|
~input() = default;
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
point _mouse_position;
|
point _mouse_position;
|
||||||
|
int _mouse_button;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <pw/core/globals.hpp>
|
#include <pw/core/globals.hpp>
|
||||||
#include <pw/core/size.hpp>
|
#include <pw/core/size.hpp>
|
||||||
|
#include <pw/core/point.hpp>
|
||||||
|
|
||||||
namespace pw {
|
namespace pw {
|
||||||
|
|
||||||
|
@ -19,6 +20,9 @@ public:
|
||||||
void set_size(const size& s);
|
void set_size(const size& s);
|
||||||
size size() const;
|
size size() const;
|
||||||
|
|
||||||
|
void set_position(const point& p);
|
||||||
|
point position() const;
|
||||||
|
|
||||||
typedef void drop_callback;
|
typedef void drop_callback;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -6,11 +6,14 @@
|
||||||
#include "pw/visual/context.hpp"
|
#include "pw/visual/context.hpp"
|
||||||
#include "pw/system/input.hpp"
|
#include "pw/system/input.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace pw {
|
namespace pw {
|
||||||
|
|
||||||
struct window_context : context {
|
struct window_context : context
|
||||||
|
{
|
||||||
virtual bool make_current() override;
|
virtual bool make_current() override;
|
||||||
virtual void resize() override;
|
virtual void resize() override;
|
||||||
// virtual context::size size() override;
|
// virtual context::size size() override;
|
||||||
|
@ -36,8 +39,10 @@ struct window::impl {
|
||||||
// window_context _context;
|
// window_context _context;
|
||||||
|
|
||||||
static void drop_callback(GLFWwindow* window, int count, const char** paths)
|
static void drop_callback(GLFWwindow* window, int count, const char** paths)
|
||||||
{
|
{
|
||||||
std::cout << __FUNCTION__ << std::endl;
|
// std::cout << __FUNCTION__ << std::endl;
|
||||||
|
// for (int i = 0; i < count; i++)
|
||||||
|
// std::cout << "\t" << paths[i] << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
static void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
|
||||||
|
@ -47,7 +52,9 @@ struct window::impl {
|
||||||
|
|
||||||
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
|
||||||
{
|
{
|
||||||
std::cout << __FUNCTION__ << std::endl;
|
input::get()._mouse_button = button;
|
||||||
|
|
||||||
|
std::cout << __FUNCTION__ << " " << button << " " << action << " " << mods << std::endl;
|
||||||
// input::get()._mouse_position
|
// input::get()._mouse_position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,15 +154,24 @@ struct window::impl {
|
||||||
glfwSetWindowSize(_window,w,h);
|
glfwSetWindowSize(_window,w,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
::pw::size size() const {
|
::pw::size size() const
|
||||||
|
{
|
||||||
int w,h;
|
int w,h;
|
||||||
glfwGetWindowSize(_window,&w,&h);
|
glfwGetWindowSize(_window,&w,&h);
|
||||||
|
|
||||||
return ::pw::size(w,h);
|
return ::pw::size(w,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::pw::point position() const
|
||||||
|
{
|
||||||
|
int x,y;
|
||||||
|
glfwGetWindowPos(_window,&x,&y);
|
||||||
|
return ::pw::point(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_position(int x,int y)
|
||||||
|
{
|
||||||
|
glfwSetWindowPos(_window,x,y);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,12 +196,22 @@ void window::set_title(const std::string& title)
|
||||||
|
|
||||||
void window::set_size(const ::pw::size& s)
|
void window::set_size(const ::pw::size& s)
|
||||||
{
|
{
|
||||||
_impl->set_size(s.width,s.height);
|
_impl->set_size(static_cast<int>(std::round(s.width)),static_cast<int>(std::round(s.height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
size window::size() const
|
size window::size() const
|
||||||
{
|
{
|
||||||
return _impl->size();
|
return _impl->size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void window::set_position(const point &p)
|
||||||
|
{
|
||||||
|
_impl->set_position(p.x,p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
point window::position() const
|
||||||
|
{
|
||||||
|
return _impl->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue