mirror of https://github.com/auygun/kaliber.git
Compare commits
1 Commits
0a78316bce
...
cfb819e3aa
Author | SHA1 | Date |
---|---|---|
Attila Uygun | cfb819e3aa |
|
@ -164,14 +164,6 @@ config("release") {
|
|||
}
|
||||
}
|
||||
|
||||
config("third_party_warnings") {
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
"/wd4242", # tmp:conversion from 'int' to 'uint8_t'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
config("warnings") {
|
||||
if (is_win) {
|
||||
cflags = [
|
||||
|
@ -195,50 +187,51 @@ config("warnings") {
|
|||
# switch specified.
|
||||
|
||||
# TODO: Not sure how I feel about these conversion warnings.
|
||||
"/Wv:18",
|
||||
"/wd4191", # 'type cast': unsafe conversion
|
||||
"/wd4244", # conversion, possible loss of data. 'int' to 'float'
|
||||
"/Wv:18", # tmp
|
||||
"/wd4191", # tmp:'type cast': unsafe conversion
|
||||
"/wd4242", # tmp:conversion from 'int' to 'uint8_t'
|
||||
"/wd4245", # tmp:conversion from 'int' to 'const unsigned int'
|
||||
# "/wd4267", # conversion, possible loss of data.
|
||||
"/wd4244", # conversion, possible loss of data. 'int' to 'float'
|
||||
"/wd4267", # conversion, possible loss of data.
|
||||
"/wd4305", # truncation from 'double' to 'float'.
|
||||
"/wd4365", # conversion, signed/unsigned mismatch.
|
||||
# "/wd5219", # conversion, possible loss of data. 'int' to 'float'
|
||||
"/wd5219", # conversion, possible loss of data. 'int' to 'float'
|
||||
|
||||
# Possible compiler bug? Needs investigation.
|
||||
"/wd4668", # '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor
|
||||
# macro, replacing with '0' for '#if/#elif'
|
||||
|
||||
# TODO:
|
||||
# "/wd4263", # member function does not override any base class virtual
|
||||
"/wd4263", # member function does not override any base class virtual
|
||||
# member function
|
||||
# "/wd4264", # no override available for virtual member function, function
|
||||
"/wd4264", # no override available for virtual member function, function
|
||||
# is hidden
|
||||
# "/wd4266", # no override available for virtual member function from base,
|
||||
"/wd4266", # no override available for virtual member function from base,
|
||||
# function is hidden
|
||||
# "/wd4355", # 'this' used in base member initializer list
|
||||
# "/wd4457", # declaration hides function parameter
|
||||
# "/wd4464", # relative include path contains '..'.
|
||||
"/wd4355", # 'this' used in base member initializer list
|
||||
"/wd4457", # declaration hides function parameter
|
||||
"/wd4464", # relative include path contains '..'.
|
||||
"/wd4625", # copy constructor was implicitly defined as deleted
|
||||
"/wd4626", # assignment operator was implicitly defined as deleted
|
||||
# "/wd4706", # assignment withing conditional expression.
|
||||
# "/wd4774", # format string expected in argument X is not a string literal
|
||||
# "/wd4828", # The file contains a character that is illegal in the current
|
||||
"/wd4706", # assignment withing conditional expression.
|
||||
"/wd4774", # format string expected in argument X is not a string literal
|
||||
"/wd4828", # The file contains a character that is illegal in the current
|
||||
# source character set
|
||||
# "/wd4946", # reinterpret_cast used between related
|
||||
# "/wd5026", # move constructor was implicitly defined as deleted
|
||||
# "/wd5027", # move assignment operator was implicitly defined as deleted
|
||||
# "/wd5039", # pointer or reference to potentially throwing function passed
|
||||
"/wd4946", # reinterpret_cast used between related
|
||||
"/wd5026", # move constructor was implicitly defined as deleted
|
||||
"/wd5027", # move assignment operator was implicitly defined as deleted
|
||||
"/wd5039", # pointer or reference to potentially throwing function passed
|
||||
# to 'extern "C"' function under -EHc. Undefined behavior may
|
||||
# occur if this function throws an exception.
|
||||
|
||||
# TODO: I don't understand these or how to fix them:
|
||||
# "/wd4458", # declaration hides class member
|
||||
"/wd4458", # declaration hides class member
|
||||
# [ GameObject::rtti ]
|
||||
# "/wd4582", # constructor is not implicitly called
|
||||
"/wd4582", # constructor is not implicitly called
|
||||
# [ intersection.h Contact ]
|
||||
# "/wd4623", # default constructor was implicitly defined as deleted
|
||||
"/wd4623", # default constructor was implicitly defined as deleted
|
||||
# [ intersection.h Contact ]
|
||||
# "/wd5243", # using incomplete class can cause potential one definition
|
||||
"/wd5243", # using incomplete class can cause potential one definition
|
||||
# rule violation due to ABI limitation
|
||||
]
|
||||
|
||||
|
|
|
@ -61,16 +61,11 @@ source_set("engine") {
|
|||
|
||||
libs = []
|
||||
|
||||
if (target_os == "linux" || target_os == "win") {
|
||||
sources += [
|
||||
"platform/asset_file_generic.cc",
|
||||
]
|
||||
}
|
||||
|
||||
if (target_os == "linux") {
|
||||
sources += [
|
||||
"audio/audio_sink_alsa.cc",
|
||||
"audio/audio_sink_alsa.h",
|
||||
"platform/asset_file_generic.cc",
|
||||
"platform/platform_linux.cc",
|
||||
"renderer/opengl/renderer_opengl_linux.cc",
|
||||
"renderer/vulkan/renderer_vulkan_linux.cc",
|
||||
|
@ -87,6 +82,7 @@ source_set("engine") {
|
|||
if (target_os == "win") {
|
||||
sources += [
|
||||
"audio/audio_sink_null.h",
|
||||
"platform/asset_file_generic.cc",
|
||||
"platform/platform_win.cc",
|
||||
"renderer/opengl/renderer_opengl_win.cc",
|
||||
"renderer/vulkan/renderer_vulkan_win.cc",
|
||||
|
@ -94,7 +90,6 @@ source_set("engine") {
|
|||
]
|
||||
|
||||
libs = [
|
||||
"gdi32.lib", # Graphics
|
||||
"user32.lib", # Win32 API core functionality.
|
||||
"opengl32.lib",
|
||||
]
|
||||
|
|
|
@ -12,7 +12,12 @@
|
|||
#include "third_party/texture_compressor/texture_compressor.h"
|
||||
|
||||
// Use aligned memory for SIMD in texture compressor.
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_MALLOC(sz) base::AlignedAlloc(sz, 16)
|
||||
#define STBI_REALLOC_SIZED(p, oldsz, newsz) \
|
||||
base::AlignedRealloc(p, oldsz, newsz, 16)
|
||||
#define STBI_FREE(p) base::AlignedFree(p)
|
||||
#include "third_party/stb/stb_image.h"
|
||||
|
||||
using namespace base;
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
#include <array>
|
||||
|
||||
#include "base/log.h"
|
||||
#define MINIMP3_ONLY_MP3
|
||||
#define MINIMP3_ONLY_SIMD
|
||||
#define MINIMP3_FLOAT_OUTPUT
|
||||
#define MINIMP3_NO_STDIO
|
||||
#define MINIMP3_IMPLEMENTATION
|
||||
#include "engine/engine.h"
|
||||
#include "engine/platform/asset_file.h"
|
||||
#include "third_party/minimp3/minimp3_ex.h"
|
||||
|
|
|
@ -27,7 +27,8 @@ AudioMixer::AudioMixer()
|
|||
audio_sink_{std::make_unique<AudioSinkAlsa>(this)} {
|
||||
#elif defined(_WIN32)
|
||||
// TODO: Implement AudioSinkWindows
|
||||
audio_sink_{std::make_unique<AudioSinkNull>()} {
|
||||
audio_sink_{std::make_unique<AudioSinkNull>()},
|
||||
audio_enabled_(false) {
|
||||
#endif
|
||||
bool res = audio_sink_->Initialize();
|
||||
CHECK(res) << "Failed to initialize audio sink.";
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#include "engine/platform/platform.h"
|
||||
|
||||
// #include <limits.h>
|
||||
// #include <stdio.h>
|
||||
// #include <cstring>
|
||||
// #include <memory>
|
||||
//
|
||||
#include "base/log.h"
|
||||
#include "base/vecmath.h"
|
||||
#include "engine/input_event.h"
|
||||
|
@ -117,32 +122,28 @@ LRESULT CALLBACK Platform::WndProc(HWND wnd,
|
|||
platform->observer_->OnWindowDestroyed();
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
case WM_ACTIVATEAPP:
|
||||
if (wparam == TRUE)
|
||||
platform->observer_->GainedFocus(false);
|
||||
else
|
||||
platform->observer_->LostFocus();
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
if (wparam == MK_LBUTTON) {
|
||||
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
|
||||
auto input_event =
|
||||
std::make_unique<InputEvent>(InputEvent::kDrag, 0, v);
|
||||
platform->observer_->AddInputEvent(std::move(input_event));
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE: {
|
||||
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
|
||||
auto input_event =
|
||||
std::make_unique<InputEvent>(InputEvent::kDrag, 0, v);
|
||||
platform->observer_->AddInputEvent(std::move(input_event));
|
||||
} break;
|
||||
|
||||
case WM_LBUTTONDOWN: {
|
||||
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
|
||||
auto input_event =
|
||||
std::make_unique<InputEvent>(InputEvent::kDragStart, 0, v);
|
||||
platform->observer_->AddInputEvent(std::move(input_event));
|
||||
} break;
|
||||
|
||||
case WM_LBUTTONUP: {
|
||||
Vector2f v(MAKEPOINTS(lparam).x, MAKEPOINTS(lparam).y);
|
||||
auto input_event =
|
||||
std::make_unique<InputEvent>(InputEvent::kDragEnd, 0, v);
|
||||
platform->observer_->AddInputEvent(std::move(input_event));
|
||||
} break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(wnd, message, wparam, lparam);
|
||||
}
|
||||
|
|
|
@ -7,20 +7,26 @@
|
|||
// do not.
|
||||
#include "third_party/android/gl3stub.h"
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#elif defined(__linux__)
|
||||
#include "third_party/glew/glew.h"
|
||||
#include "third_party/glew/glxew.h"
|
||||
#elif defined(_WIN32)
|
||||
#define GLEW_STATIC
|
||||
#include "third_party/glew/glew.h"
|
||||
#include "third_party/glew/wglew.h"
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(_WIN32)
|
||||
// Define the missing format for the etc1
|
||||
#ifndef GL_ETC1_RGB8_OES
|
||||
#define GL_ETC1_RGB8_OES 0x8D64
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32)
|
||||
#define GLEW_STATIC
|
||||
#include "third_party/glew/glew.h"
|
||||
#include "third_party/glew/wglew.h"
|
||||
|
||||
// Define the missing format for the etc1
|
||||
#ifndef GL_ETC1_RGB8_OES
|
||||
#define GL_ETC1_RGB8_OES 0x8D64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ENGINE_RENDERER_OPENGL_OPENGL_H
|
||||
|
|
|
@ -122,15 +122,11 @@ class RendererOpenGL final : public Renderer {
|
|||
int screen_height_ = 0;
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
ANativeWindow* window_ = nullptr;
|
||||
ANativeWindow* window_;
|
||||
#elif defined(__linux__)
|
||||
Display* display_ = NULL;
|
||||
Window window_ = 0;
|
||||
GLXContext glx_context_ = NULL;
|
||||
#elif defined(_WIN32)
|
||||
HWND wnd_ = nullptr;
|
||||
HDC dc_ = nullptr;
|
||||
HGLRC glrc_ = nullptr;
|
||||
#endif
|
||||
|
||||
bool InitCommon();
|
||||
|
|
|
@ -8,49 +8,6 @@ namespace eng {
|
|||
bool RendererOpenGL::Initialize(Platform* platform) {
|
||||
LOG(0) << "Initializing renderer.";
|
||||
|
||||
wnd_ = platform->GetWindow();
|
||||
dc_ = GetDC(wnd_);
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), 1,
|
||||
PFD_DRAW_TO_WINDOW | // format must support window
|
||||
PFD_SUPPORT_OPENGL | // format must support OpenGL
|
||||
PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
32, // color depth
|
||||
// Color bits ignored
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, // alpha buffer
|
||||
0, // shift bit ignored
|
||||
0, // no accumulation buffer
|
||||
// Accumulation bits ignored
|
||||
0, 0, 0, 0,
|
||||
24, // z-buffer
|
||||
0, // no stencil buffer
|
||||
0, // no auxiliary buffer
|
||||
PFD_MAIN_PLANE,
|
||||
0, // reserved
|
||||
// layer masks ignored
|
||||
0, 0, 0};
|
||||
int pf = ChoosePixelFormat(dc_, &pfd);
|
||||
if (pf == 0) {
|
||||
LOG(0) << "ChoosePixelFormat failed.";
|
||||
return false;
|
||||
}
|
||||
SetPixelFormat(dc_, pf, &pfd);
|
||||
|
||||
glrc_ = wglCreateContext(dc_);
|
||||
wglMakeCurrent(dc_, glrc_);
|
||||
|
||||
if (GLEW_OK != glewInit()) {
|
||||
LOG(0) << "Couldn't initialize OpenGL extension wrangler.";
|
||||
return false;
|
||||
}
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(platform->GetWindow(), &rect);
|
||||
OnWindowResized(rect.right, rect.bottom);
|
||||
|
||||
return InitCommon();
|
||||
}
|
||||
|
||||
|
@ -59,18 +16,9 @@ void RendererOpenGL::OnDestroy() {}
|
|||
void RendererOpenGL::Shutdown() {
|
||||
LOG(0) << "Shutting down renderer.";
|
||||
is_initialized_ = false;
|
||||
if (dc_ && glrc_) {
|
||||
wglMakeCurrent(nullptr, nullptr);
|
||||
wglDeleteContext(glrc_);
|
||||
ReleaseDC(wnd_, dc_);
|
||||
dc_ = nullptr;
|
||||
glrc_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void RendererOpenGL::Present() {
|
||||
SwapBuffers(dc_);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
active_shader_id_ = 0;
|
||||
active_texture_id_ = 0;
|
||||
fps_++;
|
||||
|
|
|
@ -59,11 +59,9 @@ source_set("third_party") {
|
|||
"glslang/glslang/MachineIndependent/reflection.cpp",
|
||||
"jsoncpp/json.h",
|
||||
"jsoncpp/jsoncpp.cpp",
|
||||
"minimp3/minimp3.cc",
|
||||
"minimp3/minimp3.h",
|
||||
"minimp3/minimp3_ex.h",
|
||||
"spirv-reflect/spirv_reflect.c",
|
||||
"stb/stb_image.cc",
|
||||
"stb/stb_image.h",
|
||||
"stb/stb_truetype.h",
|
||||
"texture_compressor/dxt_encoder.cc",
|
||||
|
@ -79,17 +77,12 @@ source_set("third_party") {
|
|||
"volk/volk.c",
|
||||
]
|
||||
|
||||
defines = [ "VMA_STATIC_VULKAN_FUNCTIONS=1", "GLEW_STATIC" ]
|
||||
|
||||
if (target_os == "linux" || target_os == "win") {
|
||||
sources += [
|
||||
"glew/glew.c",
|
||||
"glew/glew.h",
|
||||
]
|
||||
}
|
||||
defines = [ "VMA_STATIC_VULKAN_FUNCTIONS=1" ]
|
||||
|
||||
if (target_os == "linux") {
|
||||
sources += [
|
||||
"glew/glew.c",
|
||||
"glew/glew.h",
|
||||
"glew/glxew.h",
|
||||
"glslang/glslang/OSDependent/Unix/ossource.cpp",
|
||||
]
|
||||
|
@ -97,13 +90,14 @@ source_set("third_party") {
|
|||
|
||||
if (target_os == "win") {
|
||||
sources += [
|
||||
"glew/glew.c",
|
||||
"glew/glew.h",
|
||||
"glew/wglew.h",
|
||||
"glslang/glslang/OSDependent/Windows/ossource.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
configs -= [ "//build:warnings" ]
|
||||
configs += [ "//build:third_party_warnings" ]
|
||||
|
||||
deps = []
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#define MINIMP3_ONLY_MP3
|
||||
#define MINIMP3_ONLY_SIMD
|
||||
#define MINIMP3_FLOAT_OUTPUT
|
||||
#define MINIMP3_NO_STDIO
|
||||
#define MINIMP3_IMPLEMENTATION
|
||||
#include "third_party/minimp3/minimp3_ex.h"
|
|
@ -1,10 +0,0 @@
|
|||
#include "base/mem.h"
|
||||
|
||||
// Use aligned memory for SIMD in texture compressor.
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_MALLOC(sz) base::AlignedAlloc(sz, 16)
|
||||
#define STBI_REALLOC_SIZED(p, oldsz, newsz) \
|
||||
base::AlignedRealloc(p, oldsz, newsz, 16)
|
||||
#define STBI_FREE(p) base::AlignedFree(p)
|
||||
#include "third_party/stb/stb_image.h"
|
Loading…
Reference in New Issue