Jump to content

Era

Developers
  • Posts

    32
  • Joined

Posts posted by Era

  1. So while playing with this some more it seems that VS2017 can only do debug builds due to a bug on how it defines CMAKE_BUILD_TYPE.

     

     

    EDIT:

     

    Found a work around. Under the "cmake->change cmake settings" menu click any option and replace the file with this:

     

    {
       // See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
       "configurations": [
        {
        "name": "x86-Debug",
        "generator": "Visual Studio 15 2017",
        "configurationType" : "Debug",
        "buildRoot":  "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
        "cmakeCommandArgs":  "-DCMAKE_BUILD_TYPE=Debug",
        "buildCommandArgs": "-m -v:minimal"
        },
      {
        "name": "x86-Release",
        "generator": "Visual Studio 15 2017",
        "configurationType": "Release",
        "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
        "cmakeCommandArgs": "-DCMAKE_BUILD_TYPE=Release",
        "buildCommandArgs": "-m -v:minimal"
      },
      {
        "name": "x64-Debug",
        "generator": "Visual Studio 15 2017 Win64",
        "configurationType": "Debug",
        "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
        "cmakeCommandArgs": "-DCMAKE_BUILD_TYPE=Debug",
        "buildCommandArgs": "-m -v:minimal"
      },
      {
        "name": "x64-Release",
        "generator": "Visual Studio 15 2017 Win64",
        "configurationType": "Release",
        "buildRoot": "${env.LOCALAPPDATA}\\CMakeBuild\\${workspaceHash}\\build\\${name}",
        "cmakeCommandArgs": "-DCMAKE_BUILD_TYPE=Release",
        "buildCommandArgs": "-m -v:minimal"
      }
       ]
    }
    

     

    The only thing changed is the cmakeCommandArgs where we pass in the correct way to define the build type.

  2. With VS2017 supporting CMake files, and my none love for Code::Blocks I have written a CMake file that works on both Linux and Windows.(I have not tested the $ENV{HOME} yet, I had that hard coded).

     

    There is one issue I know of where VS2017 does not seem to obey the CMAKE_RUNTIME_OUTPUT_DIRECTORY line and puts the binaries in a folder called Debug or Release in side your project directoy. You can safely move them out to the top level.

     

    cmake_minimum_required (VERSION 2.8.11)
    project (Demo)
    
    if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(LEADWERKS_PATH "$ENV{HOME}/.steam/steam/steamapps/common/Leadwerks")
    else (CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(LEADWERKS_PATH "c:/Program Files (x86)/Steam/steamapps/common/Leadwerks")
    endif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
    
    set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "" FORCE)
    
    set(SOURCE
       Source/App.cpp
       Source/main.cpp
    )
    
    set(HEADERS
       Source/App.h
    )
    
    FILE(GLOB_RECURSE LUAFiles "Scripts/*.lua")
    add_custom_target(Scripts SOURCES ${LUAFiles})
    
    FILE(GLOB_RECURSE ShaderFiles "Shaders/*.shader")
    add_custom_target(Shaders SOURCES ${ShaderFiles})
    
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/)
    
    include_directories(after
       Source
       ${LEADWERKS_PATH}/Include/Libraries/VA
       ${LEADWERKS_PATH}/Include/Libraries/VHACD/src/VHACD_Lib/inc
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/coreLibrary_300/source/core
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/coreLibrary_300/source/meshUtil
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/coreLibrary_300/source/newton
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/coreLibrary_300/source/physics
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/packages/dMath
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/packages/dContainers
       ${LEADWERKS_PATH}/Include/Libraries/NewtonDynamics/packages/dCustomJoints
       ${LEADWERKS_PATH}/Include/Libraries/tolua++-1.0.93/include
       ${LEADWERKS_PATH}/Include/Libraries/lua-5.1.4
       ${LEADWERKS_PATH}/Include/Libraries/freetype-2.4.7/include
       ${LEADWERKS_PATH}/Include/Libraries/enet-1.3.1/include
       ${LEADWERKS_PATH}/Include/Libraries/RecastNavigation/DebugUtils/Include
       ${LEADWERKS_PATH}/Include/Libraries/RecastNavigation/Detour/Include
       ${LEADWERKS_PATH}/Include/Libraries/RecastNavigation/DetourCrowd/Include
       ${LEADWERKS_PATH}/Include/Libraries/RecastNavigation/DetourTileCache/Include
       ${LEADWERKS_PATH}/Include/Libraries/RecastNavigation/Recast/Include
       ${LEADWERKS_PATH}/Include/
       ${LEADWERKS_PATH}/Include/Libraries/zlib-1.2.5
       ${LEADWERKS_PATH}/Include/Libraries/zlib-1.2.5/contrib/minizip
       ${LEADWERKS_PATH}/Include/Libraries/freetype-2.4.7/include/freetype
       ${LEADWERKS_PATH}/Include/Libraries/freetype-2.4.7/include/freetype/config
       ${LEADWERKS_PATH}/Include/Libraries/LuaJIT/dynasm
       ${LEADWERKS_PATH}/Include/Libraries/glew-1.6.0/include
    )
    
    if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fexceptions -msse3 -DDG_DISABLE_ASSERT")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DZLIB -DPLATFORM_LINUX -D_NEWTON_STATIC_LIB -DFT2_BUILD_LIBRARY")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOPENGL -Dunix -D__STEAM__ -D_POSIX_VER -D_POSIX_VER_64")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDG_THREAD_EMULATION -D_STATICLIB -DDG_USE_THREAD_EMULATION")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGL_GLEXT_PROTOTYPES -DLEADWERKS_3_1 -D_GLIBCXX_USE_CXX11_ABI=0")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLUA_USE_LINUX -D_CUSTOM_JOINTS_STATIC_LIB")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable")
    
       if (CMAKE_BUILD_TYPE STREQUAL "Release")
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -O2")
        set (LEADWERKS_LIB ${LEADWERKS_PATH}/Library/Linux/Release/Leadwerks.a)
        set (BIN_NAME ${PROJECT_NAME})
       else(CMAKE_BUILD_TYPE STREQUAL "Release")
        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DDEBUG -D_DEBUG")
        set (LEADWERKS_LIB ${LEADWERKS_PATH}/Library/Linux/Debug/Leadwerks.a)
        set (BIN_NAME ${PROJECT_NAME}.debug)
       endif(CMAKE_BUILD_TYPE STREQUAL "Release")
       set (LIBS
        ${LEADWERKS_LIB} dl openal GL GLU
        ${LEADWERKS_PATH}/Library/Linux/libluajit.a
        ${CMAKE_CURRENT_SOURCE_DIR}/libsteam_api.so
        X11 Xext Xrender Xft pthread
       )
    elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DPSAPI_VERSION=1 /D__STEAM__ /D_CUSTOM_JOINTS_STATIC_LIB")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DFT2_BUILD_LIBRARY /DLEADWERKS_3_1 /DDG_DISABLE_ASSERT")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWINDOWS /DWIN32 /DOS_WINDOWS /DOPENGL /DPLATFORM_WINDOWS")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_WIN_32_VER /D_NEWTON_USE_LIB /DPTW32_STATIC_LIB /DPTW32_BUILD")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_NEWTON_STATIC_LIB /D_LIB /DDG_USE_NORMAL_PRIORITY_THREAD")
       set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DGLEW_STATIC /D_STATICLIB /D \"SLB_LIBRARY\" /MP")
       set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /DDEBUG /D_DEBUG")
       set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
    
       set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT.lib /NODEFAULTLIB:MSVCRTD.lib")
       include_directories(after
        ${LEADWERKS_PATH}/Include/Libraries/openssl/include
        ${LEADWERKS_PATH}/Include/Libraries/glslang
       )
       link_directories(${LEADWERKS_PATH}/Library/Windows/x86)
       message("Build Type: ${CMAKE_BUILD_TYPE}")
       if (CMAKE_BUILD_TYPE STREQUAL "Release")
        message("Building Win32 Release build")
        link_directories(${LEADWERKS_PATH}/Library/Windows/x86/Release)
        set (BIN_NAME ${PROJECT_NAME})
       else()
        message("Building Win32 Debug build")
        link_directories(${LEADWERKS_PATH}/Library/Windows/x86/Debug)
        set (BIN_NAME ${PROJECT_NAME}.debug)
       endif()
       set (LIBS
        libcryptoMT.lib libsslMT.lib Rpcrt4.lib crypt32.lib
        libcurl.lib msimg32.lib lua51.lib steam_api.lib
        ws2_32.lib Glu32.lib libovrd.lib OpenGL32.lib
        winmm.lib Psapi.lib OpenAL32.lib Leadwerks.lib
       )
    endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    
    add_executable (${BIN_NAME} ${SOURCE} ${HEADERS})
    target_link_libraries(${BIN_NAME} ${LIBS})
    
    
    

     

    EDIT: Minor changes to help clean it up some. Also tested the $ENV{HOME} and it does indeed work.

    EDIT2: Added a file glob for shaders and scripts so if you are using an ide like qt-creator they will show up in the project view.

    • Upvote 1
  3. Hey,

     

    I have a 5.5TB partition(raid: /dev/md124p1 5.5T 168G 5.3T 3% /home) which when I try to start leadwerks from it, be it the updater or the actual engine it spits out an error about unable to create file or directory.

     

    I worked around this by creating /opt/Leadwerks/{Engine,Projects} and bind mounting them there I expect them to be(~/Applications/Leadwerks and ~/Documents/Leadwerks) and that works just fine.

  4. Well it is strange that you get 2 for right mouse button. Because here on Ubuntu 14.04 with a Steelseries Kana mouse I set up this enum for mouse buttons and it is displaying the proper mapping

     

    namespace MouseButtons
    {
    enum Buttons {
    Left = 1,
    Middle,
    Right
    };
    }
    

     

    I am testing it with this

     

    {
    // Debugging
    if (window->MouseHit(MouseButtons::Left)) {
     std::cout << "LeftButton pressed." << std::endl;
    }
    if (window->MouseHit(MouseButtons::Middle)) {
     std::cout << "MiddleButton pressed." << std::endl;
    }
    if (window->MouseHit(MouseButtons::Right)) {
     std::cout << "RightButton pressed." << std::endl;
    }
    }
    

     

    EDIT:

     

    Ahh, in X11 The mouse buttons are Left =1, Middle = 2, and Right = 3 and in Leadwerks they are not accounting for it.

  5. I have the following code in App::Start()

     

    
     std::cout << "Left Button: " << Key::LButton << std::endl;
     std::cout << "Middle Button: " << Key::MButton << std::endl;
     std::cout << "Right Button: " << Key::RButton << std::endl;
    
    

     

    It outputs the following:

    Left Button: 1
    Middle Button: 4
    Right Button: 2

     

    Middle button should be 2 and right button should be 3.

     

    I know this because I tested with the following code:

    
     if (window->MouseDown(1)) {
       std::cout << "Left Button Pressed" << endl;
     }
    
     if (window->MouseDown(3)) {
       std::cout << "Right Button Pressed" << endl;
     }
    
     if (window->MouseDown(2)) {
       std::cout << "Middle Button Pressed" << endl;
     }

     

    Note: I tested this on Linux standalone

  6. Can we get a api hook that gets called when ever a key is pressed instead of polling Leadwerks::Window::KeyHit?

     

    It would work like the map load hook so something like this:

     

    bool App::Start()
    {
       // boiler plate
       window = Leadwerks::Window::Create("MyProject", Input);
       // more boiler plate
    }
    
    void App::Input(Leadwerks::Key key, int state)
    {
       if (state == Leadwerks::KeyState::Pressed) {
           std::cout << "Pressed: " << key << endl;
       } else if (state == Leadwerks::KeyState::Released) {
           std::cout << "Released: " << key << endl;
       }
    }
    

  7. I personally do not like Code::Blocks. So I have written a simple makefile that can be used with any C++ projects. You just need to modify the top two lines to reflect your project and where you have Leadwerks installed.

     

    PROJECTNAME=Framework
    LEADWERKS=$(HOME)/Applications/Leadwerks
    
    EXECUTABLE_RELEASE=$(PROJECTNAME)
    EXECUTABLE_DEBUG=$(PROJECTNAME).debug
    
    CC=clang++-3.5
    CFLAGS=-Wno-null-conversion \
    -Wno-extern-c-compat \
    -fexceptions \
    -msse3 \
    -DDG_DISABLE_ASSERT \
    -DZLIB \
    -DPLATFORM_LINUX \
    -D_NEWTON_STATIC_LIB \
    -DFT2_BUILD_LIBRARY \
    -DOPENGL \
    -Dunix \
    -D_POSIX_VER \
    -D_POSIX_VER_64 \
    -DDG_THREAD_EMULATION \
    -D_STATICLIB \
    -DDG_USE_THREAD_EMULATION \
    -DGL_GLEXT_PROTOTYPES \
    -DLEADWERKS_3_1 \
    -D_CUSTOM_JOINTS_STATIC_LIB
    
    INCLUDEDIRS=-I$(LEADWERKS)/Include/Libraries/NewtonDynamics/coreLibrary_300/source/core \
    -I$(LEADWERKS)/Include/Libraries/NewtonDynamics/coreLibrary_300/source/meshUtil \
    -I$(LEADWERKS)/Include/Libraries/NewtonDynamics/coreLibrary_300/source/newton \
    -I$(LEADWERKS)/Include/Libraries/NewtonDynamics/coreLibrary_300/source/physics \
    -I$(LEADWERKS)/Include/Libraries/NewtonDynamics/packages/dMath \
    -I$(LEADWERKS)/Include/Libraries/NewtonDynamics/packages/dContainers \
    -I$(LEADWERKS)/Include/Libraries/NewtonDynamics/packages/dCustomJoints \
    -I$(LEADWERKS)/Include/Libraries/tolua++-1.0.93/include \
    -I$(LEADWERKS)/Include/Libraries/lua-5.1.4 \
    -I$(LEADWERKS)/Include/Libraries/freetype-2.4.7/include \
    -I$(LEADWERKS)/Include/Libraries/enet-1.3.1/include \
    -I$(LEADWERKS)/Include/Libraries/RecastNavigation/DebugUtils/Include \
    -I$(LEADWERKS)/Include/Libraries/RecastNavigation/Detour/Include \
    -I$(LEADWERKS)/Include/Libraries/RecastNavigation/DetourCrowd/Include \
    -I$(LEADWERKS)/Include/Libraries/RecastNavigation/DetourTileCache/Include \
    -I$(LEADWERKS)/Include/Libraries/RecastNavigation/Recast/Include \
    -I$(LEADWERKS)/Include \
    -I$(LEADWERKS)/Include/Libraries/zlib-1.2.5 \
    -I$(LEADWERKS)/Include/Libraries/zlib-1.2.5/contrib/minizip \
    -I$(LEADWERKS)/Include/Libraries/freetype-2.4.7/include/freetype \
    -I$(LEADWERKS)/Include/Libraries/freetype-2.4.7/include/freetype/config \
    -I$(LEADWERKS)/Include/Libraries/LuaJIT/dynasm \
    -I$(LEADWERKS)/Include/Libraries/glew-1.6.0/include \
    -I$(LEADWERKS)/Include/Libraries/openal-soft/include
    
    LDFLAGS=-L$(LEADWERKS)/Library/Linux -lluajit \
    -lopenal -lGL -lGLU -lpthread -lX11
    
    LDFLAGS_RELEASE=-L$(LEADWERKS)/Library/Linux/Release/ -l:Leadwerks.a -O2
    LDFLAGS_DEBUG=-L$(LEADWERKS)/Library/Linux/Debug/ -l:Leadwerks.a -g -DDEBUG -D_DEBUG
    
    SOURCES=$(shell find ./Source -iname "*.cpp")
    
    OBJECTS=$(SOURCES:.cpp=.o)
    
    all: $(EXECUTABLE_RELEASE) $(EXECUTABLE_DEBUG)
    
    $(EXECUTABLE_RELEASE): $(OBJECTS)
    $(CC) $(OBJECTS) $(LDFLAGS) $(LDFLAGS_RELEASE) -o $@
    
    $(EXECUTABLE_DEBUG): $(OBJECTS)
    $(CC) $(OBJECTS) $(LDFLAGS) $(LDFLAGS_DEBUG) -o $@
    
    .cpp.o:
    $(CC) -c $(CFLAGS) $(INCLUDEDIRS) $< -o $@
    
    clean:
    -rm $(EXECUTABLE_DEBUG) $(EXECUTABLE_RELEASE) $(OBJECTS)
    
    

    • Upvote 3
  8. I am supporting this game through kickstarter so I do not have access to all the forums yet so I am posting here. (Sorry if this is the wrong spot, but no access to the programming area).

     

    So I was playing with the trial and was banging my head against the wall on how to toggle fullscreen, well I figured it out and thought I would share here for others that are having a hard time.

     

    void Settings::SetFullScreen(bool isFullscreen)
    {
     if (isFullscreen != _vidSettings._fullscreen)
     {
       _vidSettings._fullscreen = isFullscreen;
       GetCore()->window->Release();
       if (isFullscreen)
       {
      GetCore()->window = Window::Create(
        _vidSettings._title,
        0,
        0,
        _vidSettings._res.x,
        _vidSettings._res.y,
        Window::FullScreen);
       }
       else
       {
      GetCore()->window = Window::Create(
        _vidSettings._title,
        0,
        0,
        _vidSettings._res.x,
        _vidSettings._res.y,
        Window::Titlebar);
       }
       GetCore()->context = Context::Create(GetCore()->window);
     }
    }
    

     

    I have a class I pass around to everyone that pretty much just contains pointers to window, context, world, and camera that is what the GetCore() is (well it is a function that returns the core pointer but that is a personal coding style)

    • Upvote 2
×
×
  • Create New...