[SDL_tizen]add visual test 69/79569/7
authoryangchen <chen2.yang@samsung.com>
Mon, 11 Jul 2016 03:58:51 +0000 (11:58 +0800)
committeryangchen <chen2.yang@samsung.com>
Mon, 1 Aug 2016 10:18:36 +0000 (18:18 +0800)
Change-Id: I6f3124e823cd891a0914f37850f4c24725d81a3b

127 files changed:
src/test/SDL_test_log.c [changed mode: 0644->0755]
src/video/tizen/SDL_tizenmouse.c [changed mode: 0644->0755]
src/video/tizen/SDL_tizenmouse.h [changed mode: 0644->0755]
test/CMakeLists.txt [new file with mode: 0755]
test/SDL_gles2funcs.h [new file with mode: 0755]
test/loopwave.c [changed mode: 0644->0755]
test/loopwavequeue.c [changed mode: 0644->0755]
test/packaging/sdl_test.spec [new file with mode: 0755]
test/res/AutomationNotify.bmp [new file with mode: 0755]
test/res/AutomationTest.bmp [new file with mode: 0755]
test/res/InteractiveTest.bmp [new file with mode: 0755]
test/res/axis.bmp [new file with mode: 0755]
test/res/bg.bmp [new file with mode: 0755]
test/res/button.bmp [new file with mode: 0755]
test/res/controllermap.bmp [new file with mode: 0755]
test/res/icon.bmp [new file with mode: 0755]
test/res/libSDL2-2.0.so [new file with mode: 0755]
test/res/loopwave.bmp [new file with mode: 0755]
test/res/loopwavequeue.bmp [new file with mode: 0755]
test/res/moose.dat [new file with mode: 0755]
test/res/sample.bmp [new file with mode: 0755]
test/res/sample.wav [new file with mode: 0755]
test/res/test.bmp [new file with mode: 0755]
test/res/testadded.bmp [new file with mode: 0755]
test/res/testatomic.bmp [new file with mode: 0755]
test/res/testaudiohotplug.bmp [new file with mode: 0755]
test/res/testaudioinfo.bmp [new file with mode: 0755]
test/res/testchessboard.bmp [new file with mode: 0755]
test/res/testdisplayinfo.bmp [new file with mode: 0755]
test/res/testdraw2.bmp [new file with mode: 0755]
test/res/testdropfile.bmp [new file with mode: 0755]
test/res/testerror.bmp [new file with mode: 0755]
test/res/testfile.bmp [new file with mode: 0755]
test/res/testfilesystem.bmp [new file with mode: 0755]
test/res/testgles.bmp [new file with mode: 0755]
test/res/testgles2.bmp [new file with mode: 0755]
test/res/testhit.bmp [new file with mode: 0755]
test/res/testiconv.bmp [new file with mode: 0755]
test/res/testime.bmp [new file with mode: 0755]
test/res/testintersection.bmp [new file with mode: 0755]
test/res/testkeys.bmp [new file with mode: 0755]
test/res/testloadso.bmp [new file with mode: 0755]
test/res/testlock.bmp [new file with mode: 0755]
test/res/testmultiaudio.bmp [new file with mode: 0755]
test/res/testoverlay2.bmp [new file with mode: 0755]
test/res/testplatform.bmp [new file with mode: 0755]
test/res/testrelative.bmp [new file with mode: 0755]
test/res/testrendercopyex.bmp [new file with mode: 0755]
test/res/testrendertarget.bmp [new file with mode: 0755]
test/res/testresample.bmp [new file with mode: 0755]
test/res/testscale.bmp [new file with mode: 0755]
test/res/testsem.bmp [new file with mode: 0755]
test/res/testshader.bmp [new file with mode: 0755]
test/res/testsprite2.bmp [new file with mode: 0755]
test/res/testspriteminimal.bmp [new file with mode: 0755]
test/res/teststreaming.bmp [new file with mode: 0755]
test/res/testthread.bmp [new file with mode: 0755]
test/res/testtimer.bmp [new file with mode: 0755]
test/res/testtoturethread.bmp [new file with mode: 0755]
test/res/testver.bmp [new file with mode: 0755]
test/res/testviewport.bmp [new file with mode: 0755]
test/res/tobeadded.bmp [new file with mode: 0755]
test/res/toturethread.bmp [new file with mode: 0755]
test/res/utf8.txt [new file with mode: 0755]
test/testatomic.c [changed mode: 0644->0755]
test/testaudiohotplug.c [changed mode: 0644->0755]
test/testaudioinfo.c [changed mode: 0644->0755]
test/testautomation.c [changed mode: 0644->0755]
test/testautomation_audio.c [changed mode: 0644->0755]
test/testautomation_clipboard.c [changed mode: 0644->0755]
test/testautomation_events.c [changed mode: 0644->0755]
test/testautomation_hints.c [changed mode: 0644->0755]
test/testautomation_keyboard.c [changed mode: 0644->0755]
test/testautomation_main.c [changed mode: 0644->0755]
test/testautomation_mouse.c [changed mode: 0644->0755]
test/testautomation_pixels.c [changed mode: 0644->0755]
test/testautomation_platform.c [changed mode: 0644->0755]
test/testautomation_rect.c [changed mode: 0644->0755]
test/testautomation_render.c [changed mode: 0644->0755]
test/testautomation_rwops.c [changed mode: 0644->0755]
test/testautomation_sdltest.c [changed mode: 0644->0755]
test/testautomation_stdlib.c [changed mode: 0644->0755]
test/testautomation_suites.h [changed mode: 0644->0755]
test/testautomation_surface.c [changed mode: 0644->0755]
test/testautomation_syswm.c [changed mode: 0644->0755]
test/testautomation_timer.c [changed mode: 0644->0755]
test/testautomation_video.c [changed mode: 0644->0755]
test/testdisplayinfo.c [changed mode: 0644->0755]
test/testdraw2.c [changed mode: 0644->0755]
test/testdrawchessboard.c [changed mode: 0644->0755]
test/testdropfile.c [changed mode: 0644->0755]
test/testerror.c [changed mode: 0644->0755]
test/testfile.c [changed mode: 0644->0755]
test/testfilesystem.c [changed mode: 0644->0755]
test/testgles.c [changed mode: 0644->0755]
test/testgles2.c [changed mode: 0644->0755]
test/testhittesting.c [changed mode: 0644->0755]
test/testiconv.c [changed mode: 0644->0755]
test/testime.c [changed mode: 0644->0755]
test/testintersections.c [changed mode: 0644->0755]
test/testkeys.c [changed mode: 0644->0755]
test/testloadso.c [changed mode: 0644->0755]
test/testlock.c [changed mode: 0644->0755]
test/testmain.c [new file with mode: 0755]
test/testmain.h [new file with mode: 0755]
test/testmessage.c [changed mode: 0644->0755]
test/testmultiaudio.c [changed mode: 0644->0755]
test/testoverlay2.c [changed mode: 0644->0755]
test/testpicture.c [new file with mode: 0755]
test/testplatform.c [changed mode: 0644->0755]
test/testrelative.c [changed mode: 0644->0755]
test/testrendercopyex.c [changed mode: 0644->0755]
test/testrendertarget.c [changed mode: 0644->0755]
test/testresample.c [changed mode: 0644->0755]
test/testscale.c [changed mode: 0644->0755]
test/testsem.c [changed mode: 0644->0755]
test/testshader.c [changed mode: 0644->0755]
test/testshape.c [changed mode: 0644->0755]
test/testsprite2.c [changed mode: 0644->0755]
test/testspriteminimal.c [changed mode: 0644->0755]
test/teststreaming.c [changed mode: 0644->0755]
test/testthread.c [changed mode: 0644->0755]
test/testtimer.c [changed mode: 0644->0755]
test/testver.c [changed mode: 0644->0755]
test/testviewport.c [changed mode: 0644->0755]
test/torturethread.c [changed mode: 0644->0755]
test/utf8.txt [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 097372e..19f57a0
@@ -79,6 +79,38 @@ void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
     SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
     va_end(list);
 
+       //write log
+       char *message;
+    message = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+    if (!message) {
+        return;
+    }
+
+    size_t len = SDL_strlen(logMessage);
+    strcpy(message, logMessage);
+
+    // Chop off final endline.
+
+    if ((len > 0) && (message[len-1] == '\n')) {
+        message[--len] = '\0';
+        if ((len > 0) && (message[len-1] == '\r')) {  // catch "\r\n", too. 
+            message[--len] = '\0';
+        }
+    }
+
+    SDL_RWops *rwops = SDL_RWFromFile("log.txt", "a+");
+    char *text;
+    text = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+    if(text)
+    {
+        SDL_snprintf(text, SDLTEST_MAX_LOGMESSAGE_LENGTH,  " INFO: %s: %s\n", SDLTest_TimestampToString(time(0)), message);
+        SDL_RWwrite(rwops, text, 1, SDL_strlen(text));
+        SDL_stack_free(text);
+    }
+
+    SDL_RWclose(rwops);
+    SDL_stack_free(message);
+
     /* Log with timestamp and newline */
     SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO, " %s: %s", SDLTest_TimestampToString(time(0)), logMessage);
 }
@@ -97,6 +129,38 @@ void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
     SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
     va_end(list);
 
+       //write log
+       char *message;
+    message = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+    if (!message) {
+        return;
+    }
+
+    size_t len = SDL_strlen(logMessage);
+    strcpy(message, logMessage);
+
+    // Chop off final endline.
+
+    if ((len > 0) && (message[len-1] == '\n')) {
+        message[--len] = '\0';
+        if ((len > 0) && (message[len-1] == '\r')) {  // catch "\r\n", too. 
+            message[--len] = '\0';
+        }
+    }
+
+    SDL_RWops *rwops = SDL_RWFromFile("log.txt", "a+");
+    char *text;
+    text = SDL_stack_alloc(char, SDLTEST_MAX_LOGMESSAGE_LENGTH);
+    if(text)
+    {
+        SDL_snprintf(text, SDLTEST_MAX_LOGMESSAGE_LENGTH,  " ERROR: %s: %s\n", SDLTest_TimestampToString(time(0)), message);
+        SDL_RWwrite(rwops, text, 1, SDL_strlen(text));
+        SDL_stack_free(text);
+    }
+
+    SDL_RWclose(rwops);
+    SDL_stack_free(message);
+
     /* Log with timestamp and newline */
     SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
 }
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..4697676
--- /dev/null
@@ -0,0 +1,326 @@
+INCLUDE(FindPkgConfig)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sdl2_test C CXX)
+
+IF("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l") 
+ADD_DEFINITIONS("-DARCH_ARMV7") 
+ELSE() 
+ADD_DEFINITIONS("-DARCH_I586") 
+ENDIF()
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "") 
+       SET(CMAKE_BUILD_TYPE "Debug") 
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "") 
+       MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+IF(NOT DEFINED PACKAGE_NAME) 
+       SET(PACKAGE_NAME "org.tizen.${PROJECT_NAME}") 
+ENDIF(NOT DEFINED PACKAGE_NAME)
+IF(NOT DEFINED RESDIR)
+    SET(RESDIR "${PREFIX}/res")
+ENDIF(NOT DEFINED RESDIR)
+
+set(SDL_MAJOR_VERSION 2)
+set(SDL_MINOR_VERSION 0)
+set(SDL_MICRO_VERSION 4)
+set(SDL_INTERFACE_AGE 0)
+set(SDL_BINARY_AGE 4)
+set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
+
+set(LIBNAME SDL2)
+set(CMAKE_C_FLAGS "-g -O2")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
+
+ADD_DEFINITIONS(-D__TIZEN__)
+INCLUDE(FindPkgConfig)
+pkg_check_modules(APPS_PKGS REQUIRED
+       dlog
+       egl
+       glesv2
+       glesv1
+       sdl2
+)
+FOREACH(flag ${APPS_PKGS_CFLAGS}) #${APPS_PKGS_LDFLAGS}
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+
+set (SDL_TEST_SOURCE
+               testmain.c
+       )
+set (AUTOMATION_SOURCE
+               testautomation.c 
+               testautomation_audio.c 
+               testautomation_clipboard.c 
+               testautomation_events.c 
+               testautomation_hints.c
+               testautomation_keyboard.c 
+               testautomation_main.c 
+               testautomation_mouse.c 
+               testautomation_pixels.c 
+               testautomation_platform.c 
+               testautomation_rect.c 
+               testautomation_render.c 
+               testautomation_rwops.c 
+               testautomation_sdltest.c 
+               testautomation_stdlib.c 
+               testautomation_surface.c 
+               testautomation_syswm.c 
+               testautomation_timer.c 
+               testautomation_video.c 
+       )
+set (LOOPWAVE_SOURCE
+               loopwave.c
+       )
+set (LOOPWAVEQUEUE_SOURCE
+               loopwavequeue.c
+       )
+set (AUTOMIC_SOURCE
+               testatomic.c
+       )
+set (AUDIOHOTPLUGIN_SOURCE
+               testaudiohotplug.c
+       )
+set (AUDIOINFO_SOURCE
+               testaudioinfo.c
+       )
+set (DISPLAYINFO_SOURCE
+               testdisplayinfo.c
+       )
+set (DRAW2_SOURCE
+               testdraw2.c
+       )
+set (DRAWCHESSBOARD_SOURCE
+               testdrawchessboard.c
+       )
+set (DORPFILE_SOURCE
+               testdropfile.c
+       )
+set (ERROR_SOURCE
+               testerror.c
+       )
+set (FILE_SOURCE
+               testfile.c
+       )
+set (FILESYSTEM_SOURCE
+               testfilesystem.c
+       )
+set (GLES_SOURCE
+               testgles.c
+       )
+set (GLES2_SOURCE
+               testgles2.c
+       )
+set (HIT_SOURCE
+               testhittesting.c
+       )
+set (CONV_SOURCE
+               testiconv.c
+       )
+set (TIME_SOURCE
+               testime.c
+       )
+set (INTERSECTION_SOURCE
+               testintersections.c
+       )
+set (KEYS_SOURCE
+               testkeys.c
+       )
+set (LOADSO_SOURCE
+               testloadso.c
+       )
+set (LOCK_SOURCE
+               testlock.c
+       )
+set (MESSAGE_SOURCE
+               testmessage.c
+       )
+set (MULTIAUDIO_SOURCE
+               testmultiaudio.c
+       )
+set (OVERLAY2_SOURCE
+               testoverlay2.c
+       )
+set (PLATFORM_SOURCE
+               testplatform.c
+       )
+set (RELATIVE_SOURCE
+               testrelative.c
+       )
+set (RENDERCOPYEX_SOURCE
+               testrendercopyex.c
+       )
+set (RENDERTARGET_SOURCE
+               testrendertarget.c
+       )
+set (RESAMPLE_SOURCE
+               testresample.c
+       )
+set (SCALE_SOURCE
+               testscale.c
+       )
+set (SEM_SOURCE
+               testsem.c
+       )
+set (SHADER_SOURCE
+               testshader.c
+       )
+set (SHAPE_SOURCE
+               testshape.c
+       )
+set (SPRITE2_SOURCE
+               testsprite2.c
+       )
+set (SPRITEMINIMAL_SOURCE
+               testspriteminimal.c
+       )
+set (STREAMING_SOURCE
+               teststreaming.c
+       )
+set (THREAD_SOURCE
+               testthread.c
+       )
+set (TIMER_SOURCE
+               testtimer.c
+       )
+set (VER_SOURCE
+               testver.c
+       )
+set (VIEWPORT_SOURCE
+               testviewport.c
+       )
+set (TORTURETHREAD_SOURCE
+               torturethread.c
+       )
+add_executable(testmain  ${SDL_TEST_SOURCE})
+TARGET_LINK_LIBRARIES(testmain ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testautomation  ${AUTOMATION_SOURCE})
+TARGET_LINK_LIBRARIES(testautomation ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(loopwave  ${LOOPWAVE_SOURCE})
+TARGET_LINK_LIBRARIES(loopwave ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(loopwavequeue  ${LOOPWAVEQUEUE_SOURCE})
+TARGET_LINK_LIBRARIES(loopwavequeue ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testautomic  ${AUTOMIC_SOURCE})
+TARGET_LINK_LIBRARIES(testautomic ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testaudiohotplug  ${AUDIOHOTPLUGIN_SOURCE})
+TARGET_LINK_LIBRARIES(testaudiohotplug ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testaudioinfo  ${AUDIOINFO_SOURCE})
+TARGET_LINK_LIBRARIES(testaudioinfo ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testdisplayinfo  ${DISPLAYINFO_SOURCE})
+TARGET_LINK_LIBRARIES(testdisplayinfo ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testdraw2  ${DRAW2_SOURCE})
+TARGET_LINK_LIBRARIES(testdraw2 ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testdrawchessboard  ${DRAWCHESSBOARD_SOURCE})
+TARGET_LINK_LIBRARIES(testdrawchessboard ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testdorpfile  ${DRAWCHESSBOARD_SOURCE})
+TARGET_LINK_LIBRARIES(testdorpfile ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testerror  ${ERROR_SOURCE})
+TARGET_LINK_LIBRARIES(testerror ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testfile  ${FILE_SOURCE})
+TARGET_LINK_LIBRARIES(testfile ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testfilesystem  ${FILESYSTEM_SOURCE})
+TARGET_LINK_LIBRARIES(testfilesystem ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testgles  ${GLES_SOURCE})
+TARGET_LINK_LIBRARIES(testgles ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testgles2  ${GLES2_SOURCE})
+TARGET_LINK_LIBRARIES(testgles2 ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testhit  ${HIT_SOURCE})
+TARGET_LINK_LIBRARIES(testhit ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testconv  ${CONV_SOURCE})
+TARGET_LINK_LIBRARIES(testconv ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testtime  ${TIME_SOURCE})
+TARGET_LINK_LIBRARIES(testtime ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testintersection  ${INTERSECTION_SOURCE})
+TARGET_LINK_LIBRARIES(testintersection ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testkes  ${KEYS_SOURCE})
+TARGET_LINK_LIBRARIES(testkes ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testloadso  ${LOADSO_SOURCE})
+TARGET_LINK_LIBRARIES(testloadso ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testlock  ${LOCK_SOURCE})
+TARGET_LINK_LIBRARIES(testlock ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testmessage  ${MESSAGE_SOURCE})
+TARGET_LINK_LIBRARIES(testmessage ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testmultiaudio  ${MULTIAUDIO_SOURCE})
+TARGET_LINK_LIBRARIES(testmultiaudio ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testoverlay2  ${OVERLAY2_SOURCE})
+TARGET_LINK_LIBRARIES(testoverlay2 ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testplatform  ${PLATFORM_SOURCE})
+TARGET_LINK_LIBRARIES(testplatform ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testrelative  ${RELATIVE_SOURCE})
+TARGET_LINK_LIBRARIES(testrelative ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testrendercopyex  ${RENDERCOPYEX_SOURCE})
+TARGET_LINK_LIBRARIES(testrendercopyex ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testrendertarget  ${RENDERTARGET_SOURCE})
+TARGET_LINK_LIBRARIES(testrendertarget ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testresample  ${RESAMPLE_SOURCE})
+TARGET_LINK_LIBRARIES(testresample ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testscale  ${SCALE_SOURCE})
+TARGET_LINK_LIBRARIES(testscale ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testsem  ${SEM_SOURCE})
+TARGET_LINK_LIBRARIES(testsem ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testshader  ${SHADER_SOURCE})
+TARGET_LINK_LIBRARIES(testshader ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testshape  ${SHAPE_SOURCE})
+TARGET_LINK_LIBRARIES(testshape ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testsprite2  ${SPRITE2_SOURCE})
+TARGET_LINK_LIBRARIES(testsprite2 ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testspriteminimal  ${SPRITEMINIMAL_SOURCE})
+TARGET_LINK_LIBRARIES(testspriteminimal ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(teststreaming  ${STREAMING_SOURCE})
+TARGET_LINK_LIBRARIES(teststreaming ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testthread  ${THREAD_SOURCE})
+TARGET_LINK_LIBRARIES(testthread ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testtimer  ${TIMER_SOURCE})
+TARGET_LINK_LIBRARIES(testtimer ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testver  ${VER_SOURCE})
+TARGET_LINK_LIBRARIES(testver ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(testviewport  ${VIEWPORT_SOURCE})
+TARGET_LINK_LIBRARIES(testviewport ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+add_executable(torturethread  ${TORTURETHREAD_SOURCE})
+TARGET_LINK_LIBRARIES(torturethread ${APPS_PKGS_LDFLAGS} SDL2_test SDL2main)
+# Install
+INSTALL(TARGETS testmain DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testautomation DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS loopwave DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS loopwavequeue DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testautomic DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testaudiohotplug DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testaudioinfo DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testdisplayinfo DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testdraw2 DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testdrawchessboard DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testdorpfile DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testerror DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testfile DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testfilesystem DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testgles DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testgles2 DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testhit DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testconv DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testtime DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testintersection DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testkes DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testloadso DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testlock DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testmessage DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testmultiaudio DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testoverlay2 DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testplatform DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testrelative DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testrendercopyex DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testrendertarget DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testresample DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testscale DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testsem DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testshader DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testshape DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testsprite2 DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testspriteminimal DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS teststreaming DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testthread DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testtimer DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testver DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS testviewport DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(TARGETS torturethread DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/res DESTINATION /opt/usr/apps/org.tizen.sdl2_test/)
\ No newline at end of file
diff --git a/test/SDL_gles2funcs.h b/test/SDL_gles2funcs.h
new file mode 100755 (executable)
index 0000000..0ecfa7f
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+SDL_PROC(void, glActiveTexture, (GLenum))
+SDL_PROC(void, glAttachShader, (GLuint, GLuint))
+SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
+SDL_PROC(void, glBindTexture, (GLenum, GLuint))
+SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
+SDL_PROC(void, glClear, (GLbitfield))
+SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
+SDL_PROC(void, glCompileShader, (GLuint))
+SDL_PROC(GLuint, glCreateProgram, (void))
+SDL_PROC(GLuint, glCreateShader, (GLenum))
+SDL_PROC(void, glDeleteProgram, (GLuint))
+SDL_PROC(void, glDeleteShader, (GLuint))
+SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
+SDL_PROC(void, glDisable, (GLenum))
+SDL_PROC(void, glDisableVertexAttribArray, (GLuint))
+SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
+SDL_PROC(void, glEnable, (GLenum))
+SDL_PROC(void, glEnableVertexAttribArray, (GLuint))
+SDL_PROC(void, glFinish, (void))
+SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *))
+SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
+SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *))
+SDL_PROC(const GLubyte *, glGetString, (GLenum))
+SDL_PROC(GLenum, glGetError, (void))
+SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
+SDL_PROC(void, glGetProgramiv, (GLuint, GLenum, GLint *))
+SDL_PROC(void, glGetShaderInfoLog, (GLuint, GLsizei, GLsizei *, char *))
+SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *))
+SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *))
+SDL_PROC(void, glLinkProgram, (GLuint))
+SDL_PROC(void, glPixelStorei, (GLenum, GLint))
+SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
+SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
+SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
+SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
+SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
+SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
+SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
+SDL_PROC(void, glUniform1i, (GLint, GLint))
+SDL_PROC(void, glUniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat))
+SDL_PROC(void, glUniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *))
+SDL_PROC(void, glUseProgram, (GLuint))
+SDL_PROC(void, glVertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))
+SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
+SDL_PROC(void, glBindFramebuffer, (GLenum, GLuint))
+SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
+SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
+SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
+SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
+SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
+SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
+SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
+SDL_PROC(void, glBufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum))
+SDL_PROC(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *))
old mode 100644 (file)
new mode 100755 (executable)
index ec9f528..4f3e479
@@ -86,9 +86,8 @@ loop()
         emscripten_cancel_main_loop();
 }
 #endif
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     char filename[4096];
@@ -98,18 +97,18 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
     if (argc > 1) {
         SDL_strlcpy(filename, argv[1], sizeof(filename));
     } else {
-        SDL_strlcpy(filename, "sample.wav", sizeof(filename));
+        SDL_strlcpy(filename, "res/sample.wav", sizeof(filename));
     }
     /* Load the wave file into memory */
     if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
         quit(1);
     }
 
@@ -127,19 +126,19 @@ main(int argc, char *argv[])
 #endif /* HAVE_SIGNAL_H */
 
     /* Show the list of available drivers */
-    SDL_Log("Available audio drivers:");
+    SDLTest_Log("Available audio drivers:");
     for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
-        SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
+        SDLTest_Log("%i: %s", i, SDL_GetAudioDriver(i));
     }
 
     /* Initialize fillerup() variables */
     if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
         SDL_FreeWAV(wave.sound);
         quit(2);
     }
 
-    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+    SDLTest_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
 
     /* Let the audio run */
     SDL_PauseAudio(0);
@@ -148,7 +147,10 @@ main(int argc, char *argv[])
     emscripten_set_main_loop(loop, 0, 1);
 #else
     while (!done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING))
-        SDL_Delay(1000);
+       {
+        SDL_Delay(10000);
+               done = 1;
+       }
 #endif
 
     /* Clean up on signal */
old mode 100644 (file)
new mode 100755 (executable)
index 85f5bd5..c1d8de1
@@ -61,39 +61,37 @@ loop()
     {
         /* The device from SDL_OpenAudio() is always device #1. */
         const Uint32 queued = SDL_GetQueuedAudioSize(1);
-        SDL_Log("Device has %u bytes queued.\n", (unsigned int) queued);
+        SDLTest_Log("Device has %u bytes queued.\n", (unsigned int) queued);
         if (queued <= 8192) {  /* time to requeue the whole thing? */
             if (SDL_QueueAudio(1, wave.sound, wave.soundlen) == 0) {
-                SDL_Log("Device queued %u more bytes.\n", (unsigned int) wave.soundlen);
+                SDLTest_Log("Device queued %u more bytes.\n", (unsigned int) wave.soundlen);
             } else {
-                SDL_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int) wave.soundlen, SDL_GetError());
+                SDLTest_Log("Device FAILED to queue %u more bytes: %s\n", (unsigned int) wave.soundlen, SDL_GetError());
             }
         }
     }
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     char filename[4096];
-
     /* Enable standard application logging */
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
     if (argc > 1) {
         SDL_strlcpy(filename, argv[1], sizeof(filename));
     } else {
-        SDL_strlcpy(filename, "sample.wav", sizeof(filename));
+        SDL_strlcpy(filename, "res/sample.wav", sizeof(filename));
     }
     /* Load the wave file into memory */
     if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
         quit(1);
     }
 
@@ -113,7 +111,7 @@ main(int argc, char *argv[])
 
     /* Initialize fillerup() variables */
     if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
         SDL_FreeWAV(wave.sound);
         quit(2);
     }
@@ -136,7 +134,8 @@ main(int argc, char *argv[])
     {
         loop();
 
-        SDL_Delay(100);  /* let it play for awhile. */
+        SDL_Delay(10000);  /* let it play for awhile. */
+               done = 1;
     }
 #endif
 
