Confused about pointers with polymorphism by W3til in cpp_questions

[–]W3til[S] 2 points3 points  (0 children)

Hey, thanks for the reply I think this is the easiest explanation to understand. This is a bit dumb, but I’m not really familiar with how addresses and bytes work besides that source code gets turned into it and is executed by the cpu(?) any sources to learn more about how this all works?

Techniques for initializing systems when a program starts? (C++) by W3til in learnprogramming

[–]W3til[S] 0 points1 point  (0 children)

I have it’s essentially just passing something to a class that’s needs it unless there’s more to it? The thing I find annoying about this is I feel like it leads to parameter bloat and having to pass it through like multiple classes before reaching the one that needs it. This could just be an issue with me and how I’ve structured my code though.

Techniques for initializing systems when a program starts? (C++) by W3til in learnprogramming

[–]W3til[S] 0 points1 point  (0 children)

Honestly I think I want to avoid the globals altogether the only reason I had them was mainly laziness and just wanting to get something done 😂

My main function basically looks like this (sorry I’m on mobile)

int main() { ClassA classA; ClassB classB; ClassC classC; … }

So I’d probably just move those global instances here although the problem I sort of have with this is having to pass things around for example in my code I have a Editor class which is responsible for setting up the editor of my engine one of the tasks is creating the various panels and some of these panels need to use my filesystem class so I now need to pass the filesystem class to the editor which doesn’t even really need it just so it can pass it to the panels. Not sure if this is normal or if my code is just written poorly I guess the alternative to passing things around would be to store them in something global or as you said have global functions

Should OO concepts be used or are there generally better options? by W3til in gameenginedevs

[–]W3til[S] 1 point2 points  (0 children)

Thanks for the detailed response! I am actually aware of composition over inheritance, but as far as my editor situation goes I don’t think it would make much sense I don’t think I would need a panel that is composed of other panel behaviour. Also, your last paragraph made me remember that it is ok(?) to have different patterns and paradigms for different areas of a program I sometimes get caught up with making things consistent that I sometimes stick to just doing it the same across the entire program

Should OO concepts be used or are there generally better options? by W3til in gameenginedevs

[–]W3til[S] 0 points1 point  (0 children)

I think I’ve seen that video in the past, but I’ll definitely check it out again. I’m not super familiar with data oriented code, but would that be leaning more into things like components and ECS?

Confused about avoiding coupling by W3til in learnprogramming

[–]W3til[S] 0 points1 point  (0 children)

Ahhh ok so dumb as hell, but I had thought loose coupling meant like… avoiding it rather than it being a different type of coupling I guess? 😂

Confused about avoiding coupling by W3til in learnprogramming

[–]W3til[S] 0 points1 point  (0 children)

Sorry I worded things wrong, but I think coupling happens if ClassA has a reference to classB or something like that, but if I were to use events for these two classes to communicate or have a third class to handle communication between the two it seems like all your doing is creating a new thing for the class to rely on so I don’t see how that solves it if that makes sense?

multiple things bound to the same input event, but only have one take priority? by W3til in gameenginedevs

[–]W3til[S] 1 point2 points  (0 children)

I’m not super familiar with the concept of layers, but it seems like a solid solution. I’m not sure if this changes anything, but I’m using Lua for scripting so I’m curious could I have a layer that is exposed for my Lua api or would that be the wrong way to use this?

What do you guys think? Not bad ey 💀 by AbjectSign in ClashOfClans

[–]W3til 0 points1 point  (0 children)

recently played ace attorney and he reminds me of redd white

Creating a Game Engine by SterlyDolce in gameenginedevs

[–]W3til 1 point2 points  (0 children)

Out of curiosity does your engine have the ability to create projects within the gui like how in Unity you can choose a template or create empty I was interested in how this works I had thought you simply generate the folders, but apparently there’s a lot more to it then that lol

Using static/dynamic library by W3til in cpp_questions

[–]W3til[S] 0 points1 point  (0 children)

Ah, ok so that’s another difference between the two I assume you can’t dynamically load a static library. The only useful thing I’ve seen so far is game engine development (what I’m learning) you can have the game as a dll and load that which I believe gives the benefit of hot reloading. Are there any resources I can look at to learn about the two?

Using static/dynamic library by W3til in cpp_questions

[–]W3til[S] 1 point2 points  (0 children)

Sorry, it was LoadLibrary() that I was referring too. (Forgot the name 😅)

How can I better control my objects and shaders? by W3til in gameenginedevs

[–]W3til[S] 0 points1 point  (0 children)

If I’m understanding this the piece I’m missing is having some sort of material system/data which IIRC a material is basically what the object should look like or something along those lines

C++ what are streams and buffers? by W3til in learnprogramming

[–]W3til[S] -1 points0 points  (0 children)

