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

КОМЕНТАРІ • 25

  • @adammontgomery7980
    @adammontgomery7980 Рік тому +6

    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.

  • @ryanlockhart5328
    @ryanlockhart5328 2 місяці тому +1

    I may have calculated it wrong but I believe 20 MiB is 20,971,520 bytes, not 2,097,152.

  • @j3y445
    @j3y445 Рік тому +1

    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.

    • @dandymcgee
      @dandymcgee 9 місяців тому

      a more compelling solution tothat problem is just never write blocks without braces, then you don't need this wonky hack in your macros

  • @lucamaltempo723
    @lucamaltempo723 2 роки тому +3

    good work

  • @renexthegod4538
    @renexthegod4538 Рік тому

    So far so good. One thing, should I worry that my square is black instead of green?

  • @LordOfElm
    @LordOfElm Рік тому +1

    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.

    • @DylanFalconer
      @DylanFalconer  Рік тому +2

      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)

  • @anth64
    @anth64 4 місяці тому

    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?

  • @romanshvayko211
    @romanshvayko211 Рік тому +3

    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?

    • @DylanFalconer
      @DylanFalconer  Рік тому +3

      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.

  • @bernardolorenzini9213
    @bernardolorenzini9213 11 місяців тому

    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?

    • @budgetjim
      @budgetjim 10 місяців тому

      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.

  • @lewisliewguozhang5760
    @lewisliewguozhang5760 Рік тому

    im getting a big white box instead of a small green box do you know why?

  • @kaiweiyeo4279
    @kaiweiyeo4279 4 місяці тому

    @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.

    • @DylanFalconer
      @DylanFalconer  4 місяці тому

      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

  • @yluigizindev4907
    @yluigizindev4907 Рік тому

    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

    • @DylanFalconer
      @DylanFalconer  Рік тому

      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

    • @yluigizindev4907
      @yluigizindev4907 Рік тому

      @@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);

  • @nickgennady
    @nickgennady Рік тому

    Is “io.h” cross platform?

    • @DylanFalconer
      @DylanFalconer  Рік тому +1

      Yeah, we don't use any platform specific code

  • @trungthanhbp
    @trungthanhbp 2 роки тому +1

    is this 2d or 3d game engine?

    • @DylanFalconer
      @DylanFalconer  2 роки тому +1

      It's a 2D engine. You can view the end result in episode 1.