diff --git a/test/packaging/sdl_test.spec b/test/packaging/sdl_test.spec
new file mode 100755 (executable)
index 0000000..4317360
--- /dev/null
@@ -0,0 +1,71 @@
+Name:       org.tizen.sdl2_test
+Summary:    sdl2demo
+Version:    0.1
+Release:    1
+Group:      TO_BE/FILLED_IN
+License:    Apache
+Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires:  edje-bin
+BuildRequires:  pkgconfig(dlog)
+
+BuildRequires:  cmake
+BuildRequires:  edje-bin
+BuildRequires:  embryo-bin
+BuildRequires:  gettext-devel
+
+BuildRequires:  pkgconfig(egl)
+BuildRequires:  pkgconfig(glesv2)
+BuildRequires:  pkgconfig(glesv1)
+BuildRequires:  pkgconfig(sdl2)
+
+%define _packagedir /opt/usr/apps/%{name}
+%define _resdir %{_packagedir}/res
+
+
+
+Autoreq: no
+
+
+%description
+Description: sdl_test
+
+%package devel
+Summary:    sdl_test library development headers
+Group:      Development/Libraries
+Requires:   %{name} = %{version}
+
+%description devel
+Web App Service library development headers
+%prep
+%setup -q
+
+%build
+export CFLAGS="$CFLAGS %{?__vd_cflags}  -Wno-error"
+export CXXFLAGS="$CXXFLAGS %{?__vd_cxxflags} -Wno-error"
+cmake . \
+       -DCMAKE_INSTALL_PREFIX=%{_packagedir} \
+       -DPACKAGE_NAME=%{name} \
+       -DVERSION=%{version} \
+       -DTIZEN_VERSION=%{tizen}
+#make %{?jobs:-j%jobs}
+#output different color when make error
+make 2>&1 %{?jobs:-j%jobs} | sed -e 's%^.*: error: .*$%\x1b[37;41m&\x1b[m%' -e  's%^.*: warning: .*$%\x1b[30;43m&\x1b[m%'
+
+%install
+rm -rf %{buildroot}
+
+%make_install
+
+
+%clean
+rm -rf %{buildroot}
+
+%post
+
+%files
+%defattr(-,root,root,-)
+%attr(755,root,root) %{_packagedir}/*
+
+
+%files devel
diff --git a/test/res/AutomationNotify.bmp b/test/res/AutomationNotify.bmp
new file mode 100755 (executable)
index 0000000..5362952
Binary files /dev/null and b/test/res/AutomationNotify.bmp differ
diff --git a/test/res/AutomationTest.bmp b/test/res/AutomationTest.bmp
new file mode 100755 (executable)
index 0000000..b538e4c
Binary files /dev/null and b/test/res/AutomationTest.bmp differ
diff --git a/test/res/InteractiveTest.bmp b/test/res/InteractiveTest.bmp
new file mode 100755 (executable)
index 0000000..d05965a
Binary files /dev/null and b/test/res/InteractiveTest.bmp differ
diff --git a/test/res/axis.bmp b/test/res/axis.bmp
new file mode 100755 (executable)
index 0000000..c7addd3
Binary files /dev/null and b/test/res/axis.bmp differ
diff --git a/test/res/bg.bmp b/test/res/bg.bmp
new file mode 100755 (executable)
index 0000000..ca85940
Binary files /dev/null and b/test/res/bg.bmp differ
diff --git a/test/res/button.bmp b/test/res/button.bmp
new file mode 100755 (executable)
index 0000000..1593cce
Binary files /dev/null and b/test/res/button.bmp differ
diff --git a/test/res/controllermap.bmp b/test/res/controllermap.bmp
new file mode 100755 (executable)
index 0000000..df167f6
Binary files /dev/null and b/test/res/controllermap.bmp differ
diff --git a/test/res/icon.bmp b/test/res/icon.bmp
new file mode 100755 (executable)
index 0000000..cc96356
Binary files /dev/null and b/test/res/icon.bmp differ
diff --git a/test/res/libSDL2-2.0.so b/test/res/libSDL2-2.0.so
new file mode 100755 (executable)
index 0000000..9b69eb2
Binary files /dev/null and b/test/res/libSDL2-2.0.so differ
diff --git a/test/res/loopwave.bmp b/test/res/loopwave.bmp
new file mode 100755 (executable)
index 0000000..dfba54e
Binary files /dev/null and b/test/res/loopwave.bmp differ
diff --git a/test/res/loopwavequeue.bmp b/test/res/loopwavequeue.bmp
new file mode 100755 (executable)
index 0000000..f5b40ef
Binary files /dev/null and b/test/res/loopwavequeue.bmp differ
diff --git a/test/res/moose.dat b/test/res/moose.dat
new file mode 100755 (executable)
index 0000000..1053004
Binary files /dev/null and b/test/res/moose.dat differ
diff --git a/test/res/sample.bmp b/test/res/sample.bmp
new file mode 100755 (executable)
index 0000000..aca8bbc
Binary files /dev/null and b/test/res/sample.bmp differ
diff --git a/test/res/sample.wav b/test/res/sample.wav
new file mode 100755 (executable)
index 0000000..002f815
Binary files /dev/null and b/test/res/sample.wav differ
diff --git a/test/res/test.bmp b/test/res/test.bmp
new file mode 100755 (executable)
index 0000000..7f51b7c
Binary files /dev/null and b/test/res/test.bmp differ
diff --git a/test/res/testadded.bmp b/test/res/testadded.bmp
new file mode 100755 (executable)
index 0000000..5f3e736
Binary files /dev/null and b/test/res/testadded.bmp differ
diff --git a/test/res/testatomic.bmp b/test/res/testatomic.bmp
new file mode 100755 (executable)
index 0000000..33e9ac3
Binary files /dev/null and b/test/res/testatomic.bmp differ
diff --git a/test/res/testaudiohotplug.bmp b/test/res/testaudiohotplug.bmp
new file mode 100755 (executable)
index 0000000..f3a82a0
Binary files /dev/null and b/test/res/testaudiohotplug.bmp differ
diff --git a/test/res/testaudioinfo.bmp b/test/res/testaudioinfo.bmp
new file mode 100755 (executable)
index 0000000..4841fc2
Binary files /dev/null and b/test/res/testaudioinfo.bmp differ
diff --git a/test/res/testchessboard.bmp b/test/res/testchessboard.bmp
new file mode 100755 (executable)
index 0000000..16c6b45
Binary files /dev/null and b/test/res/testchessboard.bmp differ
diff --git a/test/res/testdisplayinfo.bmp b/test/res/testdisplayinfo.bmp
new file mode 100755 (executable)
index 0000000..dbec084
Binary files /dev/null and b/test/res/testdisplayinfo.bmp differ
diff --git a/test/res/testdraw2.bmp b/test/res/testdraw2.bmp
new file mode 100755 (executable)
index 0000000..6c8e44c
Binary files /dev/null and b/test/res/testdraw2.bmp differ
diff --git a/test/res/testdropfile.bmp b/test/res/testdropfile.bmp
new file mode 100755 (executable)
index 0000000..5b1acbc
Binary files /dev/null and b/test/res/testdropfile.bmp differ
diff --git a/test/res/testerror.bmp b/test/res/testerror.bmp
new file mode 100755 (executable)
index 0000000..783d09d
Binary files /dev/null and b/test/res/testerror.bmp differ
diff --git a/test/res/testfile.bmp b/test/res/testfile.bmp
new file mode 100755 (executable)
index 0000000..4fbe794
Binary files /dev/null and b/test/res/testfile.bmp differ
diff --git a/test/res/testfilesystem.bmp b/test/res/testfilesystem.bmp
new file mode 100755 (executable)
index 0000000..4a8fb68
Binary files /dev/null and b/test/res/testfilesystem.bmp differ
diff --git a/test/res/testgles.bmp b/test/res/testgles.bmp
new file mode 100755 (executable)
index 0000000..7fe456a
Binary files /dev/null and b/test/res/testgles.bmp differ
diff --git a/test/res/testgles2.bmp b/test/res/testgles2.bmp
new file mode 100755 (executable)
index 0000000..e474a07
Binary files /dev/null and b/test/res/testgles2.bmp differ
diff --git a/test/res/testhit.bmp b/test/res/testhit.bmp
new file mode 100755 (executable)
index 0000000..1990692
Binary files /dev/null and b/test/res/testhit.bmp differ
diff --git a/test/res/testiconv.bmp b/test/res/testiconv.bmp
new file mode 100755 (executable)
index 0000000..90583c4
Binary files /dev/null and b/test/res/testiconv.bmp differ
diff --git a/test/res/testime.bmp b/test/res/testime.bmp
new file mode 100755 (executable)
index 0000000..da24a4f
Binary files /dev/null and b/test/res/testime.bmp differ
diff --git a/test/res/testintersection.bmp b/test/res/testintersection.bmp
new file mode 100755 (executable)
index 0000000..45fb590
Binary files /dev/null and b/test/res/testintersection.bmp differ
diff --git a/test/res/testkeys.bmp b/test/res/testkeys.bmp
new file mode 100755 (executable)
index 0000000..0689f74
Binary files /dev/null and b/test/res/testkeys.bmp differ
diff --git a/test/res/testloadso.bmp b/test/res/testloadso.bmp
new file mode 100755 (executable)
index 0000000..4bb6912
Binary files /dev/null and b/test/res/testloadso.bmp differ
diff --git a/test/res/testlock.bmp b/test/res/testlock.bmp
new file mode 100755 (executable)
index 0000000..03d3764
Binary files /dev/null and b/test/res/testlock.bmp differ
diff --git a/test/res/testmultiaudio.bmp b/test/res/testmultiaudio.bmp
new file mode 100755 (executable)
index 0000000..a1272fa
Binary files /dev/null and b/test/res/testmultiaudio.bmp differ
diff --git a/test/res/testoverlay2.bmp b/test/res/testoverlay2.bmp
new file mode 100755 (executable)
index 0000000..8680b4f
Binary files /dev/null and b/test/res/testoverlay2.bmp differ
diff --git a/test/res/testplatform.bmp b/test/res/testplatform.bmp
new file mode 100755 (executable)
index 0000000..1519a49
Binary files /dev/null and b/test/res/testplatform.bmp differ
diff --git a/test/res/testrelative.bmp b/test/res/testrelative.bmp
new file mode 100755 (executable)
index 0000000..3849e4a
Binary files /dev/null and b/test/res/testrelative.bmp differ
diff --git a/test/res/testrendercopyex.bmp b/test/res/testrendercopyex.bmp
new file mode 100755 (executable)
index 0000000..1bb3b80
Binary files /dev/null and b/test/res/testrendercopyex.bmp differ
diff --git a/test/res/testrendertarget.bmp b/test/res/testrendertarget.bmp
new file mode 100755 (executable)
index 0000000..99354ce
Binary files /dev/null and b/test/res/testrendertarget.bmp differ
diff --git a/test/res/testresample.bmp b/test/res/testresample.bmp
new file mode 100755 (executable)
index 0000000..00765f4
Binary files /dev/null and b/test/res/testresample.bmp differ
diff --git a/test/res/testscale.bmp b/test/res/testscale.bmp
new file mode 100755 (executable)
index 0000000..278a3a9
Binary files /dev/null and b/test/res/testscale.bmp differ
diff --git a/test/res/testsem.bmp b/test/res/testsem.bmp
new file mode 100755 (executable)
index 0000000..9b84f6b
Binary files /dev/null and b/test/res/testsem.bmp differ
diff --git a/test/res/testshader.bmp b/test/res/testshader.bmp
new file mode 100755 (executable)
index 0000000..55ad4b6
Binary files /dev/null and b/test/res/testshader.bmp differ
diff --git a/test/res/testsprite2.bmp b/test/res/testsprite2.bmp
new file mode 100755 (executable)
index 0000000..f508ffe
Binary files /dev/null and b/test/res/testsprite2.bmp differ
diff --git a/test/res/testspriteminimal.bmp b/test/res/testspriteminimal.bmp
new file mode 100755 (executable)
index 0000000..c9cc47d
Binary files /dev/null and b/test/res/testspriteminimal.bmp differ
diff --git a/test/res/teststreaming.bmp b/test/res/teststreaming.bmp
new file mode 100755 (executable)
index 0000000..0ff3aec
Binary files /dev/null and b/test/res/teststreaming.bmp differ
diff --git a/test/res/testthread.bmp b/test/res/testthread.bmp
new file mode 100755 (executable)
index 0000000..51f2579
Binary files /dev/null and b/test/res/testthread.bmp differ
diff --git a/test/res/testtimer.bmp b/test/res/testtimer.bmp
new file mode 100755 (executable)
index 0000000..91049f0
Binary files /dev/null and b/test/res/testtimer.bmp differ
diff --git a/test/res/testtoturethread.bmp b/test/res/testtoturethread.bmp
new file mode 100755 (executable)
index 0000000..7edae56
Binary files /dev/null and b/test/res/testtoturethread.bmp differ
diff --git a/test/res/testver.bmp b/test/res/testver.bmp
new file mode 100755 (executable)
index 0000000..1c7b456
Binary files /dev/null and b/test/res/testver.bmp differ
diff --git a/test/res/testviewport.bmp b/test/res/testviewport.bmp
new file mode 100755 (executable)
index 0000000..986b2f7
Binary files /dev/null and b/test/res/testviewport.bmp differ
diff --git a/test/res/tobeadded.bmp b/test/res/tobeadded.bmp
new file mode 100755 (executable)
index 0000000..6efe1a9
Binary files /dev/null and b/test/res/tobeadded.bmp differ
diff --git a/test/res/toturethread.bmp b/test/res/toturethread.bmp
new file mode 100755 (executable)
index 0000000..b9c4ee8
Binary files /dev/null and b/test/res/toturethread.bmp differ
diff --git a/test/res/utf8.txt b/test/res/utf8.txt
new file mode 100755 (executable)
index 0000000..aab22f1
--- /dev/null
@@ -0,0 +1,287 @@
+UTF-8 decoder capability and stress test
+----------------------------------------
+
+Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2003-02-19
+
+This test file can help you examine, how your UTF-8 decoder handles
+various types of correct, malformed, or otherwise interesting UTF-8
+sequences. This file is not meant to be a conformance test. It does
+not prescribes any particular outcome and therefore there is no way to
+"pass" or "fail" this test file, even though the texts suggests a
+preferable decoder behaviour at some places. The aim is instead to
+help you think about and test the behaviour of your UTF-8 on a
+systematic collection of unusual inputs. Experience so far suggests
+that most first-time authors of UTF-8 decoders find at least one
+serious problem in their decoder by using this file.
+
+The test lines below cover boundary conditions, malformed UTF-8
+sequences as well as correctly encoded UTF-8 sequences of Unicode code
+points that should never occur in a correct UTF-8 file.
+
+According to ISO 10646-1:2000, sections D.7 and 2.3c, a device
+receiving UTF-8 shall interpret a "malformed sequence in the same way
+that it interprets a character that is outside the adopted subset" and
+"characters that are not within the adopted subset shall be indicated
+to the user" by a receiving device. A quite commonly used approach in
+UTF-8 decoders is to replace any malformed UTF-8 sequence by a
+replacement character (U+FFFD), which looks a bit like an inverted
+question mark, or a similar symbol. It might be a good idea to
+visually distinguish a malformed UTF-8 sequence from a correctly
+encoded Unicode character that is just not available in the current
+font but otherwise fully legal, even though ISO 10646-1 doesn't
+mandate this. In any case, just ignoring malformed sequences or
+unavailable characters does not conform to ISO 10646, will make
+debugging more difficult, and can lead to user confusion.
+
+Please check, whether a malformed UTF-8 sequence is (1) represented at
+all, (2) represented by exactly one single replacement character (or
+equivalent signal), and (3) the following quotation mark after an
+illegal UTF-8 sequence is correctly displayed, i.e. proper
+resynchronization takes place immageately after any malformed
+sequence. This file says "THE END" in the last line, so if you don't
+see that, your decoder crashed somehow before, which should always be
+cause for concern.
+
+All lines in this file are exactly 79 characters long (plus the line
+feed). In addition, all lines end with "|", except for the two test
+lines 2.1.1 and 2.2.1, which contain non-printable ASCII controls
+U+0000 and U+007F. If you display this file with a fixed-width font,
+these "|" characters should all line up in column 79 (right margin).
+This allows you to test quickly, whether your UTF-8 decoder finds the
+correct number of characters in every line, that is whether each
+malformed sequences is replaced by a single replacement character.
+
+Note that as an alternative to the notion of malformed sequence used
+here, it is also a perfectly acceptable (and in some situations even
+preferable) solution to represent each individual byte of a malformed
+sequence by a replacement character. If you follow this strategy in
+your decoder, then please ignore the "|" column.
+
+
+Here come the tests:                                                          |
+                                                                              |
+1  Some correct UTF-8 text                                                    |
+                                                                              |
+(The codepoints for this test are:                                            |
+  U+03BA U+1F79 U+03C3 U+03BC U+03B5  --ryan.)                                |
+                                                                              |
+You should see the Greek word 'kosme':       "κόσμε"                          |
+                                                                              |
+                                                                              |
+2  Boundary condition test cases                                              |
+                                                                              |
+2.1  First possible sequence of a certain length                              |
+                                                                              |
+(byte zero skipped...there's a null added at the end of the test. --ryan.)    |
+                                                                              |
+2.1.2  2 bytes (U-00000080):        "\80"                                       |
+2.1.3  3 bytes (U-00000800):        "à €"                                       |
+2.1.4  4 bytes (U-00010000):        "ð€€"                                       |
+                                                                              |
+(5 and 6 byte sequences were made illegal in rfc3629. --ryan.)                |
+2.1.5  5 bytes (U-00200000):        "øˆ€€€"                                       |
+2.1.6  6 bytes (U-04000000):        "ü„€€€€"                                       |
+                                                                              |
+2.2  Last possible sequence of a certain length                               |
+                                                                              |
+2.2.1  1 byte  (U-0000007F):        "\7f"                                       |
+2.2.2  2 bytes (U-000007FF):        "ß¿"                                       |
+                                                                              |
+(Section 5.3.2 below calls this illegal. --ryan.)                             |
+2.2.3  3 bytes (U-0000FFFF):        "ï¿¿"                                       |
+                                                                              |
+(5 and 6 bytes sequences, and 4 bytes sequences > 0x10FFFF were made illegal  |
+ in rfc3629, so these next three should be replaced with a invalid            |
+ character codepoint. --ryan.)                                                |
+2.2.4  4 bytes (U-001FFFFF):        "÷¿¿¿"                                       |
+2.2.5  5 bytes (U-03FFFFFF):        "û¿¿¿¿"                                       |
+2.2.6  6 bytes (U-7FFFFFFF):        "ý¿¿¿¿¿"                                       |
+                                                                              |
+2.3  Other boundary conditions                                                |
+                                                                              |
+2.3.1  U-0000D7FF = ed 9f bf = "퟿"                                            |
+2.3.2  U-0000E000 = ee 80 80 = ""                                            |
+2.3.3  U-0000FFFD = ef bf bd = "�"                                            |
+2.3.4  U-0010FFFF = f4 8f bf bf = "ô¿¿"                                         |
+                                                                              |
+(This one is bogus in rfc3629. --ryan.)                                       |
+2.3.5  U-00110000 = f4 90 80 80 = "ô€€"                                         |
+                                                                              |
+3  Malformed sequences                                                        |
+                                                                              |
+3.1  Unexpected continuation bytes                                            |
+                                                                              |
+Each unexpected continuation byte should be separately signalled as a         |
+malformed sequence of its own.                                                |
+                                                                              |
+3.1.1  First continuation byte 0x80: "\80"                                      |
+3.1.2  Last  continuation byte 0xbf: "¿"                                      |
+                                                                              |
+3.1.3  2 continuation bytes: "\80¿"                                             |
+3.1.4  3 continuation bytes: "\80¿\80"                                            |
+3.1.5  4 continuation bytes: "\80¿\80¿"                                           |
+3.1.6  5 continuation bytes: "\80¿\80¿\80"                                          |
+3.1.7  6 continuation bytes: "\80¿\80¿\80¿"                                         |
+3.1.8  7 continuation bytes: "\80¿\80¿\80¿\80"                                        |
+                                                                              |
+3.1.9  Sequence of all 64 possible continuation bytes (0x80-0xbf):            |
+                                                                              |
+   "\80\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f                                                          |
+    \90\91\92\93\94\95\96\97\98\99\9a\9b\9c\9d\9e\9f                                                          |
+    Â Â¡Â¢Â£Â¤Â¥Â¦Â§Â¨Â©ÂªÂ«Â¬Â­Â®Â¯                                                          |
+    Â°Â±Â²Â³Â´ÂµÂ¶Â·Â¸Â¹ÂºÂ»Â¼Â½Â¾Â¿"                                                         |
+                                                                              |
+3.2  Lonely start characters                                                  |
+                                                                              |
+3.2.1  All 32 first bytes of 2-byte sequences (0xc0-0xdf),                    |
+       each followed by a space character:                                    |
+                                                                              |
+   "À Ã Ã‚ Ãƒ Ã„ Ã… Ã† Ã‡ Ãˆ Ã‰ ÃŠ Ã‹ ÃŒ Ã ÃŽ Ã                                           |
+    Ã Ã‘ Ã’ Ã“ Ã” Ã• Ã– Ã— Ã˜ Ã™ Ãš Ã› Ãœ Ã Ãž ÃŸ "                                         |
+                                                                              |
+3.2.2  All 16 first bytes of 3-byte sequences (0xe0-0xef),                    |
+       each followed by a space character:                                    |
+                                                                              |
+   "à Ã¡ Ã¢ Ã£ Ã¤ Ã¥ Ã¦ Ã§ Ã¨ Ã© Ãª Ã« Ã¬ Ã­ Ã® Ã¯ "                                         |
+                                                                              |
+3.2.3  All 8 first bytes of 4-byte sequences (0xf0-0xf7),                     |
+       each followed by a space character:                                    |
+                                                                              |
+   "ð Ã± Ã² Ã³ Ã´ Ãµ Ã¶ Ã· "                                                         |
+                                                                              |
+3.2.4  All 4 first bytes of 5-byte sequences (0xf8-0xfb),                     |
+       each followed by a space character:                                    |
+                                                                              |
+   "ø Ã¹ Ãº Ã» "                                                                 |
+                                                                              |
+3.2.5  All 2 first bytes of 6-byte sequences (0xfc-0xfd),                     |
+       each followed by a space character:                                    |
+                                                                              |
+   "ü Ã½ "                                                                     |
+                                                                              |
+3.3  Sequences with last continuation byte missing                            |
+                                                                              |
+All bytes of an incomplete sequence should be signalled as a single           |
+malformed sequence, i.e., you should see only a single replacement            |
+character in each of the next 10 tests. (Characters as in section 2)          |
+                                                                              |
+3.3.1  2-byte sequence with last byte missing (U+0000):     "À"               |
+3.3.2  3-byte sequence with last byte missing (U+0000):     "à\80"               |
+3.3.3  4-byte sequence with last byte missing (U+0000):     "ð\80\80"               |
+3.3.4  5-byte sequence with last byte missing (U+0000):     "ø\80\80\80"               |
+3.3.5  6-byte sequence with last byte missing (U+0000):     "ü\80\80\80\80"               |
+3.3.6  2-byte sequence with last byte missing (U-000007FF): "ß"               |
+3.3.7  3-byte sequence with last byte missing (U-0000FFFF): "ï¿"               |
+3.3.8  4-byte sequence with last byte missing (U-001FFFFF): "÷¿¿"               |
+3.3.9  5-byte sequence with last byte missing (U-03FFFFFF): "û¿¿¿"               |
+3.3.10 6-byte sequence with last byte missing (U-7FFFFFFF): "ý¿¿¿¿"               |
+                                                                              |
+3.4  Concatenation of incomplete sequences                                    |
+                                                                              |
+All the 10 sequences of 3.3 concatenated, you should see 10 malformed         |
+sequences being signalled:                                                    |
+                                                                              |
+   "Àà\80ð\80\80ø\80\80\80ü\80\80\80\80ßï¿÷¿¿û¿¿¿ý¿¿¿¿"                                                               |
+                                                                              |
+3.5  Impossible bytes                                                         |
+                                                                              |
+The following two bytes cannot appear in a correct UTF-8 string               |
+                                                                              |
+3.5.1  fe = "þ"                                                               |
+3.5.2  ff = "ÿ"                                                               |
+3.5.3  fe fe ff ff = "þþÿÿ"                                                   |
+                                                                              |
+4  Overlong sequences                                                         |
+                                                                              |
+The following sequences are not malformed according to the letter of          |
+the Unicode 2.0 standard. However, they are longer then necessary and         |
+a correct UTF-8 encoder is not allowed to produce them. A "safe UTF-8         |
+decoder" should reject them just like malformed sequences for two             |
+reasons: (1) It helps to debug applications if overlong sequences are         |
+not treated as valid representations of characters, because this helps        |
+to spot problems more quickly. (2) Overlong sequences provide                 |
+alternative representations of characters, that could maliciously be          |
+used to bypass filters that check only for ASCII characters. For              |
+instance, a 2-byte encoded line feed (LF) would not be caught by a            |
+line counter that counts only 0x0a bytes, but it would still be               |
+processed as a line feed by an unsafe UTF-8 decoder later in the              |
+pipeline. From a security point of view, ASCII compatibility of UTF-8         |
+sequences means also, that ASCII characters are *only* allowed to be          |
+represented by ASCII bytes in the range 0x00-0x7f. To ensure this             |
+aspect of ASCII compatibility, use only "safe UTF-8 decoders" that            |
+reject overlong UTF-8 sequences for which a shorter encoding exists.          |
+                                                                              |
+4.1  Examples of an overlong ASCII character                                  |
+                                                                              |
+With a safe UTF-8 decoder, all of the following five overlong                 |
+representations of the ASCII character slash ("/") should be rejected         |
+like a malformed UTF-8 sequence, for instance by substituting it with         |
+a replacement character. If you see a slash below, you do not have a          |
+safe UTF-8 decoder!                                                           |
+                                                                              |
+4.1.1 U+002F = c0 af             = "À¯"                                        |
+4.1.2 U+002F = e0 80 af          = "à\80¯"                                        |
+4.1.3 U+002F = f0 80 80 af       = "ð\80\80¯"                                        |
+4.1.4 U+002F = f8 80 80 80 af    = "ø\80\80\80¯"                                        |
+4.1.5 U+002F = fc 80 80 80 80 af = "ü\80\80\80\80¯"                                        |
+                                                                              |
+4.2  Maximum overlong sequences                                               |
+                                                                              |
+Below you see the highest Unicode value that is still resulting in an         |
+overlong sequence if represented with the given number of bytes. This         |
+is a boundary test for safe UTF-8 decoders. All five characters should        |
+be rejected like malformed UTF-8 sequences.                                   |
+                                                                              |
+4.2.1  U-0000007F = c1 bf             = "ÿ"                                   |
+4.2.2  U-000007FF = e0 9f bf          = "à\9f¿"                                   |
+4.2.3  U-0000FFFF = f0 8f bf bf       = "ð\8f¿¿"                                   |
+4.2.4  U-001FFFFF = f8 87 bf bf bf    = "ø\87¿¿¿"                                   |
+4.2.5  U-03FFFFFF = fc 83 bf bf bf bf = "ü\83¿¿¿¿"                                   |
+                                                                              |
+4.3  Overlong representation of the NUL character                             |
+                                                                              |
+The following five sequences should also be rejected like malformed           |
+UTF-8 sequences and should not be treated like the ASCII NUL                  |
+character.                                                                    |
+                                                                              |
+4.3.1  U+0000 = c0 80             = "À\80"                                       |
+4.3.2  U+0000 = e0 80 80          = "à\80\80"                                       |
+4.3.3  U+0000 = f0 80 80 80       = "ð\80\80\80"                                       |
+4.3.4  U+0000 = f8 80 80 80 80    = "ø\80\80\80\80"                                       |
+4.3.5  U+0000 = fc 80 80 80 80 80 = "ü\80\80\80\80\80"                                       |
+                                                                              |
+5  Illegal code positions                                                     |
+                                                                              |
+The following UTF-8 sequences should be rejected like malformed               |
+sequences, because they never represent valid ISO 10646 characters and        |
+a UTF-8 decoder that accepts them might introduce security problems           |
+comparable to overlong UTF-8 sequences.                                       |
+                                                                              |
+5.1 Single UTF-16 surrogates                                                  |
+                                                                              |
+5.1.1  U+D800 = ed a0 80 = "í €"                                                |
+5.1.2  U+DB7F = ed ad bf = "í­¿"                                                |
+5.1.3  U+DB80 = ed ae 80 = "í®€"                                                |
+5.1.4  U+DBFF = ed af bf = "í¯¿"                                                |
+5.1.5  U+DC00 = ed b0 80 = "í°€"                                                |
+5.1.6  U+DF80 = ed be 80 = "í¾€"                                                |
+5.1.7  U+DFFF = ed bf bf = "í¿¿"                                                |
+                                                                              |
+5.2 Paired UTF-16 surrogates                                                  |
+                                                                              |
+5.2.1  U+D800 U+DC00 = ed a0 80 ed b0 80 = "𐀀"                               |
+5.2.2  U+D800 U+DFFF = ed a0 80 ed bf bf = "𐏿"                               |
+5.2.3  U+DB7F U+DC00 = ed ad bf ed b0 80 = "í­¿í°€"                               |
+5.2.4  U+DB7F U+DFFF = ed ad bf ed bf bf = "í­¿í¿¿"                               |
+5.2.5  U+DB80 U+DC00 = ed ae 80 ed b0 80 = "󰀀"                               |
+5.2.6  U+DB80 U+DFFF = ed ae 80 ed bf bf = "󰏿"                               |
+5.2.7  U+DBFF U+DC00 = ed af bf ed b0 80 = "􏰀"                               |
+5.2.8  U+DBFF U+DFFF = ed af bf ed bf bf = "􏿿"                               |
+                                                                              |
+5.3 Other illegal code positions                                              |
+                                                                              |
+5.3.1  U+FFFE = ef bf be = "￾"                                                |
+5.3.2  U+FFFF = ef bf bf = "ï¿¿"                                                |
+                                                                              |
+THE END                                                                       |
+
old mode 100644 (file)
new mode 100755 (executable)
index 41cc9ab..978815c
@@ -42,39 +42,42 @@ void RunBasicTest()
     SDL_atomic_t v;
     SDL_bool tfret = SDL_FALSE;
 
-    SDL_Log("\nspin lock---------------------------------------\n\n");
+    SDLTest_Log("\nspin lock---------------------------------------\n\n");
 
     SDL_AtomicLock(&lock);
-    SDL_Log("AtomicLock                   lock=%d\n", lock);
+    SDLTest_Log("AtomicLock                   lock=%d\n", lock);
     SDL_AtomicUnlock(&lock);
-    SDL_Log("AtomicUnlock                 lock=%d\n", lock);
+    SDLTest_Log("AtomicUnlock                 lock=%d\n", lock);
 
-    SDL_Log("\natomic -----------------------------------------\n\n");
+    SDLTest_Log("\natomic -----------------------------------------\n\n");
 
     SDL_AtomicSet(&v, 0);
     tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicSet(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicAdd(10)        tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 
     SDL_AtomicSet(&v, 0);
     SDL_AtomicIncRef(&v);
     tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     SDL_AtomicIncRef(&v);
     tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicIncRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicDecRef()       tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
 
     SDL_AtomicSet(&v, 10);
     tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
     value = SDL_AtomicGet(&v);
     tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
-    SDL_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+    SDLTest_Log("AtomicCAS()          tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+       
+       SDL_MemoryBarrierAcquire();
+       SDL_MemoryBarrierRelease();
 }
 
 /**************************************************************************/
