Giter Site home page Giter Site logo

Automate mesh description via a macro about gfx HOT 5 CLOSED

gfx-rs avatar gfx-rs commented on September 13, 2024
Automate mesh description via a macro

from gfx.

Comments (5)

kvark avatar kvark commented on September 13, 2024

Code to derive a field offset by @Kimundi:

struct Foo { bar: uint, baz: uint }
unsafe { &(*(0u as *const Foo)).baz as *const _ as uint }

Macro version:

macro_rules! offset_of { ($t:ty, $i:ident) => {unsafe { &(*(0u as *const $t)).$i as *const _ as uint }}}
struct Foo { bar: uint, baz: uint } offset_of!(Foo, baz)

Finally, the stride can be (obviously) extracted by std::mem::size_of::<T>()
The size of the attribute (number of components) should be possible to extract from the fixed-size array definition. Hence, everything seems to be ready for a macro to write.

from gfx.

brendanzab avatar brendanzab commented on September 13, 2024

What is the definition of Format in fn get_format() -> Format;?

from gfx.

kvark avatar kvark commented on September 13, 2024

@bjz Format might be as simple as Vec<mesh::Attribute>

from gfx.

kvark avatar kvark commented on September 13, 2024

After implementing shader_param attribute, this one is going to be fairly trivial for me.

from gfx.

kvark avatar kvark commented on September 13, 2024

Fixed by #122

from gfx.

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.