[Episode 5] [Code] Setup SDL2 and OpenGL and first OpenGL function (glGetString) - Modern OpenGL

Поділитися
Вставка
  • Опубліковано 27 вер 2024
  • ►Full OpenGL Series Playlist: • Introduction to OpenGL
    ►Find full courses on: courses.mshah.io/
    ►Join as member to get perks: / @mikeshah
    ►Lesson Description: In this lesson I show you step by step how to create an SDL2 window, setup an opengl context, and ultimately call your first OpenGL function. This is a longer lesson, but should be useful in helping you put together all the information you need to get started with OpenGL programming.
    ►Please like and subscribe to help the channel!
    ►UA-cam Channel: / mikeshah
    ►Join our free community: courses.mshah....
  • Наука та технологія

КОМЕНТАРІ • 63

  • @hannahm9259
    @hannahm9259 3 місяці тому +1

    Exactly what I needed! so professional and to the point. Thanks!

  • @BrandonWingerAir
    @BrandonWingerAir 7 місяців тому +2

    Amazing series, your a life changer! So glad I found it while looking to start actually learning C++ and OpenGL. Got it working on Windows with MSYS2

    • @MikeShah
      @MikeShah  7 місяців тому +1

      Cheers, enjoy!

  • @guillaumebourgeois42
    @guillaumebourgeois42 Рік тому +4

    I just started a Bachelor in Automation Engineering where I had an introduction to strict C.
    I managed to get this OpenGL and SDL2 because of this lesson and, in my opinion, this channel should be in the 500k views.
    Good explanations, lots of fiddling around (which is actually awesome because you get to see some quality troubleshooting).
    Love it so far!

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

      Cheers, thanks for the kind words! Channel growing slow and steady 😁

  • @larfingshnew6965
    @larfingshnew6965 Рік тому +5

    This is Wonderful! I'm enjoying following along in linux using the command line to compile and just a simple text editor to code. Looking forward to the rest of the series!

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

      Cheers thank you for the kind words!

  • @thoric01
    @thoric01 11 місяців тому +1

    Incredible that this course is free! Thanks a lot Mike

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

      Cheers, thanks for the kind words!

  • @MarcosCpp
    @MarcosCpp 2 роки тому +23

    The cool thing about this video is that you made everything from scratch and separated each part of the process. It became easier to understand how OpenGL really works.

    • @MikeShah
      @MikeShah  2 роки тому +5

      Thank you! Follow up videos are going to keep reinforcing these ideas 😁 💡

    • @MarcosCpp
      @MarcosCpp 2 роки тому +5

      @@MikeShah I know it's a lot of work to make the videos, but over time people will show up and in time you'll be at the top! Hugs!

    • @MikeShah
      @MikeShah  2 роки тому +2

      @@MarcosCpp Thank you for the support and words of encouragement! 😁

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

    Mike is an AMAZING teacher!! We need him in Russia

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

      Cheers! Thank you for the kind words!

  • @mohsenzare2511
    @mohsenzare2511 7 місяців тому +1

    Thanks for your great videos MAN

    • @MikeShah
      @MikeShah  7 місяців тому

      Cheers, you are most welcome!

  • @thomasnguyen1150
    @thomasnguyen1150 9 місяців тому +4

    There is also the SDL_opengl.h header file that I have seen in other tutorials. I saw it includes the same OpenGL API functions/constants found in GLAD, such as glGetString, GL_VENDOR, etc, although I had some linker issues when I tried to compile that I didn't bother with. Do you happen to know what is SDL_opengl.h used for? From what I see it can be used in place of GLAD/other OpenGL extensions but I don't see it ever used.

    • @MikeShah
      @MikeShah  9 місяців тому +1

      I believe SDL_opengl only supports older OpenGL functions, so it's still best to use something like glad, glew, etc. to load the OpenGL extensions.

  • @SandeepGupta-em8yu
    @SandeepGupta-em8yu Рік тому +1

    Great video

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

    Thanks for that awesome video.
    Can someone tell me pls, how can I set up my terminal to be so simple and convinient like your one? In which direction I should look?

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

      Cheers! My terminal is just vanilla vim and tmux :)

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

    I just recently started working on getting a GLFW project up and running but for some reason whenever I build and run, the window pops up but Linux wants to force quit the process.
    Looking forward to your future videos so I can keep working in OpenGL

    • @MikeShah
      @MikeShah  2 роки тому

      Hmm strange that glfw is doing that--perhaps try a stable version of glfw and see if that continues? I wonder if the order of setting things up is mixed up. Otherwise, feel free to follow the SDL2 instructions in this series (and more instructions on my SDL2 series for setting up window with OpenGL).
      At some point, I will run through these setups with glfw.

  • @只是約翰紐約市
    @只是約翰紐約市 9 місяців тому +1

    Hi. I have a question. Why did you choose SDL2 for OpenGL and not GLFW for example?

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

      It's a bit more rich of a library and commercially it has been used on many platforms which has some appeal.

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

    If I wanted the openGL window to be a panel or frame within a wxWidgets app, how would these steps you do here be incorporated in the wxWidgets app? I mean, would this code be in some other function or must it be where I setup the frame or panel in my application? Im a little lost as to how to setup openGL in wxWidgets. Thank you.

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

      It's on my todo list for my wxWdigets series (ua-cam.com/play/PLvv0ScY6vfd9QZOUbQ2YMghuxWnFoWuiU.html) to talk about Modern OpenGL with wxglcanvas. The samples otherwise have a few examples you could otherwise modify :)

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

    I want to create a 3D games, should I need combine SDL2 and OpenGL

    • @MikeShah
      @MikeShah  2 роки тому

      Correct! This series will help you with that. Other options include using a game engine like Unity3D or Unreal Engine if you do not want to do everything from scratch

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

    and seem glfwPollEvents is better than Pool Event of SDL because the CPU still in low percent when app go to glfwPollEvents

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

      Interesting! I haven't compared both

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

      @@MikeShah yes when apps run too SDL pool event, the CPU going to 100%

  • @abdullah.astro1
    @abdullah.astro1 3 місяці тому

    can i use glad instead?

    • @MikeShah
      @MikeShah  3 місяці тому

      We use glad in this video

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

    Everything was going well until I got to the part where you ran the program and your window popped up. When I run the program there are no errors and the main event loop is running (tested it with cout and it just fills my terminal) but no window seems to show up? Any ideas?

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

      Hmm, hard to know without seeing it. I'm guessing SDL2 is not being initialized -- you could try to return the error code and see what that gives you. Specs on your operating system are also useful. Post the fix here or on "courses.mshah.io forums" if you find anything

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

      @@MikeShah that’s the thing that’s so weird, there is no error. I have your code practically copied 1to1 up to the point where you run it with a window popping up on your other sceeen for the first time. I’m running it on Ubuntu on a Surface Book Gen 1 which supports OpenGL 4.6 (but I don’t think the OpenGL support has to do with the window not showing)
      When I get a chance I’ll push the file onto GitHub and and comment the link

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

      @@MikeShah this is what I’ve got so far, let me know if you spot anything incorrect! Any and all feedback is greatly appreciated, thank you. github.com/jackphillips31/OpenGL-Mandelbrot/blob/master/main.cpp

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

      Ps the compiled prog on that repo isn’t updated

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

      @@Fr0sTyProductions My guess is you'll need to update the mesa drivers. Try changing the MAJOR and MINOR versions to something like 3 and 3 respectively. I forget the exact command to update mesa on ubuntu, but it'll be something like sudo apt-get update libemesa-dev

  • @marshedmello
    @marshedmello 2 місяці тому

    I am having some issues with the default GPU to render this. i am not sure how to change it.
    context:
    - I am using WSL2 Ubuntu 22.04
    - I have AMD Radeon 780m Graphics integrated gpu
    - and NVIDIA GeForce rtx 4060 laptop gpu
    when i do lspci it shows both of them as "Microsoft Corporation Device 008e"
    and for the line > std::cout

    • @marshedmello
      @marshedmello 2 місяці тому

      nevermind i figure it out, i just needed to update the environment variable like so
      $ export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA
      thanks for the awesome tutorials mike, i completed the C++ series (well 70%) and started this now. really enjoying it. :D

    • @MikeShah
      @MikeShah  2 місяці тому

      @@marshedmello Cheers! And thanks for also sharing the solution with the community!

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

    I love your videos. After learning sdl, i was bored so I followed your tutorials to learn OpenGL. So far, I have been learning a lot

    • @MikeShah
      @MikeShah  2 місяці тому

      @@JumpercraftYT cheers, happy to hear that!

  • @michaelkohlhaas4427
    @michaelkohlhaas4427 7 місяців тому +1

    Hi Michael, thanks for the videos in this series! Why not having a Github repository?

    • @MikeShah
      @MikeShah  7 місяців тому

      Cheers! 1.) More to maintain 2.) Avoid students copying & pasting

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

    Only your tutorials worked out for me, they are one of their kind.
    This is not a problem, but: When you executed your application after all changes( addition of glGetString(GL_RENDERER) ), it showed in "out": nvidia discrete gpu, but for me it shows intel integrated with "mesa"
    I tried to grep glxinfo and it showed my nvidia discrete card
    Is there a way to set a default renderer to GPU in my current source code?
    (sorry, I tried to google it, but I couldn't find any suitable answers)

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

      Cheers! Thanks for the kind words. Usually can select gpu from operating system or perhaps device settings

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

      I managed to find solution, but I think it's nearly impossible to use Nvidia gpus on linux. I'm using Fedora 37 and I only solved problem with downgrading drivers and setting up Machine Owner Keys for Nvidia drivers.
      Is it worth spending time on linux to learn graphics/gamedev programming?
      Or It's better to stick with windows DirectX ( don't know about Vulkan) ?

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

      @@heyheyheyhoev419 Still worth it to do OpenGL on linux in my opinion. Historically nVidia was more difficult on linux, but I believe that to be improved or improving over time. DirectX is also coming to WSL -- so that is a big bonus for development! devblogs.microsoft.com/commandline/d3d12-gpu-video-acceleration-in-the-windows-subsystem-for-linux-now-available/

  • @downloaddave-s4e
    @downloaddave-s4e 8 місяців тому +1

    Thanks Mike for the lesson, nicely done!