Game

C++ Game Programming Tutorial – Let's make a game: Episode 1




Welcome to my new set of C++ Game Programming tutorials!

In Episode 1, we set up our Engine class and a rudimentary Sprite class that we used to load a .png. We use OpenGL, GLFW, and the SOIL library.

These are cached versions of my Twitch streams. I just started this new series a week ago and it’s basically going through the process of making a game from scratch in C++ using OpenGL and helper libraries like GLFW and SFML.

I don’t really have a set plan, as I mention in the video. The point here is collaborative efforts across the viewers and myself so that we can make something cool together! If you have any cool ideas, feel free to share them with me! We’ll end up making something cool regardless 🙂

You can watch the stream live on twitch on Wednesdays at 7pm PST starting on July 13th at
I also upload our progress onto github so that you can pull our latest code before watching the next stream! You can find the repo at

Nguồn: https://77days.net/

Xem thêm bài viết khác: https://77days.net/game/

Game
Evolution Of Popeye Games 1982 – 2005
Game
One Of The Best Survive Craft Build Games | Subsistence Gameplay | EP1
Game
TOWNSHIP – Fastest Regatta Tasks
  • I tried this and kept getting error " argument type "char" is incompatible with parameter of type "Char*" " trying to call the initialize function. Any help?


  • ok so I was getting following errors in vs19 :-

    1>SOIL.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer

    1>SOIL.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2

    How I resolved it :-

    step 1) go to SOIL>projects>VC9>SOIL (microsoft vs solution)

    step 2) build this project in vs 2019, you'll get a migration report

    step 3) now once again build but this time change solution configuration to release (previously 'debug')

    step 4) in file explorer, open SOIL>projects>VC9 >Release, you'll find SOIL.lib there (mine was of 576 kb), copy that

    step 5) go to SOIL>lib where your original SOIL.lib was present, delete that, paste new one and you're good to go!

    step 6) now build twitch and voila!

    Also, thanks for the video!


  • I cant install glfw and opengl


  • To anyone who is using visual studio 2019 and is getting an error " SOIL_load_OGL_texture.".

    There is a nupen package for soil 1.16.0 that you can download but it needs some extra work to get it working:

    1. if you have done any linking (additional dependencies etc) of Soil folders that you got online before the nupen download, remove them, it was the final reason why i couldn't get SOIL working

    2. the #include line wasn't showing soil.h, by finding its exact location on the computer, you can circumvent this issue:
    it installs soil.1.16.0 next to the nupen gl stuff, so you can find the directionary if your path is different.

    C:Users*USERNAME_HERE*sourcereposTwitchpackagessoil.1.16.0buildnativeincludesoil.h

    Great video dude, and it helped me alot, i wanted to put down my solution just in case someone wants to follow your steps without hours of research.


  • In Texture::Texture (string path) I get "unresolved external symbol" for SOIL_load_OGL_texture.
    I did everything identically and this even shows up when I clone your repo and try to build it.

    Full error message: "unresolved external symbol _SOIL_load_OGL_texture referenced in function "public: __thiscall Texture::Texture(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Texture@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)"


  • "I want the starting point to be at the bottom left" Angers every game developer ever


  • Hi thank you for your video, however i tried to create a window with the function glfCreateWindow(), and it throws an error any idea why this is happening


  • 6:31 When i type nupen, it says no extension found. When I add gl.core it still says no extension found. Can someone help me ? I've got Visual Studio Code and Version: 1.42.0.
    Thx to whoever does! I hope I get an answer


  • hi, just wanna ask, can i start learning game development without knowing c++? i mean can i learn c++ and game development simultaneously?


  • #pragma once isn't a windows thing
    also it's a preprocessor keyword

    works everywhere (at least since 2019 (I don't know how it was in 2016, but I think it was))
    the funny thing is, you said to make it platform independend, but later on you called
    #pragma comment(lib, "opengl32.lib")
    and if #pragma was a windows thing, you messed yourself up at that point 😛


  • Hello!
    When I try to run the project, I get the error:

    Severity Code Description Project File Line Suppression State
    Error LNK2019 unresolved external symbol _SOIL_load_OGL_texture referenced in function "public: __thiscall Texture::Texture(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Texture@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) Twitch_GameProject D:C++ ProjectsTwitch_GameProjectTexture.obj 1

    It has something to do with the function SOIL_load_OGL_texture. If I comment this line out in the Texture.cpp file, the code runs, but with no ID, so I get the message of Error loading image.
    Any idea on how to solve this issue so SOIL_load_OGL_texture works properly?
    This error also happens on the project I downloaded from your GitHub.

    Thanks!


  • I have done everything as you did(even downloaded the same sprite) and it didn't render the sprite for me to the screen?Any advice?


  • Visual Studio Code doesn't load my image (Reb Biplane) but I put the path in
    Sprite testSprite = Sprite("(MY PATH)",…,…). I moved the path of my image in the same path of my project but tge programs doesn't show the image! HELP MEE!


  • cant hear you very well:(


  • The Sprites texture is definitely loaded. the GetWidth and GetHeight are returning the correct size values, but the sprite is not rendering. The only thing I did differently was used nuget to add SOIL 1.16 as a dependency, I tried copying it into the project and that had worse effects and errors, I'm going to assume its not soil, because the texture is definitely loaded. Here is my render method. GetID is also returning 1, as it is the only texture.

    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, texture.GetID());

    glLoadIdentity();

    glTranslatef(xPos, yPos, 0);

    glColor4f(1, 1, 0, 0);

    glBegin(GL_QUADS);

    glTexCoord2f(0, 0);

    glVertex2f(0, 0);

    glTexCoord2f(1, 0);

    glVertex2f(texture.GetWidth(), 0);

    glTexCoord2f(1, 1);

    glVertex2f(texture.GetWidth(), texture.GetHeight());

    glTexCoord2f(0, 1);

    glVertex2f(0, texture.GetHeight());

    glEnd();

    glDisable(GL_TEXTURE_2D);


  • Wait, is this crossplatform? I got a bit into this project, but then got worried this can't target windows, linux, android, mac etc.


  • error LNK2001 and fatal error LNK 1120 can you help me solve these error?(Edited) solved it.


  • Who here saw the ad for udemy.com? like if you did 😀


  • Hi,
    I don't want to disappreciate your work and proficiency on programming, but what you did by those huge codes was just putting a downloaded image on a green screen! It seems to create a really good game we need 100 times more than what you wrote. Although, why not changing your episode title?!


  • Could someone please explain me why i can't see the plane?? "Error loading image with path:AssetsArtBiplane.png"


  • NilsNils

    Author Reply

    Thank you very much. Your tutorial has helped me break a big scary barrier going from console applications to graphical applications!


  • BGivoBGivo

    Author Reply

    Thank you for this. Few quick questions below perhaps you or someone else can help answer 🙂

    1. Is the way you imported the package through NuGet preferred or just used it to speed things up?

    2. Is #pragma once not compiler-dependent and fully supported now? You mentioned windows only, which I have read is not true. Just wanted to be clear as you seemed certain about it.


  • 'using namespace std' in a header is highly un-recommended.


  • I pressed alt+tab roughly 9000 times


  • void Render() declaration in the Engine class says “void Engine::Render() function definition for ‘Render’ not found. Please help me


  • NuGet has soil in vs2017.
    I'm using SOIL-VC141.


  • in vs 2017, use const char* not char* !!!!!!!
    will get errors if you don't!


  • @Progrematic You very well may be the fastest typist I have ever seen. Mindblowingly impressive. @_@


  • Those finger clicks are making me hungry..lol


  • No errors, no warnings…no airplane… wtf?


  • Thanks bro! 🙂


  • You can also download SOIL with Manage NuGet packages. Just type in soil. Maybe this will help somebody if not just ignore it 🙂 Btw this is very nice tutorial.


  • i learned nothing from this video.


  • Is there any prerequisites or what I need to know before watching this video or any kind of recommendations on what I need to know or have an idea of first?


  • i have newly completed c++ suggest me some projects to become pro


  • ~30:00 i can't include Engine/Engine.h, help


  • for when you did engine.Initialize("Twitch!") it did not work for me and the solution was changing it in engine.h for char* windowTitle to const char* windowTitle


  • how much time do u spend using opengl t get this versatile in it?


  • You should ctrl++ a bit.


  • Can you type a little faster? XD


  • Could make those getters inline, though the compiler is usually smart enough to do that on it's own.


  • was pretty interesting for the first few mins until you started using OPENGL lol D2D1 OR DIRECTX is much much better


  • thank you, do you have any email so I can contact you? I do have some questions


  • Hi again. I haven't been able to use soil. I am therefore using STBI. I managed to apply textures to any geometry, but I am having trouble with png files. It seems that the transparency is not interpreted correctly, or not read at all. So, where the background in the airplane png image appears white, instead of transparent. I can't understand why. Any help would be extremely appreciated. Bye!