@@ -117,7 +120,7 @@ static
 int adder(void* junk)
 {
     unsigned long N=NInter;
-    SDL_Log("Thread subtracting %d %lu times\n",CountInc,N);
+    SDLTest_Log("Thread subtracting %d %lu times\n",CountInc,N);
     while (N--) {
         SDL_AtomicAdd(&good, -CountInc);
         bad-=CountInc;
@@ -149,7 +152,7 @@ void runAdder(void)
 
     end = SDL_GetTicks();
 
-    SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
+    SDLTest_Log("Finished in %f sec\n", (end - start) / 1000.f);
 }
 
 static
@@ -158,28 +161,28 @@ void RunEpicTest()
     int b;
     atomicValue v;
 
-    SDL_Log("\nepic test---------------------------------------\n\n");
+    SDLTest_Log("\nepic test---------------------------------------\n\n");
 
-    SDL_Log("Size asserted to be >= 32-bit\n");
+    SDLTest_Log("Size asserted to be >= 32-bit\n");
     SDL_assert(sizeof(atomicValue)>=4);
 
-    SDL_Log("Check static initializer\n");
+    SDLTest_Log("Check static initializer\n");
     v=SDL_AtomicGet(&good);
     SDL_assert(v==42);
 
     SDL_assert(bad==42);
 
-    SDL_Log("Test negative values\n");
+    SDLTest_Log("Test negative values\n");
     SDL_AtomicSet(&good, -5);
     v=SDL_AtomicGet(&good);
     SDL_assert(v==-5);
 
-    SDL_Log("Verify maximum value\n");
+    SDLTest_Log("Verify maximum value\n");
     SDL_AtomicSet(&good, CountTo);
     v=SDL_AtomicGet(&good);
     SDL_assert(v==CountTo);
 
-    SDL_Log("Test compare and exchange\n");
+    SDLTest_Log("Test compare and exchange\n");
 
     b=SDL_AtomicCAS(&good, 500, 43);
     SDL_assert(!b); /* no swap since CountTo!=500 */
@@ -191,7 +194,7 @@ void RunEpicTest()
     v=SDL_AtomicGet(&good);
     SDL_assert(v==44);
 
-    SDL_Log("Test Add\n");
+    SDLTest_Log("Test Add\n");
 
     v=SDL_AtomicAdd(&good, 1);
     SDL_assert(v==44);
@@ -203,7 +206,7 @@ void RunEpicTest()
     v=SDL_AtomicGet(&good);
     SDL_assert(v==55);
 
-    SDL_Log("Test Add (Negative values)\n");
+    SDLTest_Log("Test Add (Negative values)\n");
 
     v=SDL_AtomicAdd(&good, -20);
     SDL_assert(v==55);
@@ -220,7 +223,7 @@ void RunEpicTest()
     v=SDL_AtomicGet(&good);
     SDL_assert(v==15);
 
-    SDL_Log("Reset before count down test\n");
+    SDLTest_Log("Reset before count down test\n");
     SDL_AtomicSet(&good, CountTo);
     v=SDL_AtomicGet(&good);
     SDL_assert(v==CountTo);
@@ -228,11 +231,11 @@ void RunEpicTest()
     bad=CountTo;
     SDL_assert(bad==CountTo);
 
-    SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
+    SDLTest_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
     runAdder();
 
     v=SDL_AtomicGet(&good);
-    SDL_Log("Atomic %d Non-Atomic %d\n",v,bad);
+    SDLTest_Log("Atomic %d Non-Atomic %d\n",v,bad);
     SDL_assert(v==Expect);
     SDL_assert(bad!=Expect);
 }
@@ -427,7 +430,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event
     } else if (delta < 0) {
         /* We ran into an old queue entry, which means it still needs to be dequeued */
     } else {
-        SDL_Log("ERROR: mutex failed!\n");
+        SDLTest_Log("ERROR: mutex failed!\n");
     }
 
     SDL_UnlockMutex(queue->mutex);
@@ -460,7 +463,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
     } else if (delta < 0) {
         /* We ran into an old queue entry, which means we've hit empty */
     } else {
-        SDL_Log("ERROR: mutex failed!\n");
+        SDLTest_Log("ERROR: mutex failed!\n");
     }
 
     SDL_UnlockMutex(queue->mutex);
@@ -599,8 +602,8 @@ static void RunFIFOTest(SDL_bool lock_free)
     char textBuffer[1024];
     int len;
 
-    SDL_Log("\nFIFO test---------------------------------------\n\n");
-    SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
+    SDLTest_Log("\nFIFO test---------------------------------------\n\n");
+    SDLTest_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
 
     readersDone = SDL_CreateSemaphore(0);
     writersDone = SDL_CreateSemaphore(0);
@@ -622,7 +625,7 @@ static void RunFIFOTest(SDL_bool lock_free)
 #endif
 
     /* Start the readers first */
-    SDL_Log("Starting %d readers\n", NUM_READERS);
+    SDLTest_Log("Starting %d readers\n", NUM_READERS);
     SDL_zero(readerData);
     SDL_AtomicSet(&readersRunning, NUM_READERS);
     for (i = 0; i < NUM_READERS; ++i) {
@@ -634,7 +637,7 @@ static void RunFIFOTest(SDL_bool lock_free)
     }
 
     /* Start up the writers */
-    SDL_Log("Starting %d writers\n", NUM_WRITERS);
+    SDLTest_Log("Starting %d writers\n", NUM_WRITERS);
     SDL_zero(writerData);
     SDL_AtomicSet(&writersRunning, NUM_WRITERS);
     for (i = 0; i < NUM_WRITERS; ++i) {
@@ -668,16 +671,16 @@ static void RunFIFOTest(SDL_bool lock_free)
         SDL_DestroyMutex(queue.mutex);
     }
 
-    SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
+    SDLTest_Log("Finished in %f sec\n", (end - start) / 1000.f);
 
-    SDL_Log("\n");
+    SDLTest_Log("\n");
     for (i = 0; i < NUM_WRITERS; ++i) {
-        SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
+        SDLTest_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
     }
-    SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
+    SDLTest_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
 
     /* Print a breakdown of which readers read messages from which writer */
-    SDL_Log("\n");
+    SDLTest_Log("\n");
     grand_total = 0;
     for (i = 0; i < NUM_READERS; ++i) {
         int total = 0;
@@ -685,7 +688,7 @@ static void RunFIFOTest(SDL_bool lock_free)
             total += readerData[i].counters[j];
         }
         grand_total += total;
-        SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
+        SDLTest_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
         SDL_snprintf(textBuffer, sizeof(textBuffer), "  { ");
         for (j = 0; j < NUM_WRITERS; ++j) {
             if (j > 0) {
@@ -697,16 +700,15 @@ static void RunFIFOTest(SDL_bool lock_free)
         }
         len = SDL_strlen(textBuffer);
         SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
-        SDL_Log("%s", textBuffer);
+        SDLTest_Log("%s", textBuffer);
     }
-    SDL_Log("Readers read %d total events\n", grand_total);
+    SDLTest_Log("Readers read %d total events\n", grand_total);
 }
 
 /* End FIFO test */
 /**************************************************************************/
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     /* Enable standard application logging */
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
old mode 100644 (file)
new mode 100755 (executable)
index e13868e..d822ff8
@@ -80,26 +80,26 @@ iteration()
     SDL_Event e;
     SDL_AudioDeviceID dev;
     while (SDL_PollEvent(&e)) {
-        if (e.type == SDL_QUIT) {
+        if (e.type == SDL_QUIT || e.key.keysym.sym == 0) {
             done = 1;
         } else if (e.type == SDL_AUDIODEVICEADDED) {
             const char *name = SDL_GetAudioDeviceName(e.adevice.which, 0);
-            SDL_Log("New %s audio device: %s\n", e.adevice.iscapture ? "capture" : "output", name);
+            SDLTest_Log("New %s audio device: %s\n", e.adevice.iscapture ? "capture" : "output", name);
             if (!e.adevice.iscapture) {
                 positions[posindex] = 0;
                 spec.userdata = &positions[posindex++];
                 spec.callback = fillerup;
                 dev = SDL_OpenAudioDevice(name, 0, &spec, NULL, 0);
                 if (!dev) {
-                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open '%s': %s\n", name, SDL_GetError());
+                    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open '%s': %s\n", name, SDL_GetError());
                 } else {
-                    SDL_Log("Opened '%s' as %u\n", name, (unsigned int) dev);
+                    SDLTest_Log("Opened '%s' as %u\n", name, (unsigned int) dev);
                     SDL_PauseAudioDevice(dev, 0);
                 }
             }
         } else if (e.type == SDL_AUDIODEVICEREMOVED) {
             dev = (SDL_AudioDeviceID) e.adevice.which;
-            SDL_Log("%s device %u removed.\n", e.adevice.iscapture ? "capture" : "output", (unsigned int) dev);
+            SDLTest_Log("%s device %u removed.\n", e.adevice.iscapture ? "capture" : "output", (unsigned int) dev);
             SDL_CloseAudioDevice(dev);
         }
     }
@@ -115,9 +115,8 @@ loop()
         iteration();
 }
 #endif
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     char filename[4096];
@@ -127,7 +126,7 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -137,11 +136,11 @@ main(int argc, char *argv[])
     if (argc > 1) {
         SDL_strlcpy(filename, argv[1], sizeof(filename));
     } else {
-        SDL_strlcpy(filename, "sample.wav", sizeof(filename));
+        SDL_strlcpy(filename, "res/sample.wav", sizeof(filename));
     }
     /* Load the wave file into memory */
     if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
         quit(1);
     }
 
@@ -158,12 +157,12 @@ main(int argc, char *argv[])
 #endif /* HAVE_SIGNAL_H */
 
     /* Show the list of available drivers */
-    SDL_Log("Available audio drivers:");
+    SDLTest_Log("Available audio drivers:");
     for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
-        SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
+        SDLTest_Log("%i: %s", i, SDL_GetAudioDriver(i));
     }
 
-    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+    SDLTest_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
 
 #ifdef __EMSCRIPTEN__
     emscripten_set_main_loop(loop, 0, 1);
old mode 100644 (file)
new mode 100755 (executable)
index 53bf0f5..3a6e446
@@ -18,23 +18,22 @@ print_devices(int iscapture)
     const char *typestr = ((iscapture) ? "capture" : "output");
     int n = SDL_GetNumAudioDevices(iscapture);
 
-    SDL_Log("%s devices:\n", typestr);
+    SDLTest_Log("%s devices:\n", typestr);
 
     if (n == -1)
-        SDL_Log("  Driver can't detect specific %s devices.\n\n", typestr);
+        SDLTest_Log("  Driver can't detect specific %s devices.\n\n", typestr);
     else if (n == 0)
-        SDL_Log("  No %s devices found.\n\n", typestr);
+        SDLTest_Log("  No %s devices found.\n\n", typestr);
     else {
         int i;
         for (i = 0; i < n; i++) {
-            SDL_Log("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
+            SDLTest_Log("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
         }
-        SDL_Log("\n");
+        SDLTest_Log("\n");
     }
 }
-
 int
-main(int argc, char **argv)
+SDL_main(int argc, char **argv)
 {
     int n;
 
@@ -43,24 +42,24 @@ main(int argc, char **argv)
 
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
     /* Print available audio drivers */
     n = SDL_GetNumAudioDrivers();
     if (n == 0) {
-        SDL_Log("No built-in audio drivers\n\n");
+        SDLTest_Log("No built-in audio drivers\n\n");
     } else {
         int i;
-        SDL_Log("Built-in audio drivers:\n");
+        SDLTest_Log("Built-in audio drivers:\n");
         for (i = 0; i < n; ++i) {
-            SDL_Log("  %s\n", SDL_GetAudioDriver(i));
+            SDLTest_Log("  %s\n", SDL_GetAudioDriver(i));
         }
-        SDL_Log("\n");
+        SDLTest_Log("\n");
     }
 
-    SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
+    SDLTest_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
 
     print_devices(0);
     print_devices(1);
old mode 100644 (file)
new mode 100755 (executable)
index eea74b3..f560b75
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
+#include <unistd.h>
 
 #include "SDL.h"
 #include "SDL_test.h"
@@ -28,10 +29,10 @@ quit(int rc)
     SDLTest_CommonQuit(state);
     exit(rc);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
+    
     int result;
     int testIterations = 1;
     Uint64 userExecKey = 0;
@@ -80,7 +81,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
+            SDLTest_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
                     argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -120,5 +121,4 @@ main(int argc, char *argv[])
     quit(result);
     return(result);
 }
-
 /* vi: set ts=4 sw=4 expandtab: */
old mode 100644 (file)
new mode 100755 (executable)
index bef838d..47e9238
@@ -708,6 +708,12 @@ int audio_openCloseAndGetAudioStatus()
      for (i = 0; i < count; i++) {
        /* Get device name */
        device = (char *)SDL_GetAudioDeviceName(i, 0);
+          /*add by majunqing for skip the device 1*/
+       const char* ignoreDevice = "VIRTUAL AUDIO W";
+       if(SDL_strcmp(device, ignoreDevice) == 0)
+       {\r
+               continue;
+       }
        SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
        SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
        if (device == NULL) return TEST_ABORTED;
@@ -766,6 +772,14 @@ int audio_lockUnlockOpenAudioDevice()
      for (i = 0; i < count; i++) {
        /* Get device name */
        device = (char *)SDL_GetAudioDeviceName(i, 0);
+          
+       /*add by majunqing for skip the device 1*/
+       const char* ignoreDevice = "VIRTUAL AUDIO W";
+       if(SDL_strcmp(device, ignoreDevice) == 0)
+       {\r
+               continue;
+       }
+          
        SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
        SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
        if (device == NULL) return TEST_ABORTED;
@@ -928,6 +942,13 @@ int audio_openCloseAudioDeviceConnected()
      for (i = 0; i < count; i++) {
        /* Get device name */
        device = (char *)SDL_GetAudioDeviceName(i, 0);
+             /*add by majunqing for skip the device 1*/
+       const char* ignoreDevice = "VIRTUAL AUDIO W";
+       if(SDL_strcmp(device, ignoreDevice) == 0)
+       {\r
+               continue;
+       }
+          
        SDLTest_AssertPass("SDL_GetAudioDeviceName(%i,0)", i);
        SDLTest_AssertCheck(device != NULL, "Validate device name is not NULL; got: %s", (device != NULL) ? device : "NULL");
        if (device == NULL) return TEST_ABORTED;
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index f9eb5bb..9114829
@@ -171,6 +171,8 @@ events_addDelEventWatchWithUserdata(void *arg)
    SDLTest_AssertPass("Call to SDL_PumpEvents()");
    SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called");
 
+   SDL_FlushEvent(0);
+   SDLTest_AssertPass("Call to SDL_FlushEvent()");
    return TEST_COMPLETED;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 5a1bc9b..484ef1d
@@ -1061,6 +1061,7 @@ _clearScreen(void)
 /* ================= Test References ================== */
 
 /* Render test cases */
+
 static const SDLTest_TestCaseReference renderTest1 =
         { (SDLTest_TestCaseFp)render_testGetNumRenderDrivers, "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED };
 
@@ -1087,7 +1088,7 @@ static const SDLTest_TestCaseReference renderTest7 =
 
 /* Sequence of Render test cases */
 static const SDLTest_TestCaseReference *renderTests[] =  {
-    &renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
+    /*&renderTest1,*/ &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
 };
 
 /* Render test suite (global) */
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index ca41d4a..3995509
@@ -425,6 +425,33 @@ surface_testBlit(void *arg)
    return TEST_COMPLETED;
 }
 
+int surface_testBlitScaled(void *arg)
+{
+       SDL_Surface* compareSurface;
+       int ret;
+       SDL_Rect compareSurfaceRect, srcSurfaceRect;
+       compareSurfaceRect.x = 0;
+       compareSurfaceRect.y = 0;
+       compareSurfaceRect.w = testSurface->w;
+       compareSurfaceRect.h = testSurface->h;
+
+       srcSurfaceRect.x = 1;
+       srcSurfaceRect.y = 1;
+       srcSurfaceRect.w = testSurface->w -1;
+       srcSurfaceRect.h = testSurface->h - 1;
+       compareSurface = SDL_LoadBMP("res/sample.bmp");
+       ret = SDL_BlitScaled(testSurface, NULL, compareSurface, &compareSurfaceRect);
+               
+       SDLTest_AssertCheck(ret == 0, "Validate result from SDL_BlitScaled, expected: 0, got: %i", ret);
+       //compareSurface = SDL_LoadBMP("res/sample.bmp");
+       //ret = SDL_LowerBlitScaled(testSurface, NULL, compareSurface, &compareSurfaceRect);
+
+
+       //SDLTest_AssertCheck(ret == 0, "Validate result from SDL_LowerBlitScaled, expected: 0, got: %i && the error is %s", ret, SDL_GetError());
+       //SDL_FreeSurface(compareSurface);
+                       
+       return TEST_COMPLETED;
+}
 /**
  * @brief Tests some blitting routines with color mod
  */
@@ -630,11 +657,14 @@ static const SDLTest_TestCaseReference surfaceTest11 =
 static const SDLTest_TestCaseReference surfaceTest12 =
         { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED};
 
+static const SDLTest_TestCaseReference surfaceTest13 =
+        { (SDLTest_TestCaseFp)surface_testBlitScaled, "surface_testBlitScaled", "Tests blitting scaled.", TEST_ENABLED};
+
 /* Sequence of Surface test cases */
 static const SDLTest_TestCaseReference *surfaceTests[] =  {
     &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
     &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10,
-    &surfaceTest11, &surfaceTest12, NULL
+    &surfaceTest11, &surfaceTest12, &surfaceTest13 ,NULL
 };
 
 /* Surface test suite (global) */
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 7c5b983..7b86cfb
@@ -897,9 +897,6 @@ video_getWindowId(void *arg)
 int
 video_getWindowPixelFormat(void *arg)
 {
-#if defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_TIZEN)
-  return TEST_UNSUPPORTED;
-#endif
   const char* title = "video_getWindowPixelFormat Test Window";
   SDL_Window* window;
   Uint32 format;
old mode 100644 (file)
new mode 100755 (executable)
index c228eb6..fc6a3f9
@@ -23,14 +23,15 @@ print_mode(const char *prefix, const SDL_DisplayMode *mode)
     if (!mode)
         return;
 
-    SDL_Log("%s: fmt=%s w=%d h=%d refresh=%d\n",
+    SDLTest_Log("%s: fmt=%s w=%d h=%d refresh=%d\n",
             prefix, SDL_GetPixelFormatName(mode->format),
             mode->w, mode->h, mode->refresh_rate);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
+       SDL_tizen_app_init(argc, argv);
+       SDL_SetMainReady();
     SDL_DisplayMode mode;
     int num_displays, dpy;
 
@@ -39,14 +40,14 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 1;
     }
 
-    SDL_Log("Using video target '%s'.\n", SDL_GetCurrentVideoDriver());
+    SDLTest_Log("Using video target '%s'.\n", SDL_GetCurrentVideoDriver());
     num_displays = SDL_GetNumVideoDisplays();
 
-    SDL_Log("See %d displays.\n", num_displays);
+    SDLTest_Log("See %d displays.\n", num_displays);
 
     for (dpy = 0; dpy < num_displays; dpy++) {
         const int num_modes = SDL_GetNumDisplayModes(dpy);
@@ -54,23 +55,23 @@ main(int argc, char *argv[])
         int m;
 
         SDL_GetDisplayBounds(dpy, &rect);
-        SDL_Log("%d: \"%s\" (%dx%d, (%d, %d)), %d modes.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, num_modes);
+        SDLTest_Log("%d: \"%s\" (%dx%d, (%d, %d)), %d modes.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, num_modes);
 
         if (SDL_GetCurrentDisplayMode(dpy, &mode) == -1) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "    CURRENT: failed to query (%s)\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "    CURRENT: failed to query (%s)\n", SDL_GetError());
         } else {
             print_mode("CURRENT", &mode);
         }
 
         if (SDL_GetDesktopDisplayMode(dpy, &mode) == -1) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "    DESKTOP: failed to query (%s)\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "    DESKTOP: failed to query (%s)\n", SDL_GetError());
         } else {
             print_mode("DESKTOP", &mode);
         }
 
         for (m = 0; m < num_modes; m++) {
             if (SDL_GetDisplayMode(dpy, m, &mode) == -1) {
-                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "    MODE %d: failed to query (%s)\n", m, SDL_GetError());
+                SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "    MODE %d: failed to query (%s)\n", m, SDL_GetError());
             } else {
                 char prefix[64];
                 SDL_snprintf(prefix, sizeof (prefix), "    MODE %d", m);
@@ -78,7 +79,7 @@ main(int argc, char *argv[])
             }
         }
 
-        SDL_Log("\n");
+        SDLTest_Log("\n");
     }
 
     SDL_Quit();
old mode 100644 (file)
new mode 100755 (executable)
index 77bd8c1..d926df0
@@ -21,7 +21,8 @@
 #endif
 
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 #define NUM_OBJECTS 100
 
 static SDLTest_CommonState *state;
@@ -204,9 +205,8 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     Uint32 then, now, frames;
@@ -219,6 +219,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -256,7 +258,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+            SDLTest_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
@@ -287,6 +289,8 @@ main(int argc, char *argv[])
     while (!done) {
         ++frames;
         loop();
+               //SDL_Delay(10000);  /* let it play for awhile. */
+               //done = 1;
         }
 #endif
 
@@ -297,7 +301,7 @@ main(int argc, char *argv[])
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        SDL_Log("%2.2f frames per second\n", fps);
+        SDLTest_Log("%2.2f frames per second\n", fps);
     }
     return 0;
 }
old mode 100644 (file)
new mode 100755 (executable)
index f2a1469..fccdb27
@@ -59,7 +59,7 @@ loop()
 {
     SDL_Event e;
     while (SDL_PollEvent(&e)) {
-        if (e.type == SDL_QUIT) {
+        if (e.type == SDL_QUIT || e.key.keysym.sym == SDLK_f) {
             done = 1;
 #ifdef __EMSCRIPTEN__
             emscripten_cancel_main_loop();
@@ -82,9 +82,8 @@ loop()
        now Update the drawing image on window screen */
     SDL_UpdateWindowSurface(window);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_Surface *surface;
 
@@ -94,23 +93,37 @@ main(int argc, char *argv[])
     /* Initialize SDL */
     if(SDL_Init(SDL_INIT_VIDEO) != 0)
     {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
         return 1;
     }
 
 
     /* Create window and renderer for given surface */
-    window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
+    window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 720, 1280, SDL_WINDOW_SHOWN);
     if(!window)
     {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError());
         return 1;
     }
+    SDL_SetWindowTitle(window, "chess board");
+    const char* windowtitle = SDL_GetWindowTitle(window);
+
+    if(SDL_strcmp(windowtitle, "chess board") != 0)
+    {
+       SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Set Window title fail : %s\n",SDL_GetError());
+
+    }
+
+    if(SDL_SetWindowBrightness(window, 0.5f) == -1)
+    {
+       SDLTest_Log(SDL_LOG_CATEGORY_APPLICATION, "Set Window Brightness is not supported ");
+    }
+
     surface = SDL_GetWindowSurface(window);
     renderer = SDL_CreateSoftwareRenderer(surface);
     if(!renderer)
     {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
         return 1;
     }
 
old mode 100644 (file)
new mode 100755 (executable)
index b7f215e..0b010d3
@@ -24,9 +24,8 @@ quit(int rc)
     SDLTest_CommonQuit(state);
     exit(rc);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i, done;
     SDL_Event event;
@@ -52,7 +51,7 @@ main(int argc, char *argv[])
             consumed = -1;
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+            SDLTest_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
         i += consumed;
@@ -79,7 +78,7 @@ main(int argc, char *argv[])
 
             if (event.type == SDL_DROPFILE) {
                 char *dropped_filedir = event.drop.file;
-                SDL_Log("File dropped on window: %s", dropped_filedir);
+                SDLTest_Log("File dropped on window: %s", dropped_filedir);
                 SDL_free(dropped_filedir);
             }
         }
old mode 100644 (file)
new mode 100755 (executable)
index b5fa3fb..da9fe1e
@@ -35,15 +35,14 @@ ThreadFunc(void *data)
     SDL_SetError("Thread %s (%lu) had a problem: %s",
                  (char *) data, SDL_ThreadID(), "nevermind");
     while (alive) {
-        SDL_Log("Thread '%s' is alive!\n", (char *) data);
+        SDLTest_Log("Thread '%s' is alive!\n", (char *) data);
         SDL_Delay(1 * 1000);
     }
-    SDL_Log("Child thread error string: %s\n", SDL_GetError());
+    SDLTest_Log("Child thread error string: %s\n", SDL_GetError());
     return (0);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_Thread *thread;
 
@@ -52,7 +51,7 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -62,15 +61,15 @@ main(int argc, char *argv[])
     alive = 1;
     thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
     if (thread == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
         quit(1);
     }
     SDL_Delay(5 * 1000);
-    SDL_Log("Waiting for thread #1\n");
+    SDLTest_Log("Waiting for thread #1\n");
     alive = 0;
     SDL_WaitThread(thread, NULL);
 
-    SDL_Log("Main thread error string: %s\n", SDL_GetError());
+    SDLTest_Log("Main thread error string: %s\n", SDL_GetError());
 
     SDL_Quit();
     return (0);
old mode 100644 (file)
new mode 100755 (executable)
index b45795f..cf7c944
@@ -50,7 +50,7 @@ cleanup(void)
 static void
 rwops_error_quit(unsigned line, SDL_RWops * rwops)
 {
-    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
+    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
     if (rwops) {
         rwops->close(rwops);    /* This calls SDL_FreeRW(rwops); */
     }
@@ -61,9 +61,11 @@ rwops_error_quit(unsigned line, SDL_RWops * rwops)
 #define RWOP_ERR_QUIT(x)    rwops_error_quit( __LINE__, (x) )
 
 
-
+#ifdef main
+#undef main
+#endif
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_RWops *rwops = NULL;
     char test_buf[30];
@@ -90,7 +92,7 @@ main(int argc, char *argv[])
     rwops = SDL_RWFromFile("something", NULL);
     if (rwops)
         RWOP_ERR_QUIT(rwops);
-    SDL_Log("test1 OK\n");
+    SDLTest_Log("test1 OK\n");
 
 /* test 2 : check that inexistent file is not successfully opened/created when required */
 /* modes : r, r+ imply that file MUST exist
@@ -123,7 +125,7 @@ main(int argc, char *argv[])
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
     unlink(FBASENAME2);
-    SDL_Log("test2 OK\n");
+    SDLTest_Log("test2 OK\n");
 
 /* test 3 : creation, writing , reading, seeking,
             test : w mode, r mode, w+ mode
@@ -201,7 +203,7 @@ main(int argc, char *argv[])
     if (SDL_memcmp(test_buf, "12345678901234567890", 20))
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
-    SDL_Log("test3 OK\n");
+    SDLTest_Log("test3 OK\n");
 
 /* test 4: same in r+ mode */
     rwops = SDL_RWFromFile(FBASENAME1, "rb+");  /* write + read + file must exists, no truncation */
@@ -236,7 +238,7 @@ main(int argc, char *argv[])
     if (SDL_memcmp(test_buf, "12345678901234567890", 20))
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
-    SDL_Log("test4 OK\n");
+    SDLTest_Log("test4 OK\n");
 
 /* test5 : append mode */
     rwops = SDL_RWFromFile(FBASENAME1, "ab+");  /* write + read + append */
@@ -277,7 +279,7 @@ main(int argc, char *argv[])
     if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30))
         RWOP_ERR_QUIT(rwops);
     rwops->close(rwops);
-    SDL_Log("test5 OK\n");
+    SDLTest_Log("test5 OK\n");
     cleanup();
     return 0;                   /* all ok */
 }
