Git Product home page Git Product logo

Comments (2)

lmichaelis avatar lmichaelis commented on June 1, 2024

What do you think about this?

typedef void (*PxTexDecompressCallback)(uint8_t const* data, uint32_t size, void* context);
void pxTexDecompress(PxTexture const* tex, PxTexDecompressCallback cb, void* context);

This would automatically allocate the data buffer and free it after the callback exits. You'd use it like this:

void copyTexture(uint8_t const* data, uint32_t size, void* context) {
   uint8_t** output = context;
   *output = malloc(size);
   memcpy(*output, data, size);
}

int main() {
   uint8_t* data;
   pxTexDecompress(tex, copyTexture, &data);


   // Now `data` contains the decompressed image data.
   free(data);
}

from phoenix-shared-interface.

JaXt0r avatar JaXt0r commented on June 1, 2024

Thanks for your idea. But I would like to avoid callbacks as it adds a new architecture pattern you only use for Vm right now (where it definitely makes sense).

On C# interface I already build small wrapper functions which take care of loading, transforming, and deleting C-data. No need for callbacks.

How about using it the classical way? Something like:

PXC_API uint8_t const* pxTexGetMipmapUncompressed(PxTexture const* tex, uint32_t* length, uint32_t level, uint32_t* width, uint32_t* height) {
    ...
}

Normal flow for C# sharp is right now:

  1. Get TextureMetadata - exists
  2. Decide whether to call pxTexGetMipmap() or pxTexGetMipmapUncompressed() based on TextureFormat - second half is new
  3. Then call pxTexMipmapUncompressedDestroy() if uncompressed data was received before. - new

from phoenix-shared-interface.

Related Issues (9)

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.