diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..32cc693 --- /dev/null +++ b/.clangd @@ -0,0 +1,3 @@ +CompileFlags: # Tweak the parse settings, example directory given to show format + Add: + - "--include-directory=../../src" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0f98b9b..cfe4395 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,12 @@ bin/ +lib/ CMakeFiles/ cmake_install.cmake CMakeCache.txt Makefile + +# Qt +.lupdate/ +*.pro.user* +CMakeLists.txt.user* +*_autogen/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index afb4dd9..5e36595 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required(VERSION 3.5.0) set(CMAKE_CXX_STANDARD 17) -project(GLTest VERSION 0.1.0) +project(openblocks VERSION 0.1.0) set(OpenGL_GL_PREFERENCE "GLVND") set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib ) find_package(OpenGL REQUIRED COMPONENTS OpenGL) @@ -30,6 +31,13 @@ find_package(ReactPhysics3D REQUIRED) file(MAKE_DIRECTORY bin) file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h") -add_executable(${PROJECT_NAME} ${SOURCES}) -set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "gltest") -target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} OpenGL::GL OpenGL::GLU glfw glm::glm assimp ReactPhysics3D::ReactPhysics3D) \ No newline at end of file +add_library(openblocks ${SOURCES}) +set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks") +target_link_libraries(openblocks ${SDL2_LIBRARIES} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} OpenGL::GL OpenGL::GLU glfw glm::glm assimp ReactPhysics3D::ReactPhysics3D) + +# add_executable(client "client/src/main.cpp" $) +# include_directories("src") +# target_link_libraries(client ${SDL2_LIBRARIES} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} OpenGL::GL OpenGL::GLU glfw glm::glm assimp ReactPhysics3D::ReactPhysics3D) + +add_subdirectory("client") +add_subdirectory("editor") \ No newline at end of file diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt new file mode 100644 index 0000000..c386b80 --- /dev/null +++ b/client/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_executable(client "src/main.cpp" $) +include_directories("../src") +target_link_libraries(client ${SDL2_LIBRARIES} ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} OpenGL::GL OpenGL::GLU glfw glm::glm assimp ReactPhysics3D::ReactPhysics3D) \ No newline at end of file diff --git a/src/main.cpp b/client/src/main.cpp similarity index 98% rename from src/main.cpp rename to client/src/main.cpp index 9b84822..68df237 100644 --- a/src/main.cpp +++ b/client/src/main.cpp @@ -29,7 +29,7 @@ int main() { glfwSetErrorCallback(errorCatcher); glfwInit(); - GLFWwindow *window = glfwCreateWindow(1200, 900, "GLTest", NULL, NULL); + GLFWwindow *window = glfwCreateWindow(1200, 900, "OpenBlocks Client ALPHA", NULL, NULL); glfwSetKeyCallback(window, keyCallback); glfwSetMouseButtonCallback(window, mouseButtonCallback); glfwSetCursorPosCallback(window, mouseCallback); diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt new file mode 100644 index 0000000..712367f --- /dev/null +++ b/editor/CMakeLists.txt @@ -0,0 +1,77 @@ +cmake_minimum_required(VERSION 3.16) + +project(editor VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) + +set(TS_FILES editor_en_US.ts) + +set(PROJECT_SOURCES + main.cpp + mainwindow.cpp + mainwindow.h + mainwindow.ui + ${TS_FILES} +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(editor + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET editor APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# ${CMAKE_CURRENT_SOURCE_DIR}/android) +# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation + + qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) +else() + if(ANDROID) + add_library(editor SHARED + ${PROJECT_SOURCES} + ) +# Define properties for Android with Qt 5 after find_package() calls as: +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() + add_executable(editor + ${PROJECT_SOURCES} + ) + endif() + + qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) +endif() + +target_link_libraries(editor PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) + +# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. +# If you are developing for iOS or macOS you should consider setting an +# explicit, fixed bundle identifier manually though. +if(${QT_VERSION} VERSION_LESS 6.1.0) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.qtbasic) +endif() +set_target_properties(editor PROPERTIES + ${BUNDLE_ID_OPTION} + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +include(GNUInstallDirs) +install(TARGETS editor + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(editor) +endif() diff --git a/editor/editor_en_US.ts b/editor/editor_en_US.ts new file mode 100644 index 0000000..e69de29 diff --git a/editor/main.cpp b/editor/main.cpp new file mode 100644 index 0000000..647e5d2 --- /dev/null +++ b/editor/main.cpp @@ -0,0 +1,15 @@ +#include "mainwindow.h" + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/editor/mainwindow.cpp b/editor/mainwindow.cpp new file mode 100644 index 0000000..372f69b --- /dev/null +++ b/editor/mainwindow.cpp @@ -0,0 +1,19 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" + +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} \ No newline at end of file diff --git a/editor/mainwindow.h b/editor/mainwindow.h new file mode 100644 index 0000000..f511371 --- /dev/null +++ b/editor/mainwindow.h @@ -0,0 +1,24 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { +class MainWindow; +} +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/editor/mainwindow.ui b/editor/mainwindow.ui new file mode 100644 index 0000000..1f44961 --- /dev/null +++ b/editor/mainwindow.ui @@ -0,0 +1,31 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + 0 + 0 + 800 + 30 + + + + + + + +