old mode 100644 (file)
new mode 100755 (executable)
index abd301c..838e3b1
 
 #include <stdio.h>
 #include "SDL.h"
-
+#ifdef main
+#undef main
+#endif
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     char *base_path;
     char *pref_path;
@@ -24,27 +26,27 @@ main(int argc, char *argv[])
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (SDL_Init(0) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
         return 1;
     }
 
     base_path = SDL_GetBasePath();
     if(base_path == NULL){
-      SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
+      SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
                    SDL_GetError());
       return 0;
     }
 
-    SDL_Log("base path: '%s'\n", base_path);
+    SDLTest_Log("base path: '%s'\n", base_path);
     SDL_free(base_path);
 
     pref_path = SDL_GetPrefPath("libsdl", "testfilesystem");
     if(pref_path == NULL){
-      SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n",
+      SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n",
                    SDL_GetError());
       return 0;
     }
-    SDL_Log("pref path: '%s'\n", pref_path); 
+    SDLTest_Log("pref path: '%s'\n", pref_path); 
     SDL_free(pref_path);
 
     SDL_Quit();
old mode 100644 (file)
new mode 100755 (executable)
index 291661a..dfc2565
 #include <math.h>
 
 #include "SDL_test_common.h"
-
-#if defined(__IPHONEOS__) || defined(__ANDROID__)
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
+#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__TIZEN__)
 #define HAVE_OPENGLES
 #endif
 
+#define HAVE_OPENGLES2
+
 #ifdef HAVE_OPENGLES
 
 #include "SDL_opengles.h"
@@ -27,7 +30,7 @@
 static SDLTest_CommonState *state;
 static SDL_GLContext *context = NULL;
 static int depth = 16;
-
+int once = SDL_TRUE;
 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
 static void
 quit(int rc)
@@ -98,9 +101,8 @@ Render()
     glMatrixMode(GL_MODELVIEW);
     glRotatef(5.0, 1.0, 1.0, 1.0);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int fsaa, accel;
     int value;
@@ -119,6 +121,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -146,7 +150,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
+            SDLTest_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
                     SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -175,7 +179,7 @@ main(int argc, char *argv[])
 
     context = SDL_calloc(state->num_windows, sizeof(context));
     if (context == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
 
@@ -183,7 +187,7 @@ main(int argc, char *argv[])
     for (i = 0; i < state->num_windows; i++) {
         context[i] = SDL_GL_CreateContext(state->windows[i]);
         if (!context[i]) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
             quit(2);
         }
     }
@@ -195,65 +199,65 @@ main(int argc, char *argv[])
     }
 
     SDL_GetCurrentDisplayMode(0, &mode);
-    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
-    SDL_Log("\n");
-    SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
-    SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
-    SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
-    SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
-    SDL_Log("\n");
+    SDLTest_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
+    SDLTest_Log("\n");
+    SDLTest_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
+    SDLTest_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
+    SDLTest_Log("Version    : %s\n", glGetString(GL_VERSION));
+    SDLTest_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
+    SDLTest_Log("\n");
 
     status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+        SDLTest_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+        SDLTest_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+        SDLTest_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
+        SDLTest_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
     } else {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
                 SDL_GetError());
     }
     if (fsaa) {
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
         if (!status) {
-            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+            SDLTest_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
         } else {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
                     SDL_GetError());
         }
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
         if (!status) {
-            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+            SDLTest_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
                    value);
         } else {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
                     SDL_GetError());
         }
     }
     if (accel) {
         status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
         if (!status) {
-            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
+            SDLTest_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
         } else {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
                     SDL_GetError());
         }
     }
@@ -264,7 +268,7 @@ main(int argc, char *argv[])
 
         status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
         if (status) {
-            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+            SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
             /* Continue for next window */
             continue;
@@ -291,26 +295,38 @@ main(int argc, char *argv[])
         ++frames;
         while (SDL_PollEvent(&event)) {
             switch (event.type) {
-            case SDL_WINDOWEVENT:
+            /*case SDL_WINDOWEVENT:
                 switch (event.window.event) {
                     case SDL_WINDOWEVENT_RESIZED:
                         for (i = 0; i < state->num_windows; ++i) {
                             if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
                                 status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
                                 if (status) {
-                                    SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+                                    SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
                                     break;
                                 }
-                                /* Change view port to the new window dimensions */
+                                // Change view port to the new window dimensions 
                                 glViewport(0, 0, event.window.data1, event.window.data2);
-                                /* Update window content */
+                                // Update window content 
                                 Render();
                                 SDL_GL_SwapWindow(state->windows[i]);
                                 break;
                             }
                         }
                         break;
-                }
+                }*/
+                       case SDL_KEYDOWN:
+                               if(event.key.keysym.sym == 0)
+                               {
+                                       if(once)
+                                       {
+                                               once = SDL_FALSE;
+                                       }else
+                                       {
+                                               done = 1;
+                                       }
+                               }
+                               break;
             }
             SDLTest_CommonEvent(state, &event, &done);
         }
@@ -319,7 +335,7 @@ main(int argc, char *argv[])
                 continue;
             status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
             if (status) {
-                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+                SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
                 /* Continue for next window */
                 continue;
@@ -332,7 +348,7 @@ main(int argc, char *argv[])
     /* Print out some timing information */
     now = SDL_GetTicks();
     if (now > then) {
-        SDL_Log("%2.2f frames per second\n",
+        SDLTest_Log("%2.2f frames per second\n",
                ((double) frames * 1000) / (now - then));
     }
 #if !defined(__ANDROID__)
@@ -346,7 +362,7 @@ main(int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
-    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
+    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
     return 1;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index af5962b..74700ac
 #endif
 
 #include "SDL_test_common.h"
-
-#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__)
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
+#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) || defined(__TIZEN__)
 #define HAVE_OPENGLES2
 #endif
 
+#define HAVE_OPENGLES2
+
 #ifdef HAVE_OPENGLES2
 
 #include "SDL_opengles2.h"
@@ -31,7 +34,7 @@
 typedef struct GLES2_Context
 {
 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
-#include "../src/render/opengles2/SDL_gles2funcs.h"
+#include "SDL_gles2funcs.h"
 #undef SDL_PROC
 } GLES2_Context;
 
@@ -63,7 +66,7 @@ static int LoadContext(GLES2_Context * data)
     } while ( 0 );
 #endif /* __SDL_NOGETPROCADDR__ */
 
-#include "../src/render/opengles2/SDL_gles2funcs.h"
+#include "SDL_gles2funcs.h"
 #undef SDL_PROC
     return 0;
 }
@@ -93,7 +96,7 @@ quit(int rc)
         { \
           GLenum glError = ctx.glGetError(); \
           if(glError != GL_NO_ERROR) { \
-            SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
+            SDLTest_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
             quit(1); \
           } \
         }
@@ -220,7 +223,7 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
     if(status != GL_TRUE) {
         ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]);
         buffer[length] = '\0';
-        SDL_Log("Shader compilation failed: %s", buffer);fflush(stderr);
+        SDLTest_Log("Shader compilation failed: %s", buffer);fflush(stderr);
         quit(-1);
     }
 }
@@ -426,7 +429,7 @@ void loop()
     ++frames;
     while (SDL_PollEvent(&event) && !done) {
         switch (event.type) {
-        case SDL_WINDOWEVENT:
+        /*case SDL_WINDOWEVENT:
             switch (event.window.event) {
                 case SDL_WINDOWEVENT_RESIZED:
                     for (i = 0; i < state->num_windows; ++i) {
@@ -434,22 +437,28 @@ void loop()
                             int w, h;
                             status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
                             if (status) {
-                                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+                                SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
                                 break;
                             }
-                            /* Change view port to the new window dimensions */
+                            // Change view port to the new window dimensions 
                             SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
                             ctx.glViewport(0, 0, w, h);
                             state->window_w = event.window.data1;
                             state->window_h = event.window.data2;
-                            /* Update window content */
+                            // Update window content 
                             Render(event.window.data1, event.window.data2, &datas[i]);
                             SDL_GL_SwapWindow(state->windows[i]);
                             break;
                         }
                     }
                     break;
-            }
+            }*/
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
         }
         SDLTest_CommonEvent(state, &event, &done);
     }
@@ -457,7 +466,7 @@ void loop()
       for (i = 0; i < state->num_windows; ++i) {
           status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
           if (status) {
-              SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+              SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
               /* Continue for next window */
               continue;
@@ -472,9 +481,8 @@ void loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int fsaa, accel;
     int value;
@@ -490,6 +498,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -517,7 +527,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
+            SDLTest_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
                     SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -548,7 +558,7 @@ main(int argc, char *argv[])
 
     context = SDL_calloc(state->num_windows, sizeof(context));
     if (context == NULL) {
-        SDL_Log("Out of memory!\n");
+        SDLTest_Log("Out of memory!\n");
         quit(2);
     }
     
@@ -556,14 +566,14 @@ main(int argc, char *argv[])
     for (i = 0; i < state->num_windows; i++) {
         context[i] = SDL_GL_CreateContext(state->windows[i]);
         if (!context[i]) {
-            SDL_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
+            SDLTest_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
             quit(2);
         }
     }
 
     /* Important: call this *after* creating the context */
     if (LoadContext(&ctx) < 0) {
-        SDL_Log("Could not load GLES2 functions\n");
+        SDLTest_Log("Could not load GLES2 functions\n");
         quit(2);
         return 0;
     }
@@ -577,65 +587,65 @@ main(int argc, char *argv[])
     }
 
     SDL_GetCurrentDisplayMode(0, &mode);
-    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
-    SDL_Log("\n");
-    SDL_Log("Vendor     : %s\n", ctx.glGetString(GL_VENDOR));
-    SDL_Log("Renderer   : %s\n", ctx.glGetString(GL_RENDERER));
-    SDL_Log("Version    : %s\n", ctx.glGetString(GL_VERSION));
-    SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
-    SDL_Log("\n");
+    SDLTest_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
+    SDLTest_Log("\n");
+    SDLTest_Log("Vendor     : %s\n", ctx.glGetString(GL_VENDOR));
+    SDLTest_Log("Renderer   : %s\n", ctx.glGetString(GL_RENDERER));
+    SDLTest_Log("Version    : %s\n", ctx.glGetString(GL_VERSION));
+    SDLTest_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
+    SDLTest_Log("\n");
 
     status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+        SDLTest_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_Log( "Failed to get SDL_GL_RED_SIZE: %s\n",
+        SDLTest_Log( "Failed to get SDL_GL_RED_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+        SDLTest_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n",
+        SDLTest_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+        SDLTest_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n",
+        SDLTest_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
     if (!status) {
-        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
+        SDLTest_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
     } else {
-        SDL_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
+        SDLTest_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
                 SDL_GetError());
     }
     if (fsaa) {
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
         if (!status) {
-            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+            SDLTest_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
         } else {
-            SDL_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+            SDLTest_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
                     SDL_GetError());
         }
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
         if (!status) {
-            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+            SDLTest_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
                    value);
         } else {
-            SDL_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+            SDLTest_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
                     SDL_GetError());
         }
     }
     if (accel) {
         status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
         if (!status) {
-            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
+            SDLTest_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
         } else {
-            SDL_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+            SDLTest_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
                     SDL_GetError());
         }
     }
@@ -648,7 +658,7 @@ main(int argc, char *argv[])
         int w, h;
         status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
         if (status) {
-            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+            SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
             /* Continue for next window */
             continue;
@@ -708,7 +718,7 @@ main(int argc, char *argv[])
     /* Print out some timing information */
     now = SDL_GetTicks();
     if (now > then) {
-        SDL_Log("%2.2f frames per second\n",
+        SDLTest_Log("%2.2f frames per second\n",
                ((double) frames * 1000) / (now - then));
     }
 #if !defined(__ANDROID__) && !defined(__NACL__)  
@@ -722,7 +732,7 @@ main(int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
-    SDL_Log("No OpenGL ES support on this system\n");
+    SDLTest_Log("No OpenGL ES support on this system\n");
     return 1;
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 5e32be4..fc33d6c
@@ -22,7 +22,7 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
 
     for (i = 0; i < numareas; i++) {
         if (SDL_PointInRect(pt, &areas[i])) {
-            SDL_Log("HIT-TEST: DRAGGABLE\n");
+            SDLTest_Log("HIT-TEST: DRAGGABLE\n");
             return SDL_HITTEST_DRAGGABLE;
         }
     }
@@ -30,7 +30,7 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
     SDL_GetWindowSize(window, &w, &h);
 
     #define REPORT_RESIZE_HIT(name) { \
-        SDL_Log("HIT-TEST: RESIZE_" #name "\n"); \
+        SDLTest_Log("HIT-TEST: RESIZE_" #name "\n"); \
         return SDL_HITTEST_RESIZE_##name; \
     }
 
@@ -52,12 +52,11 @@ hitTest(SDL_Window *window, const SDL_Point *pt, void *data)
         REPORT_RESIZE_HIT(LEFT);
     }
 
-    SDL_Log("HIT-TEST: NORMAL\n");
+    SDLTest_Log("HIT-TEST: NORMAL\n");
     return SDL_HITTEST_NORMAL;
 }
 
-
-int main(int argc, char **argv)
+int SDL_main(int argc, char **argv)
 {
     int done = 0;
     SDL_Window *window;
@@ -65,11 +64,11 @@ int main(int argc, char **argv)
 
     /* !!! FIXME: check for errors. */
     SDL_Init(SDL_INIT_VIDEO);
-    window = SDL_CreateWindow("Drag the red boxes", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE);
+    window = SDL_CreateWindow("Drag the red boxes", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 720, 1280, SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE);
     renderer = SDL_CreateRenderer(window, -1, 0);
 
     if (SDL_SetWindowHitTest(window, hitTest, NULL) == -1) {
-        SDL_Log("Enabling hit-testing failed!\n");
+        SDLTest_Log("Enabling hit-testing failed!\n");
         SDL_Quit();
         return 1;
     }
@@ -91,21 +90,21 @@ int main(int argc, char **argv)
             switch (e.type)
             {
                 case SDL_MOUSEBUTTONDOWN:
-                    SDL_Log("button down!\n");
+                    SDLTest_Log("button down!\n");
                     break;
 
                 case SDL_MOUSEBUTTONUP:
-                    SDL_Log("button up!\n");
+                    SDLTest_Log("button up!\n");
                     break;
 
                 case SDL_WINDOWEVENT:
                     if (e.window.event == SDL_WINDOWEVENT_MOVED) {
-                        SDL_Log("Window event moved to (%d, %d)!\n", (int) e.window.data1, (int) e.window.data2);
+                        SDLTest_Log("Window event moved to (%d, %d)!\n", (int) e.window.data1, (int) e.window.data2);
                     }
                     break;
 
                 case SDL_KEYDOWN:
-                    if (e.key.keysym.sym == SDLK_ESCAPE) {
+                    if (e.key.keysym.sym == SDLK_ESCAPE || e.key.keysym.sym == 0) {
                         done = 1;
                     } else if (e.key.keysym.sym == SDLK_x) {
                         if (!areas) {
old mode 100644 (file)
new mode 100755 (executable)
index 79efec8..d4f500c
@@ -24,9 +24,8 @@ widelen(char *data)
     }
     return len;
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     const char *formats[] = {
         "UTF8",
@@ -53,11 +52,11 @@ main(int argc, char *argv[])
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (!argv[1]) {
-        argv[1] = "utf8.txt";
+        argv[1] = "res/utf8.txt";
     }
     file = fopen(argv[1], "rb");
     if (!file) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]);
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]);
         return (1);
     }
 
@@ -72,7 +71,7 @@ main(int argc, char *argv[])
             test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
             test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
             if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) {
-                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
+                SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
                 ++errors;
             }
             SDL_free(test[0]);
old mode 100644 (file)
new mode 100755 (executable)
index d6e7ea1..91ced3b
@@ -21,6 +21,8 @@
 #endif
 
 #include "SDL_test_common.h"
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 
 #define DEFAULT_PTSIZE  30
 #define DEFAULT_FONT    "/System/Library/Fonts/åŽæ–‡ç»†é»‘.ttf"
@@ -80,7 +82,7 @@ char *utf8_advance(char *p, size_t distance)
 
 void usage()
 {
-    SDL_Log("usage: testime [--font fontfile]\n");
+    SDLTest_Log("usage: testime [--font fontfile]\n");
     exit(0);
 }
 
@@ -206,8 +208,7 @@ void Redraw() {
         SDL_RenderPresent(renderer);
     }
 }
