Comments (3)
By the way, using the '&' before 'SG_RANGE' gives me an error.
Ah right, that's a C vs C++ thing. In C++ you can do this instead (just drop the '&'):
sg_apply_uniforms(SG_SHADERSTAGE_FS, SLOT_fsParams, SG_RANGE(fs_params));
...or use the SG_RANGE_REF() macro which does the right thing both in C and C++:
sg_apply_uniforms(SG_SHADERSTAGE_FS, SLOT_fsParams, SG_RANGE_REF(fs_params));
from sokol.
Do you use the code-generated struct or your own (in the sg_apply_uniforms
call)? E.g. in the sokol-shdc output there's the following struct generated:
#pragma pack(push,1)
SOKOL_SHDC_ALIGN(16) typedef struct fsParams_t {
float time;
uint8_t _pad_4[12];
} fsParams_t;
#pragma pack(pop
Note how this is padded to a multiple of 16 bytes. This is a side effect of 'flattening' uniform blocks into a vec4 array via SPIRVCross, which allows to update uniforms with a single glUniform4fv() call per uniform-block in the GL backend (instead of one individual glUniform call per uniform block member which is otherwise used).
PS: the #version 330 core
at the top of your shader isn't necessary (and might even confuse sokol-shdc in some cases).
PPS: in general, and if possible, you should use the code-generated structs for passing uniforms into sokol-gfx, since the alignment and padding rules for uniform blocks are non-trivial, and very different from vanilla C structs.
PPPS: code example
const fsParams_t fs_params = { .time = (float)glfwGetTime() };
sg_apply_uniforms(SG_SHADERSTAGE_FS, SLOT_fsParams, &SG_RANGE(fs_params));
from sokol.
I know the #version 330 core
isn't necessary but I was pretty desperate to get it working. I am using the generated struct yes, I'd rather not make my own or mess with the generated one. And, oh, the code example you provided actually works. I guess that's it, thanks.
By the way, using the '&' before 'SG_RANGE' gives me an error. I've seen it being used every example though. The error is 'Taking address of rvalue [-fpermissive]', the program runs fine regardless of this error. I have all warnings and errors enabled so that must be the case.
from sokol.
Related Issues (20)
- sokol_audio.h: capture input HOT 2
- [sokol_app] Alt-tabbing issues on windows in a FPS game on a multi-monitor setup HOT 2
- D3D11 storage buffers do not compile on wine HOT 1
- Seems .c file not generated in bindgen, producing errors HOT 2
- test
- Sokol Fetch Http response 200 is reported as an error HOT 7
- [sokol_gfx d3d11] update_image is wrong for 3d textures HOT 10
- Offscreen with alpha background. Is it possible? HOT 4
- [webgpu] Bindgroups cache breaks down with init/uninit pattern.
- macOS huge memory usage when window minimized HOT 1
- Questions regarding default GL version HOT 5
- App Window Size on Android HOT 3
- Default value _sg_gl_uniform_t::gl_loc when uniform_desc's name isn't given in sokol_gfx HOT 1
- sokol_gfx.h: wrong define in log related to SOKOL_TRACE_HOOKS HOT 1
- WebGPU TextureView validation error HOT 6
- sokol_fetch on Android
- partial updates to buffers/textures (e.g. offset and size args to glBufferSubData, glTexSubImage) HOT 1
- Right shift is recognized as "invalid key" on Windows. HOT 9
- SAPP_EVENT_CHAR for Space is fired when Ctrl+Space is pressed. HOT 2
- Key events on Linux always use the **first** keyboard layout in the system's keyboard layout list. HOT 1
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.