Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #1

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
BasedOnStyle: LLVM

IndentWidth: 3
TabWidth: 3
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 3
ContinuationIndentWidth: 3
ObjCBlockIndentWidth: 3
UseTab: ForContinuationAndIndentation
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
NamespaceIndentation: All

DerivePointerAlignment: false
PointerAlignment: Left

BreakBeforeBraces: Attach
BreakAfterJavaFieldAnnotations: true
BreakBeforeBinaryOperators: None

AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
#AllowShortEnumsOnASingleLine: true # this breaks things?
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false

AlignAfterOpenBracket: DontAlign
FixNamespaceComments: false
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/dep/")

add_subdirectory(dep)
add_subdirectory(engine)
add_subdirectory(engine)
22 changes: 10 additions & 12 deletions dep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ message(NOTICE "OPENGL_LIBRARY " ${OPENGL_LIBRARY})
message(NOTICE "OPENGL_LIBRARIES " ${OPENGL_LIBRARIES})
message(NOTICE "OPENGL_INCLUDE_DIR " ${OPENGL_INCLUDE_DIR})


# glew
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
message(NOTICE "GLEW_LIBRARIES " ${GLEW_LIBRARIES})
message(NOTICE "GLEW_INCLUDE_DIRS " ${GLEW_INCLUDE_DIRS})


# SDL
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
Expand All @@ -33,18 +31,18 @@ message(NOTICE "GLM_INCLUDE_DIRS " ${GLM_INCLUDE_DIRS})

# Libs
set(CE_LIBS
${OPENGL_LIBRARY}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES}
${OPENGL_LIBRARY}
${GLEW_LIBRARIES}
${SDL2_LIBRARIES}

PARENT_SCOPE
PARENT_SCOPE
)

#Include
set(CE_INCLUDES
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}
${GLM_INCLUDE_DIRS}
PARENT_SCOPE
)
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}
${GLM_INCLUDE_DIRS}
PARENT_SCOPE
)
20 changes: 10 additions & 10 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
set(NAME engine)

file(GLOB_RECURSE CE_SRC
"*.hpp"
"*.cpp"
"*.c"
"*.hpp"
"*.cpp"
"*.c"
)

add_executable(${NAME}
#WIN32
${CE_SRC})
#WIN32
${CE_SRC}
)

target_link_libraries(${NAME}
${CE_LIBS}
${CE_LIBS}
)

include_directories(${NAME}
${CMAKE_CURRENT_SOURCE_DIR}
${CE_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}
${CE_INCLUDES}
)


Expand All @@ -29,9 +30,8 @@ set_target_properties(
${NAME} PROPERTIES
VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${NAME}>"
)

add_test(
NAME run
COMMAND ${NAME}
WORKING_DIRECTORY "$<TARGET_FILE_DIR:${NAME}>"
)
)
14 changes: 5 additions & 9 deletions engine/ce_event_handler.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

#ifndef _CE_EVENT_HANDLER_H_
#define _CE_EVENT_HANDLER_H_
#pragma once

#include <SDL_events.h>

namespace ce {
class IEventHandler {
private:
public:
virtual void onEvent(SDL_Event& event)=0;
private:
public:
virtual void onEvent(SDL_Event& event) = 0;
};
}

#endif // _CE_EVENT_HANDLER_H_
}
7 changes: 2 additions & 5 deletions engine/ce_math.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#ifndef _CE_MATH_H_
#define _CE_MATH_H_
#pragma once

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#endif // _CE_MATH_H_
#include <glm/gtc/type_ptr.hpp>
6 changes: 3 additions & 3 deletions engine/ce_render_fundementals.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//#include <memory>
// #include <memory>

#include "rendering/mesh.h"
#include "rendering/shader.h"
#include "rendering/texture.h"
#include "rendering/vertex.h"
#include "rendering/mesh.h"
/*
#define PTR std::shared_ptr
#define PTR_CAST = dynamic_pointer_cast
#define OBJMAP(x) std::map<std::string,PTR<x>>
*/
*/
7 changes: 2 additions & 5 deletions engine/ce_rendering.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#ifndef _CE_GL_H_
#define _CE_RENDERING_H_
#pragma once

#include <GL/glew.h>
#include <SDL.h>

#endif // !_CE_GL_H_
#include <SDL.h>
19 changes: 5 additions & 14 deletions engine/core/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@

