A Quick, Easy and Extendable OpenGL Renderer in 250 LOC!

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ธ.ค. 2024

ความคิดเห็น • 25

  • @DylanFalconer
    @DylanFalconer ปีที่แล้ว +17

    Nice, I have been using something similar myself for quite a while, but with quad rendering as the atom. Nice tip about the EBO not being worth it in these cases - I'll be using that info :)

    • @springogeek
      @springogeek ปีที่แล้ว +5

      I don't think that the EBO tip is entirely accurate. It makes sense if you have very little vertex data, but once you start adding texture coordinates, texture ids, colors, the vertex reuse saves data on quads for sure.

    • @enriquedelacal2814
      @enriquedelacal2814 2 หลายเดือนก่อน +1

      @@springogeek yea idk where he got that from, itd be nice if he clarified

  • @torphedo6286
    @torphedo6286 ปีที่แล้ว +2

    This is pretty cool! I'll consider using this if I do more 2D rendering in the future. It's a little too barebones for my 3D needs (I'm trying to support GLTF loading), but this is perfect for a 2D game.

  • @Maxjoker98
    @Maxjoker98 5 หลายเดือนก่อน +2

    Nice video, I've used completely custom "game engines" for game jams etc. before, but mostly for 2D stuff.
    However, the way you handle textures is very OpenGl 2. In more modern OpenGL you can use TEXTURE_2D_ARRAY: It is basically what you've manually implemented, you just give it 3 indices when sampling. (u, v, and "texture id" aka "layer" or "w"). I think it's an OpenGL 3 feature, might be 3.3, either way WebGL2 supports it :)

    • @juliapaci
      @juliapaci 21 วันที่ผ่านมา

      unfortunately, however, the textures must be the same resolution :(

  • @BiskitSlippers
    @BiskitSlippers ปีที่แล้ว

    Thank you for taking the time to make these videos! I think I understand the concept of a memory arena - I like to think of it as a stage where the memory lives for a certain amount of time. What I don't understand is how do you load specific data into them? Do you just use void pointers everywhere and cast them whenever you need to use them? I think I am on the edge of fully understanding this but I'm not there yet.

    • @voxelrifts
      @voxelrifts  ปีที่แล้ว

      Yeah, I implement them as linear allocators, holding an offset of where the next allocation will go with respect to a base pointer. If you haven't seen it already, I made a video about arenas that goes indepth into the semantics of it all (as you said, the allocations living a certain amount of time)

  • @yogxoth1959
    @yogxoth1959 ปีที่แล้ว +2

    Thanks a lot for this video. It’s very helpful since I’m learning OpenGL right now. But I’m wondering why you aren’t using the GL types, like GLuint? What are those u32 types?

    • @voxelrifts
      @voxelrifts  ปีที่แล้ว

      they are typedef-ed to the same thing.
      the u prefix stands for unsigned, the i prefix is for signed, the f prefix stands for floating point. the number stands for how many bits the type takes up. Only reason for using those is shorter type names. (Also since I'm doing opengl function loading myself, I'd have to typedef GL types myself so It isn't really great)

    • @torphedo6286
      @torphedo6286 ปีที่แล้ว

      GLuint is just a 32-bit int anyway, so it's the same thing. I typedef'd them to "gl_id" in my codebase to shorten the name, but "u32" works too.

  • @JacobElliottSermons
    @JacobElliottSermons 4 หลายเดือนก่อน

    I think I am grasping what you are doing. I am wanting to develop a 3D renderer. This seems to be extendable to the 3D world but I think I will need to study it and make sure. Do you think the concepts work and are transferable? It seems to me but need to think on it further.

  • @anon_y_mousse
    @anon_y_mousse ปีที่แล้ว +1

    This is a good idea, but I think it should be written more portably. Something that might help is if you download a copy of MingW or CygWin. When I was still using Windows, they made it a lot easier to target POSIX as a platform, and both include a port of bash. For getting input, you might consider using SDL, and for simple GUI construction consider GTK. I think I'm going to see what it takes to port this by getting your tetris clone working.

    • @voxelrifts
      @voxelrifts  ปีที่แล้ว +2

      Oh definitely. The main point of the repository was JUST the renderer c file. The rest of the scaffolding was just my codebase which I'm in the process of making more cross platform at the moment.

    • @torphedo6286
      @torphedo6286 ปีที่แล้ว +2

      GLFW also works and can get you both the rendering and input. I've been using that with CMake, and my code is portable to MinGW, MSVC, and GCC on Linux

    • @anon_y_mousse
      @anon_y_mousse ปีที่แล้ว

      @@torphedo6286 Yep, another excellent choice.

  • @LainIrukawa
    @LainIrukawa 10 หลายเดือนก่อน

    i like the colorscheme and font , names ?

    • @voxelrifts
      @voxelrifts  10 หลายเดือนก่อน

      Font is inconsolata, the colorscheme is Ryan fleury's which is modified from the theme Casey uses for handmade hero. I don't think it has a name.

  • @Shadowblitz16
    @Shadowblitz16 ปีที่แล้ว

    How would I use render textures?

    • @voxelrifts
      @voxelrifts  ปีที่แล้ว

      What do you mean by render textures? I cover rendering simple textures in the video

    • @Shadowblitz16
      @Shadowblitz16 ปีที่แล้ว

      @@voxelrifts like rendering a texture onto a texture

    • @voxelrifts
      @voxelrifts  ปีที่แล้ว +2

      @@Shadowblitz16 That's something you would want to use a framebuffer for separately. That's not something the renderer itself is concerned with. You make a separate framebuffer with a texture attachment. If you want to render to the framebuffer, bind the framebuffer then use the renderer like normal (begin frame, push geometry, end frame) then swap over to the screen framebuffer and use the renderer again to render the framebuffer texture

  • @asherhaun
    @asherhaun ปีที่แล้ว +1

    things look to have improved since azurite :D

    • @voxelrifts
      @voxelrifts  ปีที่แล้ว +1

      Improved AND simplified a lot indeed!

  • @enriquedelacal2814
    @enriquedelacal2814 29 วันที่ผ่านมา +1

    quads do save space with indices