diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/README | 7 | ||||
-rw-r--r-- | test/dynamic_light/config.lua | 7 | ||||
-rw-r--r-- | test/dynamic_light/main.lua | 61 | ||||
-rw-r--r-- | test/dynamic_light/treestump.png | bin | 4518 -> 0 bytes | |||
-rw-r--r-- | test/dynamic_light/treestump_diffuse.png | bin | 581 -> 0 bytes | |||
-rw-r--r-- | test/dynamic_light/treestump_lines.png | bin | 324 -> 0 bytes | |||
-rw-r--r-- | test/load ogg.cpp | 60 | ||||
-rw-r--r-- | test/load wav.cpp | 65 |
8 files changed, 0 insertions, 200 deletions
diff --git a/test/README b/test/README deleted file mode 100644 index f017cfe..0000000 --- a/test/README +++ /dev/null @@ -1,7 +0,0 @@ -usage - - jin <game directory> [-d] - -for example - - jin test -d diff --git a/test/dynamic_light/config.lua b/test/dynamic_light/config.lua deleted file mode 100644 index cf4d721..0000000 --- a/test/dynamic_light/config.lua +++ /dev/null @@ -1,7 +0,0 @@ -local config = {} - -config.width = 500 -config.height = 400 -config.fps = 60 - -return config diff --git a/test/dynamic_light/main.lua b/test/dynamic_light/main.lua deleted file mode 100644 index 0920687..0000000 --- a/test/dynamic_light/main.lua +++ /dev/null @@ -1,61 +0,0 @@ -local shader = [[ -extern Image diffuse; -extern number mx; -extern number my; - -vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) -{ - vec3 light_vec = vec3(mx ,my,1); - vec3 light_direction = light_vec - vec3(pixel_coords, 0); - float distance = length(light_direction); - light_direction = normalize(light_direction); - - vec3 normal = Texel(texture, texture_coords).xyz; - normal.y = 1 - normal.y; - normal = normalize(mix(vec3(-1), vec3(1), normal)); - - //float attenuation = 1/(7e-5*pow(distance, 2)); - float attenuation = 5000/pow(distance, 2); - //float attenuation = 1; - - float diffuse_term = clamp(attenuation * dot(normal, light_direction), 0.0, 1.0); - - vec3 dark_color = vec3(0.0, 0.0, 1); - //vec3 light_color = vec3(0.6, 0.6, 0.0); - vec3 light_color = vec3(0.8, 0.8, 0.0); - vec3 ambient = mix(dark_color, light_color, diffuse_term) * 0.20; - - // the shaded cel has a light value of 0.5, the light cel has a light value of 1 - float cel_diffuse_term = smoothstep(0.49, 0.52, diffuse_term)/2 + 0.5; - //float cel_diffuse_term = step(0.5, diffuse_term)/2 + 0.5; - - return vec4((cel_diffuse_term * Texel(diffuse, texture_coords).rgb) + ambient, Texel(texture, texture_coords).a); - //return vec4(ambient+Texel(diffuse, texture_coords).rgb/100, Texel(texture, texture_coords).a); - -} -]] - -local jg = jin.graphics -local effect = jg.Shader(shader) -local diffuse = jg.Image("treestump_diffuse.png") -local img = jg.Image("treestump.png") - -jin.core.onEvent = function(e) - if e.type == "quit" then - jin.core.quit() - end -end - -jin.core.onUpdate = function() - local mx, my = jin.mouse.position() - my = 400 - my - effect:send("number", "mx", mx) - effect:send("number", "my", my) -end - -jin.core.onDraw = function() - effect:send("Image", "diffuse", diffuse); - jg.use(effect) - jg.draw(img, 250, 200, 5, 5) - -end diff --git a/test/dynamic_light/treestump.png b/test/dynamic_light/treestump.png Binary files differdeleted file mode 100644 index 45d8d28..0000000 --- a/test/dynamic_light/treestump.png +++ /dev/null diff --git a/test/dynamic_light/treestump_diffuse.png b/test/dynamic_light/treestump_diffuse.png Binary files differdeleted file mode 100644 index 272e6a2..0000000 --- a/test/dynamic_light/treestump_diffuse.png +++ /dev/null diff --git a/test/dynamic_light/treestump_lines.png b/test/dynamic_light/treestump_lines.png Binary files differdeleted file mode 100644 index 293a757..0000000 --- a/test/dynamic_light/treestump_lines.png +++ /dev/null diff --git a/test/load ogg.cpp b/test/load ogg.cpp deleted file mode 100644 index afa5b60..0000000 --- a/test/load ogg.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "utils.h" -#if UNITTEST - -#include <iostream> -#include <stdio.h> -#include <fstream> -#include "../audio/sdl/source.h" -#include "../audio/sdl/audio.h" - -using namespace jin::audio; -using namespace std; - -struct OGG -{ - int samples; - int channel, samplerate; - short* data; - int pos; -}; - -OGG ogg; - -static void callbackfunc(void *userdata, Uint8 *stream, int len) -{ - int16_t* buffer = (int16_t*)stream; - int16_t* oggbuf = (int16_t*)ogg.data; - oggbuf += ogg.pos; - for (int i = 0; i < len / 2; ++i) - { - buffer[i] = oggbuf[i]; - } - ogg.pos += len / 2; -} - -int main(int argc, char* argv[]) -{ - Audio* audio = SDLAudio::get(); - ifstream fs; - fs.open("a.ogg", ios::binary); - fs.seekg(0, ios::end); - int size = fs.tellg(); - fs.seekg(0, ios::beg); - char* buffer = new char[size]; - memset(buffer, 0, size); - fs.read(buffer, size); - ogg.samples = stb_vorbis_decode_memory((unsigned char*)buffer, size, &ogg.channel, &ogg.samplerate, &ogg.data); - ogg.pos = 0; - SDLAudioSetting setting; - SDL_AudioSpec spe; - setting.callback = callbackfunc; - audio->init(&setting); - while (true) - { - SDL_Delay(100); - } - audio->quit(); - return 0; -} - -#endif
\ No newline at end of file diff --git a/test/load wav.cpp b/test/load wav.cpp deleted file mode 100644 index 4cd2756..0000000 --- a/test/load wav.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "utils.h" -#if UNITTEST - -#include <iostream> -#include <stdio.h> -#include <fstream> -#include "../audio/sdl/source.h" -#include "../audio/sdl/audio.h" - -using namespace jin::audio; -using namespace std; - -struct WAV -{ - int samples; - int channel, samplerate; - short* data; - int pos; -}; - -WAV wav; -static void callbackfunc(void *userdata, Uint8 *stream, int len) -{ - if (wav.pos > wav.samples) - wav.pos = 0; - int16_t* buffer = (int16_t*)stream; - int l = len / 2; - for (int i = 0; i < l; ++i) - { - buffer[i] = wav.data[wav.pos + i]; - } - wav.pos += l; -} -int length = 2226052; -char buf[2226052]; - -int main(int argc, char* argv[]) -{ - Audio* audio = SDLAudio::get(); - ifstream fs; - fs.open("a.wav", ios::binary); - fs.read(buf, length); - SDLAudioSetting setting; - SDL_AudioSpec spe; - setting.callback = callbackfunc; - wav_t wavconfig; - if (wav_read(&wavconfig, buf, length) != 0) - { - cout << "load wav failed\n"; - } - wav.channel = wavconfig.channels; - wav.data = (short*)wavconfig.data; - wav.pos = 0; - wav.samplerate = wavconfig.samplerate; - wav.samples = wavconfig.length; - audio->init(&setting); - while (true) - { - SDL_Delay(100); - } - audio->quit(); - return 0; -} - -#endif
\ No newline at end of file |