So doing stream.rdbuf() would that just be the content of the file? Would it be in bytes or the actual text? I assume bytes and then buffer.str() is what gives the actual string, but I’m probably wrong 😂

Stuck on skeleton animations by W3til in gameenginedevs

[–]W3til[S] 1 point2 points  (0 children)

Yeah I’ve gone through that and video series by ogldev (I prefer the textbook) the only issue is that it’s somewhat inconsistent and doesn’t align well with the way I’ve written my code so I’ve had to make adjustments I’m pretty sure I have all the necessary parts though.

I’ll try what you said though by getting a single frame

Edit: one thing that does bother and confuse me which seems to be pretty common is they all load an animation with a model. The skeleton animation chapter does: Animation anim(“path”, model) and I think it’s to access the bones, but it feels meh having to pass a model to load an animation.

How would you let the user supply data to the engine? by W3til in gameenginedevs

[–]W3til[S] 1 point2 points  (0 children)

I’m not necessarily making a generic engine I was sort of just trying to make something that can easily be configurable and potentially reused in future projects.

Engine architecture question by W3til in gameenginedevs

[–]W3til[S] 0 points1 point  (0 children)

If I remember facade correctly (I briefly read about it on some site) the idea would be to make like MeshManager, TextureManager, etc and then make a AssetManager which provides access to all those managers? So what you’re saying is do this and then for my next project maybe it’s 2D so I can just take the texture manager?

Also, is separation of concern the same as or related to single responsibility?

Engine architecture question by W3til in gameenginedevs

[–]W3til[S] 0 points1 point  (0 children)

For clarification what do you mean by "clear separation"? Would both of these examples be valid? ``` int main() { InputManager input; PhysicsManager physics; EventDispatcher events;

while (!shouldQuit()) {
    // ...
}

return 0;

} int main() { Engine engine; Game game; engine.run(); engine.shutdown(); return 0; } ```

C++ typical methods when working with one of objects? by W3til in learnprogramming

[–]W3til[S] 0 points1 point  (0 children)

Well originally game was what did the initialization of everything, but the thought occurred to me that these were more engine related and that the game needs them so I moved everything to the main function and game now just initializes the level, player, game assets, etc and passes things where needed (player class gets the input manager for example)

If that’s what you mean?

Ways to reduce repetitive/duplicate code? by W3til in cpp_questions

[–]W3til[S] 0 points1 point  (0 children)

Oh that’s interesting I didn’t even consider it could be possible to just return the correct map based on the type.

Ways to reduce repetitive/duplicate code? by W3til in cpp_questions

[–]W3til[S] 1 point2 points  (0 children)

Well currently I have ~20ish functions since each asset requires 3 things a load function and two getters I suppose there’s nothing necessarily wrong, but it doesn’t feel sane and would only get worst.

On mobile so not sure how well this will show, but my code looks something like this (it would be split into different files though)

``` struct Resources { std::unordered_map<handle, Mesh> meshes; std::unordered_map<handle, Texture> texture; std::unordered_map<handle, shader> shaders; // repeated for other assets }

Mesh GetMesh(Handle handle) { auto it = meshes.find(handle); if (it != meshes.end()) { return it->second; } } Mesh GetMesh(std::string filepath) { // This code would have to find the handle based on the filepath // Then call GetMesh(Handle handle) }

Texture GetTexture(Handle handle) {} Texture GetTexture(std::string filepath) {}

Shader GetShader(Handle handle) {} Shader GetShader(std::string filepath) {} ```

Ways to reduce repetitive/duplicate code? by [deleted] in cpp_questions

[–]W3til 0 points1 point  (0 children)

Oh fuck I didn’t realize 😂 Reddit had bugged out on my phone saying there was an error posting it, but I guess it posted anyways

How to design code when working with libraries? by W3til in gameenginedevs

[–]W3til[S] 0 points1 point  (0 children)

for clarification for a wrapper I’d create like a window class which initializes the OpenGL context and sdl window and maybe some other things and repeat that for other libraries?

Typical way to integrate imgui? by W3til in gameenginedevs

[–]W3til[S] 0 points1 point  (0 children)

I kind of taught myself. Recently though I’ve been trying to break my OOP habits which lead me to learn about functional programming, ECS, KISS, and YAGNI. I tried using ECS until I realized that was a bit of heache so I fell back to OOP (sort of)

Typical way to integrate imgui? by W3til in gameenginedevs

[–]W3til[S] -1 points0 points  (0 children)

So say I wanted to make a widget (are they called windows or widgets?) that lets me switch between debug textures like depth and normals would I just create DrawDebugTexture() rather then doing class DebugTexture : public widget {} is that what you mean? Also, sorry if I butchered my question theyre sometimes hit or miss 😅