Cleaned up project and ajusted window interface

main
anulax1225 ago%!(EXTRA string=11 months)
parent e65aa30c31
commit d40fa774c1
  1. 10
      premake5.lua
  2. 2
      src/bakara.h
  3. 4
      src/bakara/core/application.h
  4. 2
      src/bakara/core/entry.cpp
  5. 2
      src/bakara/core/layer.h
  6. 2
      src/bakara/core/layer_stack.h
  7. 6
      src/bakara/core/window.h
  8. 2
      src/bakara/events/event.h
  9. 1
      src/bakara/events/window_event.h
  10. 8
      src/bakara/math/mathpch.h
  11. 3
      src/bakara/math/type.h
  12. 65
      src/bakara/tools/string_fmt.h
  13. 1
      src/bakarapch.cpp
  14. 2
      src/bakarapch.h
  15. 0
      src/platforms/glfw/glfw_window.cpp
  16. 11
      src/platforms/glfw/glfw_window.h

@ -6,6 +6,9 @@ project "bakara"
targetdir("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
objdir("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}")
pchheader "bakarapch.h"
pchsource "bakarapch.cpp"
files
{
"%{wks.location}/vendor/glm/glm/**.hpp",
@ -13,8 +16,11 @@ project "bakara"
"%{wks.location}/vendor/imgui/misc/cpp/imgui_stdlib.cpp",
"%{wks.location}/vendor/imgui/backends/imgui_impl_opengl3.cpp",
"%{wks.location}/vendor/imgui/backends/imgui_impl_glfw.cpp",
"src/**.h",
"src/**.cpp",
"src/bakara/**.h",
"src/bakara/**.cpp",
"src/platforms/**.h",
"src/platforms/**.cpp",
"src/*pch.*",
}
defines

@ -14,8 +14,6 @@ Plaform namespace doc
*/
namespace Bk::Plaform {}
#define BKMOD_ALL
#include <bakatools.h>
#include <bakara/math/type.h>
#include <bakara/io/io_codes.h>

@ -4,8 +4,8 @@
This file contains the main app abstraction.
*/
#include <bkpch.h>
#include <bakara/io/window.h>
#include <bakarapch.h>
#include <bakara/core/window.h>
#include <bakara/events/events.h>
#include <bakara/core/layer_stack.h>

@ -1,4 +1,4 @@
#include <bkpch.h>
#include <bakarapch.h>
#include "application.h"
/*! \file entry.cpp

@ -1,5 +1,5 @@
#pragma once
#include <bkpch.h>
#include <bakarapch.h>
#include <bakara/events/events.h>
namespace Bk {

@ -1,6 +1,6 @@
#pragma once
#include <bkpch.h>
#include <bakarapch.h>
#include "layer.h"
namespace Bk {

@ -5,7 +5,7 @@ This file contiens all the interfaces to create a window.
Implementation possible with GLFW, Win32, etc.
*/
#include <bkpch.h>
#include <bakarapch.h>
#include <bakara/events/event.h>
namespace Bk {
@ -89,7 +89,7 @@ namespace Bk {
Indicates if the window is opened
@return Open flag
*/
bool is_open() { return h_is_open; }
virtual bool is_open() = 0;
virtual void* get_native_window() = 0;
@ -99,7 +99,5 @@ namespace Bk {
@param props : Window information
*/
static Window* create_window(const WindowProps& props = WindowProps());
protected:
bool h_is_open; //!< indicaste if the window is opened or not
};
}

@ -1,7 +1,7 @@
#pragma once
#include <bakara/core/base.h>
#include <bkpch.h>
#include <bakarapch.h>
namespace Bk {
enum class EventType

@ -1,6 +1,5 @@
#pragma once
#include <bkpch.h>
#include "event.h"
namespace Bk {

@ -1,8 +0,0 @@
#pragma once
/*! \file mathpch.h
Precompiled headers communly used in math functionnalitys.
*/
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

@ -5,7 +5,8 @@ Math types alias file used to abstract math types and not depend on any library.
As long as it's implemented here.
*/
#include <bakara/math/mathpch.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace Bk
{

@ -1,65 +0,0 @@
#pragma once
/*! \file string_fmt.h
This file provides functions to do string formatting.
*/
#include <bkpch.h>
#include <type_traits>
#include <cctype>
namespace Bk::Tools {
inline void format_impl(std::stringstream& ss, const char* format) {
while (*format) {
if (*format == '%' && *++format != '%') // %% == % (not a format directive)
throw std::invalid_argument("not enough arguments !\n");
ss << *format++;
}
}
template <typename Arg, typename... Args>
void format_impl(std::stringstream& ss, const char* format, Arg arg, Args... args) {
while (*format) {
if (*format == '%' && *++format != '%') {
auto current_format_qualifier = *format;
switch(current_format_qualifier) {
case 'd' :
if (!std::is_integral<Arg>()) throw std::invalid_argument("%d introduces integral argument");
break;
case 'f' :
if (!std::is_floating_point<Arg>()) throw std::invalid_argument("%f introduces floating point argument");
break;
case 'b' :
if(arg) ss << "true";
else ss << "false";
return format_impl(ss, ++format, args...);
case 's' :
break;
// etc.
default:
throw std::invalid_argument("Not a standard format");
break;
}
// it's true you'd have to handle many more format qualifiers, but on a safer basis
ss << arg; // arg type is deduced
return format_impl(ss, ++format, args...); // one arg less
}
ss << *format++;
} // the format string is exhausted and we still have args : throw
throw std::invalid_argument("Too many arguments\n");
}
/*! \fn std::string Bk::Tools::format(const char* fmt, Args... args)
Formats a string, printf like. Accepts integers, floating point numbers, strings, booléen.
@param fmt : string to format
@param args : variable arguments to put in the string
@return String formatted
*/
template <typename... Args>
inline std::string format(const char* fmt, Args... args) {
std::stringstream ss;
format_impl(ss, fmt, args...);
return ss.str();
}
}

@ -0,0 +1 @@
#include "bakarapch.h"

@ -17,4 +17,4 @@ Precompiled headers communly used in bakara.
#include <exception>
#include <bakatools.h>
#include <bakara/math/type.h>
#include <bakara/math/type.h>

@ -1,6 +1,6 @@
#pragma once
#include <bkpch.h>
#include <bakara/io/window.h>
#include <bakarapch.h>
#include <bakara/core/window.h>
#include <bakara/events/events.h>
#include <mutex>
#include <GLFW/glfw3.h>
@ -25,8 +25,13 @@ namespace Bk::Plaform {
void open() override;
void* get_native_window() override { return p_window; }
/*! \fn Bk::Window::is_open
Indicates if the window is opened
@return Open flag
*/
bool is_open() override { return h_is_open; }
private:
bool h_is_open; //!< indicaste if the window is opened or not
GLFWwindow* p_window;
bool p_shutdown;
Loading…
Cancel
Save