No video

Enjon: 3D/2D Game Engine, C++ / OpenGL DevLog #6

  Рет қаралды 4,078

John Jackson

John Jackson

Күн бұрын

Dev-logging my process of building an engine in C++ and OpenGL for the purposes of eventually making a hand-drawn 2D/3D Isometric Rogulike game.
Covered in this video:
- Finalized "Build Loop"
- Project Management
- GBuffer Optimizations
- Editor Transform Widgets
- SSAO Fixes
- Physics Subsystem
- New Component Creation
If you have any comments or questions, drop 'em below. Like and subscribe!

Пікірлер: 30
@nachocortizo3321
@nachocortizo3321 6 жыл бұрын
Looking good!
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Thanks!
@mash808
@mash808 6 жыл бұрын
Very nice
@johnjackson9767
@johnjackson9767 6 жыл бұрын
BaconNewdles Thanks!
@syntaxed2
@syntaxed2 6 жыл бұрын
I tried the pixel picking approach but the performance was horrible...not sure what the problem was. Your approach doesnt seem to suffer from same problem? Btw, how did you do the rotation widget? Are they quads with an alpha texture or are the circles actual geo?
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Reading back pixel information from the GPU is definitely a slow operation, but it shouldn't be too terrible. To speed things up, I make sure not to read from it every frame and only when I click the mouse while hovering over the scene view. Can you describe how you're doing it? Maybe there's something else that you're doing differently that could be causing the slowdown? This is more or less the approach I use: www.opengl-tutorial.org/miscellaneous/clicking-on-objects/picking-with-an-opengl-hack/ All the widgets have geometry and sit in world space - I just make sure to place them in a special rendering queue that renders them without depth so they sit on top of everything. I also blit them into the Gbuffer so that their object ids are present for mouse picking. Also, if you have video of your process I'd love to see it! I enjoy watching other people work on this stuff as well. P.S. Here's the code snippet I use to do the screen picking ( again, this only happens once a frame when I actually click the mouse in the scene, so it's not constantly reading from the framebuffer ): PickResult GraphicsSubsystem::GetPickedObjectResult( const iVec2& screenPosition ) { // Set pixel alignment for unpacking glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); mGbuffer->Bind( BindType::READ ); glReadBuffer( GL_COLOR_ATTACHMENT0 + ( u32 )GBufferTextureType::OBJECT_ID ); // Read at screen position and convert to color u8 data[ 4 ]; glReadPixels( screenPosition.x, GetViewport().y - screenPosition.y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, data ); ColorRGBA32 color( ( f32 )data[ 0 ] / 255.0f, ( f32 )data[ 1 ] / 255.0f, ( f32 )data[ 2 ] / 255.0f, ( f32 )data[ 3 ] / 255.0f ); // Get id from color u32 id = Renderable::ColorToID( color ); // Get the entity that this id corresponds to EntityManager* em = EngineSubsystem( EntityManager ); EntityHandle handle = em->GetRawEntity( id ); // Unbind buffer mGbuffer->Unbind( ); return PickResult { handle, id }; }
@syntaxed2
@syntaxed2 6 жыл бұрын
Good info, thanks mate! It was a while ago so I dont quite remember the process...but I def did something very wrong. At the moment Im just doing OBB+Triangle intersection tests for pickning but might give this another shot in the future!
@pajeetsingh
@pajeetsingh 3 жыл бұрын
Where is your full game?
@dmitrymetelitsa32
@dmitrymetelitsa32 6 жыл бұрын
Can you tell how do you create visual studio project for scripting?
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Black Wolf The editor loads in a .dll for the application currently loaded. Since this is a separate process, I can recompile it and reload it while the editor is running in another visual studio instance. When I create a new project, a new directory is created as well as a new cmake project which generates the visual studio solution from templates I've created.
@dmitrymetelitsa32
@dmitrymetelitsa32 6 жыл бұрын
Thank you very much
@bensam8358
@bensam8358 4 жыл бұрын
Absolutely incredible stuff! i was just wondering. From what you've explained, the editor derives from application and the game also derives from application. The editor loads the game and so the game becomes dependent on the editor. when you build the game, how does it become self-sustaining? is the entry point the same for both editor and game? and how does the win32 backend come into play?
@johnjackson9767
@johnjackson9767 4 жыл бұрын
Great question! For the backend, I'm using SDL2, so the platform layer is more or less handled via that. The editor loads the game via .dll and manages its lifetime while you're editing. When you do a final build, it spins up a process to compile your application code against the engine's library, so the editor is completely left out of that process. If you want to talk more, there's a link to my discord in the description.
@bensam8358
@bensam8358 4 жыл бұрын
@@johnjackson9767 Thanks! That was a surprisingly fast reply
@jonf9989
@jonf9989 5 жыл бұрын
Can i call you sensei?? Sensei teach meeee!!
@johnjackson9767
@johnjackson9767 5 жыл бұрын
jonF Feel free to drop into the Discord channel at any time to ask questions!
@HairyPixels
@HairyPixels 6 жыл бұрын
Hey John. If you remember I made a little demo on why I thought mapping 2D isometric sprites to quads in order to use the depth buffer wasn't going to work. Just last week I stumbled across the 3D solution and how it's actually possible to map the sprites to cubes and made a demo here (kzbin.info/www/bejne/jXzSmaKIh9yahZY). If you're interested look at the other video I made a far more complicated sorting buffer/masking 2D solution which I implemented before I found out the 3D way to handle it.
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Hairy Pixels Yeah, I remember! Glad you got it sorted out - I'll go watch it now!
@HairyPixels
@HairyPixels 6 жыл бұрын
Don't make the same mistake I did. :) I'd read the blog post I credit also since it's probably helpful. There's still merit to using the 2D approach but it's damn hard to justify unless you have very specific art requirements and don't need dynamic lighting or anything fancy with shaders.
@johnjackson9767
@johnjackson9767 6 жыл бұрын
I very much agree with this! I've moved towards a more general approach within my own engine ( which I'm sure is fairly obvious from my recent videos ), but I'd still like to have pipelines set up in the future to where game-specific rendering techniques can still be implemented.
@HairyPixels
@HairyPixels 6 жыл бұрын
Ironically on modern hardware doing 3D is now simpler than 2D. Since I'm making a 2D game I thought I'd avoid the complexity of learning 3D transformation, OpenGL, shaders etc... but that was clearly the wrong approach (2D was at least 10x more complicated). People knew this 10 years but I wasn't paying attention obviously.
@alexandrepv
@alexandrepv 6 жыл бұрын
Do you plan on open sourcing this?
@HomeGamesKiro
@HomeGamesKiro 6 жыл бұрын
How does the component mechanic works? Please
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Not sure exactly what you're asking, but if you want to know what components are then they're simply units of code that define properties and game logic that entities use which can be "attached" to and "detached" from an entity. Basically they're an integral part of how you create any game logic using entities.
@HomeGamesKiro
@HomeGamesKiro 6 жыл бұрын
John Jackson how does you game engine works? I see stuff compiled in real time.. and what are programming in vs? Are you using hot reloading? What is that ui?
@johnjackson9767
@johnjackson9767 6 жыл бұрын
The engine and editor are statically compiled. While the editor is running, it is able to load applications through .dlls and then run them. This allows me to be able to hot-reload c++ code by recompiling the .dll and then swapping it out at runtime. The UI is ImGUI, an immediate mode gui library. It's great for quickly prototyping so I'm using it for now as my editor ui. I'll most likely either swap it out for my own implementation or at least heavily abstract it around my own wrapper.
@HomeGamesKiro
@HomeGamesKiro 6 жыл бұрын
John Jackson ok thanks, that's exactly what I'm trying to do with my game engine :) but I'm building my own GUI because no one fits my needs. Good programming!
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Good luck!
@lachlanpage
@lachlanpage 6 жыл бұрын
Awesome stuff! Do you have an email address I could reach you at? Would love to ask you some questions
@johnjackson9767
@johnjackson9767 6 жыл бұрын
Lachlan Page Sure thing! My email is mrfrenik@gmail.com.
Writing a game the hard way - from scratch using C. #1
34:20
NCOT Technology
Рет қаралды 94 М.
Electromagnetic Aircraft Launcher
15:09
Tom Stanton
Рет қаралды 691 М.
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 5 МЛН
У ГОРДЕЯ ПОЖАР в ОФИСЕ!
01:01
Дима Гордей
Рет қаралды 4,5 МЛН
PEDRO PEDRO INSIDEOUT
00:10
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 24 МЛН
So you want to make a Game Engine!? (WATCH THIS before you start)
14:39
Giant Sloth Games
Рет қаралды 298 М.
Building the world's LARGEST iPhone
32:05
DIY Perks
Рет қаралды 256 М.
Header-Only Game Framework in C | Game Engineering
27:20
John Jackson
Рет қаралды 23 М.
What is the Smallest Possible .EXE?
17:57
Inkbox
Рет қаралды 381 М.
6 Horribly Common PCB Design Mistakes
10:40
Predictable Designs
Рет қаралды 193 М.
Writing a Poor Man's Reflection System in C99
44:01
John Jackson
Рет қаралды 11 М.
Gunslinger: C / Opengl Dev Stream - Wrapping Up
48:10
John Jackson
Рет қаралды 581
SOME UNIQUE C++ CODE! // Pacman Clone Code Review
26:42
The Cherno
Рет қаралды 272 М.
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 391 М.
Gunslinger: C / Opengl Christmas Stream - Header Only Game Engine
1:15:30
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 5 МЛН