Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.idea/
cmake-build-*/
bin/*
build/
*.DS_Store

src/core/Config.h
src/core/Exported.h
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Blackengine - YET another home grown 3D game engine.
- Simple API for developers

## Building using cmake and conan
This instruction is for Linux users. Windows user should do naturally same things.
This instruction is for Linux users. Windows user should do naturally same things. Instructions for Mac users can be found below.

You need to install Conan package manager to build the project.

Expand Down Expand Up @@ -46,9 +46,36 @@ cmake -DCMAKE_INSTALL_PREFIX=<installation directory> ..
```
make -j2 install
```

After this step blackengine will be installed at <installation directory>.


## Build using Xcode on MacOS

### Step 1 - 2 same as on Linux and Windows (see above)

### Step 3. Generate Xcode project
```
cmake -DCMAKE_INSTALL_PREFIX=<installation directory> -G Xcode..
```

If you get following error
```
No CMAKE_C_COMPILER could be found
No CMAKE_CXX_COMPILER could be found.
```

try run this command

```
sudo xcode-select --reset
```

then repeat step

### Step 4. Open project in Xcode

Now you can work with project like with any other Xcode project.

## Examples
There is examples of using blackengine in /examples folder of installation directory. Look for it.

Expand Down
4 changes: 4 additions & 0 deletions cmake/Libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ if(UNIX)
set(LINKLIBS_LIBRARIES ${LINKLIBS_LIBRARIES} ${CMAKE_DL_LIBS})
endif()

if(UNIX AND APPLE)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo")
endif()

list(APPEND LINKLIBS_SOURCES ${BLACKENGINE_LIBRARY_DIR}/glad/src/glad.c)

set(CONAN_DISABLE_CHECK_COMPILER ON)
Expand Down
2 changes: 2 additions & 0 deletions src/core/PlatformHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <windows.h>
#elif defined(BLACK_PLATFORM_LINUX)
#include <dlfcn.h>
#elif defined(BLACK_PLATFORM_MACOSX)
#include <dlfcn.h>
#endif

#endif //BLACKENGINE_PLATFORMHEADERS_H
4 changes: 3 additions & 1 deletion src/core/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <plugins/windows/WindowsSharedLibrary.h>
#elif defined(BLACK_PLATFORM_LINUX)
#include <plugins/linux/LinuxSharedLibrary.h>
#elif defined(BLACK_PLATFORM_MACOSX)
#include <plugins/macos/MacSharedLibrary.h>

#endif

Expand All @@ -23,7 +25,7 @@ using SharedLibrary = os::WindowsSharedLibrary;
#elif defined(BLACK_PLATFORM_LINUX)
using SharedLibrary = os::LinuxSharedLibrary;
#elif defined(BLACK_PLATFORM_MACOSX)
using SharedLibrary = os::MacOSSharedLibrary;
using SharedLibrary = os::MacSharedLibrary;
#endif

/**
Expand Down
33 changes: 33 additions & 0 deletions src/core/plugins/macos/MacSharedLibrary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Created by apopov on 16.07.2019.
//

#include "MacSharedLibrary.h"

namespace black::os {

MacSharedLibrary::MacSharedLibrary(const std::string &name)
: AbstractSharedLibrary(name) {

}

void MacSharedLibrary::load() {
auto name = this->name + ".dylib";

this->handle = dlopen(name.c_str(), RTLD_LAZY);

if (!this->handle) {
throw LibraryNotFoundException(name);
}
}

void MacSharedLibrary::unload() {
if (this->handle) {
dlclose(this->handle);
}
}

void *MacSharedLibrary::getFunctionPointer(std::string name) {
return dlsym(this->handle, name.c_str());
}
}
30 changes: 30 additions & 0 deletions src/core/plugins/macos/MacSharedLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Created by apopov on 16.07.2019.
//

#ifndef BLACKENGINE_MACSHAREDLIBRARY_H
#define BLACKENGINE_MACSHAREDLIBRARY_H

#include <PlatformHeaders.h>
#include <plugins/AbstractSharedLibrary.h>

namespace black::os {
/**
* MacOS dynamic library class
*/
class MacSharedLibrary : public AbstractSharedLibrary {
private:
void *handle;

public:
explicit MacSharedLibrary(const std::string &name);

void load() override;
void unload() override;

private:
void *getFunctionPointer(std::string name) override;
};
}

#endif //BLACKENGINE_MACSHAREDLIBRARY_H
3 changes: 2 additions & 1 deletion src/plugins/gl/src/GLSLShaderProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <shader/Shader.h>
#include <glm/gtc/type_ptr.hpp>
#include <utility>
#include <array>

namespace black {

Expand Down Expand Up @@ -117,4 +118,4 @@ void GLSLShaderProgram::setUniformVariable(const std::string &name, glm::vec4 ve
glUniform4f(glGetUniformLocation(this->program, name.c_str()), vector.r, vector.g, vector.b, vector.a);
}

}
}