Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm also making a game from scratch and reinventing wheels. What is the processing that you are doing for GLES? I see the GLSL_PREPROCESS in the GLSL.


I wanted to include common code for all shaders in a simple way, but I was too lazy write a proper parser. So instead I used the C++ preprocessor and macros to include things from common shader code and combine them in the build step.


FYI: https://docs.gl/es2/glShaderSource takes an array of strings and just internally appends them together. So, rather than trying to #include common code for all my shaders, I just pass a common_code_string and a shader_specific_code_string every time.


I could have definitely used that and I'm surprised I didn't realise it when researching how to include shader code. Luckily my setup required very little work and with my system I could share snippets between GLES and GL.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: