Comments (8)
Typedefs are just aliases so they're not going to offer type safety on their own. You'll want a struct for each id type, like typedef struct { int32_t id; } sg_buffer;
from sokol.
...I guess a better name would simply be sg_buffer, sg_image, etc... without the '_id'
from sokol.
done, but I need to figure out how to get the compilers emit warnings when assigning using the wrong type (since everything is uint32_t underneath at least clang doesn't complain when using a sg_image when an sg_buffer is expected, etc...
from sokol.
What about typedef handle like vulkan?
from sokol.
I'll try this, and also will have a look at the Vulkan headers, thanks!
from sokol.
You can use something similar to VK_DEFINE_HANDLE then have the struct implemented per backend, under opengl it would be, for example sg_buffer_id with gl handle and some other props you need.
from sokol.
Ok I wrapped the id into a struct, and type checking works now... let's see how (in-)convenient this will be with designed-initialisers though...
from sokol.
reminder feedback from @pervognsen:
-
To reply to your final comment (since I can't reply to closed issues): API users shouldn't need to deal with the id fields.
-
Just the structs as a whole. And for sentinels, you can do e.g. #define SG_BUFFER_NONE ((sg_buffer){0}) with C99 compound literals.
from sokol.
Related Issues (20)
- Using Sokol_gfx with multiple CAMetalLayers HOT 5
- sokol_app.h: support sapp_toggle_fullscreen with HTML5 HOT 2
- Triple buffering for metal - sokol_gfx.h HOT 1
- set metal resource labels - sokol_gfx.h HOT 5
- What is the best way to add tessellation shader support for OpenGL backend? HOT 2
- Rendering to different default gl framebuffers - sokol_gfx.h
- Compressed data & chunk size fails fetch HOT 7
- Some way to sponsor the project in the readme HOT 1
- Question: Where are mipmaps generated? HOT 2
- The allocator callbacks should not be called alloc/free. HOT 1
- Towards a unified sg_begin_pass()
- sg_make_image crash when Xcode Metal API Validation enabled HOT 7
- sg_begin_default_pass on metal sometimes costs 10+ms HOT 7
- Unify the various _cb, _func, _fn suffixes
- sokol_gfx.h: cubemap filtering is not seamless on GLCORE33 backend HOT 6
- Mipmap sampling of non-square image results in black texture on GL/GLES HOT 4
- Reminder: investigate live object report on D3D11
- sokol_gfx failing to compile on macOS 12.4 with `use of undeclared identifier 'MTLGPUFamilyApple8'` HOT 10
- How to sync graphics with audio? HOT 2
- Misleading error message VALIDATE_ABND_FS_EXPECTED_IMAGE_BINDING HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sokol.