Browse Source

Uses git submodules, instead of installed libs

master
Joshua Moerman 11 years ago
parent
commit
05e41577fc
  1. 9
      .gitmodules
  2. 3
      CMakeLists.txt
  3. 1
      contrib/CLWrapper
  4. 4
      contrib/CMakeLists.txt
  5. 1
      contrib/ImageStreams
  6. 1
      contrib/NSAppWrapper
  7. 26
      resources/Fractal.fsh
  8. 18
      resources/Fractal.vsh
  9. 8
      resources/Kernel.cl
  10. 15
      src/CMakeLists.txt
  11. 14
      src/main.cpp

9
.gitmodules

@ -0,0 +1,9 @@
[submodule "contrib/CLWrapper"]
path = contrib/CLWrapper
url = ../libJ/CLWrapper/
[submodule "contrib/NSAppWrapper"]
path = contrib/NSAppWrapper
url = ../libJ/NSAppWrapper/
[submodule "contrib/ImageStreams"]
path = contrib/ImageStreams
url = ../ImageStreams/

3
CMakeLists.txt

@ -3,5 +3,8 @@ cmake_minimum_required(VERSION 2.8)
add_definitions(-std=c++1y) add_definitions(-std=c++1y)
add_subdirectory("contrib")
add_subdirectory("src") add_subdirectory("src")
file(GLOB resources "resources/*")
file(COPY ${resources} DESTINATION ${CMAKE_BINARY_DIR})

1
contrib/CLWrapper

@ -0,0 +1 @@
Subproject commit ee27ef82cf59dd7a02da924312a44136dce5c4bd

4
contrib/CMakeLists.txt

@ -0,0 +1,4 @@
add_subdirectory("NSAppWrapper")
add_subdirectory("CLWrapper")
add_subdirectory("ImageStreams")

1
contrib/ImageStreams

@ -0,0 +1 @@
Subproject commit fcad14e7bf175a374c6dae12aaa059f4e325b5ca

1
contrib/NSAppWrapper

@ -0,0 +1 @@
Subproject commit 7c5ebc89b87650ae649db1b5081f729d311915c4

26
resources/Fractal.fsh

@ -0,0 +1,26 @@
#version 330
uniform float rotation;
in vec2 pos;
in vec2 start;
out vec4 fragColor;
void main(){
vec2 z = start;
int i = 0;
for (i = 0; i < 30; i++) {
vec2 zsq = z*z;
if(zsq.x + zsq.y > 16.0) break;
float t = zsq.x - zsq.y + pos.x;
z.y = 2.0*z.x*z.y + pos.y;
z.x = t;
}
fragColor = vec4(float(i) / 30.0);
fragColor.bg = 0.5 * sin(z) + 0.5;
}

18
resources/Fractal.vsh

@ -0,0 +1,18 @@
#version 330
uniform float rotation;
in vec4 position;
in vec4 color;
out vec2 pos;
out vec2 start;
void main(){
pos = position.xy;
pos.x -= 0.5;
start = sqrt(1.0 + 0.01 * rotation) * 0.3 * sin(vec2(0.1, 0.1337) * rotation);
gl_Position = position;
}

8
resources/Kernel.cl

@ -0,0 +1,8 @@
kernel void square(global float* input, size_t width, global float* output){
size_t x = get_global_id(0);
size_t y = get_global_id(1);
float i = 2.0 * (input[x + width*y] - 0.5);
output[x + width*y] = 0.5 + 0.5*sin((1.0 - i) * sin(i*i + 6.2*float(x)/width) + cos(1.0/i + 6.2*float(y)/width));
}

15
src/CMakeLists.txt

@ -1,17 +1,10 @@
file(GLOB sources "*.cpp") set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
find_library(FOUNDATION_LIBRARY Foundation) file(GLOB sources "*.cpp")
find_library(COCOA_LIBRARY Cocoa)
find_library(COREGRAPHICS_LIBRARY CoreGraphics)
find_library(QUARTZCORE_LIBRARY QuartzCore)
find_library(OPENGL_LIBRARY OpenGL)
find_library(OPENCL_LIBRARY OpenCL)
find_library(LIBJNSAppWrapper JNSAppWrapper)
find_library(LIBJOpenCL JOpenCL)
find_library(LIBPNG png)
set(libs ${FOUNDATION_LIBRARY} ${COCOA_LIBRARY} ${COREGRAPHICS_LIBRARY} ${QUARTZCORE_LIBRARY} ${OPENGL_LIBRARY} ${OPENCL_LIBRARY} ${LIBJNSAppWrapper} ${LIBJOpenCL} ${LIBPNG}) set(libs ${JCLWrapper_LIBRARIES} ${JNSAppWrapper_LIBRARIES} ${ImageStreams_LIBRARIES})
message(STATUS "Linking against the following libraries: ${libs}")
foreach(source ${sources}) foreach(source ${sources})
get_filename_component(exec ${source} NAME_WE) get_filename_component(exec ${source} NAME_WE)

14
src/main.cpp

@ -1,15 +1,7 @@
// #include <cl2.hpp>
// main.cpp
// XcodeOpenCL
//
// Created by Joshua Moerman on 28/03/14.
//
//
#include <J/cl2.hpp> #include <NSWrapper.hpp>
#include <png.hpp>
#include <J/NSWrapper.hpp>
#include "../../ImageStreams/include/png.hpp"
#include <OpenGL/gl3.h> #include <OpenGL/gl3.h>