-
-int main(int argc, char *argv[]) {
+int SDL_main(int argc, char *argv[]) {
     int i, done;
     SDL_Event event;
     const char *fontname = DEFAULT_FONT;
@@ -217,6 +218,8 @@ int main(int argc, char *argv[]) {
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -256,12 +259,12 @@ int main(int argc, char *argv[]) {
     font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
     if (! font)
     {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
         exit(-1);
     }
 #endif
 
-    SDL_Log("Using font: %s\n", fontname);
+    SDLTest_Log("Using font: %s\n", fontname);
     atexit(SDL_Quit);
 
     InitInput();
@@ -283,6 +286,9 @@ int main(int argc, char *argv[]) {
                 case SDL_KEYDOWN: {
                     switch (event.key.keysym.sym)
                     {
+                                               case SDLK_f:
+                                                       done = 1;
+                                                       break;
                         case SDLK_RETURN:
                              text[0]=0x00;
                              Redraw();
@@ -326,7 +332,7 @@ int main(int argc, char *argv[]) {
                         break;
                     }
 
-                    SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
+                    SDLTest_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
                             event.key.keysym.scancode,
                             SDL_GetScancodeName(event.key.keysym.scancode),
                             event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
@@ -337,12 +343,12 @@ int main(int argc, char *argv[]) {
                         markedRect.w < 0)
                         break;
 
-                    SDL_Log("Keyboard: text input \"%s\"\n", event.text.text);
+                    SDLTest_Log("Keyboard: text input \"%s\"\n", event.text.text);
 
                     if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
                         SDL_strlcat(text, event.text.text, sizeof(text));
 
-                    SDL_Log("text inputed: %s\n", text);
+                    SDLTest_Log("text inputed: %s\n", text);
 
                     /* After text inputed, we can clear up markedText because it */
                     /* is committed */
@@ -351,7 +357,7 @@ int main(int argc, char *argv[]) {
                     break;
 
                 case SDL_TEXTEDITING:
-                    SDL_Log("text editing \"%s\", selected range (%d, %d)\n",
+                    SDLTest_Log("text editing \"%s\", selected range (%d, %d)\n",
                             event.edit.text, event.edit.start, event.edit.length);
 
                     strcpy(markedText, event.edit.text);
old mode 100644 (file)
new mode 100755 (executable)
index 82aae63..b29bb38
@@ -21,7 +21,8 @@
 #endif
 
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 #define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0)
 #define NUM_OBJECTS 100
 
@@ -91,7 +92,7 @@ add_line(int x1, int y1, int x2, int y2)
     if ((x1 == x2) && (y1 == y2))
         return 0;
 
-    SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
+    SDLTest_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
     lines[num_lines].x = x1;
     lines[num_lines].y = y1;
     lines[num_lines].w = x2;
@@ -140,7 +141,7 @@ add_rect(int x1, int y1, int x2, int y2)
     if (y1 > y2)
         SWAP(int, y1, y2);
 
-    SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
+    SDLTest_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
            x2 - x1, y2 - y1);
 
     rects[num_rects].x = x1;
@@ -263,9 +264,8 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     Uint32 then, now, frames;
@@ -278,6 +278,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -315,7 +317,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+            SDLTest_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
                     argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
@@ -355,7 +357,7 @@ main(int argc, char *argv[])
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        SDL_Log("%2.2f frames per second\n", fps);
+        SDLTest_Log("%2.2f frames per second\n", fps);
     }
     return 0;
 }
old mode 100644 (file)
new mode 100755 (executable)
index aea496c..601bc49
@@ -18,9 +18,8 @@
 #include <string.h>
 
 #include "SDL.h"
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_Scancode scancode;
 
@@ -28,11 +27,11 @@ main(int argc, char *argv[])
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         exit(1);
     }
     for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
-        SDL_Log("Scancode #%d, \"%s\"\n", scancode,
+        SDLTest_Log("Scancode #%d, \"%s\"\n", scancode,
                SDL_GetScancodeName(scancode));
     }
     SDL_Quit();
old mode 100644 (file)
new mode 100755 (executable)
index fb87fbe..0e0713c
@@ -20,9 +20,8 @@
 #include "SDL.h"
 
 typedef int (*fntype) (const char *);
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int retval = 0;
     int hello = 0;
@@ -33,14 +32,14 @@ main(int argc, char *argv[])
 
     if (argc != 3) {
         const char *app = argv[0];
-        SDL_Log("USAGE: %s <library> <functionname>\n", app);
-        SDL_Log("       %s --hello <lib with puts()>\n", app);
+        SDLTest_Log("USAGE: %s <library> <functionname>\n", app);
+        SDLTest_Log("       %s --hello <lib with puts()>\n", app);
         return 1;
     }
 
     /* Initialize SDL */
     if (SDL_Init(0) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 2;
     }
 
@@ -55,23 +54,23 @@ main(int argc, char *argv[])
 
     lib = SDL_LoadObject(libname);
     if (lib == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
                 libname, SDL_GetError());
         retval = 3;
     } else {
         fn = (fntype) SDL_LoadFunction(lib, symname);
         if (fn == NULL) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
                     symname, SDL_GetError());
             retval = 4;
         } else {
-            SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
+            SDLTest_Log("Found %s in %s at %p\n", symname, libname, fn);
             if (hello) {
-                SDL_Log("Calling function...\n");
+                SDLTest_Log("Calling function...\n");
                 fflush(stdout);
                 fn("     HELLO, WORLD!\n");
-                SDL_Log("...apparently, we survived.  :)\n");
-                SDL_Log("Unloading library...\n");
+                SDLTest_Log("...apparently, we survived.  :)\n");
+                SDLTest_Log("Unloading library...\n");
                 fflush(stdout);
             }
         }
old mode 100644 (file)
new mode 100755 (executable)
index 1106ec3..8d34898
@@ -38,7 +38,7 @@ SDL_Quit_Wrapper(void)
 void
 printid(void)
 {
-    SDL_Log("Process %lu:  exiting\n", SDL_ThreadID());
+    SDLTest_Log("Process %lu:  exiting\n", SDL_ThreadID());
 }
 
 void
@@ -53,7 +53,7 @@ closemutex(int sig)
 {
     SDL_threadID id = SDL_ThreadID();
     int i;
-    SDL_Log("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
+    SDLTest_Log("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
     doterminate = 1;
     for (i = 0; i < 6; ++i)
         SDL_WaitThread(threads[i], NULL);
@@ -65,32 +65,35 @@ int SDLCALL
 Run(void *data)
 {
     if (SDL_ThreadID() == mainthread)
-        signal(SIGTERM, closemutex);
+       {
+        //signal(SIGTERM, closemutex);
+               SDL_Delay(5000);
+               closemutex(0);
+       }
     while (!doterminate) {
-        SDL_Log("Process %lu ready to work\n", SDL_ThreadID());
+        SDLTest_Log("Process %lu ready to work\n", SDL_ThreadID());
         if (SDL_LockMutex(mutex) < 0) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
             exit(1);
         }
-        SDL_Log("Process %lu, working!\n", SDL_ThreadID());
+        SDLTest_Log("Process %lu, working!\n", SDL_ThreadID());
         SDL_Delay(1 * 1000);
-        SDL_Log("Process %lu, done!\n", SDL_ThreadID());
+        SDLTest_Log("Process %lu, done!\n", SDL_ThreadID());
         if (SDL_UnlockMutex(mutex) < 0) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
             exit(1);
         }
         /* If this sleep isn't done, then threads may starve */
         SDL_Delay(10);
     }
     if (SDL_ThreadID() == mainthread && doterminate) {
-        SDL_Log("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
+        SDLTest_Log("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
         raise(SIGTERM);
     }
     return (0);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     int maxproc = 6;
@@ -100,24 +103,24 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
         exit(1);
     }
     atexit(SDL_Quit_Wrapper);
 
     if ((mutex = SDL_CreateMutex()) == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
         exit(1);
     }
 
     mainthread = SDL_ThreadID();
-    SDL_Log("Main thread: %lu\n", mainthread);
+    SDLTest_Log("Main thread: %lu\n", mainthread);
     atexit(printid);
     for (i = 0; i < maxproc; ++i) {
         char name[64];
         SDL_snprintf(name, sizeof (name), "Worker%d", i);
         if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL)
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
     }
     signal(SIGINT, terminate);
     Run(NULL);
diff --git a/test/testmain.c b/test/testmain.c
new file mode 100755 (executable)
index 0000000..59843b0
--- /dev/null
@@ -0,0 +1,706 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include "testmain.h"
+#include <signal.h>
+SDL_Surface* createSurface(const char* file)
+{
+       SDL_Surface* imageSurface;
+       imageSurface = SDL_LoadBMP(file);
+       if(NULL == imageSurface)
+       {
+               SDL_Log("Fail in SDL_LoadBMP: %s", SDL_GetError());
+       }
+       
+       return imageSurface;
+}
+
+SDL_Texture* loadTexture(SDL_Renderer* ren ,SDL_Surface* sur)
+{
+       SDL_Texture* texture = NULL;
+       
+       if(sur != NULL)
+       {
+               texture = SDL_CreateTextureFromSurface(ren, sur);
+               SDL_FreeSurface(sur);
+               
+               if(NULL == texture)
+               {
+                       SDL_Log("Fail in SDL_CreateTextureFromSurface: %s", SDL_GetError());
+               }
+               else
+               {
+                       //SDL_Log("Succeed to create texture from surface!\n");
+               }
+       }
+       
+       return texture;
+}
+
+void renderTexture(SDL_Texture* tex, SDL_Renderer* ren, int x, int y)
+{
+       SDL_Rect dst;
+       dst.x = x;
+       dst.y = y;
+       
+       SDL_QueryTexture(tex, NULL, NULL, &dst.w, &dst.h);
+       SDL_RenderCopy(ren, tex, NULL, &dst);
+       SDL_DestroyTexture(tex);
+}
+
+
+void  switchstate(SDL_bool* a, SDL_bool* b)
+{
+       SDL_bool tmp; 
+       tmp = *b;
+       *b = *a;
+       *a = tmp;
+}
+
+void DrawAutomationPage(SDL_Renderer* ren)
+{
+       SDL_Surface* surface = createSurface(MAINPAGE_BG);
+       SDL_Texture* texture = loadTexture(ren, surface);
+
+       
+       renderTexture(texture, ren, 0, 0);
+
+}
+
+void DrawAutomationNotify(SDL_Renderer* ren, int x, int y)
+{
+       SDL_Surface* surface = createSurface(AUTOTEST_NOTIFICATION);
+       SDL_Texture* texture = loadTexture(ren, surface);
+
+       
+       renderTexture(texture, ren, x, y);
+}
+
+void DrawMainPage(SDL_Renderer* ren)
+{
+       SDL_Surface* surface = createSurface(MAINPAGE_BG);
+       
+       SDL_Texture* texture = loadTexture(ren, surface);
+       
+       renderTexture(texture, ren, 0, 0);
+}
+
+void DrawButton(Button b,SDL_Renderer* ren)
+{
+       SDL_Surface* surface = NULL;
+       switch(b.type)
+       {
+               case AUTOTEST_BT:
+                       surface = createSurface(AUTOTEST_BT_BG);
+                       break;
+               case INTERTEST_BT:
+                       surface = createSurface(INTERTEST_BT_BG);
+                       break;
+               case LOOPWAVE_BT:
+                       surface = createSurface(LOOPWAVE_BG);
+                       break;
+               case LOOPWAVEQUEUE_BT:
+                       surface = createSurface(LOOPWAVEQUEUE_BG);
+                       break;
+               case ATOMIC_BT:
+                       surface = createSurface(ATOMIC_BG);
+                       break;
+               case AUDIOHOTPLUG_BT:
+                       surface = createSurface(AUDIOHOTPLUG_BG);
+                       break;
+               case AUDIOINFO_BT:
+                       surface = createSurface(AUDIOINFO_BG);
+                       break;
+               case CHESSBOARD_BT:
+                       surface = createSurface(CHESSBOARD_BG);
+                       break;
+               case DISPLAYINFO_BT:
+                       surface = createSurface(DISPLAYINFO_BG);
+                       break;
+               case DRAW2_BT:
+                       surface = createSurface(DRAW2_BG);
+                       break;
+               case DROPFILE_BT:
+                       surface = createSurface(DROPFILE_BG);
+                       break;
+               case ERROR_BT:
+                       surface = createSurface(ERROR_BG);
+                       break;
+               case FILE_BT:
+                       surface = createSurface(FILE_BG);
+                       break;
+               case FILESYSTEM_BT:
+                       surface = createSurface(FILESYSTEM_BG);
+                       break;
+               case GLES_BT:
+                       surface = createSurface(GLES_BG);
+                       break;
+               case GLES2_BT:
+                       surface = createSurface(GLES2_BG);
+                       break;
+               case HIT_BT:
+                       surface = createSurface(HIT_BG);
+                       break;
+               case ICONV_BT:
+                       surface = createSurface(ICONV_BG);
+                       break;
+               case IME_BT:
+                       surface = createSurface(IME_BG);
+                       break;
+               case INTERSECTION_BT:
+                       surface = createSurface(INTERSECTION_BG);
+                       break;
+               case KEYS_BT:
+                       surface = createSurface(KEYS_BG);
+                       break;
+               case LOADSO_BT:
+                       surface = createSurface(LOADSO_BG);
+                       break;
+               case LOCK_BT:
+                       surface = createSurface(LOCK_BG);
+                       break;
+               case MULTIAUDIO_BT:
+                       surface = createSurface(MULTIAUDIO_BG);
+                       break;
+               case OVERLAY2_BT:
+                       surface = createSurface(OVERLAY2_BG);
+                       break;
+               case PLATFORM_BT:
+                       surface = createSurface(PLATFORM_BG);
+                       break;
+               case RELATIVE_BT:
+                       surface = createSurface(RELATIVE_BG);
+                       break;
+               case RENDERCOPYEX_BT:
+                       surface = createSurface(RENDERCOPYEX_BG);
+                       break;
+               case RENDERTARGET_BT:
+                       surface = createSurface(RENDERTARGET_BG);
+                       break;
+               case RESAMPLE_BT:
+                       surface = createSurface(RESAMPLE_BG);
+                       break;
+               case SCALE_BT:
+                       surface = createSurface(SCALE_BG);
+                       break;
+               case SEM_BT:
+                       surface = createSurface(SEM_BG);
+                       break;
+               case SHADER_BT:
+                       surface = createSurface(SHADER_BG);
+                       break;
+               case SPRITE2_BT:
+                       surface = createSurface(SPRITE2_BG);
+                       break;
+               case SPRITEMINIMAL_BT:
+                       surface = createSurface(SPRITEMINIMAL_BG);
+                       break;
+               case STREAMING_BT:
+                       surface = createSurface(STREAMING_BG);
+                       break;
+               case THREAD_BT:
+                       surface = createSurface(THREAD_BG);
+                       break;
+               case TIMER_BT:
+                       surface = createSurface(TIMER_BG);
+                       break;
+               case VER_BT:
+                       surface = createSurface(VER_BG);
+                       break;
+               case VIEWPORT_BT:
+                       surface = createSurface(VIEWPORT_BG);
+                       break;
+               case TOTURETHREAD_BT:
+                       surface = createSurface(TOTURETHREAD_BG);
+                       break;
+               case TOBEADD1_BT:
+                       surface = createSurface(TOBEADD1_BG);
+                       break;
+               default:
+                       break;
+                               
+
+       }
+
+       
+       SDL_Texture* texture = loadTexture(ren, surface);
+       
+       renderTexture(texture, ren, b.x, b.y);
+       
+}
+
+void DrawInterractivePage(render)
+{
+       SDL_Surface* surface = createSurface(MAINPAGE_BG);
+       
+       SDL_Texture* texture = loadTexture(render, surface);
+       
+       renderTexture(texture, render, 0, 0);
+
+}
+
+
+void DrawInterractiveButtons(Button b[INTERACTIVE_ROW][INTERACTIVE_COLUM], SDL_Renderer * ren)
+{
+       int i, j;
+       for(i = 0; i < INTERACTIVE_ROW; i++)
+       {
+               for(j = 0; j < INTERACTIVE_COLUM; j++)
+               {
+                       DrawButton(b[i][j], ren);
+
+               }
+
+       }
+
+}
+
+
+void InitInteractiveButtons(Button button[INTERACTIVE_ROW][INTERACTIVE_COLUM])
+{
+       int tmpType = LOOPWAVE_BT;
+       int i, j;
+
+       for(i = 0; i < INTERACTIVE_ROW; i++)
+       {
+               for(j = 0; j < INTERACTIVE_COLUM; j++)
+               {
+                       button[i][j].x =  (j)*30 + (j) * 120;
+                       button[i][j].y =  (i)*30 + (i) *  135;
+                       //button[i][j].state = SDL_FALSE;
+                       button[i][j].type = tmpType;
+                       tmpType++;
+                       
+               }
+
+       }
+
+       //button[0][0].state = SDL_TRUE;
+
+
+}
+
+Vec2 MainPageButtonPressed(Sint32 x, Sint32 y, Button button[Main_ROW][Main_COLUM])
+{
+       int i, j;
+       Vec2 vec;
+
+       for(i = 0; i < Main_ROW; i++)
+       {
+               for(j = 0; j < Main_COLUM; j++)
+               {
+                       SDL_Point point;
+                       point.x = (int)x;
+                       point.y = (int)y;
+
+                       SDL_Rect rect;
+                       rect.x = button[i][j].x;
+                       rect.y = button[i][j].y;
+                       rect.w = MAINPAGE_BT_WIDTH;
+                       rect.h = MAINPAGE_BT_HEIGHT;
+
+                       if(SDL_PointInRect(&point, &rect))
+                       {
+                               vec.row = i;
+                               vec.column = j;
+                               return vec;
+
+                       }
+                       
+               }
+
+       }
+
+       vec.row = -1;
+       vec.column = -1;
+       return vec;
+       
+
+
+}
+
+Vec2 InterPageButtonPressed(Sint32 x, Sint32 y, Button button[INTERACTIVE_ROW][INTERACTIVE_COLUM])
+{
+       int i, j;
+       Vec2 vec;
+       for(i = 0; i < INTERACTIVE_ROW; i++)
+       {
+               for(j = 0; j < INTERACTIVE_COLUM; j++)
+               {
+                       SDL_Point point;
+                       point.x = (int)x;
+                       point.y = (int)y;
+
+                       SDL_Rect rect;
+                       rect.x = button[i][j].x;
+                       rect.y = button[i][j].y;
+                       rect.w = INTERACTIVEPAGE_BT_WIDTH;
+                       rect.h = INTERACTIVEPAGE_BT_HEIGHT;
+
+                       if(SDL_PointInRect(&point, &rect))
+                       {
+                               vec.row = i;
+                               vec.column = j;
+                               return vec;
+
+                       }
+
+               }
+
+       }
+
+       vec.row = -1;
+       vec.column = -1;
+
+       return vec;
+
+
+
+}
+
+
+int SDL_main(int argc, char*argv[])
+{
+    SDL_RWops* rwops = SDL_RWFromFile("log.txt", "w+");
+       SDL_RWclose(rwops);
+       if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
+       {
+               SDL_Log("Fail in SDL_Init: %s\n", SDL_GetError());
+               return 1;
+       }
+       
+       SDL_Window* window = NULL;
+       SDL_Renderer* render = NULL;
+       
+       window = SDL_CreateWindow("Testmain", 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
+       if(NULL == window)
+       {
+               SDL_Log("Fail in SDL_CreateWindow: %s\n", SDL_GetError());
+               return 1;
+       }
+       
+       render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
+       if(NULL == render)
+       {
+               SDL_Log("Fail in SDL_CreateRenderer: %s\n", SDL_GetError());
+               SDL_DestroyWindow(window);
+               SDL_Quit();
+               return 1;
+       }
+       
+       SDL_RenderClear(render);
+       DrawMainPage(render);
+
+       Button MainButton[Main_ROW][Main_COLUM];
+       Button AutomationButton;
+       AutomationButton.type = AUTOTEST_BT;
+       AutomationButton.state = SDL_FALSE;
+       AutomationButton.x = 110;
+       AutomationButton.y = 200;
+       DrawButton(AutomationButton, render);
+       MainButton[0][0] = AutomationButton;
+       
+
+       Button InteractiveButton;
+       InteractiveButton.type = INTERTEST_BT;
+       InteractiveButton.state = SDL_FALSE;
+       InteractiveButton.x = 110;
+       InteractiveButton.y = 400;
+       DrawButton(InteractiveButton, render);
+       MainButton[1][0] = InteractiveButton;
+       
+       SDL_RenderPresent(render);
+
+       SDL_Event e;
+       SDL_bool quit = SDL_FALSE;
+       int page = MAINPAGE;
+
+       Button InterButton[INTERACTIVE_ROW][INTERACTIVE_COLUM];
+       pid_t pid;
+       Vec2 tmpVec;
+       
+       //InitInteractiveButtons(button);
+       
+       while(!quit)
+       {
+               while(SDL_PollEvent(&e))
+               {
+                       if(e.type == SDL_KEYDOWN)
+                       {
+                               if((e.key.keysym.sym == 0) &&(page == MAINPAGE))
+                               {
+                                       quit = SDL_TRUE;
+                               }else if((e.key.keysym.sym == 0) &&(page == INTERPAGE))
+                               {
+                                       DrawMainPage(render);
+                                       DrawButton(AutomationButton, render);
+                                       DrawButton(InteractiveButton, render);
+                                       SDL_RenderPresent(render);
+                                       page = MAINPAGE;        
+                                       
+                               }
+                       }
+                       if(e.type == SDL_MOUSEBUTTONDOWN)
+                       {
+                               if(page == MAINPAGE)
+                               {
+                                       tmpVec = MainPageButtonPressed(e.button.x, e.button.y, MainButton);
+                                       if(tmpVec.row == -1 && tmpVec.column == -1)
+                                       {
+                                               continue;
+
+                                       }
+                                       if(tmpVec.row == 0)
+                                       {
+                                               //DrawAutomationPage(render);
+                                               DrawAutomationNotify(render, 0, 0);
+                                               SDL_RenderPresent(render);
+                                               page = NOTIFYPAGE;
+                                                                                               
+                                               pid = fork();
+                                       
+                                               if (pid < 0)
+                                               {
+                                                       perror("Error in create new process");
+                                                       return 1;
+                                               }
+                                               else if (pid == 0)
+                                               {
+                                                       execl("./testautomation", "testautomation" ,(char*)0);
+                                               }
+                                               else
+                                               {
+                                                       wait();
+                                                       DrawMainPage(render);
+                                                       DrawButton(AutomationButton, render);
+                                                       DrawButton(InteractiveButton, render);
+                                                       SDL_RenderPresent(render);
+                                                       page = MAINPAGE;
+                                       
+                                               }
+
+                                       }
+                                       else if(tmpVec.row == 1)
+                                       {
+                                               InitInteractiveButtons(InterButton);
+                                               DrawInterractivePage(render);
+                                               DrawInterractiveButtons(InterButton,render);
+                                               page = INTERPAGE;
+                                               SDL_RenderPresent(render);
+                                       }
+
+                               }
+                               else if(page == INTERPAGE)
+                               {
+                                       tmpVec = InterPageButtonPressed(e.button.x, e.button.y, InterButton);
+                                       if(tmpVec.row == -1 && tmpVec.column == -1)
+                                       {
+                                               continue;
+
+                                       }
+                                       //DrawAutomationPage(render);
+                                       DrawAutomationNotify(render, 0, 0);
+                                       SDL_RenderPresent(render);
+                                       page = NOTIFYPAGE;
+                                       pid = fork();
+
+                                       if (pid < 0)
+                                       {
+                                               perror("Error in create new process");
+                                               return 1;
+                                       }
+                                       else if(pid == 0)
+                                       {
+                                               
+                                               switch(InterButton[tmpVec.row][tmpVec.column].type)
+                                               {
+                                                       case LOOPWAVE_BT:
+                                                               SDLTest_Log("-------loopwave test start-------");
+                                                               execl("./loopwave", "loopwave" ,(char*)0);
+                                                               break;
+                                                       case LOOPWAVEQUEUE_BT:
+                                                               SDLTest_Log("-------loopwavequeue test start-------");
+                                                               execl("./loopwavequeue", "loopwavequeue", (char*)0);
+                                                               break;
+                                                       case ATOMIC_BT:
+                                                               SDLTest_Log("-------atomic test start-------");
+                                                               execl("./testautomic", "testautomic", (char*)0);
+                                                               break;
+                                                       case AUDIOHOTPLUG_BT:
+                                                               SDLTest_Log("-------audiohotplug test start-------");
+                                                               execl("./testaudiohotplug", "testaudiohotplug", (char*)0);
+                                                               break;
+                                                       case AUDIOINFO_BT:
+                                                               SDLTest_Log("-------audioinfo test start-------");
+                                                               execl("./testaudioinfo", "testaudioinfo", (char*)0);
+                                                               break;
+                                                       case CHESSBOARD_BT:
+                                                               SDLTest_Log("-------draw chessboard test start-------");
+                                                               execl("./testdrawchessboard", "testdrawchessboard", (char*)0);
+                                                               break;
+                                                       case DISPLAYINFO_BT:
+                                                               SDLTest_Log("-------displayinfo test start-------");
+                                                               execl("./testdisplayinfo", "testdisplayinfo",  (char*)0);
+                                                               break;
+                                                       case DRAW2_BT:
+                                                               SDLTest_Log("-------draw2 test start-------");
+                                                               execl("./testdraw2", "testdraw2", (char*)0);
+                                                               break;
+                                                       case DROPFILE_BT:
+                                                               SDLTest_Log("-------dropfile test start-------");
+                                                               execl("./testdorpfile", "testdorpfile", (char*)0);
+                                                               break;
+                                                       case ERROR_BT:
+                                                               SDLTest_Log("-------error test start-------");
+                                                               execl("./testerror", "testerror", (char*)0);
+                                                               break;
+                                                       case FILE_BT:
+                                                               SDLTest_Log("-------file test start-------");
+                                                               execl("./testfile", "testfile", (char*)0);
+                                                               break;
+                                                       case FILESYSTEM_BT:
+                                                               SDLTest_Log("-------filesystem test start-------");
+                                                               execl("./testfilesystem", "testfilesystem", (char*)0);
+                                                               break;
+                                                       case GLES_BT:
+                                                               SDLTest_Log("-------gles test start-------");
+                                                               execl("./testgles", "testgles", (char*)0);
+                                                               break;
+                                                       case GLES2_BT:
+                                                               SDLTest_Log("-------gles2 test start-------");
+                                                               execl("./testgles2", "testgles2", (char*)0);
+                                                               break;
+                                                       case HIT_BT:
+                                                               SDLTest_Log("-------hit test start-------");
+                                                               execl("./testhit", "testhit", (char*)0);
+                                                               break;
+                                                       case ICONV_BT:
+                                                               SDLTest_Log("-------iconv test start-------");
+                                                               execl("./testconv", "testconv", (char*)0);
+                                                               break;
+                                                       case IME_BT:
+                                                               SDLTest_Log("-------IME test start-------");
+                                                               execl("./testtime", "testtime", (char*)0);
+                                                               break;
+                                                       case INTERSECTION_BT:
+                                                               SDLTest_Log("-------intersection test start-------");
+                                                               execl("./testintersection", "testintersection", (char*)0);
+                                                               break;
+                                                       case KEYS_BT:
+                                                               SDLTest_Log("-------keys test start-------");
+                                                               execl("./testkes", "testkes", (char*)0);
+                                                               break;
+                                                       case LOADSO_BT:
+                                                               SDLTest_Log("-------loadso test start-------");
+                                                               execl("./testloadso", "testloadso", (char*)0);
+                                                               break;
+                                                       case LOCK_BT:
+                                                               SDLTest_Log("-------lock test start-------");
+                                                               execl("./testlock", "testlock", (char*)0);
+                                                               break;
+                                                       case MULTIAUDIO_BT:
+                                                               SDLTest_Log("-------multiaudio test start-------");
+                                                               execl("./testmultiaudio", "testmultiaudio", (char*)0);
+                                                               break;
+                                                       case OVERLAY2_BT:
+                                                               SDLTest_Log("-------overlay2 test start-------");
+                                                               execl("testoverlay2", "testoverlay2", (char*)0);
+                                                               break;
+                                                       case PLATFORM_BT:
+                                                               SDLTest_Log("-------platform test start-------");
+                                                               execl("./testplatform","testplatform", (char*)0);
+                                                               break;
+                                                       case RELATIVE_BT:
+                                                               SDLTest_Log("-------relative test start-------");
+                                                               execl("./testrelative", "testrelative", (char*)0);
+                                                               break;
+                                                       case RENDERCOPYEX_BT:
+                                                               SDLTest_Log("-------rendercopyex test start-------");
+                                                               execl("./testrendercopyex", "testrendercopyex", (char*)0);
+                                                               break;
+                                                       case RENDERTARGET_BT:
+                                                               SDLTest_Log("-------rendercopytarget test start-------");
+                                                               execl("./testrendertarget", "testrendertarget", (char*)0);
+                                                               break;
+                                                       case RESAMPLE_BT:
+                                                               SDLTest_Log("-------resample test start-------");
+                                                               execl("./testresample", "testresample", (char*)0);
+                                                               break;
+                                                       case SCALE_BT:
+                                                               SDLTest_Log("-------scale test start-------");
+                                                               execl("./testscale", "testscale", (char*)0);
+                                                               break;
+                                                       case SEM_BT:
+                                                               SDLTest_Log("-------semaphore test start-------");
+                                                               execl("./testsem", "testsem", (char*)0);
+                                                               break;
+                                                       case SHADER_BT:
+                                                               SDLTest_Log("-------shader test start-------");
+                                                               execl("./testshader", "testshader", (char*)0);
+                                                               break;
+                                                       case SPRITE2_BT:
+                                                               SDLTest_Log("-------sprite2 test start-------");
+                                                               execl("./testsprite2", "testsprite2", (char*)0);
+                                                               break;
+                                                       case SPRITEMINIMAL_BT:
+                                                               SDLTest_Log("-------testsptiteminimal test start-------");
+                                                               execl("./testspriteminimal", "testspriteminimal", (char*)0);
+                                                               break;
+                                                       case STREAMING_BT:
+                                                               SDLTest_Log("-------streaming test start-------");
+                                                               execl("./teststreaming", "teststreaming", (char*)0);
+                                                               break;
+                                                       case THREAD_BT:
+                                                               SDLTest_Log("-------thread test start-------");
+                                                               execl("./testthread", "testthread", (char*)0);
+                                                               break;
+                                                       case TIMER_BT:
+                                                               SDLTest_Log("-------timer test start-------");
+                                                               execl("./testtimer", "testtimer", (char*)0);
+                                                               break;
+                                                       case VER_BT:
+                                                               SDLTest_Log("-------version test start-------");
+                                                               execl("./testver", "testver", (char*)0);
+                                                               break;
+                                                       case VIEWPORT_BT:
+                                                               SDLTest_Log("-------viewport test start-------");
+                                                               execl("./testviewport", "testviewport", 0);
+                                                               break;
+                                                       case TOTURETHREAD_BT:
+                                                               SDLTest_Log("-------torturethread test start-------");
+                                                               execl("./torturethread", "torturethread", 0);
+                                                               break;
+                                                       default:
+                                                               signal(SIGCHLD, SIG_DFL);
+                                                               break;  
+                                               }
+                                       }
+                                       else
+                                       {
+                                               wait();
+                                               DrawInterractivePage(render);
+                                               DrawInterractiveButtons(InterButton,render);
+                                               SDL_RenderPresent(render);
+                                               page = INTERPAGE;
+                                               
+                                       }
+
+                               }
+                               
+                       }
+                       
+               }
+       }
+       
+       //SDL_Delay(10000);
+       
+       SDL_DestroyRenderer(render);
+       SDL_DestroyWindow(window);
+       SDL_Quit();
+       
+       return 0;
+
+}
diff --git a/test/testmain.h b/test/testmain.h
new file mode 100755 (executable)
index 0000000..3cc484f
--- /dev/null
@@ -0,0 +1,133 @@
+#include <SDL.h>\r
+\r
+#define WINDOW_WIDTH 720\r
+#define WINDOW_HEIGHT 1280\r
+\r
+#define INTERACTIVEPAGE_BT_WIDTH  120\r
+#define INTERACTIVEPAGE_BT_HEIGHT 135\r
+\r
+#define MAINPAGE_BT_WIDTH 500\r
+#define MAINPAGE_BT_HEIGHT 120\r
+\r
+#define MAINPAGE_BG "res/bg.bmp"\r
+#define AUTOTEST_BT_BG "res/AutomationTest.bmp"\r
+#define INTERTEST_BT_BG "res/InteractiveTest.bmp"\r
+#define AUTOTEST_BG "res/bg.bmp"\r
+#define AUTOTEST_NOTIFICATION "res/AutomationNotify.bmp"\r
+\r
+#define LOOPWAVE_BG                    "res/loopwave.bmp"\r
+#define LOOPWAVEQUEUE_BG               "res/loopwavequeue.bmp"\r
+#define ATOMIC_BG                              "res/testatomic.bmp"\r
+#define AUDIOHOTPLUG_BG                "res/testaudiohotplug.bmp"\r
+#define AUDIOINFO_BG                           "res/testaudioinfo.bmp"\r
+#define CHESSBOARD_BG                  "res/testchessboard.bmp"\r
+#define DISPLAYINFO_BG                         "res/testdisplayinfo.bmp"\r
+#define DRAW2_BG                               "res/testdraw2.bmp"\r
+#define DROPFILE_BG                            "res/testdropfile.bmp"\r
+#define ERROR_BG                               "res/testerror.bmp"\r
+#define FILE_BG                                        "res/testfile.bmp"\r
+#define FILESYSTEM_BG                  "res/testfilesystem.bmp"\r
+#define GLES_BG                                        "res/testgles.bmp"\r
+#define GLES2_BG                               "res/testgles2.bmp"\r
+#define HIT_BG                                         "res/testhit.bmp"\r
+#define ICONV_BG                                       "res/testiconv.bmp"\r
+#define IME_BG                                         "res/testime.bmp"\r
+#define INTERSECTION_BG                        "res/testintersection.bmp"\r
+#define KEYS_BG                                        "res/testkeys.bmp"\r
+#define LOADSO_BG                              "res/testloadso.bmp"\r
+#define LOCK_BG                                        "res/testlock.bmp"\r
+#define MULTIAUDIO_BG                  "res/testmultiaudio.bmp"\r
+#define OVERLAY2_BG                            "res/testoverlay2.bmp"\r
+#define PLATFORM_BG                            "res/testplatform.bmp"\r
+#define RELATIVE_BG                            "res/testrelative.bmp"\r
+#define RENDERCOPYEX_BG                "res/testrendercopyex.bmp"\r
+#define RENDERTARGET_BG                "res/testrendertarget.bmp"\r
+#define RESAMPLE_BG                            "res/testresample.bmp"\r
+#define SCALE_BG                                       "res/testscale.bmp"\r
+#define SEM_BG                                 "res/testsem.bmp"\r
+#define SHADER_BG                              "res/testshader.bmp"\r
+#define SPRITE2_BG                             "res/testsprite2.bmp"\r
+#define SPRITEMINIMAL_BG                       "res/testspriteminimal.bmp"\r
+#define STREAMING_BG                   "res/teststreaming.bmp"\r
+#define THREAD_BG                              "res/testthread.bmp"\r
+#define TIMER_BG                                       "res/testtimer.bmp"\r
+#define VER_BG                                 "res/testver.bmp"\r
+#define VIEWPORT_BG                            "res/testviewport.bmp"\r
+#define TOTURETHREAD_BG                "res/testtoturethread.bmp"\r
+#define TOBEADD1_BG                            "res/testadded.bmp"\r
+\r
+\r
+enum\r
+{\r\r
+       AUTOTEST_BT,\r
+       INTERTEST_BT,\r
+       LOOPWAVE_BT,\r
+       LOOPWAVEQUEUE_BT,\r
+       ATOMIC_BT ,\r
+       AUDIOHOTPLUG_BT ,\r
+       AUDIOINFO_BT ,\r
+       CHESSBOARD_BT,\r
+       DISPLAYINFO_BT,\r
+       DRAW2_BT ,\r
+       DROPFILE_BT,\r
+       ERROR_BT,\r
+       FILE_BT ,\r
+       FILESYSTEM_BT,\r
+       GLES_BT ,\r
+       GLES2_BT,\r
+       HIT_BT ,\r
+       ICONV_BT,\r
+       IME_BT,\r
+       INTERSECTION_BT,\r
+       KEYS_BT,\r
+       LOADSO_BT,\r
+       LOCK_BT,\r
+       MULTIAUDIO_BT,\r
+       OVERLAY2_BT,\r
+       PLATFORM_BT,\r
+       RELATIVE_BT,\r
+       RENDERCOPYEX_BT,\r
+       RENDERTARGET_BT,\r
+       RESAMPLE_BT,\r
+       SCALE_BT,\r
+       SEM_BT,\r
+       SHADER_BT,\r
+       SPRITE2_BT,\r
+       SPRITEMINIMAL_BT,\r
+       STREAMING_BT,\r
+       THREAD_BT,\r
+       TIMER_BT,\r
+       VER_BT,\r
+       VIEWPORT_BT,\r
+       TOTURETHREAD_BT,\r
+       TOBEADD1_BT\r
+\r
+};\r
+\r
+\r
+#define MAINPAGE                               0\r
+#define INTERPAGE                              1\r
+#define NOTIFYPAGE                             2\r
+\r
+#define INTERACTIVE_ROW                        8\r
+#define INTERACTIVE_COLUM              5\r
+\r
+#define Main_ROW                                       2\r
+#define Main_COLUM                             1\r
+\r
+typedef struct\r
+{\r
+       int type;\r
+       SDL_bool state;\r
+       int x;\r
+       int y;\r
+}Button;\r
+\r
+typedef struct\r
+{\r\r
+       int row;\r
+       int column;\r
+\r
+}Vec2;\r
+\r
+\r
old mode 100644 (file)
new mode 100755 (executable)
index 91968c3..1a4864a
@@ -59,7 +59,7 @@ button_messagebox(void *eventNumber)
 
     success = SDL_ShowMessageBox(&data, &button);
     if (success == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         if (eventNumber) {
             SDL_UserEvent event;
             event.type = (intptr_t)eventNumber;
@@ -69,7 +69,7 @@ button_messagebox(void *eventNumber)
             quit(2);
         }
     }
-    SDL_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" : "OK");
+    SDLTest_Log("Pressed button: %d, %s\n", button, button == -1 ? "[closed]" : button == 1 ? "Cancel" : "OK");
 
     if (eventNumber) {
         SDL_UserEvent event;
@@ -79,9 +79,8 @@ button_messagebox(void *eventNumber)
 
     return 0;
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int success;
 
@@ -93,7 +92,7 @@ main(int argc, char *argv[])
                 "This is a simple error MessageBox",
                 NULL);
     if (success == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -102,7 +101,7 @@ main(int argc, char *argv[])
                 "This is a simple MessageBox with a newline:\r\nHello world!",
                 NULL);
     if (success == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -112,7 +111,7 @@ main(int argc, char *argv[])
                 "Unicode text: '牛肉西蘭花' ...",
                 NULL);
     if (success == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -122,7 +121,7 @@ main(int argc, char *argv[])
                 "Unicode text and newline:\r\n'牛肉西蘭花'\n'牛肉西蘭花'",
                 NULL);
     if (success == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -132,7 +131,7 @@ main(int argc, char *argv[])
                 "Unicode text in the title.",
                 NULL);
     if (success == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
         quit(1);
     }
 
@@ -145,7 +144,7 @@ main(int argc, char *argv[])
        subsystem on the main thread.
      */
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
         return (1);
     }
     {
@@ -163,7 +162,7 @@ main(int argc, char *argv[])
 
         SDL_WaitThread(thread, &status);
 
-        SDL_Log("Message box thread return %i\n", status);
+        SDLTest_Log("Message box thread return %i\n", status);
     }
 
     /* Test showing a message box with a parent window */
@@ -176,7 +175,7 @@ main(int argc, char *argv[])
                     "This is a simple error MessageBox with a parent window",
                     window);
         if (success == -1) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
             quit(1);
         }
 
old mode 100644 (file)
new mode 100755 (executable)
index 117ef26..5f351b4
@@ -78,7 +78,7 @@ test_multi_audio(int devcount)
 #endif
 
     if (devcount > 64) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
                 devcount);
         devcount = 64;
     }
@@ -87,14 +87,14 @@ test_multi_audio(int devcount)
 
     for (i = 0; i < devcount; i++) {
         const char *devname = SDL_GetAudioDeviceName(i, 0);
-        SDL_Log("playing on device #%d: ('%s')...", i, devname);
+        SDLTest_Log("playing on device #%d: ('%s')...", i, devname);
         fflush(stdout);
 
         SDL_memset(&cbd[0], '\0', sizeof(callback_data));
         spec.userdata = &cbd[0];
         cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
         if (cbd[0].dev == 0) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
         } else {
             SDL_PauseAudioDevice(cbd[0].dev, 0);
 #ifdef __EMSCRIPTEN__
@@ -110,20 +110,20 @@ test_multi_audio(int devcount)
             }
             SDL_PauseAudioDevice(cbd[0].dev, 1);
 #endif
-            SDL_Log("done.\n");
+            SDLTest_Log("done.\n");
             SDL_CloseAudioDevice(cbd[0].dev);
         }
     }
 
     SDL_memset(cbd, '\0', sizeof(cbd));
 
