sync to keep working
This commit is contained in:
parent
236cdd5ef7
commit
e267a0d2ed
12 changed files with 154 additions and 89 deletions
|
@ -5,9 +5,26 @@ cmake_minimum_required(VERSION 3.8)
|
|||
|
||||
project(pixwerx)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/etc/cmake")
|
||||
|
||||
#
|
||||
# pixwerx ist C++17
|
||||
#
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# internal cmake modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake ${CMAKE_MODULE_PATH})
|
||||
|
||||
# boilerplate locations for build
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Executables go here")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Libraries go here")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Standalone DLLs go here")
|
||||
|
||||
# boilerplate settings for shared libs
|
||||
set(CMAKE_SKIP_BUILD_RPATH OFF)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
|
||||
#
|
||||
# now the actual code
|
||||
#
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(share)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#ifndef PW_CORE_TIMER_HPP_
|
||||
#define PW_CORE_TIMER_HPP_
|
||||
|
||||
|
||||
#include <pw/core/globals.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
@ -36,10 +35,6 @@ namespace pw {
|
|||
class timer {
|
||||
public:
|
||||
|
||||
const static unsigned int UnitMicroSeconds = 1000000;
|
||||
const static unsigned int UnitMilliSeconds = 1000;
|
||||
const static unsigned int UnitSeconds = 1;
|
||||
|
||||
typedef std::chrono::time_point<std::chrono::high_resolution_clock> tick_t;
|
||||
|
||||
timer(); /// c'tor
|
||||
|
@ -49,17 +44,15 @@ public:
|
|||
|
||||
/**
|
||||
* @brief elapsed time based on the scale
|
||||
* @param scale units the time will be reported
|
||||
* @return value of the time since last @see reset
|
||||
*/
|
||||
double elapsed(unsigned int scale = UnitMilliSeconds) const;
|
||||
double elapsed() const;
|
||||
|
||||
/**
|
||||
* @brief Now
|
||||
* @param scale
|
||||
* @return
|
||||
* @brief time from start of core in seconds
|
||||
* @return time in seconds
|
||||
*/
|
||||
static double now(unsigned int scale = UnitMicroSeconds);
|
||||
static double now();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -1,13 +1,27 @@
|
|||
/* vim: set tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab */
|
||||
/*
|
||||
* SSTT - Simplified Spatial Target Tracker
|
||||
* Copyright (c) 1999-2019 Hartmut Seichter
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
* (c) Copyrights 2007-2018 Hartmut Seichter
|
||||
*/
|
||||
|
||||
#include "pw/core/timer.hpp"
|
||||
|
||||
|
||||
namespace pw {
|
||||
|
||||
static timer global_timer;
|
||||
|
@ -26,15 +40,15 @@ void timer::reset()
|
|||
_start = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
double timer::elapsed( unsigned int scale ) const
|
||||
double timer::elapsed() const
|
||||
{
|
||||
std::chrono::duration<double> elapsed_seconds = std::chrono::high_resolution_clock::now() - _start;
|
||||
return elapsed_seconds.count() * scale;
|
||||
return elapsed_seconds.count();
|
||||
}
|
||||
|
||||
double timer::now( unsigned int scale )
|
||||
double timer::now()
|
||||
{
|
||||
return global_timer.elapsed(scale);
|
||||
return global_timer.elapsed();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "pw/core/debug.hpp"
|
||||
#include "pw/core/size.hpp"
|
||||
#include "pw/core/point.hpp"
|
||||
#include "pw/core/timer.hpp"
|
||||
|
||||
|
||||
namespace pw {
|
||||
|
@ -77,6 +78,13 @@ void script_core::load(sol::table &ns)
|
|||
// "none",sol::debug::level::none
|
||||
);
|
||||
|
||||
|
||||
ns.new_usertype<timer>("timer",
|
||||
"now",sol::readonly_property(&timer::now),
|
||||
"elapsed",sol::readonly_property(&timer::elapsed),
|
||||
"reset",&timer::reset
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "pw/system/display.hpp"
|
||||
|
||||
// hijacking
|
||||
#include "pw/visual/pipeline.hpp"
|
||||
//#include "pw/visual/pipeline.hpp"
|
||||
|
||||
namespace pw {
|
||||
|
||||
|
@ -13,6 +13,7 @@ void script_system::load(sol::table &ns)
|
|||
{
|
||||
ns.new_usertype<window>("window",
|
||||
"update",&window::update,
|
||||
"set_on_update",&window::set_on_update,
|
||||
"title",sol::writeonly_property(&window::set_title),
|
||||
"size",sol::property(&window::size,&window::set_size),
|
||||
"position",sol::property(&window::position,&window::set_position),
|
||||
|
@ -33,9 +34,16 @@ void script_system::load(sol::table &ns)
|
|||
"name",sol::readonly_property(&display::name)
|
||||
);
|
||||
|
||||
ns.new_usertype<pipeline>("pipeline",
|
||||
"create",&pipeline::create
|
||||
);
|
||||
|
||||
// ns.set_function("my_class_func_2", &my_class::func);
|
||||
|
||||
|
||||
//
|
||||
// // hijack part
|
||||
// //
|
||||
// ns.new_usertype<pipeline>("pipeline",
|
||||
// "create",&pipeline::create
|
||||
// );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,13 +71,17 @@ local w = pw.window.new()
|
|||
w.title = "pixwerx 0.1"
|
||||
|
||||
-- set size
|
||||
w.size = pw.size.new(1200,800)
|
||||
w.size = pw.size.new(800,600)
|
||||
-- move window
|
||||
w.position = pw.point.new(100,100)
|
||||
|
||||
local ds = pw.display:all()
|
||||
for i = 1,#ds do
|
||||
print("display ",i,ds[i].name)
|
||||
end
|
||||
|
||||
local t = pw.timer.new()
|
||||
|
||||
while w:update()
|
||||
do
|
||||
-- somehow works
|
||||
|
@ -87,6 +91,8 @@ do
|
|||
|
||||
-- just to check
|
||||
if (pw.input:get().mouse_button == 1) then
|
||||
print("elapsed",t.elapsed)
|
||||
t:reset()
|
||||
print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
#include <pw/core/size.hpp>
|
||||
#include <pw/core/point.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace pw {
|
||||
|
||||
class window {
|
||||
public:
|
||||
|
||||
typedef std::function<void(window&)> on_update_t;
|
||||
|
||||
window();
|
||||
~window();
|
||||
|
||||
|
@ -28,9 +32,12 @@ public:
|
|||
bool fullscreen() const;
|
||||
void set_fullscreen(bool use_fullscreen);
|
||||
|
||||
void set_on_update(on_update_t f) { _on_update = f; }
|
||||
|
||||
protected:
|
||||
|
||||
on_update_t _on_update;
|
||||
|
||||
struct impl;
|
||||
std::unique_ptr<impl> _impl;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace pw {
|
|||
|
||||
struct window::impl {
|
||||
|
||||
window& _parent;
|
||||
|
||||
GLFWwindow *_window = nullptr;
|
||||
|
||||
sizei _old_size;
|
||||
|
@ -125,7 +127,8 @@ struct window::impl {
|
|||
|
||||
}
|
||||
|
||||
impl()
|
||||
impl(window& w)
|
||||
: _parent(w)
|
||||
{
|
||||
// initialize
|
||||
glfwInit();
|
||||
|
@ -190,6 +193,9 @@ struct window::impl {
|
|||
// get new events
|
||||
glfwPollEvents();
|
||||
|
||||
_parent._on_update(_parent);
|
||||
|
||||
|
||||
// do other stuff
|
||||
#if 0
|
||||
glClearColor(1,0,0,1);
|
||||
|
@ -270,7 +276,8 @@ struct window::impl {
|
|||
|
||||
|
||||
window::window()
|
||||
: _impl(std::make_unique<window::impl>())
|
||||
: _impl(std::make_unique<window::impl>(*this))
|
||||
, _on_update([](window&){})
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
virtual bool make_current() = 0;
|
||||
virtual void resize() = 0;
|
||||
virtual size size() = 0;
|
||||
virtual ::pw::size size() = 0;
|
||||
virtual void flush() = 0;
|
||||
|
||||
virtual ~context() = default;
|
||||
|
|
|
@ -13,7 +13,7 @@ class pipeline {
|
|||
|
||||
public:
|
||||
pipeline();
|
||||
~pipeline() = default;
|
||||
~pipeline();
|
||||
|
||||
void draw();
|
||||
|
||||
|
|
|
@ -99,6 +99,11 @@ pipeline::pipeline()
|
|||
{
|
||||
}
|
||||
|
||||
pipeline::~pipeline()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
bool pipeline::create(size s)
|
||||
{
|
||||
return _impl->create(sizei(s.width,s.height));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue