Difference between revisions of "Chili Framework"
(→ChiliException) |
(→ChiliException) |
||
Line 24: | Line 24: | ||
=== ChiliException === | === ChiliException === | ||
− | The class <code>ChiliException</code> forms the basis for all exceptions that will be generated by the framework or the game code. <code>GraphicsException</code> and <code>WindowsException</code> are specific types that inherit from <code>ChiliException</code>. If you want to | + | The class <code>ChiliException</code> forms the basis for all exceptions that will be generated by the framework or the game code. <code>GraphicsException</code> and <code>WindowsException</code> are specific types that inherit from <code>ChiliException</code>. If you want to <code>throw</code> your own exceptions, you should inherit from <code>ChiliException</code>, but that's kind of an advanced topic, so don't sweat it broseph. |
== Other Bullshit Components == | == Other Bullshit Components == |
Revision as of 15:04, 5 July 2016
The Chili Framework is designed as a vehicle to make it fun and easy to learn C++ in a graphical context. It wraps a bunch of pain-in-the-ass WinAPI and Direct3D bullshit giving us direct access to the framebuffer for manipulating screen pixels. This allows us to explore basic graphical concepts at the same time that we are learning the fundamentals of the C++ language. Our research shows that this results in a 69% lower incidence of learners shitting themselves to death out of sheer boredom.
Contents
[hide]Core Classes
Game
The Game
class is where you put the code to make the game do the things. The predefined member functions UpdateModel()
and ComposeFrame()
are where you put your game logic and your rendering code, respectively. Game
is composed of the Graphics
object used for drawing and keeps a reference to the MainWindow
object to interface with the Windows system (which includes the keyboard and mouse inputs).
Graphics
- Main article: Graphics (Chili Framework)
This class take care of all the Direct3D setup bullshit and provides an interface to the graphical output of the application. Use Graphics
to draw on the screen, anything you like, even dicks (especially dicks). PutPixel()
is generally how this is gone about, although later on more sophisticated dick-drawing routines are created based on PutPixel()
. You can also use Graphics::ScreenWidth
etc. to make sure you keep your dicks inside the screen boundaries (color within the lines kiddies).
MainWindow
Takes care of creating the window and handling the window messages. The message handling involves piping the mouse and keyboard messages to their respective objects. In fact, MainWindow
has eaten Keyboard
and Mouse
alive, and now they live in its belly. So you need to through MainWindow
to get your input done, à la wnd.mouse.Read()
. You can also use this class to figure out whether the main window is minimized or if it's out of focus, and you can kill the fat bastard with wnd.Kill()
.
Keyboard
With Keyboard
, you can get the current state of depressed keys, and you can pop key press and release events out of an Event
queue contained in Keyboard
. You can also turn autorepeat on/off. Whopee. (Note: the kbd
object lives in MainWindow
's belly.)
Mouse
With Mouse
, you can get the current state of the mouse keys and the pointer position, and you can pop mouse events out of an Event
queue contained in Mouse
. You can also check whether the mouse is in the window client region. Whopee. (Note: lives in MainWindow
's belly.)
Color
Color
represents a 32-bit RGBA color value, and gives you member functions to access the (fudge) packed channels. There is also a Colors
namespace with predefined colors, like Colors::Aqua
(not to be confused with Aqua, the majestic Danish eurodance group).
ChiliException
The class ChiliException
forms the basis for all exceptions that will be generated by the framework or the game code. GraphicsException
and WindowsException
are specific types that inherit from ChiliException
. If you want to throw
your own exceptions, you should inherit from ChiliException
, but that's kind of an advanced topic, so don't sweat it broseph.
Other Bullshit Components
Main
The Main.cpp
file contains the function wWinMain()
, which is the entry point for the program (where the whole shebang starts). It creates the MainWindow
object, creates the Game
object, and then loops through processing windows messages and processing a game frame. There is also a bunch of exception catching code to catch any stray exceptions and display error codes via a message box.
DXErr
Some code by a guy at Microsoft that translates DirectX error codes into something with a little more je ne sais quoi. Licensing status not really clear.
ChiliWin
This file should be included in place of <Windows.h>. It includes <Windows.h>, but before doing so it defines some preprocessor switches which set the target minimum version of Windows (Vista) and cut some unused bullshit from the included Windows code, saving on compilation time. If you end up using some weird WinAPI bullshit, you might need to modify this file to re-enable that code (but it's probably not going to be an issue).
Framebuffer Shaders
Criticisms
Some people resent a proprietary framework being used in the tutorials. Fuck em.