-    SDL_Log("playing on all devices...\n");
+    SDLTest_Log("playing on all devices...\n");
     for (i = 0; i < devcount; i++) {
         const char *devname = SDL_GetAudioDeviceName(i, 0);
         spec.userdata = &cbd[i];
         cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
         if (cbd[i].dev == 0) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError());
         }
     }
 
@@ -156,13 +156,12 @@ test_multi_audio(int devcount)
         }
     }
 
-    SDL_Log("All done!\n");
+    SDLTest_Log("All done!\n");
 #endif
 }
 
-
 int
-main(int argc, char **argv)
+SDL_main(int argc, char **argv)
 {
     int devcount = 0;
 
@@ -171,23 +170,23 @@ main(int argc, char **argv)
 
     /* Load the SDL library */
     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
-    SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+    SDLTest_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
     
     devcount = SDL_GetNumAudioDevices(0);
     if (devcount < 1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
     } else {
         if (argv[1] == NULL) {
-            argv[1] = "sample.wav";
+            argv[1] = "res/sample.wav";
         }
 
         /* Load the wave file into memory */
         if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
                     SDL_GetError());
         } else {
             test_multi_audio(devcount);
old mode 100644 (file)
new mode 100755 (executable)
index 453f0f4..1025a71
@@ -248,18 +248,18 @@ ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h,
 static void
 PrintUsage(char *argv0)
 {
-    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
-    SDL_Log("\n");
-    SDL_Log("Where 'arg' is any of the following options:\n");
-    SDL_Log("\n");
-    SDL_Log("    -fps <frames per second>\n");
-    SDL_Log("    -nodelay\n");
-    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
-    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
-    SDL_Log("    -help (shows this help)\n");
-    SDL_Log("\n");
-    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
-    SDL_Log("\n");
+    SDLTest_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
+    SDLTest_Log("\n");
+    SDLTest_Log("Where 'arg' is any of the following options:\n");
+    SDLTest_Log("\n");
+    SDLTest_Log("    -fps <frames per second>\n");
+    SDLTest_Log("    -nodelay\n");
+    SDLTest_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
+    SDLTest_Log("    -scale <scale factor> (initial scale of the overlay)\n");
+    SDLTest_Log("    -help (shows this help)\n");
+    SDLTest_Log("\n");
+    SDLTest_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
+    SDLTest_Log("\n");
 }
 
 void
@@ -294,6 +294,11 @@ loop()
             if (event.key.keysym.sym != SDLK_ESCAPE) {
                 break;
             }
+          if(event.key.keysym.sym == 0)
+          {
+               done = SDL_TRUE;
+               break;
+          }
         case SDL_QUIT:
             done = SDL_TRUE;
             break;
@@ -319,9 +324,8 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char **argv)
+SDL_main(int argc, char **argv)
 {
     Uint8 *RawMooseData;
     SDL_RWops *handle;
@@ -341,7 +345,7 @@ main(int argc, char **argv)
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 3;
     }
 
@@ -350,19 +354,19 @@ main(int argc, char **argv)
             if (argv[2]) {
                 fps = atoi(argv[2]);
                 if (fps == 0) {
-                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                     quit(10);
                 }
                 if ((fps < 0) || (fps > 1000)) {
-                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -fps option must be in range from 1 to 1000, default is 12.\n");
                     quit(10);
                 }
                 argv += 2;
                 argc -= 2;
             } else {
-                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,
                         "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                 quit(10);
             }
@@ -374,19 +378,19 @@ main(int argc, char **argv)
             if (argv[2]) {
                 scale = atoi(argv[2]);
                 if (scale == 0) {
-                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -scale option requires an argument [from 1 to 50], default is 5.\n");
                     quit(10);
                 }
                 if ((scale < 0) || (scale > 50)) {
-                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                    SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,
                             "The -scale option must be in range from 1 to 50, default is 5.\n");
                     quit(10);
                 }
                 argv += 2;
                 argc -= 2;
             } else {
-                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
+                SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,
                         "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
                 quit(10);
             }
@@ -395,7 +399,7 @@ main(int argc, char **argv)
             PrintUsage(argv[0]);
             quit(0);
         } else {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
             quit(10);
         }
         break;
@@ -403,15 +407,15 @@ main(int argc, char **argv)
 
     RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
     if (RawMooseData == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
         free(RawMooseData);
         quit(1);
     }
 
     /* load the trojan moose images */
-    handle = SDL_RWFromFile("moose.dat", "rb");
+    handle = SDL_RWFromFile("res/moose.dat", "rb");
     if (handle == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
         free(RawMooseData);
         quit(2);
     }
@@ -429,21 +433,21 @@ main(int argc, char **argv)
                               window_w, window_h,
                               SDL_WINDOW_RESIZABLE);
     if (!window) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
         free(RawMooseData);
         quit(4);
     }
 
     renderer = SDL_CreateRenderer(window, -1, 0);
     if (!renderer) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
         free(RawMooseData);
         quit(4);
     }
 
     MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
     if (!MooseTexture) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
         free(RawMooseData);
         quit(5);
     }
@@ -471,7 +475,7 @@ main(int argc, char **argv)
             ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
             break;
         default:
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
             break;
         }
     }
diff --git a/test/testpicture.c b/test/testpicture.c
new file mode 100755 (executable)
index 0000000..cc6f86d
--- /dev/null
@@ -0,0 +1,46 @@
+#include "SDL.h"
+
+int SDL_main(int argc, char *argv[]) {
+   
+    SDL_Window *win = NULL;
+    SDL_Renderer *renderer = NULL;
+    SDL_Texture *bitmapTex = NULL;
+    SDL_Surface *bitmapSurface = NULL;
+    int posX = 100, posY = 100, width = 320, height = 240;
+
+    SDL_Init(SDL_INIT_VIDEO);
+
+    win = SDL_CreateWindow("Hello World", posX, posY, width, height, 0);
+
+    renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
+
+    bitmapSurface = SDL_LoadBMP("res/test.bmp");
+    bitmapTex = SDL_CreateTextureFromSurface(renderer, bitmapSurface);
+    SDL_FreeSurface(bitmapSurface);
+
+    SDL_RenderClear(renderer);
+    SDL_RenderCopy(renderer, bitmapTex, NULL, NULL);
+    SDL_RenderPresent(renderer);
+
+    /*
+    while (1) {
+        SDL_Event e;
+        if (SDL_PollEvent(&e)) {
+            if (e.type == SDL_QUIT) {
+                break;
+            }
+        }
+
+    }*/
+
+    SDL_Delay(5000);
+
+    SDL_DestroyTexture(bitmapTex);
+    SDL_DestroyRenderer(renderer);
+    SDL_DestroyWindow(win);
+
+    SDL_Quit();
+
+    return 0;
+}
+
old mode 100644 (file)
new mode 100755 (executable)
index 14acac4..82b350c
@@ -32,30 +32,30 @@ TestTypes(SDL_bool verbose)
 
     if (badsize(sizeof(Uint8), 1)) {
         if (verbose)
-            SDL_Log("sizeof(Uint8) != 1, instead = %u\n",
+            SDLTest_Log("sizeof(Uint8) != 1, instead = %u\n",
                    (unsigned int)sizeof(Uint8));
         ++error;
     }
     if (badsize(sizeof(Uint16), 2)) {
         if (verbose)
-            SDL_Log("sizeof(Uint16) != 2, instead = %u\n",
+            SDLTest_Log("sizeof(Uint16) != 2, instead = %u\n",
                    (unsigned int)sizeof(Uint16));
         ++error;
     }
     if (badsize(sizeof(Uint32), 4)) {
         if (verbose)
-            SDL_Log("sizeof(Uint32) != 4, instead = %u\n",
+            SDLTest_Log("sizeof(Uint32) != 4, instead = %u\n",
                    (unsigned int)sizeof(Uint32));
         ++error;
     }
     if (badsize(sizeof(Uint64), 8)) {
         if (verbose)
-            SDL_Log("sizeof(Uint64) != 8, instead = %u\n",
+            SDLTest_Log("sizeof(Uint64) != 8, instead = %u\n",
                    (unsigned int)sizeof(Uint64));
         ++error;
     }
     if (verbose && !error)
-        SDL_Log("All data types are the expected size.\n");
+        SDLTest_Log("All data types are the expected size.\n");
 
     return (error ? 1 : 0);
 }
@@ -80,7 +80,7 @@ TestEndian(SDL_bool verbose)
     swapped64 |= 0xDEADBEEF;
 
     if (verbose) {
-        SDL_Log("Detected a %s endian machine.\n",
+        SDLTest_Log("Detected a %s endian machine.\n",
                (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
     }
     if ((*((char *) &value) >> 4) == 0x1) {
@@ -90,38 +90,38 @@ TestEndian(SDL_bool verbose)
     }
     if (real_byteorder != SDL_BYTEORDER) {
         if (verbose) {
-            SDL_Log("Actually a %s endian machine!\n",
+            SDLTest_Log("Actually a %s endian machine!\n",
                    (real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
         }
         ++error;
     }
     if (verbose) {
-        SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
+        SDLTest_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
                SDL_Swap16(value16));
     }
     if (SDL_Swap16(value16) != swapped16) {
         if (verbose) {
-            SDL_Log("16 bit value swapped incorrectly!\n");
+            SDLTest_Log("16 bit value swapped incorrectly!\n");
         }
         ++error;
     }
     if (verbose) {
-        SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32,
+        SDLTest_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32,
                SDL_Swap32(value32));
     }
     if (SDL_Swap32(value32) != swapped32) {
         if (verbose) {
-            SDL_Log("32 bit value swapped incorrectly!\n");
+            SDLTest_Log("32 bit value swapped incorrectly!\n");
         }
         ++error;
     }
     if (verbose) {
-        SDL_Log("Value 64 = 0x%"SDL_PRIX64", swapped = 0x%"SDL_PRIX64"\n", value64,
+        SDLTest_Log("Value 64 = 0x%"SDL_PRIX64", swapped = 0x%"SDL_PRIX64"\n", value64,
                SDL_Swap64(value64));
     }
     if (SDL_Swap64(value64) != swapped64) {
         if (verbose) {
-            SDL_Log("64 bit value swapped incorrectly!\n");
+            SDLTest_Log("64 bit value swapped incorrectly!\n");
         }
         ++error;
     }
@@ -133,19 +133,19 @@ int
 TestCPUInfo(SDL_bool verbose)
 {
     if (verbose) {
-        SDL_Log("CPU count: %d\n", SDL_GetCPUCount());
-        SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
-        SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
-        SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
-        SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
-        SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
-        SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
-        SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
-        SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
-        SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
-        SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
-        SDL_Log("AVX %s\n", SDL_HasAVX()? "detected" : "not detected");
-        SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM());
+        SDLTest_Log("CPU count: %d\n", SDL_GetCPUCount());
+        SDLTest_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
+        SDLTest_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
+        SDLTest_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
+        SDLTest_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
+        SDLTest_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
+        SDLTest_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
+        SDLTest_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
+        SDLTest_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
+        SDLTest_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
+        SDLTest_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
+        SDLTest_Log("AVX %s\n", SDL_HasAVX()? "detected" : "not detected");
+        SDLTest_Log("System RAM %d MB\n", SDL_GetSystemRAM());
     }
     return (0);
 }
@@ -169,7 +169,7 @@ TestAssertions(SDL_bool verbose)
     {
         const SDL_AssertData *item = SDL_GetAssertionReport();
         while (item) {
-            SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
+            SDLTest_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
                 item->condition, item->function, item->filename,
                 item->linenum, item->trigger_count,
                 item->always_ignore ? "yes" : "no");
@@ -178,9 +178,8 @@ TestAssertions(SDL_bool verbose)
     }
     return (0);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_bool verbose = SDL_TRUE;
     int status = 0;
@@ -192,7 +191,7 @@ main(int argc, char *argv[])
         verbose = SDL_FALSE;
     }
     if (verbose) {
-        SDL_Log("This system is running %s\n", SDL_GetPlatform());
+        SDLTest_Log("This system is running %s\n", SDL_GetPlatform());
     }
 
     status += TestTypes(verbose);
old mode 100644 (file)
new mode 100755 (executable)
index 59d23f6..020c5ed
@@ -17,7 +17,8 @@
 #include <time.h>
 
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 #ifdef __EMSCRIPTEN__
 #include <emscripten/emscripten.h>
 #endif
@@ -46,6 +47,12 @@ loop(){
                 rect.y += event.motion.yrel;
             }
             break;
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
         }
     }
     for (i = 0; i < state->num_windows; ++i) {
@@ -73,16 +80,16 @@ loop(){
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
-
     /* Enable standard application logging */
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -106,8 +113,8 @@ main(int argc, char *argv[])
         return 3;
     };
 
-    rect.x = DEFAULT_WINDOW_WIDTH / 2;
-    rect.y = DEFAULT_WINDOW_HEIGHT / 2;
+    rect.x = WINDOW_WIDTH / 2;
+    rect.y = WINDOW_HEIGHT / 2;
     rect.w = 10;
     rect.h = 10;
     /* Main render loop */
old mode 100644 (file)
new mode 100755 (executable)
index 856abf7..f626e9f
@@ -20,7 +20,8 @@
 #endif
 
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 
 static SDLTest_CommonState *state;
 
@@ -53,7 +54,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return NULL;
     }
 
@@ -84,7 +85,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
     /* Create textures from the image */
     texture = SDL_CreateTextureFromSurface(renderer, temp);
     if (!texture) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return NULL;
     }
@@ -146,6 +147,14 @@ void loop()
 
     while (SDL_PollEvent(&event)) {
         SDLTest_CommonEvent(state, &event, &done);
+               switch(event.type) {
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
+        }
     }
     for (i = 0; i < state->num_windows; ++i) {
         if (state->windows[i] == NULL)
@@ -158,9 +167,8 @@ void loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     int frames;
@@ -171,6 +179,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -179,7 +189,7 @@ main(int argc, char *argv[])
 
         consumed = SDLTest_CommonArg(state, i);
         if (consumed == 0) {
-            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+            SDLTest_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
         i += consumed;
@@ -194,8 +204,8 @@ main(int argc, char *argv[])
 
         drawstate->window = state->windows[i];
         drawstate->renderer = state->renderers[i];
-        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE);
-        drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE);
+        drawstate->sprite = LoadTexture(drawstate->renderer, "res/icon.bmp", SDL_TRUE);
+        drawstate->background = LoadTexture(drawstate->renderer, "res/sample.bmp", SDL_FALSE);
         if (!drawstate->sprite || !drawstate->background) {
             quit(2);
         }
@@ -221,7 +231,7 @@ main(int argc, char *argv[])
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        SDL_Log("%2.2f frames per second\n", fps);
+        SDLTest_Log("%2.2f frames per second\n", fps);
     }
 
     SDL_stack_free(drawstates);
old mode 100644 (file)
new mode 100755 (executable)
index c5e1dce..ec38cd6
@@ -20,7 +20,8 @@
 #endif
 
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 
 static SDLTest_CommonState *state;
 
@@ -54,7 +55,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return NULL;
     }
 
@@ -85,7 +86,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
     /* Create textures from the image */
     texture = SDL_CreateTextureFromSurface(renderer, temp);
     if (!texture) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return NULL;
     }
@@ -122,7 +123,7 @@ DrawComposite(DrawState *s)
         SDL_RenderCopy(s->renderer, A, NULL, NULL);
         SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P));
 
-        SDL_Log("Blended pixel: 0x%8.8X\n", P);
+        SDLTest_Log("Blended pixel: 0x%8.8X\n", P);
 
         SDL_DestroyTexture(A);
         SDL_DestroyTexture(B);
@@ -188,7 +189,7 @@ Draw(DrawState *s)
 
     target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h);
     if (!target) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError());
         return SDL_FALSE;
     }
     SDL_SetRenderTarget(s->renderer, target);
@@ -231,6 +232,14 @@ loop()
     /* Check for events */
     while (SDL_PollEvent(&event)) {
         SDLTest_CommonEvent(state, &event, &done);
+               switch(event.type) {
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
+        }
     }
     for (i = 0; i < state->num_windows; ++i) {
         if (state->windows[i] == NULL)
@@ -247,9 +256,11 @@ loop()
     }
 #endif
 }
-
+#ifdef main
+#undef main
+#endif
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     int frames;
@@ -260,6 +271,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -275,7 +288,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s [--composite]\n",
+            SDLTest_Log("Usage: %s %s [--composite]\n",
                     argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -292,11 +305,11 @@ main(int argc, char *argv[])
         drawstate->window = state->windows[i];
         drawstate->renderer = state->renderers[i];
         if (test_composite) {
-            drawstate->sprite = LoadTexture(drawstate->renderer, "icon-alpha.bmp", SDL_TRUE);
+            drawstate->sprite = LoadTexture(drawstate->renderer, "res/icon-alpha.bmp", SDL_TRUE);
         } else {
-            drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE);
+            drawstate->sprite = LoadTexture(drawstate->renderer, "res/icon.bmp", SDL_TRUE);
         }
-        drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE);
+        drawstate->background = LoadTexture(drawstate->renderer, "res/sample.bmp", SDL_FALSE);
         if (!drawstate->sprite || !drawstate->background) {
             quit(2);
         }
@@ -323,7 +336,7 @@ main(int argc, char *argv[])
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        SDL_Log("%2.2f frames per second\n", fps);
+        SDLTest_Log("%2.2f frames per second\n", fps);
     }
 
     SDL_stack_free(drawstates);
old mode 100644 (file)
new mode 100755 (executable)
index 0e92bbe..3397644
@@ -11,9 +11,8 @@
 */
 
 #include "SDL.h"
-
 int
-main(int argc, char **argv)
+SDL_main(int argc, char **argv)
 {
     SDL_AudioSpec spec;
     SDL_AudioCVT cvt;
@@ -29,26 +28,26 @@ main(int argc, char **argv)
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (argc != 4) {
-        SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
+        SDLTest_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
         return 1;
     }
 
     cvtfreq = SDL_atoi(argv[3]);
 
     if (SDL_Init(SDL_INIT_AUDIO) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
         return 2;
     }
 
     if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError());
         SDL_Quit();
         return 3;
     }
 
     if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
                           spec.format, spec.channels, cvtfreq) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
         SDL_FreeWAV(data);
         SDL_Quit();
         return 4;