#include <ce_rendering.h>

float ce::Time::getTime()
{
return SDL_GetTicks()/1000.0f;
float ce::Time::getTime() {
return SDL_GetTicks() / 1000.0f;
}
ce::Time::Time():
m_last(getTime()),
m_now(0),
m_dt(0),
m_fps(0)
{}
ce::Time::Time() : m_last(getTime()), m_now(0), m_dt(0), m_fps(0) {}

ce::Time::~Time()
{
}
ce::Time::~Time() {}

void ce::Time::update()
{
void ce::Time::update() {
m_now = getTime();
m_dt = m_now - m_last;
m_fps = 1 / m_dt;
Expand Down
33 changes: 13 additions & 20 deletions engine/core/time.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
#ifndef _CE_TIME_H_
#define _CE_TIME_H_
#pragma once

namespace ce {
class Time
{
private:
float
m_now,
m_last,
m_dt,
m_fps;
class Time {
private:
float m_now, m_last, m_dt, m_fps;

float getTime();
public:
Time();
~Time();
float getTime();

void update();
public:
Time();
~Time();

float getDeltaTime() {return m_dt;}
float getFPS() {return m_fps;};
};
}
void update();

#endif // !_CE_TIME_H_
float getDeltaTime() { return m_dt; }
float getFPS() { return m_fps; };
};
}
35 changes: 18 additions & 17 deletions engine/core/tpnt_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@
* Tumpnt Logger
* Author: Cameron Trow <[email protected]>
* Source: https://github.com/Tumpnt/TumpntAudio/blob/master/src/core/ta_log.h
*
*
* Example Usage
*
*
* int main() {
* LOG_INFO("Hello World");
* return 0;
* }
*
*
* Output:
* [INFO][main.cpp:3|main]: Hello World
*
*
*/
#ifndef _TPNT_LOG_H_
#define _TPNT_LOG_H_
#pragma once

#include <stdio.h>
#include <cstring>
#include <stdio.h>
#include <string>

#define TPNT_LOGGER_STR(X) (std::string("")+X).c_str()
#define TPNT_LOGGER_STR(X) (std::string("") + X).c_str()
#define TPNT_LOGGER_FORMAT "[%s][%s:%d|%s]: %s\n"
#define TPNT_LOGGER_FILE strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__
#define TPNT_LOGGER_CONTEXT TPNT_LOGGER_FILE,__LINE__,__FUNCTION__
#define TPNT_LOG(L,X) printf(TPNT_LOGGER_FORMAT,TPNT_LOGGER_STR(L),TPNT_LOGGER_CONTEXT,TPNT_LOGGER_STR(X))
#define TPNT_LOGGER_FILE \
strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__
#define TPNT_LOGGER_CONTEXT TPNT_LOGGER_FILE, __LINE__, __FUNCTION__
#define TPNT_LOG(L, X) \
printf(TPNT_LOGGER_FORMAT, TPNT_LOGGER_STR(L), TPNT_LOGGER_CONTEXT, \
TPNT_LOGGER_STR(X))
#define TPNT_LOG_RESET "\033[0m"
#define TPNT_LOG_SUCCESS "\033[1;32m"
#define TPNT_LOG_WARN "\033[1;33m"
#define TPNT_LOG_ERROR "\033[1;31m"

#define LOG_INFO(X) TPNT_LOG("INFO",X)
#define LOG_WARN(X) TPNT_LOG(TPNT_LOG_WARN+"WARN"+TPNT_LOG_RESET,X)
#define LOG_ERROR(X) TPNT_LOG(TPNT_LOG_ERROR+"ERROR"+TPNT_LOG_RESET,X)
#define LOG_SUCCESS(X) TPNT_LOG(TPNT_LOG_SUCCESS+"SUCCESS"+TPNT_LOG_RESET,X)

#endif // _TPNT_LOG_H_
#define LOG_INFO(X) TPNT_LOG("INFO", X)
#define LOG_WARN(X) TPNT_LOG(TPNT_LOG_WARN + "WARN" + TPNT_LOG_RESET, X)
#define LOG_ERROR(X) TPNT_LOG(TPNT_LOG_ERROR + "ERROR" + TPNT_LOG_RESET, X)
#define LOG_SUCCESS(X) \
TPNT_LOG(TPNT_LOG_SUCCESS + "SUCCESS" + TPNT_LOG_RESET, X)
Loading