Format code

This commit is contained in:
MrLetsplay 2023-09-13 20:42:01 +02:00
parent d47eb8c943
commit 74367e5fb0
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
43 changed files with 365 additions and 360 deletions

View File

@ -1,11 +1,11 @@
#include "defaultplayercontroller.h"
#include "input.h"
#include "internal.h"
#include "internal/physics.h"
#include "internal/ui.h"
#include "noclipplayercontroller.h"
#include "ui.h"
#include "uielements.h"
#include "defaultplayercontroller.h"
#include "noclipplayercontroller.h"
#include "internal.h"
#include "internal/ui.h"
#include "internal/physics.h"
namespace kek::Defaults {
@ -118,8 +118,7 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
}
switch(Input::getCursorMode()) {
case GLFWCursorMode::CAPTURE:
{
case GLFWCursorMode::CAPTURE: {
float xoff = lastX - x;
float yoff = lastY - y;
@ -131,8 +130,7 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
break;
}
case GLFWCursorMode::FREE:
case GLFWCursorMode::HIDDEN:
{
case GLFWCursorMode::HIDDEN: {
doUIMouseHover(x, y);
break;
}
@ -144,19 +142,16 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
static void defaultMouseButtonCallback(GLFWwindow *window, int button, int action, int mods, void *data) {
switch(Input::getCursorMode()) {
case GLFWCursorMode::CAPTURE:
{
case GLFWCursorMode::CAPTURE: {
// TODO
break;
}
case GLFWCursorMode::FREE:
case GLFWCursorMode::HIDDEN:
{
case GLFWCursorMode::HIDDEN: {
switch(action) {
case GLFW_PRESS:
break;
case GLFW_RELEASE:
{
case GLFW_RELEASE: {
double x, y;
glfwGetCursorPos(window, &x, &y);
doUIMouseClick(x, y, (GLFWMouseButton) button);
@ -220,7 +215,6 @@ void init() {
}
void destroy() {
}
}

View File

@ -1,33 +1,33 @@
#include "engine.h"
#include <iostream>
#include <chrono>
#include <cstring>
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/gtc/type_ptr.hpp>
#include <chrono>
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image.h>
#include <stb_image_write.h>
#include "errordialog.h"
#include "objparser.h"
#include "resource.h"
#include "camera.h"
#include "constants.h"
#include "gameobject.h"
#include "scene.h"
#include "defaults.h"
#include "errordialog.h"
#include "gameobject.h"
#include "objparser.h"
#include "physics.h"
#include "resource.h"
#include "scene.h"
#include "ui.h"
#include "uielements.h"
#include "physics.h"
#include "internal.h"
#include "internal/ui.h"
#include "internal/input.h"
#include "internal/ui.h"
kek::KekData kek::kekData;
@ -228,23 +228,20 @@ int start() {
ShaderLight shLight;
memcpy(shLight.color, glm::value_ptr(light->color), sizeof(shLight.color));
switch(light->getType()) {
case LightType::POINT:
{
case LightType::POINT: {
PointLight *l = (PointLight *) light;
memcpy(&shLight.position, glm::value_ptr(l->getPosition()), sizeof(shLight.position));
memcpy(&shLight.attenuation, glm::value_ptr(glm::vec3(l->constant, l->linear, l->quadratic)), sizeof(shLight.attenuation));
numPointLights++;
break;
}
case LightType::DIRECTIONAL:
{
case LightType::DIRECTIONAL: {
DirectionalLight *l = (DirectionalLight *) light;
memcpy(&shLight.direction, glm::value_ptr(l->direction), sizeof(shLight.direction));
numDirectionalLights++;
break;
}
case LightType::SPOT:
{
case LightType::SPOT: {
SpotLight *l = (SpotLight *) light;
memcpy(&shLight.position, glm::value_ptr(l->getPosition()), sizeof(shLight.position));
memcpy(&shLight.direction, glm::value_ptr(l->direction), sizeof(shLight.direction));

View File

@ -1,7 +1,7 @@
#include "input.h"
#include <map>
#include <iostream>
#include <map>
#include "internal.h"
#include "internal/input.h"
@ -157,8 +157,7 @@ KeyboardCapture captureKeyboardInput(KeyCharCallback charCallback, KeyCallback k
id,
charCallback,
keyCallback,
uncaptureCallback
};
uncaptureCallback};
return id;
}
@ -169,8 +168,7 @@ bool uncaptureKeyboardInput(KeyboardCapture capture) {
KEK_INVALID_ID,
KeyCharCallback(),
KeyCallback(),
Callable()
};
Callable()};
return true;
}

View File

@ -1,7 +1,7 @@
#include <vector>
#include "light.h"
#include "constants.h"
#include "light.h"
namespace kek {
@ -10,29 +10,28 @@ Light::Light(glm::vec3 color) {
}
Light::~Light() {
}
PointLight::PointLight(glm::vec3 color, float constant, float linear, float quadratic): Light(color) {
PointLight::PointLight(glm::vec3 color, float constant, float linear, float quadratic)
: Light(color) {
this->constant = constant;
this->linear = linear;
this->quadratic = quadratic;
}
PointLight::~PointLight() {
}
LightType PointLight::getType() {
return LightType::POINT;
}
DirectionalLight::DirectionalLight(glm::vec3 color, glm::vec3 direction): Light(color) {
DirectionalLight::DirectionalLight(glm::vec3 color, glm::vec3 direction)
: Light(color) {
this->direction = direction;
}
DirectionalLight::~DirectionalLight() {
}
LightType DirectionalLight::getType() {
@ -43,7 +42,8 @@ void DirectionalLight::lookAt(glm::vec3 direction){
this->direction = direction;
}
SpotLight::SpotLight(glm::vec3 color, glm::vec3 direction, float constant, float linear, float quadratic, float innerCutoff, float outerCutoff): Light(color) {
SpotLight::SpotLight(glm::vec3 color, glm::vec3 direction, float constant, float linear, float quadratic, float innerCutoff, float outerCutoff)
: Light(color) {
this->direction = direction;
this->constant = constant;
this->linear = linear;
@ -53,7 +53,6 @@ SpotLight::SpotLight(glm::vec3 color, glm::vec3 direction, float constant, float
}
SpotLight::~SpotLight() {
}
LightType SpotLight::getType() {
@ -65,14 +64,19 @@ void SpotLight::lookAt(glm::vec3 direction) {
}
LightList::LightList() {
}
void LightList::add(Light *light) {
switch(light->getType()) {
case LightType::POINT: point.push_back((PointLight *) light); break;
case LightType::DIRECTIONAL: directional.push_back((DirectionalLight *) light); break;
case LightType::SPOT: spot.push_back((SpotLight *) light); break;
case LightType::POINT:
point.push_back((PointLight *) light);
break;
case LightType::DIRECTIONAL:
directional.push_back((DirectionalLight *) light);
break;
case LightType::SPOT:
spot.push_back((SpotLight *) light);
break;
}
}

View File

@ -3,8 +3,8 @@
#include "internal.h"
#include "internal/physics.h"
#include <glm/gtx/vector_angle.hpp>
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
#include <glm/gtx/vector_angle.hpp>
namespace kek {
@ -49,11 +49,9 @@ static bool checkPlayerGrounded(float groundDistance, float maxWalkAngle, const
}
DefaultPlayerController::DefaultPlayerController() {
}
DefaultPlayerController::~DefaultPlayerController() {
}
glm::vec3 DefaultPlayerController::move(glm::vec3 movement) {

View File

@ -5,11 +5,9 @@
namespace kek {
NoclipPlayerController::NoclipPlayerController() {
}
NoclipPlayerController::~NoclipPlayerController() {
}
glm::vec3 NoclipPlayerController::move(glm::vec3 movement) {

View File

@ -5,8 +5,8 @@
namespace kek {
Player::Player(): RotateableObject() {
Player::Player()
: RotateableObject() {
}
void Player::rotateTo(glm::quat rotation) {

View File

@ -3,7 +3,6 @@
namespace kek {
PlayerController::~PlayerController() {
}
}

View File

@ -5,8 +5,8 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <math.h>
#include <glm/gtx/matrix_decompose.hpp>
#include <math.h>
#include "object.h"
#include "utils.h"

View File

@ -1,15 +1,15 @@
#include "fonts.h"
#include <stb_image_write.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <glm/gtc/type_ptr.hpp>
#include <iostream>
#include <stb_image_write.h>
#include "shader.h"
#include "engine.h"
#include "constants.h"
#include "engine.h"
#include "internal.h"
#include "shader.h"
#include "unicode.h"
namespace kek {
@ -37,7 +37,8 @@ void TextObject::destroy() {
blocks.clear();
}
TextObject::TextObject(TextObject &&other): blocks(other.blocks) {
TextObject::TextObject(TextObject &&other)
: blocks(other.blocks) {
other.blocks.clear();
}
@ -79,8 +80,7 @@ struct RenderChar {
xPos + w, yPos, texR, texU,
xPos + w, yPos, texR, texU,
xPos, yPos + h, texL, texD,
xPos + w, yPos + h, texR, texD
};
xPos + w, yPos + h, texR, texD};
for(int i = 0; i < 24; i++) data[i] = coords[i];
}
};

View File

@ -1,7 +1,7 @@
#include "shader.h"
#include "types.h"
#include "resource.h"
#include "constants.h"
#include "resource.h"
#include "types.h"
#include <GL/glew.h>
@ -47,7 +47,8 @@ static GLuint compileShader(GLenum type, std::string path) {
if(!success) {
char log[512];
glGetShaderInfoLog(shaderID, 512, nullptr, log);
std::cout << "Failed to compile shader \"" << path << "\":\n" << log << std::endl;
std::cout << "Failed to compile shader \"" << path << "\":\n"
<< log << std::endl;
throw std::exception();
}
@ -76,7 +77,8 @@ static GLuint compileProgram(unsigned int n, GLenum *types, std::string *paths)
if(!success) {
char log[512];
glGetProgramInfoLog(id, 512, nullptr, log);
std::cout << "Failed to link program:\n" << log << std::endl;
std::cout << "Failed to link program:\n"
<< log << std::endl;
throw std::exception();
}

View File

@ -3,8 +3,8 @@
#include <stb_image.h>
#include <stb_image_write.h>
#include "resource.h"
#include "internal.h"
#include "resource.h"
namespace kek {

View File

@ -7,12 +7,12 @@
namespace kek {
UIElement::UIElement(UIValue x, UIValue y): x(x), y(y) {
UIElement::UIElement(UIValue x, UIValue y)
: x(x),
y(y) {
}
UIElement::~UIElement() {
}
// Returns the element's position relative to its parent in pixels

View File

@ -7,7 +7,8 @@
namespace kek {
TextElement::TextElement(UIValue x, UIValue y, Font *font): UIElement(x, y) {
TextElement::TextElement(UIValue x, UIValue y, Font *font)
: UIElement(x, y) {
this->text = new TextObject(font, "Text");
this->sizePixels = KEK_DEFAULT_FONT_SIZE_PIXELS;
this->color = Colors::WHITE;
@ -15,7 +16,8 @@ TextElement::TextElement(UIValue x, UIValue y, Font *font): UIElement(x, y) {
this->textBounds = TextBounds::SMALLEST;
}
TextElement::TextElement(UIValue x, UIValue y): TextElement(x, y, kekData.ui->defaultFont) {}
TextElement::TextElement(UIValue x, UIValue y)
: TextElement(x, y, kekData.ui->defaultFont) {}
TextElement::~TextElement() {
delete text;
@ -49,7 +51,6 @@ UIBounds TextElement::getBounds() {
default:
return offsetUIBounds(w, h, origin);
}
}
void TextElement::setText(std::string text) {
@ -84,12 +85,12 @@ void TextElement::draw(UIPoint screenPos, glm::mat4 projection) {
}
}
UIWindow::UIWindow(UIValue x, UIValue y): UIElement(x, y) {
UIWindow::UIWindow(UIValue x, UIValue y)
: UIElement(x, y) {
addChild(new TextElement(x, y));
}
UIWindow::~UIWindow() {
}
UIElementType UIWindow::getType() {
@ -97,19 +98,25 @@ UIElementType UIWindow::getType() {
}
void UIWindow::draw(UIPoint screenPos, glm::mat4 projection) {
}
static float rectangleVerts[] = {
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
1.0f, 0.0f,
0.0f, 0.0f,
0.0f, 1.0f,
0.0f,
1.0f,
1.0f,
1.0f,
1.0f,
0.0f,
1.0f,
0.0f,
0.0f,
0.0f,
0.0f,
1.0f,
};
RectangleElement::RectangleElement(UIValue x, UIValue y, UIValue w, UIValue h): UIElement(x, y) {
RectangleElement::RectangleElement(UIValue x, UIValue y, UIValue w, UIValue h)
: UIElement(x, y) {
this->w = w;
this->h = h;
color = Colors::BLACK;
@ -153,7 +160,8 @@ void RectangleElement::draw(UIPoint screenPos, glm::mat4 projection) {
glDrawArrays(GL_TRIANGLES, 0, 6);
}
ButtonElement::ButtonElement(UIValue x, UIValue y, UIValue w, UIValue h): RectangleElement(x, y, w, h) {
ButtonElement::ButtonElement(UIValue x, UIValue y, UIValue w, UIValue h)
: RectangleElement(x, y, w, h) {
clickable = true;
color = Colors::CYAN;

View File

@ -44,7 +44,8 @@ static void show(GtkMessageType type, GtkButtonsType buttons, const char *title,
gtk_dialog_run(GTK_DIALOG(d));
gtk_widget_destroy(w);
gtk_widget_destroy(d);
while(g_main_context_iteration(nullptr, false));
while(g_main_context_iteration(nullptr, false))
;
}
void showInfo(std::string message) {

View File

@ -1,12 +1,12 @@
#include "objparser.h"
#include <iostream>
#include <string>
#include <sstream>
#include <glm/glm.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include "types.h"
#include "resource.h"
#include "types.h"
namespace kek::ObjParser {

View File

@ -38,7 +38,6 @@ public:
glm::vec3 eulerAngles();
void applyEuler(glm::vec3 euler);
};
}

View File

@ -5,11 +5,17 @@ namespace kek {
struct Color {
float r, g, b, a;
constexpr Color(float r, float g, float b, float a): r(r), g(g), b(b), a(a) {}
constexpr Color(float r, float g, float b, float a)
: r(r),
g(g),
b(b),
a(a) {}
constexpr Color(float r, float g, float b): Color(r, g, b, 1.0) {}
constexpr Color(float r, float g, float b)
: Color(r, g, b, 1.0) {}
constexpr Color(): Color(0,0,0,1) {}
constexpr Color()
: Color(0, 0, 0, 1) {}
float *valuePointer() {
return &r;
@ -22,7 +28,6 @@ struct Color {
constexpr Color brighter(float factor = 0.7) const {
return Color(r / factor, g / factor, b / factor, a);
}
};
class Colors {

View File

@ -1,7 +1,7 @@
#pragma once
#include "playercontroller.h"
#include "input.h"
#include "playercontroller.h"
namespace kek {
@ -28,7 +28,6 @@ public:
virtual glm::vec3 move(glm::vec3 movement);
virtual void update();
};
}

View File

@ -4,8 +4,8 @@
#include FT_FREETYPE_H
#include <glm/glm.hpp>
#include <string>
#include <map>
#include <string>
#include "color.h"
#include "resource.h"
@ -102,7 +102,6 @@ private:
void allocateBuffer(TextBlock *block, int numChars);
void loadChars();
};
class Font {
@ -118,7 +117,6 @@ private:
std::map<unsigned int, CharacterBlock> characterBlocks;
public:
Font(std::string path);
~Font();
@ -153,7 +151,6 @@ public:
private:
CharacterBlock generateCharacterBlock(unsigned int block);
};
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "object.h"
#include "mesh.h"
#include "object.h"
#include "physics.h"
#include <BulletCollision/CollisionShapes/btCollisionShape.h>
@ -40,7 +40,6 @@ public:
virtual void moveTo(glm::vec3 position);
virtual glm::vec3 getPosition();
};
}

View File

@ -4,13 +4,13 @@
#include <memory>
#include <vector>
#include "input.h"
#include "camera.h"
#include "fonts.h"
#include "input.h"
#include "player.h"
#include "scene.h"
#include "texture.h"
#include "fonts.h"
#include "ui.h"
#include "player.h"
namespace kek {

View File

@ -1,5 +1,9 @@
#pragma once
#include <map>
#include "../input.h"
namespace kek {
struct ActiveKeyboardCapture {

View File

@ -1,7 +1,10 @@
#pragma once
#include <btBulletDynamicsCommon.h>
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <btBulletDynamicsCommon.h>
#include <glm/glm.hpp>
#include "../physics.h"
namespace kek {
@ -18,8 +21,8 @@ struct PlayerPhysicsObjectData: public PhysicsObjectData {
};
struct ClosestNotSelfConvexResultCallback: public btCollisionWorld::ConvexResultCallback {
ClosestNotSelfConvexResultCallback(const btVector3& convexFromWorld, const btVector3& convexToWorld, btCollisionObject *self) :
m_self(self),
ClosestNotSelfConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, btCollisionObject *self)
: m_self(self),
m_convexFromWorld(convexFromWorld),
m_convexToWorld(convexToWorld),
m_hitCollisionObject(0) {}

View File

@ -1,5 +1,7 @@
#pragma once
#include "../ui.h"
namespace kek {
struct UIData {

View File

@ -23,7 +23,6 @@ public:
virtual ~Light();
virtual LightType getType() = 0;
};
class PointLight: public Light, public DefaultObject {
@ -36,7 +35,6 @@ public:
~PointLight();
LightType getType();
};
class DirectionalLight: public Light {
@ -51,7 +49,6 @@ public:
LightType getType();
void lookAt(glm::vec3 direction);
};
class SpotLight: public Light, public DefaultObject {
@ -68,7 +65,6 @@ public:
LightType getType();
void lookAt(glm::vec3 direction);
};
class LightList {
@ -81,7 +77,6 @@ public:
LightList();
void add(Light *light);
};
}

View File

@ -1,10 +1,10 @@
#pragma once
#include <glm/glm.hpp>
#include <vector>
#include <cstdint>
#include <glm/glm.hpp>
#include <iostream>
#include <memory>
#include <vector>
#include "shader.h"
#include "texture.h"
@ -17,7 +17,6 @@ struct Vertex {
glm::vec2 texCoords;
Vertex(glm::vec3 pos, glm::vec3 normal, glm::vec2 texCoords);
};
struct Material {
@ -29,7 +28,6 @@ public:
float shininess;
Material(std::shared_ptr<Texture> ambient, std::shared_ptr<Texture> diffuse, std::shared_ptr<Texture> specular, float shininess);
};
class Mesh {
@ -46,7 +44,6 @@ public:
~Mesh();
void draw(Shader *shader);
};
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "playercontroller.h"
#include "input.h"
#include "playercontroller.h"
namespace kek {
@ -24,7 +24,6 @@ public:
virtual glm::vec3 move(glm::vec3 movement);
virtual void update();
};
}

View File

@ -21,7 +21,6 @@ public:
virtual void moveTo(glm::vec3 position) = 0;
virtual glm::vec3 getPosition() = 0;
};
class DefaultObject: public Object {
@ -39,7 +38,6 @@ public:
virtual void moveTo(glm::vec3 position);
virtual glm::vec3 getPosition();
};
class RotateableObject: public Object {
@ -56,7 +54,6 @@ public:
virtual void lookAtPos(glm::vec3 position);
virtual glm::quat getRotation() = 0;
};
class DefaultRotateableObject: public RotateableObject, public DefaultObject {
@ -82,7 +79,6 @@ public:
virtual void moveTo(glm::vec3 position) { DefaultObject::moveTo(position); };
virtual glm::vec3 getPosition() { return DefaultObject::getPosition(); };
};
}

View File

@ -2,8 +2,8 @@
#include <map>
#include "types.h"
#include "mesh.h"
#include "types.h"
namespace kek::ObjParser {

View File

@ -32,7 +32,6 @@ public:
virtual glm::vec3 getEyePosition() { return getPosition() + glm::vec3(0, KEK_PLAYER_EYE_OFFSET, 0); }
virtual glm::vec3 getFootPosition() { return getPosition() - glm::vec3(0, KEK_PLAYER_HEIGHT / 2, 0); };
};
}

View File

@ -11,7 +11,6 @@ public:
virtual glm::vec3 move(glm::vec3 movement) = 0;
virtual void update() = 0;
};
}

View File

@ -25,7 +25,6 @@ public:
// Draws the scene
void draw(Shader *shader);
};
}

View File

@ -1,13 +1,14 @@
#pragma once
#include <string>
#include <glm/glm.hpp>
#include <string>
#include "constants.h"
namespace kek {
#pragma pack(push, 1)
struct ShaderLight {
float color[3];
float pad;
@ -21,6 +22,7 @@ struct ShaderLight {
// float lightSpaceMatrix[16]; // mat4
float padding[2];
};
#pragma pack(pop)
// Lighting data for shader
@ -46,7 +48,6 @@ public:
void initLighting();
void use();
};
}

View File

@ -4,9 +4,9 @@
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <vector>
#include <string>
#include <memory>
#include <string>
#include <vector>
namespace kek {
@ -27,7 +27,6 @@ public:
static std::shared_ptr<Texture> load(std::string texturePath);
static std::shared_ptr<Texture> generateColor(glm::vec3 color);
};
}

View File

@ -1,9 +1,9 @@
#pragma once
#include <glm/glm.hpp>
#include <vector>
#include <cstdint>
#include <glm/glm.hpp>
#include <iostream>
#include <vector>
namespace kek {
@ -22,7 +22,6 @@ public:
~MemoryBuffer() {
free(buffer);
}
};
}

View File

@ -16,13 +16,20 @@ namespace kek {
struct UIPoint {
int x, y;
UIPoint(int x, int y): x(x), y(y) {}
UIPoint(int x, int y)
: x(x),
y(y) {}
};
struct UIBounds {
int x, y, w, h;
UIBounds(int x, int y, int w, int h): x(x), y(y), w(w), h(h) {}
UIBounds(int x, int y, int w, int h)
: x(x),
y(y),
w(w),
h(h) {}
inline bool contains(UIPoint pos) {
return pos.x > x && pos.y > y && pos.x < x + w && pos.y < y + h;
@ -115,7 +122,6 @@ struct UIValue {
constexpr friend UIValue operator-(const UIValue &lhs, const UIValue &rhs) {
return UIValue(lhs) -= rhs;
}
};
class UIElement {
@ -182,7 +188,6 @@ public:
virtual void dragEnter(UIPoint pos, UIPoint screenPos){};
virtual void drag(UIPoint pos, UIPoint screenPos){};
virtual void dragExit(UIPoint pos, UIPoint screenPos){};
};
namespace UI {

View File

@ -13,7 +13,6 @@ class UIWindow: public UIElement {
virtual UIElementType getType();
virtual void draw(UIPoint screenPos, glm::mat4 projection);
};
enum class TextMode {
@ -54,7 +53,6 @@ public:
std::string getText();
virtual void draw(UIPoint screenPos, glm::mat4 projection);
};
class RectangleElement: public UIElement {
@ -77,7 +75,6 @@ public:
virtual UIBounds getBounds();
virtual void draw(UIPoint screenPos, glm::mat4 projection);
};
class ButtonElement: public RectangleElement {
@ -97,7 +94,6 @@ public:
virtual void click(UIPoint pos, UIPoint screenPos, GLFWMouseButton button);
virtual void draw(UIPoint screenPos, glm::mat4 projection);
};
}

View File

@ -16,11 +16,17 @@ struct GenericCallable {
GenericFunction<Args..., void *> function;
void *data;
GenericCallable(): function(nullptr), data(nullptr) {}
GenericCallable()
: function(nullptr),
data(nullptr) {}
GenericCallable(GenericFunction<Args..., void *> function): function(function), data(nullptr) {};
GenericCallable(GenericFunction<Args..., void *> function)
: function(function),
data(nullptr){};
GenericCallable(GenericFunction<Args..., void *> function, void *data): function(function), data(data) {}
GenericCallable(GenericFunction<Args..., void *> function, void *data)
: function(function),
data(data) {}
void operator()(Args... args) {
if(function == nullptr) return;
@ -39,7 +45,12 @@ float clampCyclic(int value, int min, int max);
float clamp(int value, int min, int max);
enum class CubeFace {
FRONT, BACK, UP, DOWN, LEFT, RIGHT
FRONT,
BACK,
UP,
DOWN,
LEFT,
RIGHT
};
glm::vec3 faceNormal(CubeFace face);

View File

@ -17,21 +17,19 @@ static ButtonElement *button;
static KeyboardCapture capture = KEK_INVALID_ID;
void periodicCallback(GLFWwindow *window, void *data) {
}
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods, void *data) {
}
void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods, void *data) {
}
void onButtonClick(void *data) {
button->color = Colors::RED;
button->hoverColor = Colors::ORANGE;
capture = Input::captureKeyboardInput(KeyCharCallback([](GLFWwindow *window, unsigned int codepoint, void *data) {
capture = Input::captureKeyboardInput(
KeyCharCallback([](GLFWwindow *window, unsigned int codepoint, void *data) {
std::u32string str = Unicode::convertStdToU32(button->text->getText());
if(codepoint == KEK_INPUT_DELETE) {
str = str.substr(0, str.length() - 1);
@ -39,14 +37,19 @@ void onButtonClick(void *data) {
str.push_back(codepoint);
}
button->text->setText(Unicode::convertU32ToStd(str));
}, nullptr), KeyCallback([](GLFWwindow *window, int key, int scancode, int action, int mods, void *data) {
},
nullptr),
KeyCallback([](GLFWwindow *window, int key, int scancode, int action, int mods, void *data) {
if(key == GLFW_KEY_ENTER && action == GLFW_PRESS) {
Input::uncaptureKeyboardInput(capture);
}
}, nullptr), Callable([](void *data) {
},
nullptr),
Callable([](void *data) {
button->color = Colors::WHITE;
button->hoverColor = Colors::GRAY;
}, nullptr));
},
nullptr));
}
int main(int argc, char **argv) {