@@ -57,7 +56,7 @@ main(int argc, char **argv)
     cvt.len = len;
     cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult);
     if (cvt.buf == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
         SDL_FreeWAV(data);
         SDL_Quit();
         return 5;
@@ -65,7 +64,7 @@ main(int argc, char **argv)
     SDL_memcpy(cvt.buf, data, len);
 
     if (SDL_ConvertAudio(&cvt) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
         SDL_free(cvt.buf);
         SDL_FreeWAV(data);
         SDL_Quit();
@@ -75,7 +74,7 @@ main(int argc, char **argv)
     /* write out a WAV header... */
     io = SDL_RWFromFile(argv[2], "wb");
     if (io == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
         SDL_free(cvt.buf);
         SDL_FreeWAV(data);
         SDL_Quit();
@@ -102,7 +101,7 @@ main(int argc, char **argv)
     SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
 
     if (SDL_RWclose(io) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
         SDL_free(cvt.buf);
         SDL_FreeWAV(data);
         SDL_Quit();
old mode 100644 (file)
new mode 100755 (executable)
index 9f5fdbf..f71457d
@@ -21,8 +21,8 @@
 
 #include "SDL_test_common.h"
 
-#define WINDOW_WIDTH    640
-#define WINDOW_HEIGHT   480
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 
 static SDLTest_CommonState *state;
 
@@ -55,7 +55,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return NULL;
     }
 
@@ -86,7 +86,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
     /* Create textures from the image */
     texture = SDL_CreateTextureFromSurface(renderer, temp);
     if (!texture) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return NULL;
     }
@@ -136,6 +136,14 @@ loop()
     /* Check for events */
     while (SDL_PollEvent(&event)) {
         SDLTest_CommonEvent(state, &event, &done);
+               switch(event.type) {
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
+        }
     }
     for (i = 0; i < state->num_windows; ++i) {
         if (state->windows[i] == NULL)
@@ -148,9 +156,8 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     int frames;
@@ -161,6 +168,8 @@ main(int argc, char *argv[])
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -169,7 +178,7 @@ main(int argc, char *argv[])
 
         consumed = SDLTest_CommonArg(state, i);
         if (consumed == 0) {
-            SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+            SDLTest_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
             return 1;
         }
         i += consumed;
@@ -184,8 +193,8 @@ main(int argc, char *argv[])
 
         drawstate->window = state->windows[i];
         drawstate->renderer = state->renderers[i];
-        drawstate->sprite = LoadTexture(drawstate->renderer, "icon.bmp", SDL_TRUE);
-        drawstate->background = LoadTexture(drawstate->renderer, "sample.bmp", SDL_FALSE);
+        drawstate->sprite = LoadTexture(drawstate->renderer, "res/icon.bmp", SDL_TRUE);
+        drawstate->background = LoadTexture(drawstate->renderer, "res/sample.bmp", SDL_FALSE);
         if (!drawstate->sprite || !drawstate->background) {
             quit(2);
         }
@@ -212,7 +221,7 @@ main(int argc, char *argv[])
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        SDL_Log("%2.2f frames per second\n", fps);
+        SDLTest_Log("%2.2f frames per second\n", fps);
     }
 
     SDL_stack_free(drawstates);
old mode 100644 (file)
new mode 100755 (executable)
index b8d3b27..e3d1ace
@@ -29,15 +29,15 @@ ThreadFunc(void *data)
     int threadnum = (int) (uintptr_t) data;
     while (alive) {
         SDL_SemWait(sem);
-        SDL_Log("Thread number %d has got the semaphore (value = %d)!\n",
+        SDLTest_Log("Thread number %d has got the semaphore (value = %d)!\n",
                 threadnum, SDL_SemValue(sem));
         SDL_Delay(200);
         SDL_SemPost(sem);
-        SDL_Log("Thread number %d has released the semaphore (value = %d)!\n",
+        SDLTest_Log("Thread number %d has released the semaphore (value = %d)!\n",
                 threadnum, SDL_SemValue(sem));
         SDL_Delay(1);           /* For the scheduler */
     }
-    SDL_Log("Thread number %d exiting.\n", threadnum);
+    SDLTest_Log("Thread number %d exiting.\n", threadnum);
     return 0;
 }
 
@@ -46,7 +46,24 @@ killed(int sig)
 {
     alive = 0;
 }
-
+static void 
+TestSDLCond(void)
+{
+       SDL_mutex *mutex = SDL_CreateMutex();
+       SDL_cond *cond= SDL_CreateCond();
+       SDL_CondSignal(cond);
+       SDL_CondBroadcast(cond);
+       
+       SDL_LockMutex(mutex);
+       SDL_CondWait(cond, mutex);
+       SDL_UnlockMutex(mutex);
+       
+       int retval = SDL_CondWaitTimeout(cond, mutex, 300);
+       if(retval != SDL_MUTEX_TIMEDOUT)
+       {
+               SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CondWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
+       }
+}
 static void
 TestWaitTimeout(void)
 {
@@ -56,7 +73,7 @@ TestWaitTimeout(void)
     int retval;
 
     sem = SDL_CreateSemaphore(0);
-    SDL_Log("Waiting 2 seconds on semaphore\n");
+    SDLTest_Log("Waiting 2 seconds on semaphore\n");
 
     start_ticks = SDL_GetTicks();
     retval = SDL_SemWaitTimeout(sem, 2000);
@@ -66,17 +83,16 @@ TestWaitTimeout(void)
 
     /* Accept a little offset in the effective wait */
     if (duration > 1900 && duration < 2050)
-        SDL_Log("Wait done.\n");
+        SDLTest_Log("Wait done.\n");
     else
-        SDL_Log("Wait took %d milliseconds\n", duration);
+        SDLTest_Log("Wait took %d milliseconds\n", duration);
 
     /* Check to make sure the return value indicates timed out */
     if (retval != SDL_MUTEX_TIMEDOUT)
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
 }
-
 int
-main(int argc, char **argv)
+SDL_main(int argc, char **argv)
 {
     SDL_Thread *threads[NUM_THREADS];
     uintptr_t i;
@@ -86,13 +102,13 @@ main(int argc, char **argv)
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (argc < 2) {
-        SDL_Log("Usage: %s init_value\n", argv[0]);
+        SDLTest_Log("Usage: %s init_value\n", argv[0]);
         return (1);
     }
 
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
     signal(SIGTERM, killed);
@@ -101,7 +117,7 @@ main(int argc, char **argv)
     init_sem = atoi(argv[1]);
     sem = SDL_CreateSemaphore(init_sem);
 
-    SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
+    SDLTest_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
            init_sem);
     /* Create all the threads */
     for (i = 0; i < NUM_THREADS; ++i) {
@@ -114,17 +130,17 @@ main(int argc, char **argv)
     SDL_Delay(10 * 1000);
 
     /* Wait for all threads to finish */
-    SDL_Log("Waiting for threads to finish\n");
+    SDLTest_Log("Waiting for threads to finish\n");
     alive = 0;
     for (i = 0; i < NUM_THREADS; ++i) {
         SDL_WaitThread(threads[i], NULL);
     }
-    SDL_Log("Finished waiting for threads\n");
+    SDLTest_Log("Finished waiting for threads\n");
 
     SDL_DestroySemaphore(sem);
 
     TestWaitTimeout();
-
+       TestSDLCond();
     SDL_Quit();
     return (0);
 }
old mode 100644 (file)
new mode 100755 (executable)
index fc6da29..807be1b
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright (r) 1997-2016 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
   including commercial applications, and to alter it and redistribute it
   freely.
 */
-/* This is a simple example of using GLSL shaders with SDL */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
 
-#include "SDL.h"
+#ifdef __EMSCRIPTEN__
+#include <emscripten/emscripten.h>
+#endif
 
-#ifdef HAVE_OPENGL
+#include "SDL_test_common.h"
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
+#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) || defined(__TIZEN__)
+#define HAVE_OPENGLES2
+#endif
 
-#include "SDL_opengl.h"
+#define HAVE_OPENGLES2
 
+#ifdef HAVE_OPENGLES2
 
-static SDL_bool shaders_supported;
-static int      current_shader = 0;
+#include "SDL_opengles2.h"
 
-enum {
-    SHADER_COLOR,
-    SHADER_TEXTURE,
-    SHADER_TEXCOORDS,
-    NUM_SHADERS
-};
+typedef struct GLES2_Context
+{
+#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
+#include "SDL_gles2funcs.h"
+#undef SDL_PROC
+} GLES2_Context;
 
-typedef struct {
-    GLhandleARB program;
-    GLhandleARB vert_shader;
-    GLhandleARB frag_shader;
-    const char *vert_source;
-    const char *frag_source;
-} ShaderData;
-
-static ShaderData shaders[NUM_SHADERS] = {
-
-    /* SHADER_COLOR */
-    { 0, 0, 0,
-        /* vertex shader */
-"varying vec4 v_color;\n"
-"\n"
-"void main()\n"
-"{\n"
-"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-"    v_color = gl_Color;\n"
-"}",
-        /* fragment shader */
-"varying vec4 v_color;\n"
-"\n"
-"void main()\n"
-"{\n"
-"    gl_FragColor = v_color;\n"
-"}"
-    },
-
-    /* SHADER_TEXTURE */
-    { 0, 0, 0,
-        /* vertex shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-"    v_color = gl_Color;\n"
-"    v_texCoord = vec2(gl_MultiTexCoord0);\n"
-"}",
-        /* fragment shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"uniform sampler2D tex0;\n"
-"\n"
-"void main()\n"
-"{\n"
-"    gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n"
-"}"
-    },
-
-    /* SHADER_TEXCOORDS */
-    { 0, 0, 0,
-        /* vertex shader */
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-"    v_texCoord = vec2(gl_MultiTexCoord0);\n"
-"}",
-        /* fragment shader */
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-"    vec4 color;\n"
-"    vec2 delta;\n"
-"    float dist;\n"
-"\n"
-"    delta = vec2(0.5, 0.5) - v_texCoord;\n"
-"    dist = dot(delta, delta);\n"
-"\n"
-"    color.r = v_texCoord.x;\n"
-"    color.g = v_texCoord.x * v_texCoord.y;\n"
-"    color.b = v_texCoord.y;\n"
-"    color.a = 1.0 - (dist * 4.0);\n"
-"    gl_FragColor = color;\n"
-"}"
-    },
-};
 
-static PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
-static PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
-static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
-static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
-static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
-static PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
-static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
-static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
-static PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
-static PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
-static PFNGLUNIFORM1IARBPROC glUniform1iARB;
-static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
-
-static SDL_bool CompileShader(GLhandleARB shader, const char *source)
+static SDLTest_CommonState *state;
+static SDL_GLContext *context = NULL;
+static int depth = 16;
+static GLES2_Context ctx;
+
+static int LoadContext(GLES2_Context * data)
 {
-    GLint status;
-
-    glShaderSourceARB(shader, 1, &source, NULL);
-    glCompileShaderARB(shader);
-    glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
-    if (status == 0) {
-        GLint length;
-        char *info;
-
-        glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
-        info = SDL_stack_alloc(char, length+1);
-        glGetInfoLogARB(shader, length, NULL, info);
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
-        SDL_stack_free(info);
-
-        return SDL_FALSE;
-    } else {
-        return SDL_TRUE;
-    }
+#if SDL_VIDEO_DRIVER_UIKIT
+#define __SDL_NOGETPROCADDR__
+#elif SDL_VIDEO_DRIVER_ANDROID
+#define __SDL_NOGETPROCADDR__
+#elif SDL_VIDEO_DRIVER_PANDORA
+#define __SDL_NOGETPROCADDR__
+#endif
+
+#if defined __SDL_NOGETPROCADDR__
+#define SDL_PROC(ret,func,params) data->func=func;
+#else
+#define SDL_PROC(ret,func,params) \
+    do { \
+        data->func = SDL_GL_GetProcAddress(#func); \
+        if ( ! data->func ) { \
+            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
+        } \
+    } while ( 0 );
+#endif /* __SDL_NOGETPROCADDR__ */
+
+#include "SDL_gles2funcs.h"
+#undef SDL_PROC
+    return 0;
 }
 
-static SDL_bool CompileShaderProgram(ShaderData *data)
+/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
+static void
+quit(int rc)
 {
-    const int num_tmus_bound = 4;
     int i;
-    GLint location;
 
-    glGetError();
-
-    /* Create one program object to rule them all */
-    data->program = glCreateProgramObjectARB();
+    if (context != NULL) {
+        for (i = 0; i < state->num_windows; i++) {
+            if (context[i]) {
+                SDL_GL_DeleteContext(context[i]);
+            }
+        }
 
-    /* Create the vertex shader */
-    data->vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
-    if (!CompileShader(data->vert_shader, data->vert_source)) {
-        return SDL_FALSE;
+        SDL_free(context);
     }
 
-    /* Create the fragment shader */
-    data->frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
-    if (!CompileShader(data->frag_shader, data->frag_source)) {
-        return SDL_FALSE;
-    }
+    SDLTest_CommonQuit(state);
+    exit(rc);
+}
 
-    /* ... and in the darkness bind them */
-    glAttachObjectARB(data->program, data->vert_shader);
-    glAttachObjectARB(data->program, data->frag_shader);
-    glLinkProgramARB(data->program);
-
-    /* Set up some uniform variables */
-    glUseProgramObjectARB(data->program);
-    for (i = 0; i < num_tmus_bound; ++i) {
-        char tex_name[5];
-        SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
-        location = glGetUniformLocationARB(data->program, tex_name);
-        if (location >= 0) {
-            glUniform1iARB(location, i);
+#define GL_CHECK(x) \
+        x; \
+        { \
+          GLenum glError = ctx.glGetError(); \
+          if(glError != GL_NO_ERROR) { \
+            SDLTest_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
+            quit(1); \
+          } \
         }
+
+/* 
+ * Simulates desktop's glRotatef. The matrix is returned in column-major 
+ * order. 
+ */
+static void
+rotate_matrix(float angle, float x, float y, float z, float *r)
+{
+    float radians, c, s, c1, u[3], length;
+    int i, j;
+
+    radians = (float)(angle * M_PI) / 180.0f;
+
+    c = SDL_cosf(radians);
+    s = SDL_sinf(radians);
+
+    c1 = 1.0f - SDL_cosf(radians);
+
+    length = (float)SDL_sqrt(x * x + y * y + z * z);
+
+    u[0] = x / length;
+    u[1] = y / length;
+    u[2] = z / length;
+
+    for (i = 0; i < 16; i++) {
+        r[i] = 0.0;
     }
-    glUseProgramObjectARB(0);
 
-    return (glGetError() == GL_NO_ERROR) ? SDL_TRUE : SDL_FALSE;
-}
+    r[15] = 1.0;
 
-static void DestroyShaderProgram(ShaderData *data)
-{
-    if (shaders_supported) {
-        glDeleteObjectARB(data->vert_shader);
-        glDeleteObjectARB(data->frag_shader);
-        glDeleteObjectARB(data->program);
+    for (i = 0; i < 3; i++) {
+        r[i * 4 + (i + 1) % 3] = u[(i + 2) % 3] * s;
+        r[i * 4 + (i + 2) % 3] = -u[(i + 1) % 3] * s;
+    }
+
+    for (i = 0; i < 3; i++) {
+        for (j = 0; j < 3; j++) {
+            r[i * 4 + j] += c1 * u[i] * u[j] + (i == j ? c : 0.0f);
+        }
     }
 }
 
-static SDL_bool InitShaders()
+/* 
+ * Simulates gluPerspectiveMatrix 
+ */
+static void 
+perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r)
 {
     int i;
+    float f;
 
-    /* Check for shader support */
-    shaders_supported = SDL_FALSE;
-    if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") &&
-        SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") &&
-        SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") &&
-        SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) {
-        glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB");
-        glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB");
-        glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB");
-        glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB");
-        glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB");
-        glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB");
-        glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB");
-        glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB");
-        glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB");
-        glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB");
-        glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB");
-        glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB");
-        if (glAttachObjectARB &&
-            glCompileShaderARB &&
-            glCreateProgramObjectARB &&
-            glCreateShaderObjectARB &&
-            glDeleteObjectARB &&
-            glGetInfoLogARB &&
-            glGetObjectParameterivARB &&
-            glGetUniformLocationARB &&
-            glLinkProgramARB &&
-            glShaderSourceARB &&
-            glUniform1iARB &&
-            glUseProgramObjectARB) {
-            shaders_supported = SDL_TRUE;
-        }
-    }
+    f = 1.0f/SDL_tanf(fovy * 0.5f);
 
-    if (!shaders_supported) {
-        return SDL_FALSE;
+    for (i = 0; i < 16; i++) {
+        r[i] = 0.0;
     }
 
-    /* Compile all the shaders */
-    for (i = 0; i < NUM_SHADERS; ++i) {
-        if (!CompileShaderProgram(&shaders[i])) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
-            return SDL_FALSE;
+    r[0] = f / aspect;
+    r[5] = f;
+    r[10] = (znear + zfar) / (znear - zfar);
+    r[11] = -1.0f;
+    r[14] = (2.0f * znear * zfar) / (znear - zfar);
+    r[15] = 0.0f;
+}
+
+/* 
+ * Multiplies lhs by rhs and writes out to r. All matrices are 4x4 and column
+ * major. In-place multiplication is supported.
+ */
+static void
+multiply_matrix(float *lhs, float *rhs, float *r)
+{
+    int i, j, k;
+    float tmp[16];
+
+    for (i = 0; i < 4; i++) {
+        for (j = 0; j < 4; j++) {
+            tmp[j * 4 + i] = 0.0;
+
+            for (k = 0; k < 4; k++) {
+                tmp[j * 4 + i] += lhs[k * 4 + i] * rhs[j * 4 + k];
+            }
         }
     }
 
-    /* We're done! */
-    return SDL_TRUE;
+    for (i = 0; i < 16; i++) {
+        r[i] = tmp[i];
+    }
 }
 
-static void QuitShaders()
+/* 
+ * Create shader, load in source, compile, dump debug as necessary.
+ *
+ * shader: Pointer to return created shader ID.
+ * source: Passed-in shader source code.
+ * shader_type: Passed to GL, e.g. GL_VERTEX_SHADER.
+ */
+void 
+process_shader(GLuint *shader, const char * source, GLint shader_type)
 {
-    int i;
+    GLint status = GL_FALSE;
+    const char *shaders[1] = { NULL };
+    char buffer[1024];
+    GLsizei length;
+
+    /* Create shader and load into GL. */
+    *shader = GL_CHECK(ctx.glCreateShader(shader_type));
+
+    shaders[0] = source;
 
-    for (i = 0; i < NUM_SHADERS; ++i) {
-        DestroyShaderProgram(&shaders[i]);
+    GL_CHECK(ctx.glShaderSource(*shader, 1, shaders, NULL));
+
+    /* Clean up shader source. */
+    shaders[0] = NULL;
+
+    /* Try compiling the shader. */
+    GL_CHECK(ctx.glCompileShader(*shader));
+    GL_CHECK(ctx.glGetShaderiv(*shader, GL_COMPILE_STATUS, &status));
+
+    /* Dump debug info (source and log) if compilation failed. */
+    if(status != GL_TRUE) {
+        ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]);
+        buffer[length] = '\0';
+        SDLTest_Log("Shader compilation failed: %s", buffer);fflush(stderr);
+        quit(-1);
     }
 }
 
-/* Quick utility function for texture creation */
-static int
-power_of_two(int input)
+/* 3D data. Vertex range -0.5..0.5 in all axes.
+* Z -0.5 is near, 0.5 is far. */
+const float _vertices[] =
 {
-    int value = 1;
+    /* Front face. */
+    /* Bottom left */
+    -0.5,  0.5, -0.5,
+    0.5, -0.5, -0.5,
+    -0.5, -0.5, -0.5,
+    /* Top right */
+    -0.5,  0.5, -0.5,
+    0.5,  0.5, -0.5,
+    0.5, -0.5, -0.5,
+    /* Left face */
+    /* Bottom left */
+    -0.5,  0.5,  0.5,
+    -0.5, -0.5, -0.5,
+    -0.5, -0.5,  0.5,
+    /* Top right */
+    -0.5,  0.5,  0.5,
+    -0.5,  0.5, -0.5,
+    -0.5, -0.5, -0.5,
+    /* Top face */
+    /* Bottom left */
+    -0.5,  0.5,  0.5,
+    0.5,  0.5, -0.5,
+    -0.5,  0.5, -0.5,
+    /* Top right */
+    -0.5,  0.5,  0.5,
+    0.5,  0.5,  0.5,
+    0.5,  0.5, -0.5,
+    /* Right face */
+    /* Bottom left */
+    0.5,  0.5, -0.5,
+    0.5, -0.5,  0.5,
+    0.5, -0.5, -0.5,
+    /* Top right */
+    0.5,  0.5, -0.5,
+    0.5,  0.5,  0.5,
+    0.5, -0.5,  0.5,
+    /* Back face */
+    /* Bottom left */
+    0.5,  0.5,  0.5,
+    -0.5, -0.5,  0.5,
+    0.5, -0.5,  0.5,
+    /* Top right */
+    0.5,  0.5,  0.5,
+    -0.5,  0.5,  0.5,
+    -0.5, -0.5,  0.5,
+    /* Bottom face */
+    /* Bottom left */
+    -0.5, -0.5, -0.5,
+    0.5, -0.5,  0.5,
+    -0.5, -0.5,  0.5,
+    /* Top right */
+    -0.5, -0.5, -0.5,
+    0.5, -0.5, -0.5,
+    0.5, -0.5,  0.5,
+};
 
-    while (value < input) {
-        value <<= 1;
-    }
-    return value;
-}
+const float _colors[] =
+{
+    /* Front face */
+    /* Bottom left */
+    1.0, 0.0, 0.0, /* red */
+    0.0, 0.0, 1.0, /* blue */
+    0.0, 1.0, 0.0, /* green */
+    /* Top right */
+    1.0, 0.0, 0.0, /* red */
+    1.0, 1.0, 0.0, /* yellow */
+    0.0, 0.0, 1.0, /* blue */
+    /* Left face */
+    /* Bottom left */
+    1.0, 1.0, 1.0, /* white */
+    0.0, 1.0, 0.0, /* green */
+    0.0, 1.0, 1.0, /* cyan */
+    /* Top right */
+    1.0, 1.0, 1.0, /* white */
+    1.0, 0.0, 0.0, /* red */
+    0.0, 1.0, 0.0, /* green */
+    /* Top face */
+    /* Bottom left */
+    1.0, 1.0, 1.0, /* white */
+    1.0, 1.0, 0.0, /* yellow */
+    1.0, 0.0, 0.0, /* red */
+    /* Top right */
+    1.0, 1.0, 1.0, /* white */
+    0.0, 0.0, 0.0, /* black */
+    1.0, 1.0, 0.0, /* yellow */
+    /* Right face */
+    /* Bottom left */
+    1.0, 1.0, 0.0, /* yellow */
+    1.0, 0.0, 1.0, /* magenta */
+    0.0, 0.0, 1.0, /* blue */
+    /* Top right */
+    1.0, 1.0, 0.0, /* yellow */
+    0.0, 0.0, 0.0, /* black */
+    1.0, 0.0, 1.0, /* magenta */
+    /* Back face */
+    /* Bottom left */
+    0.0, 0.0, 0.0, /* black */
+    0.0, 1.0, 1.0, /* cyan */
+    1.0, 0.0, 1.0, /* magenta */
+    /* Top right */
+    0.0, 0.0, 0.0, /* black */
+    1.0, 1.0, 1.0, /* white */
+    0.0, 1.0, 1.0, /* cyan */
+    /* Bottom face */
+    /* Bottom left */
+    0.0, 1.0, 0.0, /* green */
+    1.0, 0.0, 1.0, /* magenta */
+    0.0, 1.0, 1.0, /* cyan */
+    /* Top right */
+    0.0, 1.0, 0.0, /* green */
+    0.0, 0.0, 1.0, /* blue */
+    1.0, 0.0, 1.0, /* magenta */
+};
 
-GLuint
-SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord)
+const char* _shader_vert_src = 
+" attribute vec4 av4position; "
+" attribute vec3 av3color; "
+" uniform mat4 mvp; "
+" varying vec3 vv3color; "
+" void main() { "
+"    vv3color = av3color; "
+"    gl_Position = mvp * av4position; "
+" } ";
+
+const char* _shader_frag_src = 
+" precision lowp float; "
+" varying vec3 vv3color; "
+" void main() { "
+"    gl_FragColor = vec4(vv3color, 1.0); "
+" } ";
+
+typedef struct shader_data
 {
-    GLuint texture;
-    int w, h;
-    SDL_Surface *image;
-    SDL_Rect area;
-    SDL_BlendMode saved_mode;
-
-    /* Use the surface width and height expanded to powers of 2 */
-    w = power_of_two(surface->w);
-    h = power_of_two(surface->h);
-    texcoord[0] = 0.0f;         /* Min X */
-    texcoord[1] = 0.0f;         /* Min Y */
-    texcoord[2] = (GLfloat) surface->w / w;     /* Max X */
-    texcoord[3] = (GLfloat) surface->h / h;     /* Max Y */
-
-    image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN     /* OpenGL RGBA masks */
-                                 0x000000FF,
-                                 0x0000FF00, 0x00FF0000, 0xFF000000
-#else
-                                 0xFF000000,
-                                 0x00FF0000, 0x0000FF00, 0x000000FF
-#endif
-        );
-    if (image == NULL) {
-        return 0;
-    }
+    GLuint shader_program, shader_frag, shader_vert;
 
-    /* Save the alpha blending attributes */
-    SDL_GetSurfaceBlendMode(surface, &saved_mode);
-    SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
-
-    /* Copy the surface into the GL texture image */
-    area.x = 0;
-    area.y = 0;
-    area.w = surface->w;
-    area.h = surface->h;
-    SDL_BlitSurface(surface, &area, image, &area);
-
-    /* Restore the alpha blending attributes */
-    SDL_SetSurfaceBlendMode(surface, saved_mode);
-
-    /* Create an OpenGL texture for the image */
-    glGenTextures(1, &texture);
-    glBindTexture(GL_TEXTURE_2D, texture);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glTexImage2D(GL_TEXTURE_2D,
-                 0,
-                 GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
-    SDL_FreeSurface(image);     /* No longer needed */
-
-    return texture;
-}
+    GLint attr_position;
+    GLint attr_color, attr_mvp;
+
+    int angle_x, angle_y, angle_z;
 
-/* A general OpenGL initialization function.    Sets all of the initial parameters. */
-void InitGL(int Width, int Height)                    /* We call this right after our OpenGL window is created. */
+} shader_data;
+
+static void
+Render(unsigned int width, unsigned int height, shader_data* data)
 {
-    GLdouble aspect;
+    float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_mvp[16];
+
+    /* 
+    * Do some rotation with Euler angles. It is not a fixed axis as
+    * quaterions would be, but the effect is cool. 
+    */
+    rotate_matrix((float)data->angle_x, 1.0f, 0.0f, 0.0f, matrix_modelview);
+    rotate_matrix((float)data->angle_y, 0.0f, 1.0f, 0.0f, matrix_rotate);
 
-    glViewport(0, 0, Width, Height);
-    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);        /* This Will Clear The Background Color To Black */
-    glClearDepth(1.0);                /* Enables Clearing Of The Depth Buffer */
-    glDepthFunc(GL_LESS);                /* The Type Of Depth Test To Do */
-    glEnable(GL_DEPTH_TEST);            /* Enables Depth Testing */
-    glShadeModel(GL_SMOOTH);            /* Enables Smooth Color Shading */
+    multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
 
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();                /* Reset The Projection Matrix */
+    rotate_matrix((float)data->angle_z, 0.0f, 1.0f, 0.0f, matrix_rotate);
 
-    aspect = (GLdouble)Width / Height;
-    glOrtho(-3.0, 3.0, -3.0 / aspect, 3.0 / aspect, 0.0, 1.0);
+    multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
 
-    glMatrixMode(GL_MODELVIEW);
+    /* Pull the camera back from the cube */
+    matrix_modelview[14] -= 2.5;
+
+    perspective_matrix(45.0f, (float)width/height, 0.01f, 100.0f, matrix_perspective);
+    multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp);
+
+    GL_CHECK(ctx.glUniformMatrix4fv(data->attr_mvp, 1, GL_FALSE, matrix_mvp));
+
+    data->angle_x += 3;
+    data->angle_y += 2;
+    data->angle_z += 1;
+
+    if(data->angle_x >= 360) data->angle_x -= 360;
+    if(data->angle_x < 0) data->angle_x += 360;
+    if(data->angle_y >= 360) data->angle_y -= 360;
+    if(data->angle_y < 0) data->angle_y += 360;
+    if(data->angle_z >= 360) data->angle_z -= 360;
+    if(data->angle_z < 0) data->angle_z += 360;
+
+    GL_CHECK(ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
+    GL_CHECK(ctx.glDrawArrays(GL_TRIANGLES, 0, 36));
 }
 
-/* The main drawing function. */
-void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat * texcoord)
+int done;
+Uint32 frames;
+shader_data *datas;
+
+void loop()
 {
-    /* Texture coordinate lookup, to make it simple */
-    enum {
-        MINX,
-        MINY,
-        MAXX,
-        MAXY
-    };
-
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);        /* Clear The Screen And The Depth Buffer */
-    glLoadIdentity();                /* Reset The View */
-
-    glTranslatef(-1.5f,0.0f,0.0f);        /* Move Left 1.5 Units */
-
-    /* draw a triangle (in smooth coloring mode) */
-    glBegin(GL_POLYGON);                /* start drawing a polygon */
-    glColor3f(1.0f,0.0f,0.0f);            /* Set The Color To Red */
-    glVertex3f( 0.0f, 1.0f, 0.0f);        /* Top */
-    glColor3f(0.0f,1.0f,0.0f);            /* Set The Color To Green */
-    glVertex3f( 1.0f,-1.0f, 0.0f);        /* Bottom Right */
-    glColor3f(0.0f,0.0f,1.0f);            /* Set The Color To Blue */
-    glVertex3f(-1.0f,-1.0f, 0.0f);        /* Bottom Left */
-    glEnd();                    /* we're done with the polygon (smooth color interpolation) */
-
-    glTranslatef(3.0f,0.0f,0.0f);         /* Move Right 3 Units */
-
-    /* Enable blending */
-    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-    /* draw a textured square (quadrilateral) */
-    glEnable(GL_TEXTURE_2D);
-    glBindTexture(GL_TEXTURE_2D, texture);
-    glColor3f(1.0f,1.0f,1.0f);
-    if (shaders_supported) {
-        glUseProgramObjectARB(shaders[current_shader].program);
+    SDL_Event event;
+    int i;
+    int status;
+
+    /* Check for events */
+    ++frames;
+    while (SDL_PollEvent(&event) && !done) {
+        switch (event.type) {
+        /*case SDL_WINDOWEVENT:
+            switch (event.window.event) {
+                case SDL_WINDOWEVENT_RESIZED:
+                    for (i = 0; i < state->num_windows; ++i) {
+                        if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
+                            int w, h;
+                            status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
+                            if (status) {
+                                SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+                                break;
+                            }
+                            // Change view port to the new window dimensions 
+                            SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
+                            ctx.glViewport(0, 0, w, h);
+                            state->window_w = event.window.data1;
+                            state->window_h = event.window.data2;
+                            // Update window content 
+                            Render(event.window.data1, event.window.data2, &datas[i]);
+                            SDL_GL_SwapWindow(state->windows[i]);
+                            break;
+                        }
+                    }
+                    break;
+            }*/
+               case SDL_KEYDOWN:
+               if(event.key.keysym.sym == 0)
+               {
+                       done = 1;
+               }
+               break;
+        }
+        SDLTest_CommonEvent(state, &event, &done);
     }
-
-    glBegin(GL_QUADS);                /* start drawing a polygon (4 sided) */
-    glTexCoord2f(texcoord[MINX], texcoord[MINY]);
-    glVertex3f(-1.0f, 1.0f, 0.0f);        /* Top Left */
-    glTexCoord2f(texcoord[MAXX], texcoord[MINY]);
-    glVertex3f( 1.0f, 1.0f, 0.0f);        /* Top Right */
-    glTexCoord2f(texcoord[MAXX], texcoord[MAXY]);
-    glVertex3f( 1.0f,-1.0f, 0.0f);        /* Bottom Right */
-    glTexCoord2f(texcoord[MINX], texcoord[MAXY]);
-    glVertex3f(-1.0f,-1.0f, 0.0f);        /* Bottom Left */
-    glEnd();                    /* done with the polygon */
-
-    if (shaders_supported) {
-        glUseProgramObjectARB(0);
+    if (!done) {
+      for (i = 0; i < state->num_windows; ++i) {
+          status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
+          if (status) {
+              SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+
+              /* Continue for next window */
+              continue;
+          }
+          Render(state->window_w, state->window_h, &datas[i]);
+          SDL_GL_SwapWindow(state->windows[i]);
+      }
     }
-    glDisable(GL_TEXTURE_2D);
-
-    /* swap buffers to display, since we're double buffered. */
-    SDL_GL_SwapWindow(window);
+#ifdef __EMSCRIPTEN__
+    else {
+        emscripten_cancel_main_loop();
+    }
+#endif
 }
-
-int main(int argc, char **argv)
+int
+SDL_main(int argc, char *argv[])
 {
-    int done;
-    SDL_Window *window;
-    SDL_Surface *surface;
-    GLuint texture;
-    GLfloat texcoords[4];
-
-    /* Enable standard application logging */
-    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
-
-    /* Initialize SDL for video output */
-    if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
-        exit(1);
+    int fsaa, accel;
+    int value;
+    int i;
+    SDL_DisplayMode mode;
+    Uint32 then, now;
+    int status;
+    shader_data *data;
+
+    /* Initialize parameters */
+    fsaa = 0;
+    accel = 0;
+
+    /* Initialize test framework */
+    state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
+    if (!state) {
+        return 1;
+    }
+    for (i = 1; i < argc;) {
+        int consumed;
+
+        consumed = SDLTest_CommonArg(state, i);
+        if (consumed == 0) {
+            if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
+                ++fsaa;
+                consumed = 1;
+            } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
+                ++accel;
+                consumed = 1;
+            } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
+                i++;
+                if (!argv[i]) {
+                    consumed = -1;
+                } else {
+                    depth = SDL_atoi(argv[i]);
+                    consumed = 1;
+                }
+            } else {
+                consumed = -1;
+            }
+        }
+        if (consumed < 0) {
+            SDLTest_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
+                    SDLTest_CommonUsage(state));
+            quit(1);
+        }
+        i += consumed;
+    }
+
+    /* Set OpenGL parameters */
+    state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
+    state->gl_red_size = 5;
+    state->gl_green_size = 5;
+    state->gl_blue_size = 5;
+    state->gl_depth_size = depth;
+    state->gl_major_version = 2;
+    state->gl_minor_version = 0;
+    state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
+
+    if (fsaa) {
+        state->gl_multisamplebuffers=1;
+        state->gl_multisamplesamples=fsaa;
+    }
+    if (accel) {
+        state->gl_accelerated=1;
+    }
+    if (!SDLTest_CommonInit(state)) {
+        quit(2);
+        return 0;
     }
 
-    /* Create a 640x480 OpenGL screen */
-    window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL );
-    if ( !window ) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
-        SDL_Quit();
-        exit(2);
+    context = SDL_calloc(state->num_windows, sizeof(context));
+    if (context == NULL) {
+        SDLTest_Log("Out of memory!\n");
+        quit(2);
+    }
+    
+    /* Create OpenGL ES contexts */
+    for (i = 0; i < state->num_windows; i++) {
+        context[i] = SDL_GL_CreateContext(state->windows[i]);
+        if (!context[i]) {
+            SDLTest_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
+            quit(2);
+        }
     }
 
