Shaders and Reading Files | C Game + Engine From Scratch 03
Вставка
- Опубліковано 12 чер 2022
- Code used in recording: github.com/Falconerd/engine-f...
Pixel art for this series is custom made by Presley Carvalho. Check out his website here: perigic.com/
Background pixel art for this series is Kings and Pigs by Pixel Frog. Check it out here: pixelfrog-assets.itch.io/king...
Music for this series is from Breezy's Mega Quest by RyanAvx. Check it out here: ryanavx.itch.io/breezys-mega-...
➤ Support the channel: ko-fi.com/falconerd
➤ Website: dylanfalconer.com
➤ GitHub: github.com/Falconerd
➤ Twitch: / falconerd
➤ Discord: / discord
This is great! I'm on linux and using glew but was able to get through your last video with some effort. One nitpick is the autocompletion popups flashing. Maybe another editor theme would make the videos more watchable. Either way, I'm subscribing and along for the ride.
I may have calculated it wrong but I believe 20 MiB is 20,971,520 bytes, not 2,097,152.
I would also consider wrapping all macros that are multiline or multistatement around 'do {...} while(0)' This protects against situations where there may be unwanted behavior from a multiline macro. This even applies to your error out macro where you have two statements ending with a semicolon. The most common pitfall is with single line if statements with no block syntax. The lines beyond the first line won't be within the branched block, so you get unwanted behavior.
a more compelling solution tothat problem is just never write blocks without braces, then you don't need this wonky hack in your macros
good work
Thanks!
So far so good. One thing, should I worry that my square is black instead of green?
Thank you for the good tutorial.
I realize this is not exactly a new video so forgive the necro-post, but I am finding it helpful and had some questions.
First, how does the shader match the uniform texture_id? Is it a reserved word in glsl that auto-magically knows to use the currently bound texture?
Second, are there any good guides on Matrix(es?)? They feel like black magic, and unless I had someone telling me exactly how to create them, what functions to call, and what to pass to those functions, I don't think I'd get anywhere.
Sorry if these get explained in a later video.
That's fine, I don't go over the graphics programming too much because I'm in a similar position. My mathematics skills are lacking and so I too rely on just using what other people have done.
When we call glBindTexture(GL_TEXTURE_2D, my_texture_id) we are setting the default active texture that's in slot 0.
If you want to use multiple textures in one draw-call you'll need to set them first:
glActiveTexture(GL_TEXTURE0)
Loving this series so far. However I noticed that in io_file_read(...) in src/engine/io/io.c there is no call to fclose(). Is there a reason for this? Would there be a memory leak every time we read a file, or does fread() close the file once reaching the end?
Hello. Thanks for video. Can you explain the next code: (const *char *const *)&file_fragment. Can't you just pass &file_fragment.data? And one more question. The way that you implement io_file_read function much better than fseek method? I've read stackoverflow and it seems like if I don't care about sockes and pipes I can use fseek method. Right?
Hi there! Yeah, you can pass &file_fragment.data if you want to ignore the compiler warnings. You can also clear the type by casting to (void*)&file_fragment.data to get rid of the warnings. It's just the function signature required by OpenGL requires that cast to be fully compliant. As for the loading function - it's definitely not needed for this scale and the fseek method will work just fine, it was more of an exercise in how to handle larger files.
I am using an macOS and I got just an black window, I changed the version to 410 but still nothing, I guess I shouldd add some gl commands after initialising the gl, or not?
I was having a similar issue on my mac. I re-arranged my SDL_GL_SetAttribute calls so they occur after creating the window, but before creating the GL context, and then they were respected properly.
im getting a big white box instead of a small green box do you know why?
ignore this I was setting render w and h to SDL_WINDOW_FULLSCREEN
@Dylan, I've managed to get the code to compile but the game will open and then immediately close. Is there a solution to this problem? Thank you.
Hi Kai, if possible, try compiling with debug symbols /Zi and running the program in a debugger like the free RAD Debugger. You will get more info
help im having this errors on compiling:
Error compiling fragment shader. 0(2) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
0(2) : error C0000: ... or #version 410
0(3) : error C7548: 'layout(location)' requires "#extension GL_ARB_separate_shader_objects : enable" before use
0(3) : error C0000: ... or #version 410
0(12) : error C5052: gl_Position is not accessible in this profile
Hi there, seems like you are trying to use a different OpenGL version, which is fine but you want to make sure your glad version corresponds
@@DylanFalconer im trying to use OpenGL 3.3, and in the glad version, same, 3.3, core, but my actual opengl version is 4.6.0, and im setting this attributes on render_init.c:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
Is “io.h” cross platform?
Yeah, we don't use any platform specific code
is this 2d or 3d game engine?
It's a 2D engine. You can view the end result in episode 1.