A downloadable game for Windows

Warning to folks who want to download the OpenGL version. It doesn't really work. I'll update it with the fixed version soon!

Assignment Write Up:

  • Show a screenshot of your game running
    • Hey, look. A screenshot!
  • Explain how you made Graphics.cpp platform-independent:
    • To be honest, I was just a little bit annoyed about that we had to delete the Graphics.d3d.cpp and Graphics.gl.cpp files in creating our new Graphics.cpp file. If I could create some helpful functions that contained the platform-specific code in those files and then were called through non-platform-specific interfaces in Graphics.cpp, I think the code would have been very nice and seamless. I don't know, maybe I just liked the idea of being able to plug the platform-specific piece of Graphics.cpp onto the "main" piece of Graphics.cpp. If that made any sense. Anyway, I just created a Graphics-Utils file that held that information. I was reading through some of the other people's write ups after I did that and really liked the idea of having a "Device" namespace. In true programmer fashion, I'm just terrible at naming things.


      • What new interfaces did you have to create? Where did you decide to declare these interfaces?
        • I think I mostly answered this in my previous ramble, but I basically made a single interface that allowed for platform specific functions in Init, Draw and CleanUp that are called in each of the "main" graphics functions. Of course, if there's nothing platform specific to be done, then nothing happens.
      • Where did you define the platform-specific implementations for these interfaces?
        • In their own .d3d.cpp and .gl.cpp files. Successfully resisted the urge to use preprocessor directives.
  • Show us your code in the Graphics.cpp file that clears the back buffer color
    • Hey, more pictures!
  • Show a screenshot of your game with a clear color (i.e. background) other than black
    • I think that's already in the main image. I like teal.
  • Show code from your Graphics.cpp file that initializes an effect
    • Effects are initialized by passing in an EffectInitParams struct to the Initialize() method on the Effect object. The struct just contains the two string paths to the vertex shader and the fragment shader.
  • Tell us how much memory a single effect takes up in both platforms (use sizeof() with a debugger rather than guessing). Is there any way to make it smaller?
    • OpenGL took 16 bytes and Direct3D took 12 bytes. I'm not convinced it can really get smaller than this, but I think we could optimize memory by using the same Effect instance on multiple objects that use it instead of creating a new instance for each.
  • Show code from your Graphics.cpp file that initializes a 3D object
    • The geometry object is initialized in a similar way to the effects. We fill up a GeometryInitParams struct with the data we need and pass that to the Initialize() method on the geometry object. For this struct, we need the vertex data, the number of vertices, the index data and the number of indices.
  • Tell us how much memory a single object takes up in both platforms (use sizeof() with a debugger rather than guessing). Is there any way to make it smaller?
    • OpenGL took 28 bytes and Direct3D took 44 bytes. I'm suddenly not sure this is actually correct, but I'm pretty sure my code is right, so it must be?  I imagine that being able to combine Geometry objects with common vertices will help reduce the overall memory use of these objects.

Issues I ran into:

There are two major issues I haven't been able to fix.

1) The cVertexFormat manager seems to thing there's an asset that hasn't been released, but I can't find where it is. I'll keep searching, because it's probably just my sleep-addled brain being unable to find it. It's been a wild week.

2) Okay so this is super weird: the x86 build actually freezes on running, but only when you run the build on its own. While debugging, it works fine. This makes debugging the actual problem really hard because I literally can't find any issues using the debugger. I guess it's time to litter my code with log-output statements and keep checking the log file.

Download

Download
MyGame_x86_OpenGL.zip 161 kB
Download
MyGame_x64_Direct3D.zip 166 kB

Leave a comment

Log in with itch.io to leave a comment.