fixes from the slop

This commit is contained in:
mrq 2025-08-23 11:36:36 -05:00
parent c5f0ec69b2
commit 8ccf468c2a
10 changed files with 140 additions and 113 deletions

View File

@ -118,7 +118,11 @@ ifneq (,$(findstring opengl,$(REQ_DEPS)))
# OpenGL through GLEW
else
FLAGS += -DUF_USE_GLEW
DEPS += -lglew32 -lopengl32 -lglu32
ifneq (,$(findstring linux,$(ARCH)))
DEPS += -lGLU -lglut -lGLEW
else
DEPS += -lglew32 -lopengl32 -lglu32
endif
endif
endif

View File

@ -4,13 +4,6 @@
#include <vulkan/vulkan.h>
#include <vk_mem_alloc.h>
#if UF_ENV_LINUX
#ifdef Success
#undef Success
#undef None
#endif
#endif
#include <typeinfo>
#include <iostream>
#include <cassert>

View File

@ -8,6 +8,9 @@ namespace spec {
typedef spec::unknown::Context Context;
}
#else
#include <GL/glx.h>
namespace spec {
namespace x11 {
class UF_API_VAR Context : public spec::uni::Context {

View File

@ -11,9 +11,17 @@
#if UF_USE_VULKAN
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_xlib.h>
// #include <vulkan/vulkan_xlib.h>
#elif UF_USE_OPENGL
#include <GL/glx.h>
// #include <GL/glx.h>
#endif
// these macros interfere with other things
#ifdef Success
#undef Success
#endif
#ifdef None
#undef None
#endif
namespace spec {
@ -47,6 +55,7 @@ namespace spec {
void UF_API_CALL create(const vector_t& size, const title_t& title = L"Window");
void UF_API_CALL terminate();
Display* UF_API_CALL getDisplay() const;
handle_t UF_API_CALL getHandle() const;
vector_t UF_API_CALL getPosition() const;
vector_t UF_API_CALL getSize() const;
@ -91,4 +100,5 @@ namespace spec {
namespace uf {
using Window = spec::x11::Window;
}
#endif

View File

@ -1,99 +0,0 @@
#include <uf/ext/lua/lua.h>
#if UF_USE_LUA
#include <uf/utils/math/quaternion.h>
namespace {
typedef pod::Quaternion<> Quaternion;
}
namespace binds {
float index( const ::Quaternion& self, size_t index ) {
return self[index];
}
::Quaternion lookAt( const pod::Vector3f& at, const pod::Vector3f& up ) {
return uf::quaternion::lookAt( at, up );
}
::Quaternion normalize( const ::Quaternion& self ) {
return uf::quaternion::normalize( self );
}
::Quaternion multiply( const ::Quaternion& left, const ::Quaternion& right ) {
return uf::quaternion::multiply( left, right );
}
::Quaternion axisAngle( sol::object arg, float angle ){
if ( arg.is<pod::Vector3f>() ) {
return uf::quaternion::axisAngle( arg.as<pod::Vector3f>(), angle );
} else if ( arg.is<sol::table>() ) {
sol::table table = arg.as<sol::table>();
return uf::quaternion::axisAngle( pod::Vector3f{ table[0], table[1], table[2] }, angle );
}
return ::Quaternion{};
}
pod::Vector3f rotate( const ::Quaternion& left, const pod::Vector3f& right ) {
return uf::quaternion::rotate( left, right );
}
::Quaternion eulerAngles( const ::Quaternion& quaternion ) {
return uf::quaternion::eulerAngles( quaternion );
}
::Quaternion conjugate( const ::Quaternion& quaternion ) {
return uf::quaternion::conjugate( quaternion );
}
::Quaternion inverse( const ::Quaternion& quaternion ) {
return uf::quaternion::inverse( quaternion );
}
float pitch( const ::Quaternion& quaternion ) {
return uf::quaternion::pitch( quaternion );
}
float yaw( const ::Quaternion& quaternion ) {
return uf::quaternion::yaw( quaternion );
}
float roll( const ::Quaternion& quaternion ) {
return uf::quaternion::roll( quaternion );
}
::Quaternion slerp( const ::Quaternion& left, const ::Quaternion& right, float a ) {
return uf::quaternion::slerp( left, right, a );
}
pod::Matrix4f matrix( const ::Quaternion& q ) {
return uf::quaternion::matrix( q );
}
uf::stl::string __tostring( const ::Quaternion& self ) {
return uf::string::toString( self );
}
}
#include <uf/ext/lua/component.h>
UF_LUA_REGISTER_USERTYPE_AND_COMPONENT(::Quaternion,
sol::call_constructor, sol::initializers(
[]( ::Quaternion& self ) {
return self = {0,0,0,1};
},
[]( ::Quaternion& self, const ::Quaternion& copy ) {
return self = copy;
},
[]( ::Quaternion& self, float x, float y, float z, float w ) {
return self = uf::vector::create(x, y, z, w);
}
),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::x),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::y),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::z),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::w),
UF_LUA_REGISTER_USERTYPE_DEFINE( v, UF_LUA_C_FUN(::binds::index) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( lookAt, UF_LUA_C_FUN(::binds::lookAt) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( normalize, UF_LUA_C_FUN(::binds::normalize) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( multiply, UF_LUA_C_FUN(::binds::multiply) ),
sol::meta_function::multiplication, UF_LUA_C_FUN(::binds::multiply),
UF_LUA_REGISTER_USERTYPE_DEFINE(axisAngle, UF_LUA_C_FUN(::binds::axisAngle) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( rotate, UF_LUA_C_FUN( ::binds::rotate ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( eulerAngles, UF_LUA_C_FUN( ::binds::eulerAngles ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( conjugate, UF_LUA_C_FUN( ::binds::conjugate ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( inverse, UF_LUA_C_FUN( ::binds::inverse ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( pitch, UF_LUA_C_FUN( ::binds::pitch ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( yaw, UF_LUA_C_FUN( ::binds::yaw ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( roll, UF_LUA_C_FUN( ::binds::roll ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( slerp, UF_LUA_C_FUN( ::binds::slerp ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( matrix, UF_LUA_C_FUN( ::binds::matrix ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( __tostring, UF_LUA_C_FUN( ::binds::__tostring ) )
)
#endif

View File

@ -1,6 +1,12 @@
#include <uf/ext/lua/lua.h>
#if UF_USE_LUA
#include <uf/utils/math/vector.h>
#include <uf/utils/math/quaternion.h>
namespace {
// I don't remember specifically why beyond having the name drop the <> despite it getting culled anyways in last_ns or whatever
typedef pod::Quaternion<> Quaternion;
}
namespace binds {
namespace v3f {
@ -165,4 +171,94 @@ UF_LUA_REGISTER_USERTYPE_AND_COMPONENT(pod::Vector4f,
UF_LUA_REGISTER_USERTYPE_DEFINE( dot, UF_LUA_C_FUN(::binds::v4f::dot) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( __tostring, UF_LUA_C_FUN(::binds::v4f::toString) )
)
// need to handle quaternions here because it may get initialized after the above on systems where static initialization order is undefined (Linux)
namespace binds {
float index( const ::Quaternion& self, size_t index ) {
return self[index];
}
::Quaternion lookAt( const pod::Vector3f& at, const pod::Vector3f& up ) {
return uf::quaternion::lookAt( at, up );
}
::Quaternion normalize( const ::Quaternion& self ) {
return uf::quaternion::normalize( self );
}
::Quaternion multiply( const ::Quaternion& left, const ::Quaternion& right ) {
return uf::quaternion::multiply( left, right );
}
::Quaternion axisAngle( sol::object arg, float angle ){
if ( arg.is<pod::Vector3f>() ) {
return uf::quaternion::axisAngle( arg.as<pod::Vector3f>(), angle );
} else if ( arg.is<sol::table>() ) {
sol::table table = arg.as<sol::table>();
return uf::quaternion::axisAngle( pod::Vector3f{ table[0], table[1], table[2] }, angle );
}
return ::Quaternion{};
}
pod::Vector3f rotate( const ::Quaternion& left, const pod::Vector3f& right ) {
return uf::quaternion::rotate( left, right );
}
::Quaternion eulerAngles( const ::Quaternion& quaternion ) {
return uf::quaternion::eulerAngles( quaternion );
}
::Quaternion conjugate( const ::Quaternion& quaternion ) {
return uf::quaternion::conjugate( quaternion );
}
::Quaternion inverse( const ::Quaternion& quaternion ) {
return uf::quaternion::inverse( quaternion );
}
float pitch( const ::Quaternion& quaternion ) {
return uf::quaternion::pitch( quaternion );
}
float yaw( const ::Quaternion& quaternion ) {
return uf::quaternion::yaw( quaternion );
}
float roll( const ::Quaternion& quaternion ) {
return uf::quaternion::roll( quaternion );
}
::Quaternion slerp( const ::Quaternion& left, const ::Quaternion& right, float a ) {
return uf::quaternion::slerp( left, right, a );
}
pod::Matrix4f matrix( const ::Quaternion& q ) {
return uf::quaternion::matrix( q );
}
uf::stl::string __tostring( const ::Quaternion& self ) {
return uf::string::toString( self );
}
}
UF_LUA_REGISTER_USERTYPE_AND_COMPONENT(::Quaternion,
sol::call_constructor, sol::initializers(
[]( ::Quaternion& self ) {
return self = {0,0,0,1};
},
[]( ::Quaternion& self, const ::Quaternion& copy ) {
return self = copy;
},
[]( ::Quaternion& self, float x, float y, float z, float w ) {
return self = uf::vector::create(x, y, z, w);
}
),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::x),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::y),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::z),
UF_LUA_REGISTER_USERTYPE_MEMBER(::Quaternion::w),
UF_LUA_REGISTER_USERTYPE_DEFINE( v, UF_LUA_C_FUN(::binds::index) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( lookAt, UF_LUA_C_FUN(::binds::lookAt) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( normalize, UF_LUA_C_FUN(::binds::normalize) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( multiply, UF_LUA_C_FUN(::binds::multiply) ),
sol::meta_function::multiplication, UF_LUA_C_FUN(::binds::multiply),
UF_LUA_REGISTER_USERTYPE_DEFINE( axisAngle, UF_LUA_C_FUN(::binds::axisAngle) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( rotate, UF_LUA_C_FUN( ::binds::rotate ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( eulerAngles, UF_LUA_C_FUN( ::binds::eulerAngles ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( conjugate, UF_LUA_C_FUN( ::binds::conjugate ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( inverse, UF_LUA_C_FUN( ::binds::inverse ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( pitch, UF_LUA_C_FUN( ::binds::pitch ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( yaw, UF_LUA_C_FUN( ::binds::yaw ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( roll, UF_LUA_C_FUN( ::binds::roll ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( slerp, UF_LUA_C_FUN( ::binds::slerp ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( matrix, UF_LUA_C_FUN( ::binds::matrix ) ),
UF_LUA_REGISTER_USERTYPE_DEFINE( __tostring, UF_LUA_C_FUN( ::binds::__tostring ) )
)
#endif

View File

@ -209,6 +209,8 @@ void ext::al::close( uf::audio::Metadata& metadata ) {
}
void ext::al::listener( const pod::Transform<>& transform ) {
if ( uf::audio::muted ) return;
float o[6] = { transform.forward.x, transform.forward.y, transform.forward.z, transform.up.x, transform.up.y, transform.up.z };
AL_CHECK_RESULT(alListener3f( AL_POSITION, transform.position.x, transform.position.y, transform.position.z ));
AL_CHECK_RESULT(alListener3f( AL_VELOCITY, 0, 0, 0 ));

View File

@ -77,7 +77,7 @@ GLhandle(VkColorSpaceKHR) ext::opengl::settings::formats::colorSpace;
ext::opengl::enums::Format::type_t ext::opengl::settings::formats::color = ext::opengl::enums::Format::R8G8B8A8_UNORM;
ext::opengl::enums::Format::type_t ext::opengl::settings::formats::depth = ext::opengl::enums::Format::D32_SFLOAT;
ext::opengl::Device* ext::opengl::device = NULL;
ext::opengl::Device ext::opengl::device;
std::mutex ext::opengl::mutex;
std::mutex ext::opengl::immediateModeMutex;
@ -505,8 +505,6 @@ void ext::opengl::destroy() {
// swapchain.destroy();
device.destroy();
ext::opengl::mutex.unlock();
delete device;
}
void ext::opengl::synchronize( uint8_t flag ) {
if ( flag & 0b01 ) {

View File

@ -8,6 +8,9 @@
#include <GL/glx.h>
#include <GL/glxext.h>
#define None 0L
#define Success 0
spec::x11::Context::Context( uni::Context* shared, const Context::Settings& settings ) :
uni::Context(NULL, true, settings),
m_display(nullptr),
@ -26,7 +29,8 @@ spec::x11::Context::Context( uni::Context* shared, const Context::Settings& sett
XSetWindowAttributes swa;
swa.event_mask = StructureNotifyMask;
m_window = XCreateSimpleWindow(m_display, RootWindow(m_display, scr), 0, 0, 1, 1, 0, 0, 0);
XMapWindow(m_display, m_window);
//XMapWindow(m_display, m_window);
this->create(shared);
}

View File

@ -14,6 +14,13 @@
#define UF_HOOK_USE_USERDATA 1
#define UF_HOOK_USE_JSON 0
#if UF_USE_VULKAN
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_xlib.h>
#elif UF_USE_OPENGL
#include <GL/glx.h>
#endif
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrandr.h>
@ -23,6 +30,9 @@
#include <cstring>
#include <iostream>
#define None 0L
#define Success 0
namespace {
Display *globalDisplay = nullptr;
int windowCount = 0;
@ -239,6 +249,9 @@ void spec::x11::Window::terminate() {
#endif
}
Display* spec::x11::Window::getDisplay() const {
return m_display;
}
spec::x11::Window::handle_t spec::x11::Window::getHandle() const {
return m_handle;
}
@ -1053,6 +1066,9 @@ void spec::x11::Window::processEvents() {
pod::payloads::windowMouseMoved move{
{{"window:Mouse.Moved", "client"}, {getSize()}},
{current, current - last, 0}};
if ( current == last ) break;
this->pushEvent(move.type, move);
last = current;