Skip to content
Merged
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
90 changes: 90 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false

AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine

# Custom brace breaking
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeElse: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true

# Make the closing brace of container literals go to a new line
Cpp11BracedListStyle: false

# Never format includes
IncludeBlocks: Preserve
# clang-format version 4.0 through 12.0:
#SortIncludes: false
# clang-format version 13.0+:
#SortIncludes: Never

# No length limit, in case it breaks macros, you can
# disable it with /* clang-format off/on */ comments
ColumnLimit: 0

IndentWidth: 4
ContinuationIndentWidth: 4
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: NoIndent

PointerAlignment: Right
SpaceAfterCStyleCast: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false

UseCRLF: false
UseTab: Never

ForEachMacros:
[
"spa_list_for_each",
"spa_list_for_each_safe",
"wl_list_for_each",
"wl_array_for_each",
"udev_list_entry_foreach",
]

---

43 changes: 43 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.13)
project(OpenGX VERSION 0.1)

set(CMAKE_C_STANDARD 11)

set(TARGET opengx)

include(GNUInstallDirs)

find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL REQUIRED IMPORTED_TARGET sdl2)

add_library(${TARGET} STATIC
src/gc_gl.c
src/image_DXT.c
src/image_DXT.h
src/opengx.h
)
set_target_properties(${TARGET} PROPERTIES
PUBLIC_HEADER src/opengx.h
)

target_include_directories(${TARGET} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(${TARGET} PUBLIC
PkgConfig::SDL
)

configure_file(opengl.pc.in opengl.pc @ONLY)

install(TARGETS ${TARGET}
LIBRARY
ARCHIVE
RUNTIME
PUBLIC_HEADER
)
install(DIRECTORY "include/GL" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opengl.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES OpenGLConfig.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenGL")
39 changes: 39 additions & 0 deletions OpenGLConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
find_path(_OPENGL_gl_gl_INCLUDE_DIR NAMES GL/gl.h)
find_path(_OPENGL_gl_egl_INCLUDE_DIR NAMES EGL/egl.h)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGL
REQUIRED_VARS _OPENGL_gl_gl_INCLUDE_DIR
)

set(_OPENGL_glapi_LIBRARY "opengx")
set(OPENGL_FOUND ${OpenGL_FOUND})
set(OPENGL_XMESA_FOUND OFF)
set(OPENGL_GLU_FOUND OFF)
set(OPENGL_OpenGL_FOUND ${OpenGL_FOUND})
set(OpenGL_GLX_FOUND OFF)
set(OpenGL_EGL_FOUND ${OpenGL_FOUND})
set(OPENGL_INCLUDE_DIR ${_OPENGL_gl_gl_INCLUDE_DIR})
set(OPENGL_EGL_INCLUDE_DIRS ${_OPENGL_gl_egl_INCLUDE_DIR})
set(OPENGL_LIBRARIES ${OPENGL_egl_LIBRARY} ${_OPENGL_glapi_LIBRARY})

set(OPENGL_LIBRARY ${OPENGL_LIBRARIES})
set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})

if(OpenGL_FOUND)
if(NOT TARGET OpenGL::EGL)
add_library(OpenGL::EGL INTERFACE IMPORTED)
set_target_properties(OpenGL::EGL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_OPENGL_gl_egl_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OPENGL_egl_LIBRARY};${_OPENGL_glapi_LIBRARY}"
)
endif()

if(NOT TARGET OpenGL::GL)
add_library(OpenGL::GL INTERFACE IMPORTED)
set_target_properties(OpenGL::GL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_OPENGL_gl_gl_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OPENGL_egl_LIBRARY};${_OPENGL_glapi_LIBRARY}"
)
endif()
endif()
3 changes: 2 additions & 1 deletion nehe_lessons/lesson07/lesson07.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ int main( int argc, char **argv )
}

#ifdef GAMECUBE_WII
InitializeGLdata();
// TODO: this should not be here, SDL will take care of this
ogx_initialize();
#endif

/* initialize OpenGL */
Expand Down
9 changes: 9 additions & 0 deletions opengl.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib
includedir=${prefix}/include

Name: OpenGL
Description: OpenGL (without GLX) library and headers.
Version: @PROJECT_VERSION@
Libs: -L${libdir} -lopengx
Cflags: -I${includedir}
Loading