Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added OpenCL/OpenGL particle system, moved android code to android fo…
…lder to make this an overall particle system project
- Loading branch information
Showing
41 changed files
with
2,171 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,41 +1,24 @@ | |||
Simple OpenGL Particle system written in C |
|
||
|
******************************************************************* | ||
No physics yet... just figured out enough interaction between Java and C to get to work | ### EnjaParticles in C++ using OpenCL and OpenGL interoperability | ||
|
|
||
built against android-7 (must have 2.1 to run) | enjacl/ | ||
to build: | the particle system library as well as a main.cpp to run it | ||
#build the C files (found in jni folder) | check the README in here for build instructions and more info | ||
ndk-build | cmake/ | ||
#build the java stuff | cmake modules to help find necessary libraries | ||
ant debug |
|
||
#move to phone or use -e instead of -d for emulator | environment/ | ||
adb -d install bin/EnjaParticles-debug.apk | scripts to set the environment variables that cmake needs | ||
|
|
||
I use ddms command to capture log output from my app, just add a tag filter for EnjaParticles so you can get useful output |
|
||
|
|
||
#Particle System | ******************************************************************* | ||
particles are emitted from a generator (initialized as a static array) | ### EnjaParticles on the Android using the NDK and OpenGL | ||
several static arrays govern the behavior of the particles |
|
||
the position of the particles is stored in static vertices array | android/ | ||
vertices array is used to draw the particles | the C code is in the jni folder | ||
colors array determines color of each particle, with seperate alpha array that updates it | read the README in this folder for more info | ||
|
|
||
#Weird stuff I don't get yet: |
|
||
When calling a function defined in enja.c from app-android.c I can't pass floating point values, | ******************************************************************* | ||
I had to pass a pointer to static floats instead. integers work just fine, I believe it's something to | |||
do with the JNI but I know too little about it. | |||
I'm not really happy with the way the code is laid out, the particle system should probably be its own library | |||
with all the application stuff in the native function area. I'm not that used to C and playing with statics | |||
Doing this in C++ might make design a bit easier. | |||
|
|||
|
|||
#TODO | |||
//make an actual particle system | |||
better paramaterization for elements of the system | |||
make consistant way for variables to depend on time | |||
add physical interaction | |||
2d texture effects | |||
timing to measure costs of effects and compare devices | |||
rewrite in c++? maybe I can avoid weird JNI hack for passing floats | |||
write a version for OpengGL ES 2.0 with shaders to make pretty effects | |||
get OpenCL running on a phone ;D |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,41 @@ | |||
Simple OpenGL Particle system written in C | |||
|
|||
No physics yet... just figured out enough interaction between Java and C to get to work | |||
|
|||
built against android-7 (must have 2.1 to run) | |||
to build: | |||
#build the C files (found in jni folder) | |||
ndk-build | |||
#build the java stuff | |||
ant debug | |||
#move to phone or use -e instead of -d for emulator | |||
adb -d install bin/EnjaParticles-debug.apk | |||
|
|||
I use ddms command to capture log output from my app, just add a tag filter for EnjaParticles so you can get useful output | |||
|
|||
#Particle System | |||
particles are emitted from a generator (initialized as a static array) | |||
several static arrays govern the behavior of the particles | |||
the position of the particles is stored in static vertices array | |||
vertices array is used to draw the particles | |||
colors array determines color of each particle, with seperate alpha array that updates it | |||
|
|||
#Weird stuff I don't get yet: | |||
When calling a function defined in enja.c from app-android.c I can't pass floating point values, | |||
I had to pass a pointer to static floats instead. integers work just fine, I believe it's something to | |||
do with the JNI but I know too little about it. | |||
I'm not really happy with the way the code is laid out, the particle system should probably be its own library | |||
with all the application stuff in the native function area. I'm not that used to C and playing with statics | |||
Doing this in C++ might make design a bit easier. | |||
|
|||
|
|||
#TODO | |||
//make an actual particle system | |||
better paramaterization for elements of the system | |||
make consistant way for variables to depend on time | |||
add physical interaction | |||
2d texture effects | |||
timing to measure costs of effects and compare devices | |||
rewrite in c++? maybe I can avoid weird JNI hack for passing floats | |||
write a version for OpengGL ES 2.0 with shaders to make pretty effects | |||
get OpenCL running on a phone ;D |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,152 @@ | |||
############################################### | |||
# Build Options (Definitions and compiler flags) | |||
############################################### | |||
# Used by ALL compilers | |||
#ADD_DEFINITIONS(-g) | |||
# Used by SPECIFIC compilers | |||
# SET (CMAKE_CXX_FLAGS ) | |||
|
|||
|
|||
############################################### | |||
# EXTENSIONS TO INCLUDE: | |||
############################################### | |||
ENABLE_TESTING() | |||
#INCLUDE (CPack) | |||
#INCLUDE (UseDoxygen) | |||
#FIND_PACKAGE (MPI) | |||
|
|||
FIND_PACKAGE (GLUT) | |||
FIND_PACKAGE (OpenGL) | |||
FIND_PACKAGE (OPENCL) | |||
|
|||
############################################### | |||
# External dependency search paths | |||
############################################### | |||
# Directories searched for headers ORDER does not matter. | |||
# If a directory does not exist it is skipped | |||
set ( GLIB ${CMAKE_CURRENT_SOURCE_DIR} ) | |||
set ( SWAN $ENV{SWAN} ) | |||
|
|||
############################################### | |||
# Locate Required Libraries | |||
############################################### | |||
# Find library: find_library(<VAR> name1 [path1 path2 ...]) | |||
# These are from gordon_tests (should repackage as subdirectories here for redistribution) | |||
#FIND_LIBRARY (utilities utilities PATHS ${GLIB}/utilities) | |||
#FIND_LIBRARY (amira amira PATHS ${GLIB}/amira) | |||
|
|||
FIND_LIBRARY (swan_cuda swan_cuda PATHS ${SWAN}/lib) | |||
FIND_LIBRARY (swan_ocl swan_ocl PATHS ${SWAN}/lib) | |||
|
|||
if (SWAN_CUDA) | |||
set(swan_lib ${swan_cuda}) | |||
set(SWAN_TRANSLATE go_cuda.x) | |||
set (GPU_INCLUDE cuda) | |||
endif (SWAN_CUDA) | |||
|
|||
if (SWAN_OPENCL) | |||
set(swan_lib ${swan_ocl}) | |||
set(SWAN_TRANSLATE go_opencl.x) | |||
set (GPU_INCLUDE opencl) | |||
endif (SWAN_OPENCL) | |||
|
|||
message(***** : GPU_INCLUDE: "${GPU_INCLUDE}" ****) | |||
|
|||
|
|||
# Download and install Armadillo separately. | |||
# Specify local installation dir here. If installed globally the dir is unnecessary. | |||
#FIND_LIBRARY (armadillo armadillo PATHS /Users/erlebach/Documents/src/armadillo-0.6.12 /usr/local/lib64 ~/local/lib) | |||
|
|||
# Typically installed separately. Same rules as Armadillo (local dir here; global unecessary) | |||
#FIND_LIBRARY(fftw fftw3 PATHS /Users/erlebach/Documents/src/fftw-3.2.2/.libs) | |||
|
|||
|
|||
|
|||
SET (INCLUDE_DIRS | |||
. | |||
${GLIB}/utilities | |||
${GLIB}/graphics_utils | |||
${SWAN}/include | |||
#${GLIB}/cuda_utilities | |||
#${GLIB}/swan_utilities | |||
) | |||
|
|||
INCLUDE_DIRECTORIES ( ${INCLUDE_DIRS} ) | |||
|
|||
############################################### | |||
# Setup MPI (needed later) | |||
############################################### | |||
|
|||
#OPTION (USE_MPI "Enable/Disable parallel build and linking with MPI" ON) | |||
#IF (MPI_FOUND AND USE_MPI) | |||
#SET (CMAKE_CXX_FLAGS ${MPI_COMPILE_FLAGS}) | |||
#SET (CMAKE_C_FLAGS ${MPI_COMPILE_FLAGS}) | |||
#SET (CMAKE_LINK_FLAGS ${MPI_LINK_FLAGS}) | |||
|
|||
#INCLUDE_DIRECTORIES (${MPI_INCLUDE_PATH}) | |||
# NOTE: add a target_link_library( MPI_LIBRARIES) for libs and bins | |||
# TESTS that run parallel should use MPIEXEC | |||
#ENDIF (MPI_FOUND AND USE_MPI) | |||
|
|||
|
|||
############################################### | |||
# Allow 32bit compilation override | |||
# Written by Evan Bollig | |||
############################################### | |||
|
|||
OPTION(FORCE_32BIT "Force the compile and link process to build a 32bit i386 executable/library" ON) | |||
|
|||
SET(TEMP_VAR ${CMAKE_CURRENT_SOURCE_DIR}/lib ) | |||
|
|||
IF (FORCE_32BIT) | |||
# TEMPORARY (NOT worried about 32bit MPI right now) | |||
SET(USE_MPI OFF) | |||
MESSAGE("\n\nWARNING!!! Forcing MPI OFF (for 32bit build)\n\n") | |||
|
|||
# The C compiler is our linker | |||
MESSAGE("Original Search Path: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") | |||
|
|||
# EXTEND THE DEFAULT LIBRARY SEARCH PATH TO LOOK FOR i386 | |||
# ARCHITECTURE LIBRARIES | |||
# /usr/lib32: for kirk (ubuntu) | |||
SET(TEMP_VAR ${TEMP_VAR}/lib /usr/lib32 ) | |||
FOREACH(libdir ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}) | |||
# NOTE: ${OS_SPECIFIC_32BIT_IMPLICIT_LIB_SUBDIR}) is defined in the | |||
# OS specific cmake builds (e.g., OSX_CONFIG.cmake) | |||
SET(TEMP_VAR ${TEMP_VAR} ${libdir}/${OS_SPECIFIC_32BIT_IMPLICIT_LIB_SUBDIR}) | |||
SET(TEMP_VAR ${TEMP_VAR} ${libdir}${OS_SPECIFIC_32BIT_IMPLICIT_LIB_SUBDIR}) | |||
ENDFOREACH(libdir) | |||
|
|||
# THIS DOES NOT WORK!!! | |||
# I WANT TO OVERRIDE THE IMPLICIT LINK DIRS FOR 32bit | |||
# BUT THIS DOES NOT PROPAGATE TO THE LINKER CALL | |||
|
|||
# SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${TEMP_VAR}) | |||
|
|||
# This works but gives warnings about the 64bit libraries | |||
LINK_DIRECTORIES(${TEMP_VAR}) | |||
|
|||
MESSAGE("Updated Search Path: ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") | |||
#MESSAGE("CXX Implicit: ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}") | |||
#MESSAGE("FORTRAN Implicit: ${CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES}") | |||
|
|||
# FORCE COMPILERS INTO 32bit mode | |||
ADD_DEFINITIONS( -m32 ) | |||
# FORCE LINKERS INTO 32bit mode | |||
SET( CMAKE_EXE_LINKER_FLAGS -m32) | |||
|
|||
SET(LIB32_SEARCH_PATH ${TEMP_VAR} CACHE STRING "library search path") | |||
ENDIF(FORCE_32BIT) | |||
|
|||
|
|||
|
|||
# TEMPORARY. DO not know whether should be put in common | |||
IF($ENV{HOSTNAME} MATCHES "mark2") | |||
FIND_PACKAGE(CUDA_mark2) | |||
ELSE($ENV{HOSTNAME} MATCHES "mark2") | |||
FIND_PACKAGE(CUDA) | |||
ENDIF($ENV{HOSTNAME} MATCHES "mark2") | |||
|
|||
FIND_LIBRARY(stdc stdc++ PATH /usr/lib32) #/gcc/x86_64-linux-gnu/4.4/32/) | |||
|
|||
LINK_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/lib ${LINK_DIRECTORIES} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
# | |||
# Try to find GLEW library and include path. | |||
# Once done this will define | |||
# | |||
# GLEW_FOUND | |||
# GLEW_INCLUDE_PATH | |||
# GLEW_LIBRARY | |||
# | |||
|
|||
IF (WIN32) | |||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h | |||
$ENV{PROGRAMFILES}/GLEW/include | |||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/include | |||
DOC "The directory where GL/glew.h resides") | |||
FIND_LIBRARY( GLEW_LIBRARY | |||
NAMES glew GLEW glew32 glew32s | |||
PATHS | |||
$ENV{PROGRAMFILES}/GLEW/lib | |||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin | |||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib | |||
DOC "The GLEW library") | |||
ELSE (WIN32) | |||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h | |||
/usr/include | |||
/usr/local/include | |||
/sw/include | |||
/opt/local/include | |||
DOC "The directory where GL/glew.h resides") | |||
FIND_LIBRARY( GLEW_LIBRARY | |||
NAMES GLEW glew | |||
PATHS | |||
/usr/lib64 | |||
/usr/lib | |||
/usr/local/lib64 | |||
/usr/local/lib | |||
/sw/lib | |||
/opt/local/lib | |||
DOC "The GLEW library") | |||
ENDIF (WIN32) | |||
|
|||
IF (GLEW_INCLUDE_PATH) | |||
SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") | |||
ELSE (GLEW_INCLUDE_PATH) | |||
SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") | |||
ENDIF (GLEW_INCLUDE_PATH) | |||
|
|||
MARK_AS_ADVANCED( GLEW_FOUND ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
# - Try to find OpenCL | |||
# Once done this will define | |||
# | |||
# OPENCL_FOUND - system has OpenCL | |||
# OPENCL_INCLUDE_DIR - the OpenCL include directory | |||
# OPENCL_LIBRARIES - link these to use OpenCL | |||
# | |||
# WIN32 should work, but is untested | |||
|
|||
IF (WIN32) | |||
|
|||
FIND_PATH(OPENCL_INCLUDE_DIR CL/cl.h ) | |||
|
|||
# TODO this is only a hack assuming the 64 bit library will | |||
# not be found on 32 bit system | |||
FIND_LIBRARY(OPENCL_LIBRARIES opencl64 ) | |||
IF( OPENCL_LIBRARIES ) | |||
FIND_LIBRARY(OPENCL_LIBRARIES opencl32 ) | |||
ENDIF( OPENCL_LIBRARIES ) | |||
|
|||
ELSE (WIN32) | |||
|
|||
# Unix style platforms | |||
# We also search for OpenCL in the NVIDIA GPU SDK default location | |||
SET(OPENCL_INCLUDE_DIR "$ENV{OPENCL_HOME}/common/inc" | |||
CACHE PATH "path to Opencl Include files") | |||
|
|||
message(***** OPENCL_INCLUDE_DIR: "${OPENCL_INCLUDE_DIR}" ********) | |||
|
|||
# does not work. WHY? | |||
#SET(inc $ENV{CUDA_LOCAL}/../OpenCL/common/inc /usr/include) | |||
#FIND_PATH(OPENCL_INCLUDE_DIR CL/cl.h PATHS ${inc} /usr/include ) | |||
|
|||
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL ENV LD_LIBRARY_PATH) | |||
|
|||
message(***** OPENCL ENV: "$ENV{GPU_SDK}" ********) | |||
|
|||
#~/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc/ | |||
|
|||
|
|||
ENDIF (WIN32) | |||
|
|||
SET( OPENCL_FOUND "NO" ) | |||
IF(OPENCL_LIBRARIES ) | |||
SET( OPENCL_FOUND "YES" ) | |||
ENDIF(OPENCL_LIBRARIES) | |||
|
|||
MARK_AS_ADVANCED( | |||
OPENCL_INCLUDE_DIR | |||
) |
Oops, something went wrong.