Skip to content

Commit

Permalink
fix compiler issues (#18)
Browse files Browse the repository at this point in the history
* fix compiler issues

* default clang

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update VertexArrayObject.cxx

* Update bazel.yml

* Update .bazelrc

* Delete BUILD.bazel

* Delete .bazelrc

* Delete .github/workflows/bazel.yml

* Delete WORKSPACE.bazel
  • Loading branch information
lindemeier authored Jun 11, 2024
1 parent ed72593 commit 7b788af
Show file tree
Hide file tree
Showing 14 changed files with 160 additions and 151 deletions.
1 change: 0 additions & 1 deletion .bazelrc

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/bazel.yml

This file was deleted.

68 changes: 34 additions & 34 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,37 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libglfw3-dev clang-10 ninja-build libglew-dev
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=/usr/bin/clang-10 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-10 -DCMAKE_BUILD_TYPE=$BUILD_TYPE -GNinja

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
- uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libglfw3-dev clang ninja-build libglew-dev
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_BUILD_TYPE=$BUILD_TYPE -GNinja

- name: Build
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE

- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
32 changes: 0 additions & 32 deletions BUILD.bazel

This file was deleted.

40 changes: 19 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ project(prgl)

find_package(glfw3 REQUIRED)
find_package(OpenGL REQUIRED)
find_package (Threads REQUIRED)
find_package(Threads REQUIRED)

# glew
if (UNIX)
if(UNIX)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLEW REQUIRED glew)
else ()
else()
file(TO_CMAKE_PATH "$ENV{GLEW_HOME}" GLEW_HOME)
set(GLEW_INCLUDE_DIR "${GLEW_HOME}/include")
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATHS "${GLEW_HOME}/lib" NO_DEFAULT_PATH)
set(GLEW_LIBRARIES ${GLEW_LIBRARY})
endif (UNIX)
endif(UNIX)

add_library(${PROJECT_NAME} STATIC
src/ContextImplementation.cxx
Expand All @@ -28,24 +28,23 @@ add_library(${PROJECT_NAME} STATIC
src/GlslComputeShader.cxx
src/VertexBufferObject.cxx
src/VertexArrayObject.cxx

)

set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Weverything -Wno-c++98-compat -Wno-padded -Wno-documentation -Werror -Wno-global-constructors -Wno-exit-time-destructors)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Werror)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
endif()


target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/>
PUBLIC $<INSTALL_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/>
Expand All @@ -54,16 +53,14 @@ target_include_directories(${PROJECT_NAME}
PUBLIC ${GLEW_INCLUDE_DIRS}
)


target_link_libraries(${PROJECT_NAME}
OpenGL::GL
glfw
${GLEW_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)


## testing
# # testing

# executable
add_executable(${PROJECT_NAME}_test
Expand All @@ -79,14 +76,15 @@ set_property(TARGET ${PROJECT_NAME}_test PROPERTY CXX_STANDARD_REQUIRED ON)

include(FetchContent)
option(RUN_TESTS "Build and run the tests" ON)

if(RUN_TESTS)
# get google test
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(test)
# get google test
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(test)
endif()
1 change: 0 additions & 1 deletion WORKSPACE.bazel

This file was deleted.

2 changes: 2 additions & 0 deletions prgl/FrameBufferObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class FrameBufferObject final {
const std::shared_ptr<Texture2d>& getTarget() const;
const std::shared_ptr<Texture2d>& getDepth() const;

void clear(const std::array<float, 4UL>& clearColor, double clearDepth);

private:
FrameBufferObject(const FrameBufferObject&) = delete;
FrameBufferObject& operator=(const FrameBufferObject&) = delete;
Expand Down
7 changes: 6 additions & 1 deletion prgl/VertexArrayObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,20 @@ class VertexArrayObject final {
const std::shared_ptr<VertexBufferObject>& vbo);

void render(const DrawMode& mode, uint32_t first, uint32_t count);
void renderAll(const DrawMode& mode);

private:
VertexArrayObject(const VertexArrayObject&) = delete;
VertexArrayObject(const VertexArrayObject&) = delete;
VertexArrayObject& operator=(const VertexArrayObject&) = delete;

protected:
uint32_t mVao;

std::size_t mIndicesCount;

std::map<uint32_t, std::shared_ptr<VertexBufferObject>> mVboMap;
};

} // namespace prgl

#endif // PRGL_VERTEX_ARRAY_OBJECT_H
4 changes: 3 additions & 1 deletion prgl/VertexBufferObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ class VertexBufferObject final {

DataType getVertexComponentDataType() const;
uint32_t getVertexComponentDataColumns() const;
size_t getVerticesCount() const;
std::size_t getVerticesCount() const;

std::size_t getSize() const;

private:
VertexBufferObject(const VertexBufferObject&) = delete;
Expand Down
8 changes: 8 additions & 0 deletions src/ContextImplementation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ void checkGLError(const char* file, const char* function, int line) {
error = "GL_INVALID_FRAMEBUFFER_OPERATION";
break;
// case GL_CONTEXT_LOST: error = "GL_CONTEXT_LOST"; break;
default:
break;
}

std::cerr << "ERROR::" << error.c_str() << "\n\tfile:\t" << file
Expand Down Expand Up @@ -82,6 +84,9 @@ static void APIENTRY openGlDebugCallback(GLenum /*unused*/, GLenum type,
case GL_DEBUG_TYPE_OTHER:
std::cerr << "OTHER";
break;
default:
std::cerr << "UNKNOWN";
break;
}
std::cerr << std::endl;

Expand All @@ -97,6 +102,9 @@ static void APIENTRY openGlDebugCallback(GLenum /*unused*/, GLenum type,
case GL_DEBUG_SEVERITY_HIGH:
std::cerr << "HIGH";
break;
default:
std::cerr << "UNKNOWN";
break;
}
std::cerr << std::endl;
std::cerr << "---------------------opengl-callback-end--------------"
Expand Down
Loading

0 comments on commit 7b788af

Please sign in to comment.