Giter VIP home page Giter VIP logo

Comments (6)

ChemistAion avatar ChemistAion commented on June 18, 2024 1

...finally, let say that we could close it since I will "break" im3d internals for these wrappers and use local new/delete scheme

from im3d.

john-chapman avatar john-chapman commented on June 18, 2024 1

It wouldn't break the internals, but it would be a breaking change for users who have set up the im3d_config.h file. The purpose of that is to have a single, central place for users to configure the library and then receive updates by overwriting the other library files. No, it's not elegant but it is very simple!

It's common for users to extend Im3d by adding stuff to im3d_config.h - so in your case adding IM3D_NEW(),IM3D_DELETE(), etc. macros there would be in line with the typical way of extending the library.

from im3d.

ChemistAion avatar ChemistAion commented on June 18, 2024

Please consider this: https://github.com/ocornut/imgui/blob/6b2e03c5b1bc4f99dbd86d10e5fd12af9e3fe1c2/imgui.h#L1772-L1779

from im3d.

john-chapman avatar john-chapman commented on June 18, 2024

I don't think I understand the use case - these macros are only used internally so there's no need for the defaults to be externally visible.

from im3d.

ChemistAion avatar ChemistAion commented on June 18, 2024

I am wrapping im3d into im3d_impl_win32 and im3d_impl_dx12 similarly to:
https://github.com/ocornut/imgui/tree/master/backends

This req allows to be consistent with im3d in such a wrapper (even defaults with malloc/free does not trigger ctor/dtor), e.g.:

bool Im3d_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* heap)
{
    Im3d::AppData& ad = Im3d::GetAppData();
    IM3D_ASSERT(ad.m_rendererData == nullptr && "The im3d already initialized at platform backend!");
    //  IM3D_ASSERT(device);
    //  IM3D_ASSERT(num_frames_in_flight > 0);
    //  IM3D_ASSERT(heap);

    Im3d_ImplDX12_Data* data = (Im3d_ImplDX12_Data*)IM3D_MALLOC(sizeof(Im3d_ImplDX12_Data));
    ad.m_rendererData = (void*)data;

    data->device_ = device;
    data->heap_ = heap;
    data->num_frames_in_flight_ = num_frames_in_flight;
    data->frame_index_ = UINT_MAX;
    data->rtv_format_ = rtv_format;
    data->frame_resources_ = (Im3d_ImplDX12_RenderBuffers*)IM3D_MALLOC(num_frames_in_flight * sizeof(Im3d_ImplDX12_RenderBuffers));
        
    for (int index = 0; index < num_frames_in_flight; ++index)
    {
        Im3d_ImplDX12_RenderBuffers* render_buffer = &data->frame_resources_[index];

        render_buffer->index_buffer_ = nullptr;
        render_buffer->vertex_buffer_ = nullptr;
        render_buffer->index_buffer_size_ = 0;
        render_buffer->vertex_buffer_size_ = 0;
    }

	(...)

    return true;
}

btw: IM3D_ASSERT is visible from im3d.h 😇

from im3d.

ChemistAion avatar ChemistAion commented on June 18, 2024

Yes, I understand.
Let's proceed then with the current approach for extending the library 🚀

from im3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.