Skip to content

Commit

Permalink
[feature] gl: stars (#14) (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikp123 committed Feb 16, 2022
1 parent 62f66e7 commit 27aaa4b
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/output/shared/gl/modules/stars/build.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Project default
option(GL_MODULES "GL_MODULES" ON)

# Xorg
if(GL_MODULES)
# OpenGL/GLEW
find_library(GLEW glew32)
pkg_check_modules(GLEW QUIET glew)
if(GLEW OR GLEW_FOUND)
add_library(gl_stars SHARED "${XAVA_MODULE_DIR}/main.c"
"${XAVA_MODULE_DIR}/../../util/shader.c"
"${XAVA_MODULE_DIR}/../../util/misc.c"
"${GLOBAL_FUNCTION_SOURCES}")
target_link_directories(gl_stars PRIVATE
"${GLEW_LIBRARY_DIRS}")
target_include_directories(gl_stars PRIVATE
"${GLEW_INCLUDE_DIRS}")

if(WINDOWS OR MINGW OR MSVC OR CYGWIN)
target_link_libraries(gl_stars xava-shared "-lglew32 -lopengl32")
else()
target_link_libraries(gl_stars xava-shared "${GLEW_LIBRARIES}")
endif()
target_compile_definitions(gl_stars PUBLIC -DGL)

set_target_properties(gl_stars PROPERTIES PREFIX "")
set_target_properties(gl_stars PROPERTIES IMPORT_PREFIX "")
set_target_properties(gl_stars PROPERTIES OUTPUT_NAME "gl/module/stars/module")

# this copies the dlls for mr. windows
#find_and_copy_dlls(gl_stars)

configure_file("${XAVA_MODULE_DIR}/vertex.glsl" gl/module/stars/vertex.glsl COPYONLY)
configure_file("${XAVA_MODULE_DIR}/fragment.glsl" gl/module/stars/fragment.glsl COPYONLY)
configure_file("${XAVA_MODULE_DIR}/config.ini" gl/module/stars/config.ini COPYONLY)

install(TARGETS gl_stars RENAME module DESTINATION share/xava/gl/module/stars/)
install(FILES "${CMAKE_BINARY_DIR}/gl/module/stars/vertex.glsl" RENAME vertex.glsl.example DESTINATION share/xava/gl/module/stars/)
install(FILES "${CMAKE_BINARY_DIR}/gl/module/stars/fragment.glsl" RENAME fragment.glsl.example DESTINATION share/xava/gl/module/stars/)
install(FILES "${CMAKE_BINARY_DIR}/gl/module/stars/config.ini" RENAME config.ini.example DESTINATION share/xava/gl/module/stars/)

# Maybe GL license?
else()
message(WARNING "GLEW library not found; \"gl_stars\" won't build")
endif()
endif()
25 changes: 25 additions & 0 deletions src/output/shared/gl/modules/stars/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Config options related to the "stars" gl module
# Remove ';' for the config options to apply

[stars]

# Change star color in AARRGGB hex fashion
; color = "#ffffffff"

# Set a specific number of stars. If enabled, "density" will stop working.
; count = 100

# Control density of stars on the screen. Calculates the number of stars
# relative to screen resolution and this is just a simple scalar to that
# WARNING: Setting this value too high may cause graphical glitches due
# to Cairo draw limits
; density = 1.0

# Set maximum star size (in pixels)
; max_size = 5

# Enable/disable depth test for the stars.
# This is used for cases where the depth buffer is undesired for the stars, such
# as when using the shadow post shader.
; depth_test = false

19 changes: 19 additions & 0 deletions src/output/shared/gl/modules/stars/fragment.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#version 420 core

// color passed from the host
uniform vec4 foreground_color;

// color passed from the host
uniform vec4 background_color;

// screen width and height
uniform vec2 resolution;

uniform float intensity;

layout(location=0) out vec4 FragColor;

void main() {
FragColor = foreground_color;
}

Loading

0 comments on commit 27aaa4b

Please sign in to comment.