properly color a gui element under opengl, some cleanup for dead code that's not needed

This commit is contained in:
ecker 2025-08-09 13:35:04 -05:00
parent 2186e41641
commit 0b40786798
13 changed files with 51 additions and 292 deletions

View File

@ -1,8 +1,8 @@
{
// "import": "./rp_downtown_v2.json"
// "import": "./ss2_medsci1.json"
"import": "./ss2_medsci1.json"
// "import": "./sh2_mcdonalds.json"
"import": "./animal_crossing.json"
// "import": "./animal_crossing.json"
// "import": "./mds_mcdonalds.json"
// "import": "./gm_construct.json"
}

View File

@ -6,5 +6,7 @@ namespace pod {
struct UF_API Uniform {
pod::Matrix4f modelView = uf::matrix::identity();
pod::Matrix4f projection = uf::matrix::identity();
pod::Vector4f color = pod::Vector4f{1.0f, 1.0f, 1.0f, 1.0f};
};
}

View File

@ -2,13 +2,13 @@
namespace uf {
class UF_API SoundEmitter {
class UF_API AudioEmitter {
public:
typedef uf::stl::vector<uf::Audio> container_t;
protected:
uf::SoundEmitter::container_t m_container;
uf::AudioEmitter::container_t m_container;
public:
~SoundEmitter();
~AudioEmitter();
bool has( const uf::stl::string& ) const;
@ -26,13 +26,13 @@ namespace uf {
void update();
void cleanup( bool = false );
};
class UF_API MappedSoundEmitter {
class UF_API MappedAudioEmitter {
public:
typedef uf::stl::unordered_map<uf::stl::string, uf::Audio> container_t;
protected:
uf::MappedSoundEmitter::container_t m_container;
uf::MappedAudioEmitter::container_t m_container;
public:
~MappedSoundEmitter();
~MappedAudioEmitter();
bool has( const uf::stl::string& ) const;
@ -49,4 +49,7 @@ namespace uf {
void update();
void cleanup( bool = false );
};
using SoundEmitter = AudioEmitter; // alias
using MappedSoundEmitter = MappedAudioEmitter; // alias
}

View File

@ -441,16 +441,11 @@ void ext::opengl::CommandBuffer::drawIndexed( const ext::opengl::CommandBuffer::
GL_ERROR_CHECK(glBindTexture(drawInfo.textures.primary.viewType, drawInfo.textures.primary.image));
GL_ERROR_CHECK(glTexCoordPointer(2, uvType, drawInfo.attributes.uv.stride, uvPtr));
#if UF_ENV_DREAMCAST
if ( drawInfo.attributes.color.pointer || drawInfo.color.enabled ) {
GL_ERROR_CHECK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE));
} else {
GL_ERROR_CHECK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
}
#else
// modern drivers for fixed function OpenGL does not implement GL_MODULATE properly for vertex colored + texture sampling
GL_ERROR_CHECK(glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE));
#endif
if ( drawInfo.textures.secondary.image && drawInfo.attributes.st.pointer ) {
GL_ERROR_CHECK(glClientActiveTexture(GL_TEXTURE1));

View File

@ -361,7 +361,7 @@ void ext::opengl::Graphic::record( CommandBuffer& commandBuffer, const GraphicDe
auto uniformBuffer = (*uniformBufferIt).buffer;
auto uniformBufferSize = (*uniformBufferIt).range;
pod::Camera::Viewports* viewports = (pod::Camera::Viewports*) device->getBuffer( uniformBuffer );
pod::Uniform* viewports2 = (pod::Uniform*) device->getBuffer( uniformBuffer );
pod::Uniform* uniforms = (pod::Uniform*) device->getBuffer( uniformBuffer );
CommandBuffer::InfoDraw drawCommandInfoBase = {};
drawCommandInfoBase.type = ext::opengl::enums::Command::DRAW;
@ -372,16 +372,21 @@ void ext::opengl::Graphic::record( CommandBuffer& commandBuffer, const GraphicDe
if ( attribute.descriptor.name == "position" ) drawCommandInfoBase.attributes.position = attribute;
else if ( attribute.descriptor.name == "uv" ) drawCommandInfoBase.attributes.uv = attribute;
else if ( attribute.descriptor.name == "st" ) drawCommandInfoBase.attributes.st = attribute;
// else if ( attribute.descriptor.name == "normal" ) drawCommandInfoBase.attributes.normal = attribute;
// else if ( attribute.descriptor.name == "color" ) drawCommandInfoBase.attributes.color = attribute;
else if ( attribute.descriptor.name == "normal" ) drawCommandInfoBase.attributes.normal = attribute;
else if ( attribute.descriptor.name == "color" ) drawCommandInfoBase.attributes.color = attribute;
}
if ( uniformBufferSize == sizeof(pod::Camera::Viewports) ) {
drawCommandInfoBase.matrices.view = &viewports->matrices[0].view;
drawCommandInfoBase.matrices.projection = &viewports->matrices[0].projection;
} else if ( uniformBufferSize == sizeof(pod::Uniform) ) {
drawCommandInfoBase.matrices.model = &viewports2->modelView;
drawCommandInfoBase.matrices.projection = &viewports2->projection;
drawCommandInfoBase.matrices.model = &uniforms->modelView;
drawCommandInfoBase.matrices.projection = &uniforms->projection;
drawCommandInfoBase.color.value = uniforms->color;
drawCommandInfoBase.color.enabled = drawCommandInfoBase.color.value != pod::Vector4f{1.0f, 1.0f, 1.0f, 1.0f};
UF_MSG_DEBUG("{}: {}", uf::vector::toString(drawCommandInfoBase.color.value), drawCommandInfoBase.color.enabled);
}
struct {
@ -462,9 +467,12 @@ void ext::opengl::Graphic::record( CommandBuffer& commandBuffer, const GraphicDe
} else {
CommandBuffer::InfoDraw drawCommandInfo = drawCommandInfoBase;
// ???
/*
drawCommandInfoBase.matrices.model = NULL;
drawCommandInfoBase.matrices.view = NULL;
drawCommandInfoBase.matrices.projection = NULL;
*/
if ( !material.textures.empty() ) {
auto& texture = material.textures.front();

View File

@ -1,54 +1,54 @@
#include <uf/utils/audio/audio.h>
#include <uf/utils/string/ext.h>
uf::SoundEmitter::~SoundEmitter() {
uf::AudioEmitter::~AudioEmitter() {
this->cleanup(true);
}
bool uf::SoundEmitter::has( const uf::stl::string& filename ) const {
bool uf::AudioEmitter::has( const uf::stl::string& filename ) const {
for ( auto& audio : this->m_container ) if ( audio.getFilename() == filename ) return true;
return false;
}
uf::Audio& uf::SoundEmitter::add() {
uf::Audio& uf::AudioEmitter::add() {
return this->m_container.emplace_back();
}
uf::Audio& uf::SoundEmitter::add( const uf::stl::string& filename ) {
uf::Audio& uf::AudioEmitter::add( const uf::stl::string& filename ) {
// if ( this->has(filename) ) return this->get(filename);
uf::Audio& sound = this->add();
sound.open(filename);
return sound;
}
uf::Audio& uf::SoundEmitter::load( const uf::stl::string& filename ) {
uf::Audio& uf::AudioEmitter::load( const uf::stl::string& filename ) {
// if ( this->has(filename) ) return this->get(filename);
uf::Audio& sound = this->add();
sound.load(filename);
return sound;
}
uf::Audio& uf::SoundEmitter::stream( const uf::stl::string& filename ) {
uf::Audio& uf::AudioEmitter::stream( const uf::stl::string& filename ) {
// if ( this->has(filename) ) return this->get(filename);
uf::Audio& sound = this->add();
sound.stream(filename);
return sound;
}
uf::Audio& uf::SoundEmitter::get( const uf::stl::string& filename ) {
uf::Audio& uf::AudioEmitter::get( const uf::stl::string& filename ) {
if ( !this->has(filename) ) return this->add(filename);
for ( auto& audio : this->m_container ) if ( audio.getFilename() == filename ) return audio;
return this->add();
}
const uf::Audio& uf::SoundEmitter::get( const uf::stl::string& filename ) const {
const uf::Audio& uf::AudioEmitter::get( const uf::stl::string& filename ) const {
for ( auto& audio : this->m_container ) if ( audio.getFilename() == filename ) return audio;
return uf::audio::null;
}
uf::SoundEmitter::container_t& uf::SoundEmitter::get() {
uf::AudioEmitter::container_t& uf::AudioEmitter::get() {
return this->m_container;
}
const uf::SoundEmitter::container_t& uf::SoundEmitter::get() const {
const uf::AudioEmitter::container_t& uf::AudioEmitter::get() const {
return this->m_container;
}
void uf::SoundEmitter::update() {
void uf::AudioEmitter::update() {
for ( auto& audio : this->m_container ) if ( audio.playing() ) audio.update();
}
void uf::SoundEmitter::cleanup( bool purge ) {
void uf::AudioEmitter::cleanup( bool purge ) {
for ( size_t i = 0; i < this->m_container.size(); ++i ) {
if ( !purge && this->m_container[i].playing() ) continue;
this->m_container[i].destroy();
@ -57,13 +57,13 @@ void uf::SoundEmitter::cleanup( bool purge ) {
}
//
uf::MappedSoundEmitter::~MappedSoundEmitter() {
uf::MappedAudioEmitter::~MappedAudioEmitter() {
this->cleanup(true);
}
bool uf::MappedSoundEmitter::has( const uf::stl::string& filename ) const {
bool uf::MappedAudioEmitter::has( const uf::stl::string& filename ) const {
return this->m_container.count(filename) > 0;
}
uf::Audio& uf::MappedSoundEmitter::add( const uf::stl::string& filename ) {
uf::Audio& uf::MappedAudioEmitter::add( const uf::stl::string& filename ) {
if ( this->has(filename) ) return this->get(filename);
uf::Audio& sound = this->m_container[filename];
@ -71,14 +71,14 @@ uf::Audio& uf::MappedSoundEmitter::add( const uf::stl::string& filename ) {
return sound;
}
uf::Audio& uf::MappedSoundEmitter::load( const uf::stl::string& filename ) {
uf::Audio& uf::MappedAudioEmitter::load( const uf::stl::string& filename ) {
if ( this->has(filename) ) return this->get(filename);
uf::Audio& sound = this->m_container[filename];
sound.load(filename);
return sound;
}
uf::Audio& uf::MappedSoundEmitter::stream( const uf::stl::string& filename ) {
uf::Audio& uf::MappedAudioEmitter::stream( const uf::stl::string& filename ) {
if ( this->has(filename) ) return this->get(filename);
uf::Audio& sound = this->m_container[filename];
@ -86,25 +86,25 @@ uf::Audio& uf::MappedSoundEmitter::stream( const uf::stl::string& filename ) {
return sound;
}
uf::Audio& uf::MappedSoundEmitter::get( const uf::stl::string& filename ) {
uf::Audio& uf::MappedAudioEmitter::get( const uf::stl::string& filename ) {
if ( !this->has(filename) ) return this->add(filename);
return this->m_container[filename];
}
const uf::Audio& uf::MappedSoundEmitter::get( const uf::stl::string& filename ) const {
const uf::Audio& uf::MappedAudioEmitter::get( const uf::stl::string& filename ) const {
return this->m_container.at(filename);
}
uf::MappedSoundEmitter::container_t& uf::MappedSoundEmitter::get() {
uf::MappedAudioEmitter::container_t& uf::MappedAudioEmitter::get() {
return this->m_container;
}
const uf::MappedSoundEmitter::container_t& uf::MappedSoundEmitter::get() const {
const uf::MappedAudioEmitter::container_t& uf::MappedAudioEmitter::get() const {
return this->m_container;
}
void uf::MappedSoundEmitter::update() {
void uf::MappedAudioEmitter::update() {
for ( auto& pair : this->m_container ) {
pair.second.update();
}
}
void uf::MappedSoundEmitter::cleanup( bool purge ) {
void uf::MappedAudioEmitter::cleanup( bool purge ) {
for ( auto& pair : this->m_container ) {
if ( purge || !pair.second.playing() ) {
pair.second.stop();

View File

@ -476,6 +476,7 @@ void ext::GuiBehavior::tick( uf::Object& self ) {
model = uf::transform::model( transform );
auto& shader = graphic.material.getShader("vertex");
pod::Uniform uniform;
uniform.color = metadata.color;
if ( metadata.mode == 1 ) {
uniform.modelView = model;

View File

@ -1,39 +0,0 @@
#pragma once
/* Read persistent data */ if ( false ) {
struct {
bool exists = false;
uf::stl::string filename = uf::io::root+"/persistent.json";
} file;
struct {
uf::Serializer file;
} config;
/* Read from file */ if (( file.exists = config.file.readFromFile(file.filename) )) {
persistent.window.size = uf::vector::decode( config.file["window"]["size"], pod::Vector2ui{} );
// persistent.window.size.x = config.file["window"]["size"]["x"].as<size_t>();
// persistent.window.size.y = config.file["window"]["size"]["y"].as<size_t>();
if ( config.file["window"]["title"] != "null" ) {
persistent.window.title = config.file["window"]["title"].as<uf::stl::string>();
}
/* Update window size */ {
ext::json::Value json;
uf::stl::string hook = "window:Resized";
json["type"] = hook;
json["invoker"] = "ext";
json["window"]["size"] = uf::vector::encode( persistent.window.size );
// json["window"]["size"]["x"] = persistent.window.size.x;
// json["window"]["size"]["y"] = persistent.window.size.y;
if ( persistent.window.size.x != 0 && persistent.window.size.y != 0 )
uf::hooks.call(hook, json);
}
/* Update window title */ {
ext::json::Value json;
uf::stl::string hook = "window:Title.Changed";
json["type"] = hook;
json["invoker"] = "ext";
json["window"]["title"] = uf::stl::string(persistent.window.title);
uf::hooks.call(hook, json);
}
}
}

View File

@ -640,42 +640,6 @@ void EXT_API ext::initialize() {
}
}
#if UF_USE_VULKAN
/* Callbacks for 2KHR stuffs */ {
uf::hooks.addHook("vulkan:Instance.ExtensionsEnabled", []( const ext::json::Value& json ) {
// UF_MSG_DEBUG("vulkan:Instance.ExtensionsEnabled: " << json);
});
uf::hooks.addHook("vulkan:Device.ExtensionsEnabled", []( const ext::json::Value& json ) {
// UF_MSG_DEBUG("vulkan:Device.ExtensionsEnabled: " << json);
});
uf::hooks.addHook("vulkan:Device.FeaturesEnabled", []( const ext::json::Value& json ) {
// UF_MSG_DEBUG("vulkan:Device.FeaturesEnabled: " << json);
VkPhysicalDeviceFeatures2KHR deviceFeatures2{};
VkPhysicalDeviceMultiviewFeaturesKHR extFeatures{};
extFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR;
deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
deviceFeatures2.pNext = &extFeatures;
PFN_vkGetPhysicalDeviceFeatures2KHR vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>(vkGetInstanceProcAddr(uf::renderer::device.instance, "vkGetPhysicalDeviceFeatures2KHR"));
vkGetPhysicalDeviceFeatures2KHR(uf::renderer::device.physicalDevice, &deviceFeatures2);
// UF_MSG_DEBUG("Multiview features:" );
// UF_MSG_DEBUG("\tmultiview = " << extFeatures.multiview );
// UF_MSG_DEBUG("\tmultiviewGeometryShader = " << extFeatures.multiviewGeometryShader );
// UF_MSG_DEBUG("\tmultiviewTessellationShader = " << extFeatures.multiviewTessellationShader );
VkPhysicalDeviceProperties2KHR deviceProps2{};
VkPhysicalDeviceMultiviewPropertiesKHR extProps{};
extProps.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHR;
deviceProps2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
deviceProps2.pNext = &extProps;
PFN_vkGetPhysicalDeviceProperties2KHR vkGetPhysicalDeviceProperties2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties2KHR>(vkGetInstanceProcAddr(uf::renderer::device.instance, "vkGetPhysicalDeviceProperties2KHR"));
vkGetPhysicalDeviceProperties2KHR(uf::renderer::device.physicalDevice, &deviceProps2);
// UF_MSG_DEBUG("Multiview properties:");
// UF_MSG_DEBUG("\tmaxMultiviewViewCount = " << extProps.maxMultiviewViewCount);
// UF_MSG_DEBUG("\tmaxMultiviewInstanceIndex = " << extProps.maxMultiviewInstanceIndex);
});
}
#endif
}
#if UF_USE_OPENVR
if ( ext::openvr::enabled ) {
@ -752,47 +716,6 @@ void EXT_API ext::initialize() {
}
#endif
/* Add hooks */ {
#if 0
uf::hooks.addHook( "game:Scene.Load", [&](ext::json::Value& json){
auto function = [json](){
uf::hooks.call("game:Scene.Cleanup");
auto& scene = uf::scene::loadScene( json["scene"].as<uf::stl::string>() );
auto& metadata = scene.getComponent<uf::Serializer>();
};
if ( json["immediate"].as<bool>(false) ) function();
else uf::thread::queue( uf::thread::get(uf::thread::mainThreadName), function );
});
uf::hooks.addHook( "game:Scene.Cleanup", [&](){
if ( ::requestDedicatedRenderThread ) {
::requestDedicatedRenderThread = true;
uf::renderer::settings::experimental::dedicatedThread = false;
}
if ( ::requestDeferredCommandBufferSubmit ) {
::requestDeferredCommandBufferSubmit = true;
uf::renderer::settings::defaultCommandBufferImmediate = true;
}
uf::renderer::synchronize();
uf::renderer::flushCommandBuffers();
uf::scene::unloadScene();
/*
// do GC
if ( ::config.engine.gc.enabled ) {
size_t collected = uf::instantiator::collect( ::config.engine.gc.mode );
if ( collected > 0 ) {
if ( ::config.engine.gc.announce ) UF_MSG_DEBUG("GC collected {} unused entities", (int) collected);
uf::renderer::states::rebuild = true;
}
}
*/
});
#endif
uf::hooks.addHook( "game:Scene.Load", [&](ext::json::Value& json){
::sceneTransition.payload = json;
::sceneTransition.phase = 0;
@ -806,17 +729,6 @@ void EXT_API ext::initialize() {
}
/* Initialize root scene*/ {
/*
ext::json::Value payload;
payload["scene"] = ::json["engine"]["scenes"]["start"];
payload["immediate"] = true;
uf::hooks.call("game:Scene.Load", payload);
*/
/*
ext::json::Value payload;
payload["scene"] = ::json["engine"]["scenes"]["start"];
uf::hooks.call("game:Scene.Load", payload);
*/
ext::json::Value payload;
payload["scene"] = ::json["engine"]["scenes"]["start"];
::sceneTransition.payload = payload;
@ -833,99 +745,6 @@ void EXT_API ext::initialize() {
ext::ready = true;
UF_MSG_INFO("EXT took {} seconds to initialize", times.sys.elapsed().asDouble());
//
/*
{
struct Position {
pod::Vector3f position;
pod::Vector3f normal;
pod::Vector4f tangent;
};
struct TexCoord {
pod::ColorRgba color;
pod::Vector2f16 uv;
pod::Vector2f st;
pod::Vector2f16 wx;
};
struct Weight {
pod::Vector4f alpha;
pod::Vector4f indices;
};
auto ib_buffer = uf::io::readAsBuffer( "./data/tmp/a.ib" );
auto ib_buffer_start = (uint32_t*) ib_buffer.data();
auto pos_buffer = uf::io::readAsBuffer( "./data/tmp/pos.buf" );
auto uv_buffer = uf::io::readAsBuffer( "./data/tmp/uv.buf" );
auto weight_buffer = uf::io::readAsBuffer( "./data/tmp/weight.buf" );
auto pos_buffer_start = (Position*) pos_buffer.data();
auto uv_buffer_start = (TexCoord*) uv_buffer.data();
auto weight_buffer_start = (Weight*) weight_buffer.data();
auto pos_stride = sizeof(float) * 10;
auto uv_stride = sizeof(uint8_t) * 4 + sizeof(float) * 4;
auto weight_stride = sizeof(float) * 8;
auto vb_stride = pos_stride + uv_stride + weight_stride;
auto ib_stride = sizeof(uint32_t);
auto ib_count = ib_buffer.size() / ib_stride;
auto vb_count = pos_buffer.size() / pos_stride;
uf::stl::vector<uint32_t> indices( ib_buffer_start, ib_buffer_start + ib_count );
uf::stl::vector<uf::graph::mesh::Skinned> vertices( vb_count );
for ( auto i = 0; i < vb_count; ++i ) {
auto& vertex = vertices[i];
auto& pos = pos_buffer_start[i];
auto& uv = uv_buffer_start[i];
auto& weight = weight_buffer_start[i];
vertex.position = pos.position;
vertex.normal = pos.normal;
vertex.tangent = pos.tangent;
vertex.color = uv.color;
vertex.uv[0] = uv.uv[0];
vertex.uv[1] = uv.uv[1];
vertex.st = uv.st;
vertex.joints = weight.indices;
vertex.weights = weight.alpha;
}
// printout
std::stringstream ib_ss;
std::stringstream vb_ss;
ib_ss << "byte offset: 0\nfirst index: 0\nindex count: " << ib_count << "\ntopology: trianglelist\nformat: DXGI_FORMAT_R16_UINT\n\n";
vb_ss << "stride: 92\nfirst vertex: 0\nvertex count: " << vb_count << "\ntopology: trianglelist\nelement[0]:\n SemanticName: POSITION\n SemanticIndex: 0\n Format: R32G32B32_FLOAT\n InputSlot: 0\n AlignedByteOffset: 0\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[1]:\n SemanticName: NORMAL\n SemanticIndex: 0\n Format: R32G32B32_FLOAT\n InputSlot: 0\n AlignedByteOffset: 12\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[2]:\n SemanticName: TANGENT\n SemanticIndex: 0\n Format: R32G32B32A32_FLOAT\n InputSlot: 0\n AlignedByteOffset: 24\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[3]:\n SemanticName: BLENDWEIGHTS\n SemanticIndex: 0\n Format: R32G32B32A32_FLOAT\n InputSlot: 0\n AlignedByteOffset: 40\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[4]:\n SemanticName: BLENDINDICES\n SemanticIndex: 0\n Format: R32G32B32A32_UINT\n InputSlot: 0\n AlignedByteOffset: 56\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[5]:\n SemanticName: COLOR\n SemanticIndex: 0\n Format: R8G8B8A8_UNORM\n InputSlot: 0\n AlignedByteOffset: 72\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[6]:\n SemanticName: TEXCOORD\n SemanticIndex: 0\n Format: R16G16_FLOAT\n InputSlot: 0\n AlignedByteOffset: 76\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[7]:\n SemanticName: TEXCOORD\n SemanticIndex: 1\n Format: R32G32_FLOAT\n InputSlot: 0\n AlignedByteOffset: 80\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nelement[8]:\n SemanticName: TEXCOORD\n SemanticIndex: 2\n Format: R16G16_FLOAT\n InputSlot: 0\n AlignedByteOffset: 88\n InputSlotClass: per-vertex\n InstanceDataStepRate: 0\nvertex-data:\n\n";
for ( auto i = 0; i < ib_count / 3; ++i ) {
ib_ss << indices[i*3+0] << " " << indices[i*3+1] << " " << indices[i*3+2] << "\n";
}
for ( auto i = 0; i < vb_count; ++i ) {
auto& vertex = vertices[i];
vb_ss << "vb0[" << i << "]+000 POSITION: " << vertex.position[0] << ", " << vertex.position[1] << ", " << vertex.position[2] <<
"\nvb0[" << i << "]+012 NORMAL: " << vertex.normal[0] << ", " << vertex.normal[1] << ", " << vertex.normal[2] <<
"\nvb0[" << i << "]+024 TANGENT: " << vertex.tangent[0] << ", " << vertex.tangent[1] << ", " << vertex.tangent[2] << ", " << vertex.tangent[3] <<
"\nvb0[" << i << "]+040 BLENDWEIGHTS: " << vertex.weights[0] << ", " << vertex.weights[1] << ", " << vertex.weights[2] << ", " << vertex.weights[3] <<
"\nvb0[" << i << "]+056 BLENDINDICES: " << vertex.joints[0] << ", " << vertex.joints[1] << ", " << vertex.joints[2] << ", " << vertex.joints[3] <<
"\nvb0[" << i << "]+072 COLOR: " << (int) vertex.color[0] << ", " << (int) vertex.color[1] << ", " << (int) vertex.color[2] << ", " << (int) vertex.color[3] <<
"\nvb0[" << i << "]+076 TEXCOORD: " << vertex.uv[0] << ", " << vertex.uv[1] <<
"\nvb0[" << i << "]+080 TEXCOORD1: " << vertex.st[0] << ", " << vertex.st[1] <<
"\nvb0[" << i << "]+088 TEXCOORD2: " << vertex.uv[0] << ", " << vertex.uv[1] <<
"\n\n";
}
uf::io::write( "./data/tmp/vb.txt", vb_ss.str() );
uf::io::write( "./data/tmp/ib.txt", ib_ss.str() );
}
*/
}
void EXT_API ext::tick() {
@ -1043,7 +862,7 @@ void EXT_API ext::tick() {
/* Update vulkan */ {
uf::renderer::tick();
}
//UF_TIMER_TRACE("ticking renderer");
#if UF_USE_DISCORD
/* Discord */ if ( ::config.engine.ext.discord.enabled ) {
ext::discord::tick();
@ -1068,7 +887,6 @@ void EXT_API ext::tick() {
auto& controller = uf::scene::getCurrentScene().getController();
// if ( controller.getName() == "Player" ) {
if ( ::config.engine.gc.enabled ) {
TIMER( ::config.engine.gc.every ) {
size_t collected = uf::instantiator::collect( ::config.engine.gc.mode );
@ -1080,45 +898,16 @@ void EXT_API ext::tick() {
#if !UF_ENV_DREAMCAST
if ( ::times.limiter > 0 ) {
double limiter = ::times.limiter * 1000.0;
/*
static std::chrono::system_clock::time_point cur = std::chrono::system_clock::now();
static std::chrono::system_clock::time_point prev = std::chrono::system_clock::now();
cur = std::chrono::system_clock::now();
std::chrono::duration<double, std::milli> elapsed = cur - prev;
if ( elapsed.count() < limiter ) {
std::chrono::duration<double, std::milli> delta(limiter - elapsed.count());
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(delta);
if ( ::config.engine.limiter.print ) UF_MSG_DEBUG("Frame limiting: sleeping for {:.3f}ms (from {:.3f}ms < {:.3f}ms)", delta.count(), elapsed.count(), limiter);
std::this_thread::sleep_for(std::chrono::milliseconds(duration.count()));
}
prev = std::chrono::system_clock::now();
// std::chrono::duration<double, std::milli> sleep_time = prev - cur;
// UF_MSG_DEBUG("Frame limiting: total time {:.3f}ms ({:.3f}ms + {:.3f}ms)", elapsed.count() + sleep_time.count(), elapsed.count(), sleep_time.count());
*/
static uf::Timer<long long> timer(false);
if ( !timer.running() ) timer.start();
auto elapsed = timer.elapsed().asMilliseconds();
if ( elapsed < limiter ) {
std::chrono::duration<double, std::milli> delta(limiter - elapsed);
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(delta);
// if ( ::config.engine.limiter.print ) UF_MSG_DEBUG("Frame limiting: sleeping for {}ms (from {}ms < {}ms)", delta.count(), elapsed, limiter);
std::this_thread::sleep_for(std::chrono::milliseconds(duration.count()));
}
timer.reset();
/*
static uf::Timer<long long> timer(false);
if ( !timer.running() ) timer.start();
auto elapsed = timer.elapsed().asMilliseconds();
long long sleep = (::times.limiter * 1000) - elapsed;
if ( sleep > 0 ) {
if ( ::config.engine.limiter.print ) UF_MSG_DEBUG("Frame limiting: sleeping for {}ms (from {})", elapsed, ::times.limiter * 1000);
std::this_thread::sleep_for(std::chrono::milliseconds(sleep));
}
timer.reset();
*/
}