mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Updates SDL to 2.0.12
This commit is contained in:
parent
3108a08650
commit
a526029f2f
861 changed files with 25596 additions and 8904 deletions
|
|
@ -86,6 +86,7 @@ add_executable(testbounds testbounds.c)
|
|||
add_executable(testcustomcursor testcustomcursor.c)
|
||||
add_executable(controllermap controllermap.c)
|
||||
add_executable(testvulkan testvulkan.c)
|
||||
add_executable(testoffscreen testoffscreen.c)
|
||||
|
||||
# HACK: Dummy target to cause the resource files to be copied to the build directory.
|
||||
# Need to make it an executable so we can use the TARGET_FILE_DIR generator expression.
|
||||
|
|
@ -101,22 +102,54 @@ endforeach(RESOURCE_FILE)
|
|||
file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# TODO: Might be easier to make all targets depend on the resources...?
|
||||
add_dependencies(testscale SDL2_test_resoureces)
|
||||
add_dependencies(testrendercopyex SDL2_test_resoureces)
|
||||
add_dependencies(controllermap SDL2_test_resoureces)
|
||||
add_dependencies(testyuv SDL2_test_resoureces)
|
||||
add_dependencies(testgamecontroller SDL2_test_resoureces)
|
||||
add_dependencies(testshape SDL2_test_resoureces)
|
||||
add_dependencies(testshader SDL2_test_resoureces)
|
||||
add_dependencies(testnative SDL2_test_resoureces)
|
||||
add_dependencies(testspriteminimal SDL2_test_resoureces)
|
||||
add_dependencies(testautomation SDL2_test_resoureces)
|
||||
add_dependencies(testcustomcursor SDL2_test_resoureces)
|
||||
add_dependencies(testrendertarget SDL2_test_resoureces)
|
||||
add_dependencies(testsprite2 SDL2_test_resoureces)
|
||||
|
||||
add_dependencies(loopwave SDL2_test_resoureces)
|
||||
add_dependencies(loopwavequeue SDL2_test_resoureces)
|
||||
add_dependencies(testresample SDL2_test_resoureces)
|
||||
add_dependencies(testaudiohotplug SDL2_test_resoureces)
|
||||
add_dependencies(testmultiaudio SDL2_test_resoureces)
|
||||
set(NEEDS_RESOURCES
|
||||
testscale
|
||||
testrendercopyex
|
||||
controllermap
|
||||
testyuv
|
||||
testgamecontroller
|
||||
testshape
|
||||
testshader
|
||||
testnative
|
||||
testspriteminimal
|
||||
testautomation
|
||||
testcustomcursor
|
||||
testrendertarget
|
||||
testsprite2
|
||||
loopwave
|
||||
loopwavequeue
|
||||
testresample
|
||||
testaudiohotplug
|
||||
testmultiaudio
|
||||
)
|
||||
foreach(APP IN LISTS NEEDS_RESOURCES)
|
||||
add_dependencies(${APP} SDL2_test_resoureces)
|
||||
if(APPLE)
|
||||
# Make sure resource files get installed into macOS/iOS .app bundles.
|
||||
target_sources(${APP} PRIVATE "${RESOURCE_FILES}")
|
||||
set_target_properties(${APP} PROPERTIES RESOURCE "${RESOURCE_FILES}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Set Apple App ID / Bundle ID. This is needed to launch apps on some Apple
|
||||
# platforms (iOS, for example).
|
||||
if(APPLE)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
|
||||
# CMake's 'BUILDSYSTEM_TARGETS' property is only available in
|
||||
# CMake 3.7 and above.
|
||||
message(WARNING "Unable to set Bundle ID for Apple .app builds due to old CMake (pre 3.7).")
|
||||
else()
|
||||
get_property(TARGETS DIRECTORY ${CMAKE_CURRENT_LIST_DIR} PROPERTY BUILDSYSTEM_TARGETS)
|
||||
foreach(CURRENT_TARGET IN LISTS TARGETS)
|
||||
get_property(TARGET_TYPE TARGET ${CURRENT_TARGET} PROPERTY TYPE)
|
||||
if(TARGET_TYPE STREQUAL "EXECUTABLE")
|
||||
set_target_properties("${CURRENT_TARGET}" PROPERTIES
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "org.libsdl.${CURRENT_TARGET}"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${SDL_VERSION}"
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${SDL_VERSION}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ $(TESTLIB): $(COBJS)
|
|||
wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@
|
||||
|
||||
.c.obj:
|
||||
wcc386 $(CFLAGS) -wcd=107 -fo=$^@ $<
|
||||
wcc386 $(CFLAGS) -fo=$^@ $<
|
||||
|
||||
# specials
|
||||
testautomation.exe: $(TAOBJS)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
26
Engine/lib/sdl/test/configure
vendored
26
Engine/lib/sdl/test/configure
vendored
|
|
@ -2988,6 +2988,11 @@ fi
|
|||
MATHLIB=""
|
||||
SYS_GL_LIBS=""
|
||||
;;
|
||||
*-*-riscos* )
|
||||
EXE=",e1f"
|
||||
MATHLIB=""
|
||||
SYS_GL_LIBS=""
|
||||
;;
|
||||
*)
|
||||
ISUNIX="true"
|
||||
EXE=""
|
||||
|
|
@ -3820,6 +3825,9 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|||
/* end confdefs.h. */
|
||||
|
||||
#include "SDL_opengl.h"
|
||||
#ifndef SDL_VIDEO_OPENGL
|
||||
#error SDL_VIDEO_OPENGL
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
|
|
@ -3845,11 +3853,10 @@ have_opengles=no
|
|||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#if defined (__IPHONEOS__)
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#else
|
||||
#include <GLES/gl.h>
|
||||
#endif /* __QNXNTO__ */
|
||||
#include "SDL_opengles.h"
|
||||
#ifndef SDL_VIDEO_OPENGL_ES
|
||||
#error SDL_VIDEO_OPENGL_ES
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
|
|
@ -3875,12 +3882,9 @@ have_opengles2=no
|
|||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#if defined (__IPHONEOS__)
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include "SDL_opengles2.h"
|
||||
#ifndef SDL_VIDEO_OPENGL_ES2
|
||||
#error SDL_VIDEO_OPENGL_ES2
|
||||
#endif
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -71,6 +71,11 @@ case "$host" in
|
|||
MATHLIB=""
|
||||
SYS_GL_LIBS=""
|
||||
;;
|
||||
*-*-riscos* )
|
||||
EXE=",e1f"
|
||||
MATHLIB=""
|
||||
SYS_GL_LIBS=""
|
||||
;;
|
||||
*)
|
||||
dnl Oh well, call it Unix...
|
||||
ISUNIX="true"
|
||||
|
|
@ -120,6 +125,9 @@ AC_MSG_CHECKING(for OpenGL support)
|
|||
have_opengl=no
|
||||
AC_TRY_COMPILE([
|
||||
#include "SDL_opengl.h"
|
||||
#ifndef SDL_VIDEO_OPENGL
|
||||
#error SDL_VIDEO_OPENGL
|
||||
#endif
|
||||
],[
|
||||
],[
|
||||
have_opengl=yes
|
||||
|
|
@ -130,11 +138,10 @@ dnl Check for OpenGL ES
|
|||
AC_MSG_CHECKING(for OpenGL ES support)
|
||||
have_opengles=no
|
||||
AC_TRY_COMPILE([
|
||||
#if defined (__IPHONEOS__)
|
||||
#include <OpenGLES/ES1/gl.h>
|
||||
#else
|
||||
#include <GLES/gl.h>
|
||||
#endif /* __QNXNTO__ */
|
||||
#include "SDL_opengles.h"
|
||||
#ifndef SDL_VIDEO_OPENGL_ES
|
||||
#error SDL_VIDEO_OPENGL_ES
|
||||
#endif
|
||||
],[
|
||||
],[
|
||||
have_opengles=yes
|
||||
|
|
@ -145,12 +152,9 @@ dnl Check for OpenGL ES2
|
|||
AC_MSG_CHECKING(for OpenGL ES2 support)
|
||||
have_opengles2=no
|
||||
AC_TRY_COMPILE([
|
||||
#if defined (__IPHONEOS__)
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include "SDL_opengles2.h"
|
||||
#ifndef SDL_VIDEO_OPENGL_ES2
|
||||
#error SDL_VIDEO_OPENGL_ES2
|
||||
#endif
|
||||
],[
|
||||
],[
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
|
||||
/* Define this for verbose output while mapping controllers */
|
||||
#define DEBUG_CONTROLLERMAP
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
#define SCREEN_WIDTH 320
|
||||
#define SCREEN_HEIGHT 480
|
||||
|
|
@ -140,6 +143,7 @@ static SDL_GameControllerExtendedBind s_arrBindings[BINDING_COUNT];
|
|||
typedef struct
|
||||
{
|
||||
SDL_bool m_bMoving;
|
||||
int m_nLastValue;
|
||||
int m_nStartingValue;
|
||||
int m_nFarthestValue;
|
||||
} AxisState;
|
||||
|
|
@ -363,7 +367,6 @@ WatchJoystick(SDL_Joystick * joystick)
|
|||
Uint8 alpha=200, alpha_step = -1;
|
||||
Uint32 alpha_ticks = 0;
|
||||
SDL_JoystickID nJoystickID;
|
||||
int iIndex;
|
||||
|
||||
/* Create a window to display joystick axis position */
|
||||
window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED,
|
||||
|
|
@ -410,13 +413,11 @@ WatchJoystick(SDL_Joystick * joystick)
|
|||
|
||||
s_nNumAxes = SDL_JoystickNumAxes(joystick);
|
||||
s_arrAxisState = (AxisState *)SDL_calloc(s_nNumAxes, sizeof(*s_arrAxisState));
|
||||
for (iIndex = 0; iIndex < s_nNumAxes; ++iIndex) {
|
||||
AxisState *pAxisState = &s_arrAxisState[iIndex];
|
||||
Sint16 nInitialValue;
|
||||
pAxisState->m_bMoving = SDL_JoystickGetAxisInitialState(joystick, iIndex, &nInitialValue);
|
||||
pAxisState->m_nStartingValue = nInitialValue;
|
||||
pAxisState->m_nFarthestValue = nInitialValue;
|
||||
}
|
||||
|
||||
/* Skip any spurious events at start */
|
||||
while (SDL_PollEvent(&event) > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Loop, getting joystick events! */
|
||||
while (!done && !s_bBindingComplete) {
|
||||
|
|
@ -465,13 +466,20 @@ WatchJoystick(SDL_Joystick * joystick)
|
|||
break;
|
||||
case SDL_JOYAXISMOTION:
|
||||
if (event.jaxis.which == nJoystickID) {
|
||||
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
|
||||
AxisState *pAxisState = &s_arrAxisState[event.jaxis.axis];
|
||||
int nValue = event.jaxis.value;
|
||||
int nCurrentDistance, nFarthestDistance;
|
||||
if (!pAxisState->m_bMoving) {
|
||||
pAxisState->m_bMoving = SDL_TRUE;
|
||||
pAxisState->m_nStartingValue = nValue;
|
||||
pAxisState->m_nFarthestValue = nValue;
|
||||
Sint16 nInitialValue;
|
||||
pAxisState->m_bMoving = SDL_JoystickGetAxisInitialState(joystick, event.jaxis.axis, &nInitialValue);
|
||||
pAxisState->m_nLastValue = nInitialValue;
|
||||
pAxisState->m_nStartingValue = nInitialValue;
|
||||
pAxisState->m_nFarthestValue = nInitialValue;
|
||||
} else if (SDL_abs(nValue - pAxisState->m_nLastValue) <= MAX_ALLOWED_JITTER) {
|
||||
break;
|
||||
} else {
|
||||
pAxisState->m_nLastValue = nValue;
|
||||
}
|
||||
nCurrentDistance = SDL_abs(nValue - pAxisState->m_nStartingValue);
|
||||
nFarthestDistance = SDL_abs(pAxisState->m_nFarthestValue - pAxisState->m_nStartingValue);
|
||||
|
|
@ -773,7 +781,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -626,7 +626,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
|||
|
||||
/* Start the readers first */
|
||||
SDL_Log("Starting %d readers\n", NUM_READERS);
|
||||
SDL_zero(readerData);
|
||||
SDL_zeroa(readerData);
|
||||
SDL_AtomicSet(&readersRunning, NUM_READERS);
|
||||
for (i = 0; i < NUM_READERS; ++i) {
|
||||
char name[64];
|
||||
|
|
@ -638,7 +638,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
|||
|
||||
/* Start up the writers */
|
||||
SDL_Log("Starting %d writers\n", NUM_WRITERS);
|
||||
SDL_zero(writerData);
|
||||
SDL_zeroa(writerData);
|
||||
SDL_AtomicSet(&writersRunning, NUM_WRITERS);
|
||||
for (i = 0; i < NUM_WRITERS; ++i) {
|
||||
char name[64];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
/* Test case functions */
|
||||
|
||||
/* Definition of all RGB formats used to test pixel conversions */
|
||||
const int _numRGBPixelFormats = 30;
|
||||
const int _numRGBPixelFormats = 31;
|
||||
Uint32 _RGBPixelFormats[] =
|
||||
{
|
||||
SDL_PIXELFORMAT_INDEX1LSB,
|
||||
|
|
@ -20,6 +20,7 @@ Uint32 _RGBPixelFormats[] =
|
|||
SDL_PIXELFORMAT_INDEX8,
|
||||
SDL_PIXELFORMAT_RGB332,
|
||||
SDL_PIXELFORMAT_RGB444,
|
||||
SDL_PIXELFORMAT_BGR444,
|
||||
SDL_PIXELFORMAT_RGB555,
|
||||
SDL_PIXELFORMAT_BGR555,
|
||||
SDL_PIXELFORMAT_ARGB4444,
|
||||
|
|
@ -53,6 +54,7 @@ char* _RGBPixelFormatsVerbose[] =
|
|||
"SDL_PIXELFORMAT_INDEX8",
|
||||
"SDL_PIXELFORMAT_RGB332",
|
||||
"SDL_PIXELFORMAT_RGB444",
|
||||
"SDL_PIXELFORMAT_BGR444",
|
||||
"SDL_PIXELFORMAT_RGB555",
|
||||
"SDL_PIXELFORMAT_BGR555",
|
||||
"SDL_PIXELFORMAT_ARGB4444",
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write)
|
|||
int seekPos = SDLTest_RandomIntegerInRange(4, 8);
|
||||
|
||||
/* Clear buffer */
|
||||
SDL_zero(buf);
|
||||
SDL_zeroa(buf);
|
||||
|
||||
/* Set to start. */
|
||||
i = SDL_RWseek(rw, 0, RW_SEEK_SET );
|
||||
|
|
@ -226,7 +226,7 @@ rwops_testMem (void)
|
|||
int result;
|
||||
|
||||
/* Clear buffer */
|
||||
SDL_zero(mem);
|
||||
SDL_zeroa(mem);
|
||||
|
||||
/* Open */
|
||||
rw = SDL_RWFromMem(mem, sizeof(RWopsHelloWorldTestString)-1);
|
||||
|
|
|
|||
|
|
@ -310,6 +310,7 @@ surface_testCompleteSurfaceConversion(void *arg)
|
|||
SDL_PIXELFORMAT_INDEX8,
|
||||
SDL_PIXELFORMAT_RGB332,
|
||||
SDL_PIXELFORMAT_RGB444,
|
||||
SDL_PIXELFORMAT_BGR444,
|
||||
SDL_PIXELFORMAT_RGB555,
|
||||
SDL_PIXELFORMAT_BGR555,
|
||||
SDL_PIXELFORMAT_ARGB4444,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -32,28 +32,28 @@ main(int argc, char *argv[])
|
|||
if(base_path == NULL){
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n",
|
||||
SDL_GetError());
|
||||
return 1;
|
||||
} else {
|
||||
SDL_Log("base path: '%s'\n", base_path);
|
||||
SDL_free(base_path);
|
||||
}
|
||||
SDL_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",
|
||||
SDL_GetError());
|
||||
return 1;
|
||||
} else {
|
||||
SDL_Log("pref path: '%s'\n", pref_path);
|
||||
SDL_free(pref_path);
|
||||
}
|
||||
SDL_Log("pref path: '%s'\n", pref_path);
|
||||
SDL_free(pref_path);
|
||||
|
||||
pref_path = SDL_GetPrefPath(NULL, "testfilesystem");
|
||||
if(pref_path == NULL){
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n",
|
||||
SDL_GetError());
|
||||
return 1;
|
||||
} else {
|
||||
SDL_Log("pref path: '%s'\n", pref_path);
|
||||
SDL_free(pref_path);
|
||||
}
|
||||
SDL_Log("pref path: '%s'\n", pref_path);
|
||||
SDL_free(pref_path);
|
||||
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -114,11 +114,6 @@ loop(void *arg)
|
|||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
SDL_Log("Controller button %s %s\n", SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released");
|
||||
/* First button triggers a 0.5 second full strength rumble */
|
||||
if (event.type == SDL_CONTROLLERBUTTONDOWN &&
|
||||
event.cbutton.button == SDL_CONTROLLER_BUTTON_A) {
|
||||
SDL_GameControllerRumble(gamecontroller, 0xFFFF, 0xFFFF, 500);
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
if (event.key.keysym.sym != SDLK_ESCAPE) {
|
||||
|
|
@ -155,6 +150,13 @@ loop(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
/* Update rumble based on trigger state */
|
||||
{
|
||||
Uint16 low_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERLEFT) * 2;
|
||||
Uint16 high_frequency_rumble = SDL_GameControllerGetAxis(gamecontroller, SDL_CONTROLLER_AXIS_TRIGGERRIGHT) * 2;
|
||||
SDL_GameControllerRumble(gamecontroller, low_frequency_rumble, high_frequency_rumble, 250);
|
||||
}
|
||||
|
||||
SDL_RenderPresent(screen);
|
||||
|
||||
if (!SDL_GameControllerGetAttached(gamecontroller)) {
|
||||
|
|
@ -292,14 +294,33 @@ main(int argc, char *argv[])
|
|||
{
|
||||
nController++;
|
||||
name = SDL_GameControllerNameForIndex(i);
|
||||
description = "Controller";
|
||||
switch (SDL_GameControllerTypeForIndex(i)) {
|
||||
case SDL_CONTROLLER_TYPE_XBOX360:
|
||||
description = "XBox 360 Controller";
|
||||
break;
|
||||
case SDL_CONTROLLER_TYPE_XBOXONE:
|
||||
description = "XBox One Controller";
|
||||
break;
|
||||
case SDL_CONTROLLER_TYPE_PS3:
|
||||
description = "PS3 Controller";
|
||||
break;
|
||||
case SDL_CONTROLLER_TYPE_PS4:
|
||||
description = "PS4 Controller";
|
||||
break;
|
||||
case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO:
|
||||
description = "Nintendo Switch Pro Controller";
|
||||
break;
|
||||
default:
|
||||
description = "Game Controller";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
name = SDL_JoystickNameForIndex(i);
|
||||
description = "Joystick";
|
||||
}
|
||||
SDL_Log("%s %d: %s (guid %s, VID 0x%.4x, PID 0x%.4x)\n",
|
||||
SDL_Log("%s %d: %s (guid %s, VID 0x%.4x, PID 0x%.4x, player index = %d)\n",
|
||||
description, i, name ? name : "Unknown", guid,
|
||||
SDL_JoystickGetDeviceVendor(i), SDL_JoystickGetDeviceProduct(i));
|
||||
SDL_JoystickGetDeviceVendor(i), SDL_JoystickGetDeviceProduct(i), SDL_JoystickGetDevicePlayerIndex(i));
|
||||
}
|
||||
SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
|
||||
|
||||
|
|
@ -367,7 +388,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -363,7 +363,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -379,7 +379,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
170
Engine/lib/sdl/test/testoffscreen.c
Normal file
170
Engine/lib/sdl/test/testoffscreen.c
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
Copyright (C) 1997-2020 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.
|
||||
*/
|
||||
|
||||
/* Simple program: picks the offscreen backend and renders each frame to a bmp */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_opengl.h"
|
||||
|
||||
static SDL_Renderer *renderer = NULL;
|
||||
static SDL_Window *window = NULL;
|
||||
static int done = SDL_FALSE;
|
||||
static int frame_number = 0;
|
||||
static int width = 640;
|
||||
static int height = 480;
|
||||
static int max_frames = 200;
|
||||
|
||||
void
|
||||
draw()
|
||||
{
|
||||
SDL_Rect Rect;
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 0x10, 0x9A, 0xCE, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
/* Grow based on the frame just to show a difference per frame of the region */
|
||||
Rect.x = 0;
|
||||
Rect.y = 0;
|
||||
Rect.w = (frame_number * 2) % width;
|
||||
Rect.h = (frame_number * 2) % height;
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0x10, 0x21, 0xFF);
|
||||
SDL_RenderFillRect(renderer, &Rect);
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
void
|
||||
save_surface_to_bmp()
|
||||
{
|
||||
SDL_Surface* surface;
|
||||
Uint32 r_mask, g_mask, b_mask, a_mask;
|
||||
Uint32 pixel_format;
|
||||
char file[128];
|
||||
int bbp;
|
||||
|
||||
pixel_format = SDL_GetWindowPixelFormat(window);
|
||||
SDL_PixelFormatEnumToMasks(pixel_format, &bbp, &r_mask, &g_mask, &b_mask, &a_mask);
|
||||
|
||||
surface = SDL_CreateRGBSurface(0, width, height, bbp, r_mask, g_mask, b_mask, a_mask);
|
||||
SDL_RenderReadPixels(renderer, NULL, pixel_format, (void*)surface->pixels, surface->pitch);
|
||||
|
||||
SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
|
||||
SDL_GetWindowID(window), ++frame_number);
|
||||
|
||||
SDL_SaveBMP(surface, file);
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
void
|
||||
loop()
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
draw();
|
||||
save_surface_to_bmp();
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Uint32 then, now, frames;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Force the offscreen renderer, if it cannot be created then fail out */
|
||||
if (SDL_VideoInit("offscreen") < 0) {
|
||||
SDL_Log("Couldn't initialize the offscreen video driver: %s\n",
|
||||
SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* If OPENGL fails to init it will fallback to using a framebuffer for rendering */
|
||||
window = SDL_CreateWindow("Offscreen Test",
|
||||
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
width, height, 0);
|
||||
|
||||
if (!window) {
|
||||
SDL_Log("Couldn't create window: %s\n",
|
||||
SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||
|
||||
if (!renderer) {
|
||||
SDL_Log("Couldn't create renderer: %s\n",
|
||||
SDL_GetError());
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
/* Main render loop */
|
||||
frames = 0;
|
||||
then = SDL_GetTicks();
|
||||
done = 0;
|
||||
|
||||
SDL_Log("Rendering %i frames offscreen\n", max_frames);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(loop, 0, 1);
|
||||
#else
|
||||
while (!done && frames < max_frames) {
|
||||
++frames;
|
||||
loop();
|
||||
|
||||
/* Print out some timing information, along with remaining frames */
|
||||
if (frames % (max_frames / 10) == 0) {
|
||||
now = SDL_GetTicks();
|
||||
if (now > then) {
|
||||
double fps = ((double) frames * 1000) / (now - then);
|
||||
SDL_Log("Frames remaining: %i rendering at %2.2f frames per second\n", max_frames - frames, fps);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -16,6 +16,8 @@
|
|||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -57,13 +57,11 @@ main(int argc, char *argv[])
|
|||
success = SDL_sscanf(argv[1] + 2, "%llx", &seed);
|
||||
else
|
||||
success = SDL_sscanf(argv[1], "%llu", &seed);
|
||||
if (!success)
|
||||
{
|
||||
if (!success) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n");
|
||||
return 1;
|
||||
}
|
||||
if (seed <= 0xffffffff)
|
||||
{
|
||||
if (seed <= ((Uint64)0xffffffff)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Seed must be equal or greater than 0x100000000.\n");
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -147,7 +147,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
|
||||
exit(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
@ -25,12 +25,14 @@
|
|||
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
SDL_Rect viewport;
|
||||
int done, j;
|
||||
SDL_bool use_target = SDL_FALSE;
|
||||
static SDL_Rect viewport;
|
||||
static int done, j;
|
||||
static SDL_bool use_target = SDL_FALSE;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
Uint32 wait_start;
|
||||
static Uint32 wait_start;
|
||||
#endif
|
||||
static SDL_Texture *sprite;
|
||||
static int sprite_w, sprite_h;
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
|
|
@ -40,6 +42,55 @@ quit(int rc)
|
|||
exit(rc);
|
||||
}
|
||||
|
||||
int
|
||||
LoadSprite(char *file, SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Surface *temp;
|
||||
|
||||
/* 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());
|
||||
return (-1);
|
||||
}
|
||||
sprite_w = temp->w;
|
||||
sprite_h = temp->h;
|
||||
|
||||
/* Set transparent pixel as the pixel at (0,0) */
|
||||
if (temp->format->palette) {
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint8 *) temp->pixels);
|
||||
} else {
|
||||
switch (temp->format->BitsPerPixel) {
|
||||
case 15:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint16 *) temp->pixels) & 0x00007FFF);
|
||||
break;
|
||||
case 16:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint16 *) temp->pixels);
|
||||
break;
|
||||
case 24:
|
||||
SDL_SetColorKey(temp, SDL_TRUE,
|
||||
(*(Uint32 *) temp->pixels) & 0x00FFFFFF);
|
||||
break;
|
||||
case 32:
|
||||
SDL_SetColorKey(temp, SDL_TRUE, *(Uint32 *) temp->pixels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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());
|
||||
SDL_FreeSurface(temp);
|
||||
return (-1);
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
/* We're ready to roll. :) */
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport)
|
||||
{
|
||||
|
|
@ -53,11 +104,11 @@ DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport)
|
|||
SDL_RenderClear(renderer);
|
||||
|
||||
/* Test inside points */
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xF, 0xFF);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 + 10, viewport.w/2);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 - 10, viewport.w/2);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - 10);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + 10);
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0x00, 0xFF);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 + 20, viewport.w/2);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 - 20, viewport.w/2);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - 20);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + 20);
|
||||
|
||||
/* Test horizontal and vertical lines */
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
|
||||
|
|
@ -68,17 +119,15 @@ DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport)
|
|||
|
||||
/* Test diagonal lines */
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0xFF, 0xFF);
|
||||
SDL_RenderDrawLine(renderer, 0, 0,
|
||||
viewport.w-1, viewport.h-1);
|
||||
SDL_RenderDrawLine(renderer, viewport.w-1, 0,
|
||||
0, viewport.h-1);
|
||||
SDL_RenderDrawLine(renderer, 0, 0, viewport.w-1, viewport.h-1);
|
||||
SDL_RenderDrawLine(renderer, viewport.w-1, 0, 0, viewport.h-1);
|
||||
|
||||
/* Test outside points */
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xF, 0xFF);
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0x00, 0xFF);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 + viewport.h, viewport.w/2);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 - viewport.h, viewport.w/2);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 - viewport.w);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2 , viewport.w/2 + viewport.w);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2, viewport.w/2 - viewport.w);
|
||||
SDL_RenderDrawPoint(renderer, viewport.h/2, viewport.w/2 + viewport.w);
|
||||
|
||||
/* Add a box at the top */
|
||||
rect.w = 8;
|
||||
|
|
@ -86,6 +135,14 @@ DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport)
|
|||
rect.x = (viewport.w - rect.w) / 2;
|
||||
rect.y = 0;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
/* Add a clip rect and fill it with the sprite */
|
||||
SDL_QueryTexture(sprite, NULL, NULL, &rect.w, &rect.h);
|
||||
rect.x = (viewport.w - rect.w) / 2;
|
||||
rect.y = (viewport.h - rect.h) / 2;
|
||||
SDL_RenderSetClipRect(renderer, &rect);
|
||||
SDL_RenderCopy(renderer, sprite, NULL, &rect);
|
||||
SDL_RenderSetClipRect(renderer, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -149,6 +206,7 @@ main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
|
||||
|
|
@ -171,6 +229,10 @@ main(int argc, char *argv[])
|
|||
quit(2);
|
||||
}
|
||||
|
||||
if (LoadSprite("icon.bmp", state->renderers[0]) < 0) {
|
||||
quit(2);
|
||||
}
|
||||
|
||||
if (use_target) {
|
||||
int w, h;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2020 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue