Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opengl can't compile the shader #45

Open
GmosNM opened this issue Jan 7, 2023 · 9 comments
Open

opengl can't compile the shader #45

GmosNM opened this issue Jan 7, 2023 · 9 comments

Comments

@GmosNM
Copy link

GmosNM commented Jan 7, 2023

GL version 3.3
GL CALLBACK: type = 0x8251, severity = 0x826b, message = Buffer detailed info: Buffer object 1 (bound to GL_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations.
ERROR: could not compile GL_VERTEX_SHADER
0(28) : error C0000: syntax error, unexpected $undefined at token ""

ERROR: failed to compile ./shaders/free_glyph.vert shader file

@GmosNM GmosNM changed the title opengl can't render the shader opengl can't compile the shader Jan 7, 2023
@IRooc
Copy link

IRooc commented Jan 13, 2023

I think this is due to the fact that the read_entire_file does not zero out the remaining space if for instance you load a shader of 100 bytes and after that a shader of 90 bytes the last 10 bytes will still be of the old shader. The count in the SB will be correctly set to 90, but only the .items pointer is passed to the compile_shader function

if (!compile_shader_source(source.items, shader_type, shader)) {

which apparently does not take into account null terminators halfway in the chararray.

So memsetting the full SB to 0 before reading the file helps

fread(sb->items, size, 1, f);

Note there is a PR with a working windows build (both local and CI) if you're interested #42

@GmosNM
Copy link
Author

GmosNM commented Jan 13, 2023

I think this is due to the fact that the read_entire_file does not zero out the remaining space if for instance you load a shader of 100 bytes and after that a shader of 90 bytes the last 10 bytes will still be of the old shader. The count in the SB will be correctly set to 90, but only the .items pointer is passed to the compile_shader function

if (!compile_shader_source(source.items, shader_type, shader)) {

which apparently does not take into account null terminators halfway in the chararray.
So memsetting the full SB to 0 before reading the file helps

fread(sb->items, size, 1, f);

Note there is a PR with a working windows build (both local and CI) if you're interested #42

yo thank you but its not working for me
image

@IRooc
Copy link

IRooc commented Jan 14, 2023

Are you trying to run the build_msvc file or the ded.exe?

The ded.exe needs the SDL2.dll and freetype.dll and it's the 64 bit version that is build maybe that's the issue.

Could you try to run from the commandline to see if there is some extra logging?

@GmosNM
Copy link
Author

GmosNM commented Jan 14, 2023

image

@GmosNM
Copy link
Author

GmosNM commented Jan 14, 2023

image

@IRooc
Copy link

IRooc commented Jan 15, 2023

Weird indeed, the good news is it builds 👍
What machine are you trying to run it on? 32bit vs 64bit?

Maybe this will have some guidance? https://www.passfab.com/windows-10/this-app-cant-run-on-your-pc.html

@drwbns
Copy link

drwbns commented Aug 22, 2023

I think this is due to the fact that the read_entire_file does not zero out the remaining space if for instance you load a shader of 100 bytes and after that a shader of 90 bytes the last 10 bytes will still be of the old shader. The count in the SB will be correctly set to 90, but only the .items pointer is passed to the compile_shader function

if (!compile_shader_source(source.items, shader_type, shader)) {

which apparently does not take into account null terminators halfway in the chararray.
So memsetting the full SB to 0 before reading the file helps

fread(sb->items, size, 1, f);

Note there is a PR with a working windows build (both local and CI) if you're interested #42

I am having the same issue as OP. I tried memset(sb, 0, size) before line 105 but I just get a crash. C isn't really my strength. Any thoughts on how to fix the shader compile error or am I just memsetting wrong?

@IRooc
Copy link

IRooc commented Aug 22, 2023

Hi maybe you memset to early? I have it on line 109 and that seems to work
https://github.com/tsoding/ded/pull/42/files#diff-f6c5883a603e481644b9ef028b158acace9eabf59598f164dbec7b97d8da231fL109

@drwbns
Copy link

drwbns commented Aug 22, 2023

Hi maybe you memset to early? I have it on line 109 and that seems to work https://github.com/tsoding/ded/pull/42/files#diff-f6c5883a603e481644b9ef028b158acace9eabf59598f164dbec7b97d8da231fL109

That made it start working for me. I was memsetting the entire var, not just the items. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants