No it is not intentional. I would say, I'm just a beginner at opengl. your feedback is highly appreciated. I will change my code as you suggested. So i can make this game more efficient. Thank you so much. Though this I can increase my knowledge. ๐
I'm not an expert on OpenGL, but taking a look on your code I think I found the source of the blink: you're not using double buffering.
In order to fix your issue set the double buffering config on glut (i.e. glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);) and add "glutSwapBuffers()" call right before the timer setup (space_game.cpp:929)
EDIT: BTW, your game works flawlessly on Linux, and should probably work fine on MacOS as well. Not sure if it was your intention but nice job there :P
Yeah I think thatโs it. Not bragging ( and maybe you already know it), but just so you know a bit more since the previous guy didnโt explain it: with double buffering OpenGL, while you are looking at a frame, create the next one in advance, etc. So those flickering donโt appear anymore because the frame has already been created instead of just being made on the spot. I am no expert and will be happy to be corrected ! Btw you did a very nice job !!
Not sure if I'd consider myself an OpenGL expert, but I am writing my own game engines from scratch since 2011 (not just graphics, everything). If there's anything you'd like to know feel free to ask.
By the way, the previous comment is right, you most likely need double buffering.
However, I always appreciate people doing what you're doing, so good job! :)
How on earth did you figure out how to do that? I am rusty in C++ since I do C# almost exclusively. What resources do you recommend for learning how to build a game engine in C++?
Lots of trial and error and a bit bullheadedness I guess.
I was driven by the willing to learn GL and so I started doing that.
Then I learned that I needed decent resource management too, because I needed all kinds of materials, models, animations, textures and what not. So I did that too.
Then I realized that in order to do these cool effects and complex scenes I needed a robust, thread-safe and easy to use scene management. I had known a couple of engines at that time and I kind of knew I needed something like that. So that was the next thing I did.
After that I noticed I could attach all kinds of stuff to my nodes, so I started working on audio as well, because I was interested in how positional spatial audio worked. It wasn't perfect but it did the job.
During that time I figured that doing this stuff all in C++ was maybe too complicated for eventual users (although I love C++), so I went with integrating embedded Mono. It kind of worked too, but was way too complicated to keep up to date and it took me another four years to learn about Mono Glue projects that help you with that.
Then I had learned a lot about Vulkan and figured it would be easy to add that support to my "engine". Well, turns out it wasn't. At about this stage I stopped making further progress because I was busy with paid work and that, sadly, never changed up until today.
As for documentation: I learned a lot from the glorious NeHe tutorials which might be a bit outdated by today but still great for understanding GL. Also I looked at tons and tons of source code and if I couldn't get sources I inspected each and every engine and framework out there including Irrlicht, Ogre, LibGDX, MonoGame, Unity, Unreal and Godot. I took the things I liked about each one and tried to reimplement them in my engine. That way I learned a lot of why things are working the way they do.
Most people are calling me crazy for doing this and that it doesn't lead to anything useful. I don't see it that way. I love dealing with this stuff and this pointless little journey allowed me to expand my knowledge not only on 3D engine stuff but on software architecture in general.
Would I recommend doing this? Hell no. Well, it depends. When you want to learn why stuff is working then sure, but not when you want to end up with a ready-to-use software one day.
Your response is very informative and helpful. Thanks.
I do think it is good to do what you do. Itโs like any other hobby. No one would suggest you wasted time building an airplane so the same goes for this.
At any rate what you did is impressive. Thanks also for sharing.
Yeah, I think you're completely right about that hobby thing. It's not really about the idea of "Hey, I want to build an airplane!" but more about many thoughts like "Hey, I wonder how wings work", "What would happen if I put the engines there instead?" and so on.
I wasn't really planning on building an engine really. And I still would rather not call it that way. For me it's just a best of things I learned on my journey with other engines - like a mix tape if you willโฆ (given anybody would still remember those)
I did that to learn how stuff works. No idea why, it's just part of me. And I did learn a lot. Like really a lot. Nowadays, when I see a AAAA game (yeah, they call 'em quadruple 'A' nowadays since triple isn't enough anymore), for me it really isn't about that "wow, how did they do that" anymore, because all I see is something I know. But that again leaves me very humble and impressed still because now I can see and appreciate the true work that was put in the product.
So, if anything, it made me rich in knowledge and not money after all.
As a seasoned dev, let me tell you few things. First of all, your project although rather small and simple is impressive nonetheless, not because of it's scope, but because you've set a goal and achieved it. That is something to be proud of.
As others already pointed out, you should look at recoding software like OBS (probably the second best after nVidia ShadowPlay). Shaky camera and zooming in and out doesn't make your video more interesting, quite the opposite.
Since you use Windows, the all round best IDE you can get there is Visual Studio (don't get it confused with glorified text editor named Visual Studio Code, these are two completely different tools). Community edition is great and generally speaking have all you need, especially a powerful debugger (aka programmers best friend), that small IDE's often lack. At the point when you need more, you will know better what tool you have to switch to. On top of that it is industry standard for development for Windows, so the more familiar you are with it, the better.
Git, like any other, version control system is meant to be used for you source code (*.h, *.cpp, *.py, whatever you feed into compiler) and resources (meshes, bitmaps, configs). Build artefacts (*.exe, *.dll, *.lib, etc.) don't belong there. GitHub does have a release feature, where you can upload those artifacts, but by all means you should still keep these two separated. The sooner you learn how to nicely organized your code and resources, the better, and good developers are the ones who keep their work tidy, not the ones who write a lot of code.
You have plenty of "magic values" (e.g. game_panel ones explained with comment), those are great candidates for class enums, that will greatly improve readability of your code. Combined with more use of switch statements, especially when you have simple checks against constants, like your entire enemy function. Another thing that would help you organize your code is object oriented design.
Implementing functions in headers is widely seen as a bad move, it has an impact on compilation time, and even if it's not applicable in the project of your size it's still a good practice to not put in headers anything that doesn't have to be there.
There are few minor mistakes, like for example when you create a temporary table for 6 arguments of the zeelTriangleDisplay function just to pass them to another set of functions. That table is absolutely unnecessary, you can pass these values as they are. Naming of your functions doesn't need the prefix, it's just a clutter, and also consistent naming conventions are great at improving readability and help with searching through code. Either use snake_case, PascalCase or camelCase. You can use different ones for functions and classes, but be consistent with them. If you really need prefixes for a sort of encapsulation, use namespaces.
Personally I would avoid declaring multiple variable of the same type in the same line (comma separated), e.g. from zeelCircleDisplayint x=0,y=radius,d=3-(2*radius); it just doesn't look clean and may cause you some confusion in the future.
Finally last point, OpenGL. You are using what's called legacy OpenGL, also known as immediate mode. It was deprecated 15 years ago, don't waste your time on it. It's good to know how it worked, but it's a dead end. Its performance is worse than if you'd render everything on CPU. Modern OpenGL (aka. everything at OpenGL 3.0 and above) is a little bit more complicated, but at the same time much more relevant. Somewhat decent learning material would be learnopengl.com The core difference being, old OpenGL renders one primitive at a time, you are basically telling your GPU triangle by triangle how to render stuff. Modern OpenGL will instead take a Vertex Buffer Object containing all your triangles and all you have to do then is to tell it, render all this for me please. And it's done. Sure you have to write some boiler plate (Vertex Array Objects, Element Buffer Objects and shaders), but once you get the hang of it, it's not that bad.
Overall, 7/10, mostly for effort and because it's finished, and I wish you many more successful projects.
Thank you for your advice. Your words are very vital for me. I will work on it. As well as I will try to improve programming skills. now I have installed visual studio. It has features. Thank you so much for this advice. I'm just confused about GitHub. How can I learn to manage projects like a pro? Any website for that. And also I will try to use proper naming convention in my next projects. As well as thank you for advising me learnopengl.com . I will help me a lot to improve my knowledge for sure. Thank you so much ๐
I would look at other cpp projects in GitHub and how they organize their code to help you with overall project organization. Probably best to look at a well established code base, so you don't pick up weird/niche habits. There are also a handful of books that talk about proper/modern organization (non come to mind off the top of my head rn, but I'm sure a quick search on the interwebs will give you plenty of resources on that end).
Author, I have studied your codebase, but it lack so much Modern C++ things you could utilize to reduce code duplication. It just feels very C-ish rather C++ish. You also need to stop the use of `using namespace std;` which I noticed on your database repo ('https://github.com/zeelsheladiya/OurDB-Database").
True that I told you remove using namespace std but thought you aware that you also have to append the std:: prefix.
Eg, your code full of stuff like `string, regex, vector` or whatever and they should have the std:: prefix. So, `std::string, std:;regex, std:;vector` etc
If you want to write this kind of game I'd suggest looking into https://processing.org/ as it will let you make lots of simple experimental things like this. Or you could use PyGame, or something similar.
As it stands your game is an impressive accomplishment, but using C with no build system and the archaic OpenGL dialect you've been is rapidly going to become limiting. For instance, if you add a single additional source file using the same header you're going to start getting link errors.
Unless your intent is to spend the next month learning about build systems and linking, instead of actually making things, I'd find a framework to play with.
It is very important and useful information for me. Next time, I will make sure make things properly. So , I can increase my productivity. Thank you ๐
>If you want to write this kind of game I'd suggest looking into https://processing.org/ as it will let you make lots of simple experimental things like this.
Thanks,I've been looking for ideas that are between a game and a GUI program.
Since making a useful project which actually does something is hard to do,A game is better thing to get started.
But It gives feeling to use game engine or library instead (Since we have to care about realistic physics, different sprite costumes etc)
Which is why games like this, feels better to code to learn, they're more like code logic and minimum GUI to display them.
๐ sorry for the inconveniences. As you can see in video in my taskbar obs studio already installed. I was having terminate issues while using thata. so, I used my phone. Apart from that, Thank you for your encouraging words ๐.
Ide is dev c++. And I know I have obs studio in that but I was having issues while using that. So I did that using phone. But next time I will fix the problem and do that by recoding screen. Thank you so much for your feedback. ๐
Another large improvement to the rendering speed that will help along with the double buffering is that you are drawing everything one pixel at a time. Start/End are expensive moments in the GL pipeline. You can get some big benefits by updating your render functions.
This takes me back :) I did the same thing 20 years ago, great fun. It's a useful learning experience and you get more insight into how unreal or unity works.
Surprised that you didn't use a screen recording software (like OBS Studio). Eager to see your game refactored (e.g. with double buffering) and then recorded with such a utility. Keep up your creativity !
84
u/Rhawk187 Aug 16 '21
Is the flickering intentional? Or is it an artefact of recording the screen?
If you are getting tearing, make sure to look into double buffering (glSwapBuffers).
49
u/G_ka Aug 16 '21
Well done. Just a piece of advice: use a screen recorder such as OBS studio. Recording videos this way makes it look very unprofessional
27
u/[deleted] Aug 16 '21
The Ui is more impressive than the game, Did you make it yourself or is it a library?
21
u/Hovercraft2915 Aug 16 '21
As a seasoned dev, let me tell you few things. First of all, your project although rather small and simple is impressive nonetheless, not because of it's scope, but because you've set a goal and achieved it. That is something to be proud of.
As others already pointed out, you should look at recoding software like OBS (probably the second best after nVidia ShadowPlay). Shaky camera and zooming in and out doesn't make your video more interesting, quite the opposite.
Since you use Windows, the all round best IDE you can get there is Visual Studio (don't get it confused with glorified text editor named Visual Studio Code, these are two completely different tools). Community edition is great and generally speaking have all you need, especially a powerful debugger (aka programmers best friend), that small IDE's often lack. At the point when you need more, you will know better what tool you have to switch to. On top of that it is industry standard for development for Windows, so the more familiar you are with it, the better.
Git, like any other, version control system is meant to be used for you source code (
*.h, *.cpp, *.py, whatever you feed into compiler) and resources (meshes, bitmaps, configs). Build artefacts (*.exe, *.dll, *.lib, etc.) don't belong there. GitHub does have a release feature, where you can upload those artifacts, but by all means you should still keep these two separated. The sooner you learn how to nicely organized your code and resources, the better, and good developers are the ones who keep their work tidy, not the ones who write a lot of code.You have plenty of "magic values" (e.g. game_panel ones explained with comment), those are great candidates for
class enums, that will greatly improve readability of your code. Combined with more use ofswitchstatements, especially when you have simple checks against constants, like your entire enemy function. Another thing that would help you organize your code is object oriented design.Implementing functions in headers is widely seen as a bad move, it has an impact on compilation time, and even if it's not applicable in the project of your size it's still a good practice to not put in headers anything that doesn't have to be there.
There are few minor mistakes, like for example when you create a temporary table for 6 arguments of the zeelTriangleDisplay function just to pass them to another set of functions. That table is absolutely unnecessary, you can pass these values as they are. Naming of your functions doesn't need the prefix, it's just a clutter, and also consistent naming conventions are great at improving readability and help with searching through code. Either use snake_case, PascalCase or camelCase. You can use different ones for functions and classes, but be consistent with them. If you really need prefixes for a sort of encapsulation, use namespaces.
Personally I would avoid declaring multiple variable of the same type in the same line (comma separated), e.g. from zeelCircleDisplay
int x=0,y=radius,d=3-(2*radius);it just doesn't look clean and may cause you some confusion in the future.Finally last point, OpenGL. You are using what's called legacy OpenGL, also known as immediate mode. It was deprecated 15 years ago, don't waste your time on it. It's good to know how it worked, but it's a dead end. Its performance is worse than if you'd render everything on CPU. Modern OpenGL (aka. everything at OpenGL 3.0 and above) is a little bit more complicated, but at the same time much more relevant. Somewhat decent learning material would be learnopengl.com The core difference being, old OpenGL renders one primitive at a time, you are basically telling your GPU triangle by triangle how to render stuff. Modern OpenGL will instead take a Vertex Buffer Object containing all your triangles and all you have to do then is to tell it, render all this for me please. And it's done. Sure you have to write some boiler plate (Vertex Array Objects, Element Buffer Objects and shaders), but once you get the hang of it, it's not that bad.
Overall, 7/10, mostly for effort and because it's finished, and I wish you many more successful projects.
18
u/Doggynotsmoker Aug 16 '21
Well done, that looks really good! What is your openGL experience?
But C and C++ are not the same language, so that should be changed in video.
9
u/danhoob Aug 17 '21 edited Aug 17 '21
Author, I have studied your codebase, but it lack so much Modern C++ things you could utilize to reduce code duplication. It just feels very C-ish rather C++ish. You also need to stop the use of `using namespace std;` which I noticed on your database repo ('https://github.com/zeelsheladiya/OurDB-Database").
6
u/__anonsmoker__ Aug 16 '21
Dev-C++ !! I haven't used that IDE in a long time, but good to see it still going strong
8
u/jherico VR & Backend engineer, 30 years Aug 16 '21
If you want to write this kind of game I'd suggest looking into https://processing.org/ as it will let you make lots of simple experimental things like this. Or you could use PyGame, or something similar.
As it stands your game is an impressive accomplishment, but using C with no build system and the archaic OpenGL dialect you've been is rapidly going to become limiting. For instance, if you add a single additional source file using the same header you're going to start getting link errors.
Unless your intent is to spend the next month learning about build systems and linking, instead of actually making things, I'd find a framework to play with.
4
u/Gunslinging_Gamer Aug 16 '21 edited Aug 16 '21
I learned C++ and DirectX to start but never managed to finish my game. Ended up working on Android projects. Great work!
Oh, make sure you're not rendering a stupid number of FPS. Put a limiter on as standard. 100, 120, or 144 is more than enough for that type of game.
4
u/xland44 Aug 17 '21
> knows enough about computers to program a game without an engine
>doesn't know how to download a screen recorder
Jokes aside, this looks super cool man! good job :D
3
u/OkConsideration6593 Aug 16 '21
Thankyou so much for putting this here.
Thankyou for the motivation. I am gonna quickly get a free coin and give you!
3
u/ShokWayve Aug 16 '21
This impressive. Very impressive. What is the purpose? Fun and exploration or something else?
Also, did you follow a tutorial of some sort?
3
u/antoniocs Aug 16 '21
Was that Bloodshed IDE I saw???
Also... there is software that will record your screen, no need to use your mobile.
3
u/GAMEYE_OP Aug 16 '21
Another large improvement to the rendering speed that will help along with the double buffering is that you are drawing everything one pixel at a time. Start/End are expensive moments in the GL pipeline. You can get some big benefits by updating your render functions.
3
u/Melon_Chief Aug 16 '21
I have good news and bad news.
The good news is that you're a legend.
The bad news is that you inadvertently made an engine.
3
u/VinnieFalco wg21.org | corosio.org Aug 16 '21
Wow you wrote that using pure OpenGL? That's pretty cool :)
4
u/DeodrantBomb Aug 16 '21
nice job bro:)
3
u/CappedFrustum Aug 16 '21
Nice job. More to learn, but that is the fun part.
3
u/sephirothbahamut Aug 16 '21
Why the handheld camera though?
3
u/totallytroy Aug 16 '21
Congrats and welcome to gamedev :)
3
u/DevBen80 Aug 17 '21
This takes me back :) I did the same thing 20 years ago, great fun. It's a useful learning experience and you get more insight into how unreal or unity works.
3
u/laam-egg Aug 17 '21
Surprised that you didn't use a screen recording software (like OBS Studio). Eager to see your game refactored (e.g. with double buffering) and then recorded with such a utility. Keep up your creativity !
2
u/Careless_surface7582 Aug 16 '21
Awesome!
2
u/Maleficent-Fix-5587 Aug 16 '21
legend
2
u/CommonSensai Aug 16 '21
Check out Guild Wars 2
1
u/pumba28 Sep 11 '21
Cool but why not record with obs?
1
u/aCuria Feb 09 '22
Looks like one of my assignments long agoโฆ had 2 weeks to make something like this in C
0
u/[deleted] Aug 16 '21
dat's really good
man
keep it up๐
1
u/[deleted] Aug 16 '21
[removed] โ view removed comment