Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Pelham committed Sep 7, 2024
2 parents 5c86164 + 1cfcdbc commit df3a549
Showing 1 changed file with 76 additions and 3 deletions.
79 changes: 76 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,84 @@ Creating native C++ GUI apps is cumbersome when all the mature options seem to l
<!-- USAGE EXAMPLES -->
## Usage and Examples

TODO: The library has yet to be implemented, but I do the README first for absolutely no reason.
Here is how you create the application entry point, this is optional and you can instead create an application instance yourself. [Check here](https://github.com/bonezone2001/prism/blob/master/include/prism/entry_point.h)
```cpp
#include "windows/main_window.h"
#include "prism/entry_point.h"

Prism::Application* Prism::AppCreate(int argc, char** argv)
{
Prism::Application* app = new Prism::Application("Prism App");
app->addWindow<MainWindow>();

return app;
}
```
For each window you create, simply create a class and override it's methods.
```cpp
#pragma once
#include "prism/prism.h"
class MainWindow : public Prism::Window
{
public:
MainWindow();
MainWindow(Prism::WindowSettings settings);
~MainWindow();
void onUpdate() override;
void onRender() override;
};
```

Here is an example implementation
```cpp
#include "main_window.h"

// Here is just a sample of a window that can be created with Prism.
MainWindow::MainWindow(int test)
: Prism::Window({
.width = 1000,
.height = 1000,
.title = "Prism Window",
.resizable = false,
.fullscreen = false,
.useCustomTitlebar = false,
.showOnCreate = true,
.parent = nullptr
}),
test(test)
{}

//
MainWindow::MainWindow(Prism::WindowSettings settings)
: Prism::Window(settings)
{}

MainWindow::~MainWindow()
{
// The deconstructor is called when the window is destroyed.
}

void MainWindow::onUpdate()
{
// Any code you want to run before rendering goes here.
}

void MainWindow::onRender()
{
// Any code related to rendering goes here.

ImGui::Begin("Test Window");
ImGui::Text("Test: %d", test);
ImGui::End();
}
```
Note: the constructor here is slightly different (a test number being passed for the sake of example)
<br>

<!-- CONTRIBUTING -->
## Contributing
Expand All @@ -73,4 +146,4 @@ Don't forget to give the project a star! Mwah!
<!-- LICENSE -->
## License
Distributed under the MIT License. See [LICENSE](https://github.com/bonezone2001/prism/blob/master/LICENSE) for more information.
Distributed under the MIT License. See [LICENSE](https://github.com/bonezone2001/prism/blob/master/LICENSE) for more information.

0 comments on commit df3a549

Please sign in to comment.