-    if ( !SDL_GL_CreateContext(window)) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
-        SDL_Quit();
-        exit(2);
+    /* Important: call this *after* creating the context */
+    if (LoadContext(&ctx) < 0) {
+        SDLTest_Log("Could not load GLES2 functions\n");
+        quit(2);
+        return 0;
     }
 
-    surface = SDL_LoadBMP("icon.bmp");
-    if ( ! surface ) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
-        SDL_Quit();
-        exit(3);
+
+
+    if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
+        SDL_GL_SetSwapInterval(1);
+    } else {
+        SDL_GL_SetSwapInterval(0);
     }
-    texture = SDL_GL_LoadTexture(surface, texcoords);
-    SDL_FreeSurface(surface);
 
-    /* Loop, drawing and checking events */
-    InitGL(640, 480);
-    if (InitShaders()) {
-        SDL_Log("Shaders supported, press SPACE to cycle them.\n");
+    SDL_GetCurrentDisplayMode(0, &mode);
+    SDLTest_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
+    SDLTest_Log("\n");
+    SDLTest_Log("Vendor     : %s\n", ctx.glGetString(GL_VENDOR));
+    SDLTest_Log("Renderer   : %s\n", ctx.glGetString(GL_RENDERER));
+    SDLTest_Log("Version    : %s\n", ctx.glGetString(GL_VERSION));
+    SDLTest_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
+    SDLTest_Log("\n");
+
+    status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
+    if (!status) {
+        SDLTest_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
+        SDLTest_Log( "Failed to get SDL_GL_RED_SIZE: %s\n",
+                SDL_GetError());
     }
-    done = 0;
-    while ( ! done ) {
-        DrawGLScene(window, texture, texcoords);
-
-        /* This could go in a separate function */
-        { SDL_Event event;
-            while ( SDL_PollEvent(&event) ) {
-                if ( event.type == SDL_QUIT ) {
-                    done = 1;
-                }
-                if ( event.type == SDL_KEYDOWN ) {
-                    if ( event.key.keysym.sym == SDLK_SPACE ) {
-                        current_shader = (current_shader + 1) % NUM_SHADERS;
-                    }
-                    if ( event.key.keysym.sym == SDLK_ESCAPE ) {
-                        done = 1;
-                    }
-                }
-            }
+    status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
+    if (!status) {
+        SDLTest_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+    } else {
+        SDLTest_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n",
+                SDL_GetError());
+    }
+    status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
+    if (!status) {
+        SDLTest_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+    } else {
+        SDLTest_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n",
+                SDL_GetError());
+    }
+    status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
+    if (!status) {
+        SDLTest_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
+    } else {
+        SDLTest_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
+                SDL_GetError());
+    }
+    if (fsaa) {
+        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
+        if (!status) {
+            SDLTest_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+        } else {
+            SDLTest_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+                    SDL_GetError());
+        }
+        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
+        if (!status) {
+            SDLTest_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+                   value);
+        } else {
+            SDLTest_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+                    SDL_GetError());
         }
     }
-    QuitShaders();
-    SDL_Quit();
-    return 1;
+    if (accel) {
+        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
+        if (!status) {
+            SDLTest_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
+        } else {
+            SDLTest_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+                    SDL_GetError());
+        }
+    }
+
+    datas = SDL_calloc(state->num_windows, sizeof(shader_data));
+
+    /* Set rendering settings for each context */
+    for (i = 0; i < state->num_windows; ++i) {
+
+        int w, h;
+        status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
+        if (status) {
+            SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+
+            /* Continue for next window */
+            continue;
+        }
+        SDL_GL_GetDrawableSize(state->windows[i], &w, &h);
+        ctx.glViewport(0, 0, w, h);
+
+        data = &datas[i];
+        data->angle_x = 0; data->angle_y = 0; data->angle_z = 0;
+
+        /* Shader Initialization */
+        process_shader(&data->shader_vert, _shader_vert_src, GL_VERTEX_SHADER);
+        process_shader(&data->shader_frag, _shader_frag_src, GL_FRAGMENT_SHADER);
+
+        /* Create shader_program (ready to attach shaders) */
+        data->shader_program = GL_CHECK(ctx.glCreateProgram());
+
+        /* Attach shaders and link shader_program */
+        GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_vert));
+        GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_frag));
+        GL_CHECK(ctx.glLinkProgram(data->shader_program));
+
+        /* Get attribute locations of non-fixed attributes like color and texture coordinates. */
+        data->attr_position = GL_CHECK(ctx.glGetAttribLocation(data->shader_program, "av4position"));
+        data->attr_color = GL_CHECK(ctx.glGetAttribLocation(data->shader_program, "av3color"));
+
+        /* Get uniform locations */
+        data->attr_mvp = GL_CHECK(ctx.glGetUniformLocation(data->shader_program, "mvp"));
+
+        GL_CHECK(ctx.glUseProgram(data->shader_program));
+
+        /* Enable attributes for position, color and texture coordinates etc. */
+        GL_CHECK(ctx.glEnableVertexAttribArray(data->attr_position));
+        GL_CHECK(ctx.glEnableVertexAttribArray(data->attr_color));
+
+        /* Populate attributes for position, color and texture coordinates etc. */
+        GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, _vertices));
+        GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, _colors));
+
+        GL_CHECK(ctx.glEnable(GL_CULL_FACE));
+        GL_CHECK(ctx.glEnable(GL_DEPTH_TEST));
+    }
+
+    /* Main render loop */
+    frames = 0;
+    then = SDL_GetTicks();
+    done = 0;
+
+#ifdef __EMSCRIPTEN__
+    emscripten_set_main_loop(loop, 0, 1);
+#else
+    while (!done) {
+        loop();
+    }
+#endif
+
+    /* Print out some timing information */
+    now = SDL_GetTicks();
+    if (now > then) {
+        SDLTest_Log("%2.2f frames per second\n",
+               ((double) frames * 1000) / (now - then));
+    }
+#if !defined(__ANDROID__) && !defined(__NACL__)  
+    quit(0);
+#endif    
+    return 0;
 }
 
-#else /* HAVE_OPENGL */
+#else /* HAVE_OPENGLES2 */
 
 int
 main(int argc, char *argv[])
 {
-    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
+    SDLTest_Log("No OpenGL ES support on this system\n");
     return 1;
 }
 
-#endif /* HAVE_OPENGL */
+#endif /* HAVE_OPENGLES2 */
 
 /* vi: set ts=4 sw=4 expandtab: */
old mode 100644 (file)
new mode 100755 (executable)
index 00750a9..44c8c16
@@ -37,8 +37,7 @@ void render(SDL_Renderer *renderer,SDL_Texture *texture,SDL_Rect texture_dimensi
 
     SDL_RenderPresent(renderer);
 }
-
-int main(int argc,char** argv)
+int SDL_main(int argc,char** argv)
 {
     Uint8 num_pictures;
     LoadedPicture* pictures;
@@ -60,12 +59,12 @@ int main(int argc,char** argv)
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if(argc < 2) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument.");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument.");
         exit(-1);
     }
 
     if(SDL_VideoInit(NULL) == -1) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video.");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video.");
         exit(-2);
     }
 
@@ -82,7 +81,7 @@ int main(int argc,char** argv)
                 SDL_FreeSurface(pictures[j].surface);
             SDL_free(pictures);
             SDL_VideoQuit();
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file: %s", argv[i+1]);
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file: %s", argv[i+1]);
             exit(-3);
         }
 
@@ -107,7 +106,7 @@ int main(int argc,char** argv)
             SDL_FreeSurface(pictures[i].surface);
         SDL_free(pictures);
         SDL_VideoQuit();
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
         exit(-4);
     }
     renderer = SDL_CreateRenderer(window,-1,0);
@@ -117,7 +116,7 @@ int main(int argc,char** argv)
             SDL_FreeSurface(pictures[i].surface);
         SDL_free(pictures);
         SDL_VideoQuit();
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
         exit(-5);
     }
 
@@ -136,7 +135,7 @@ int main(int argc,char** argv)
             SDL_DestroyRenderer(renderer);
             SDL_DestroyWindow(window);
             SDL_VideoQuit();
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
             exit(-6);
         }
     }
@@ -159,7 +158,7 @@ int main(int argc,char** argv)
         if(event_pending == 1) {
             if(event.type == SDL_KEYDOWN) {
                 button_down = 1;
-                if(event.key.keysym.sym == SDLK_ESCAPE) {
+                if(event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == 0) {
                     should_exit = 1;
                     break;
                 }
old mode 100644 (file)
new mode 100755 (executable)
index 7a33af3..8067990
@@ -21,7 +21,8 @@
 
 #include "SDL_test.h"
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH 720
+#define WINDOW_HEIGHT 1280
 #define NUM_SPRITES    100
 #define MAX_SPEED     1
 
@@ -64,11 +65,22 @@ LoadSprite(const char *file)
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
         return (-1);
     }
     sprite_w = temp->w;
     sprite_h = temp->h;
+    SDL_SetClipRect(temp, NULL);
+    SDL_Rect clipRect, full_clipRect;
+    SDL_GetClipRect(temp,&clipRect);
+    full_clipRect.x = 0;
+    full_clipRect.y = 0;
+    full_clipRect.w = sprite_w;
+    full_clipRect.h = sprite_h;
+    if(clipRect.x != full_clipRect.x || clipRect.y != full_clipRect.y || clipRect.w != full_clipRect.w || clipRect.h != full_clipRect.h)
+    {
+       SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION ,"Couldn't set cliprect!\n");
+    }
 
     /* Set transparent pixel as the pixel at (0,0) */
     if (temp->format->palette) {
@@ -95,11 +107,17 @@ LoadSprite(const char *file)
         SDL_Renderer *renderer = state->renderers[i];
         sprites[i] = SDL_CreateTextureFromSurface(renderer, temp);
         if (!sprites[i]) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
             SDL_FreeSurface(temp);
             return (-1);
         }
         SDL_SetTextureBlendMode(sprites[i], blendMode);
+       SDL_BlendMode  retblendMode;
+       SDL_GetTextureBlendMode(sprites[i],&retblendMode);
+       if(blendMode != retblendMode)
+       {
+               SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Texture blend fails!\n");
+       }
     }
     SDL_FreeSurface(temp);
 
@@ -162,6 +180,18 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite)
     SDL_RenderDrawLine(renderer, 0, 1, 0, viewport.h-2);
     SDL_RenderDrawLine(renderer, viewport.w-1, 1, viewport.w-1, viewport.h-2);
 
+    SDL_Rect rect[2];
+    rect[0].x = 0;
+    rect[0].y = 0;
+    rect[0].w = 100;
+    rect[0].h = 100;
+    rect[1].x = 200;
+    rect[1].y = 200;
+    rect[1].w = 100;
+    rect[1].h = 100;
+    SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
+    SDL_RenderDrawRects(renderer,rect, 2);
+
     /* Test fill and copy */
     SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
     temp.x = 1;
@@ -245,6 +275,14 @@ loop()
     /* Check for events */
     while (SDL_PollEvent(&event)) {
         SDLTest_CommonEvent(state, &event, &done);
+               switch(event.type) {
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
+        }
     }
     for (i = 0; i < state->num_windows; ++i) {
         if (state->windows[i] == NULL)
@@ -257,20 +295,21 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     Uint32 then, now, frames;
     Uint64 seed;
-    const char *icon = "icon.bmp";
+    const char *icon = "res/icon.bmp";
 
     /* Initialize parameters */
     num_sprites = NUM_SPRITES;
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -332,7 +371,7 @@ main(int argc, char *argv[])
     sprites =
         (SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
     if (!sprites) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
     for (i = 0; i < state->num_windows; ++i) {
@@ -344,11 +383,34 @@ main(int argc, char *argv[])
         quit(2);
     }
 
+    if(SDL_RenderTargetSupported(state->renderers[0]) == SDL_FALSE)
+    {
+       SDLTest_Log(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenderTarget is not support!\n");
+    }
+    else
+    {
+       SDL_Texture* renderTargetTexture = SDL_GetRenderTarget(state->renderers[0]);
+       if(renderTargetTexture == NULL)
+       {
+               SDLTest_Log(SDL_LOG_CATEGORY_APPLICATION, "renderTargetTexture is NULL!\n");
+       }
+    }
+
+    int render_width, render_height;
+    SDL_RenderGetLogicalSize(state->renderers[0], &render_width, &render_height);
+    SDLTest_Log(SDL_LOG_CATEGORY_APPLICATION, "Render Logical size is %d * %d", render_width, render_height);
+
+    if(SDL_RenderIsClipEnabled(state->renderers[0]) == SDL_FALSE)
+    {
+       SDLTest_Log(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenderIsClipEnabled is not support!\n");
+    }
+
+
     /* Allocate memory for the sprite info */
     positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
     velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
     if (!positions || !velocities) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
         quit(2);
     }
 
old mode 100644 (file)
new mode 100755 (executable)
index 05f9730..b686b43
@@ -21,8 +21,8 @@
 
 #include "SDL.h"
 
-#define WINDOW_WIDTH    640
-#define WINDOW_HEIGHT   480
+#define WINDOW_WIDTH    720
+#define WINDOW_HEIGHT   1280
 #define NUM_SPRITES     100
 #define MAX_SPEED       1
 
@@ -49,7 +49,7 @@ LoadSprite(char *file, SDL_Renderer *renderer)
     /* Load the sprite image */
     temp = SDL_LoadBMP(file);
     if (temp == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
         return (-1);
     }
     sprite_w = temp->w;
@@ -80,7 +80,7 @@ LoadSprite(char *file, SDL_Renderer *renderer)
     /* Create textures from the image */
     sprite = SDL_CreateTextureFromSurface(renderer, temp);
     if (!sprite) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
         SDL_FreeSurface(temp);
         return (-1);
     }
@@ -142,9 +142,8 @@ void loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_Window *window;
     int i;
@@ -157,7 +156,7 @@ main(int argc, char *argv[])
         quit(2);
     }
 
-    if (LoadSprite("icon.bmp", renderer) < 0) {
+    if (LoadSprite("res/icon.bmp", renderer) < 0) {
         quit(2);
     }
 
old mode 100644 (file)
new mode 100755 (executable)
index 86cc139..d14d10d
@@ -77,7 +77,7 @@ void UpdateTexture(SDL_Texture *texture, int frame)
     int pitch;
 
     if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
         quit(5);
     }
     src = MooseFrames[frame];
@@ -99,7 +99,7 @@ loop()
     while (SDL_PollEvent(&event)) {
         switch (event.type) {
         case SDL_KEYDOWN:
-            if (event.key.keysym.sym == SDLK_ESCAPE) {
+            if (event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_f) {
                 done = SDL_TRUE;
             }
             break;
@@ -122,9 +122,8 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char **argv)
+SDL_main(int argc, char **argv)
 {
     SDL_Window *window;
     SDL_RWops *handle;
@@ -133,14 +132,14 @@ main(int argc, char **argv)
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return 1;
     }
 
     /* load the moose images */
-    handle = SDL_RWFromFile("moose.dat", "rb");
+    handle = SDL_RWFromFile("res/moose.dat", "rb");
     if (handle == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
         quit(2);
     }
     SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
@@ -154,19 +153,19 @@ main(int argc, char **argv)
                               MOOSEPIC_W*4, MOOSEPIC_H*4,
                               SDL_WINDOW_RESIZABLE);
     if (!window) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
         quit(3);
     }
 
     renderer = SDL_CreateRenderer(window, -1, 0);
     if (!renderer) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
         quit(4);
     }
 
     MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
     if (!MooseTexture) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
         quit(5);
     }
 
old mode 100644 (file)
new mode 100755 (executable)
index 90e2c60..214dd3d
@@ -33,27 +33,26 @@ int SDLCALL
 ThreadFunc(void *data)
 {
     SDL_TLSSet(tls, "baby thread", NULL);
-    SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n",
+    SDLTest_Log("Started thread %s: My thread id is %lu, thread data = %s\n",
            (char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
     while (alive) {
-        SDL_Log("Thread '%s' is alive!\n", (char *) data);
+        SDLTest_Log("Thread '%s' is alive!\n", (char *) data);
         SDL_Delay(1 * 1000);
     }
-    SDL_Log("Thread '%s' exiting!\n", (char *) data);
+    SDLTest_Log("Thread '%s' exiting!\n", (char *) data);
     return (0);
 }
 
 static void
 killed(int sig)
 {
-    SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
+    SDLTest_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
     SDL_Delay(5 * 1000);
     alive = 0;
     quit(0);
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_Thread *thread;
 
@@ -62,33 +61,33 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
     tls = SDL_TLSCreate();
     SDL_assert(tls);
     SDL_TLSSet(tls, "main thread", NULL);
-    SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
+    SDLTest_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
 
     alive = 1;
     thread = SDL_CreateThread(ThreadFunc, "One", "#1");
     if (thread == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
         quit(1);
     }
     SDL_Delay(5 * 1000);
-    SDL_Log("Waiting for thread #1\n");
+    SDLTest_Log("Waiting for thread #1\n");
     alive = 0;
     SDL_WaitThread(thread, NULL);
 
-    SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
+    SDLTest_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
 
     alive = 1;
     signal(SIGTERM, killed);
     thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
     if (thread == NULL) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
         quit(1);
     }
     raise(SIGTERM);
old mode 100644 (file)
new mode 100755 (executable)
index 32b7490..584668c
@@ -33,12 +33,11 @@ ticktock(Uint32 interval, void *param)
 static Uint32 SDLCALL
 callback(Uint32 interval, void *param)
 {
-    SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
+    SDLTest_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
     return interval;
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i, desired;
     SDL_TimerID t1, t2, t3;
@@ -49,7 +48,7 @@ main(int argc, char *argv[])
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
     if (SDL_Init(SDL_INIT_TIMER) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -64,7 +63,7 @@ main(int argc, char *argv[])
     t1 = SDL_AddTimer(desired, ticktock, NULL);
 
     /* Wait 10 seconds */
-    SDL_Log("Waiting 10 seconds\n");
+    SDLTest_Log("Waiting 10 seconds\n");
     SDL_Delay(10 * 1000);
 
     /* Stop the timer */
@@ -72,27 +71,27 @@ main(int argc, char *argv[])
 
     /* Print the results */
     if (ticks) {
-        SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n",
+        SDLTest_Log("Timer resolution: desired = %d ms, actual = %f ms\n",
                 desired, (double) (10 * 1000) / ticks);
     }
 
     /* Test multiple timers */
-    SDL_Log("Testing multiple timers...\n");
+    SDLTest_Log("Testing multiple timers...\n");
     t1 = SDL_AddTimer(100, callback, (void *) 1);
     if (!t1)
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError());
     t2 = SDL_AddTimer(50, callback, (void *) 2);
     if (!t2)
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError());
     t3 = SDL_AddTimer(233, callback, (void *) 3);
     if (!t3)
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError());
 
     /* Wait 10 seconds */
-    SDL_Log("Waiting 10 seconds\n");
+    SDLTest_Log("Waiting 10 seconds\n");
     SDL_Delay(10 * 1000);
 
-    SDL_Log("Removing timer 1 and waiting 5 more seconds\n");
+    SDLTest_Log("Removing timer 1 and waiting 5 more seconds\n");
     SDL_RemoveTimer(t1);
 
     SDL_Delay(5 * 1000);
@@ -105,15 +104,15 @@ main(int argc, char *argv[])
         ticktock(0, NULL);
     }
     now = SDL_GetPerformanceCounter();
-    SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
+    SDLTest_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
 
-    SDL_Log("Performance counter frequency: %"SDL_PRIu64"\n", (unsigned long long) SDL_GetPerformanceFrequency());
+    SDLTest_Log("Performance counter frequency: %"SDL_PRIu64"\n", (unsigned long long) SDL_GetPerformanceFrequency());
     start32 = SDL_GetTicks();
     start = SDL_GetPerformanceCounter();
     SDL_Delay(1000);
     now = SDL_GetPerformanceCounter();
     now32 = SDL_GetTicks();
-    SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
+    SDLTest_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
 
     SDL_Quit();
     return (0);
old mode 100644 (file)
new mode 100755 (executable)
index f0e3bcf..ca6a934
@@ -19,9 +19,8 @@
 
 #include "SDL.h"
 #include "SDL_revision.h"
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_version compiled;
     SDL_version linked;
@@ -30,18 +29,19 @@ main(int argc, char *argv[])
     SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 
 #if SDL_VERSION_ATLEAST(2, 0, 0)
-    SDL_Log("Compiled with SDL 2.0 or newer\n");
+    SDLTest_Log("Compiled with SDL 2.0 or newer\n");
 #else
-    SDL_Log("Compiled with SDL older than 2.0\n");
+    SDLTest_Log("Compiled with SDL older than 2.0\n");
 #endif
     SDL_VERSION(&compiled);
-    SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n",
+    SDLTest_Log("Compiled version: %d.%d.%d.%d (%s)\n",
            compiled.major, compiled.minor, compiled.patch,
            SDL_REVISION_NUMBER, SDL_REVISION);
     SDL_GetVersion(&linked);
-    SDL_Log("Linked version: %d.%d.%d.%d (%s)\n",
+    SDLTest_Log("Linked version: %d.%d.%d.%d (%s)\n",
            linked.major, linked.minor, linked.patch,
            SDL_GetRevisionNumber(), SDL_GetRevision());
     SDL_Quit();
     return (0);
 }
+
old mode 100644 (file)
new mode 100755 (executable)
index 7ed4e6e..41840b5
@@ -21,7 +21,8 @@
 
 #include "SDL_test.h"
 #include "SDL_test_common.h"
-
+#define WINDOW_WIDTH    720
+#define WINDOW_HEIGHT   1280
 
 static SDLTest_CommonState *state;
 
@@ -102,6 +103,14 @@ loop()
     /* Check for events */
     while (SDL_PollEvent(&event)) {
         SDLTest_CommonEvent(state, &event, &done);
+               switch(event.type) {
+               case SDL_KEYDOWN:
+                       if(event.key.keysym.sym == 0)
+                       {
+                               done = 1;
+                       }
+                       break;
+        }
     }
 
     /* Move a viewport box in steps around the screen */
@@ -110,7 +119,7 @@ loop()
     viewport.w = 100 + j * 50;
     viewport.h = 100 + j * 50;
     j = (j + 1) % 4;
-    SDL_Log("Current Viewport x=%i y=%i w=%i h=%i", viewport.x, viewport.y, viewport.w, viewport.h);
+    SDLTest_Log("Current Viewport x=%i y=%i w=%i h=%i", viewport.x, viewport.y, viewport.w, viewport.h);
 
     for (i = 0; i < state->num_windows; ++i) {
         if (state->windows[i] == NULL)
@@ -136,15 +145,16 @@ loop()
     }
 #endif
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     int i;
     Uint32 then, now, frames;
 
     /* Initialize test framework */
     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
+       state->window_w = WINDOW_WIDTH;
+    state->window_h = WINDOW_HEIGHT;
     if (!state) {
         return 1;
     }
@@ -161,7 +171,7 @@ main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDL_Log("Usage: %s %s [--target]\n",
+            SDLTest_Log("Usage: %s %s [--target]\n",
                     argv[0], SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -208,7 +218,7 @@ main(int argc, char *argv[])
     now = SDL_GetTicks();
     if (now > then) {
         double fps = ((double) frames * 1000) / (now - then);
-        SDL_Log("%2.2f frames per second\n", fps);
+        SDLTest_Log("%2.2f frames per second\n", fps);
     }
     quit(0);
     return 0;
old mode 100644 (file)
new mode 100755 (executable)
index 5719a71..1a13d92
@@ -48,7 +48,7 @@ ThreadFunc(void *data)
     int i;
     int tid = (int) (uintptr_t) data;
 
-    SDL_Log("Creating Thread %d\n", tid);
+    SDLTest_Log("Creating Thread %d\n", tid);
 
     for (i = 0; i < NUMTHREADS; i++) {
         char name[64];
@@ -57,24 +57,23 @@ ThreadFunc(void *data)
         sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
     }
 
-    SDL_Log("Thread '%d' waiting for signal\n", tid);
+    SDLTest_Log("Thread '%d' waiting for signal\n", tid);
     while (time_for_threads_to_die[tid] != 1) {
         ;                       /* do nothing */
     }
 
-    SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
+    SDLTest_Log("Thread '%d' sending signals to subthreads\n", tid);
     for (i = 0; i < NUMTHREADS; i++) {
         flags[i] = 1;
         SDL_WaitThread(sub_threads[i], NULL);
     }
 
-    SDL_Log("Thread '%d' exiting!\n", tid);
+    SDLTest_Log("Thread '%d' exiting!\n", tid);
 
     return 0;
 }
-
 int
-main(int argc, char *argv[])
+SDL_main(int argc, char *argv[])
 {
     SDL_Thread *threads[NUMTHREADS];
     int i;
@@ -84,7 +83,7 @@ main(int argc, char *argv[])
 
     /* Load the SDL library */
     if (SDL_Init(0) < 0) {
-        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
         return (1);
     }
 
@@ -96,7 +95,7 @@ main(int argc, char *argv[])
         threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i);
 
         if (threads[i] == NULL) {
-            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
+            SDLTest_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
             quit(1);
         }
     }
old mode 100644 (file)
new mode 100755 (executable)