forked from GSoC/sdl-2.30.3-kolibri
Update to SDL2-2.30.6
This commit is contained in:
@@ -107,7 +107,7 @@ print_modifiers(char **text, size_t *maxlen)
|
||||
}
|
||||
|
||||
static void
|
||||
PrintModifierState()
|
||||
PrintModifierState(void)
|
||||
{
|
||||
char message[512];
|
||||
char *spot;
|
||||
@@ -166,7 +166,7 @@ PrintText(const char *eventtype, const char *text)
|
||||
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
/* Check for events */
|
||||
|
@@ -103,7 +103,7 @@ print_modifiers(char **text, size_t *maxlen)
|
||||
}
|
||||
|
||||
static void
|
||||
PrintModifierState()
|
||||
PrintModifierState(void)
|
||||
{
|
||||
char message[512];
|
||||
char *spot;
|
||||
@@ -162,7 +162,7 @@ PrintText(const char *eventtype, const char *text)
|
||||
SDL_Log("%s Text (%s): \"%s%s\"\n", eventtype, expanded, *text == '"' ? "\\" : "", text);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
/* Check for events */
|
||||
|
25
test/emscripten/joystick-pre.js
Normal file
25
test/emscripten/joystick-pre.js
Normal file
@@ -0,0 +1,25 @@
|
||||
Module['arguments'] = ['0'];
|
||||
//Gamepads don't appear until a button is pressed and the joystick/gamepad tests expect one to be connected
|
||||
Module['preRun'].push(function()
|
||||
{
|
||||
Module['print']("Waiting for gamepad...");
|
||||
Module['addRunDependency']("gamepad");
|
||||
window.addEventListener('gamepadconnected', function()
|
||||
{
|
||||
//OK, got one
|
||||
Module['removeRunDependency']("gamepad");
|
||||
}, false);
|
||||
|
||||
//chrome
|
||||
if(!!navigator.webkitGetGamepads)
|
||||
{
|
||||
var timeout = function()
|
||||
{
|
||||
if(navigator.webkitGetGamepads()[0] !== undefined)
|
||||
Module['removeRunDependency']("gamepad");
|
||||
else
|
||||
setTimeout(timeout, 100);
|
||||
}
|
||||
setTimeout(timeout, 100);
|
||||
}
|
||||
});
|
@@ -46,7 +46,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
static void
|
||||
close_audio()
|
||||
close_audio(void)
|
||||
{
|
||||
if (device != 0) {
|
||||
SDL_CloseAudioDevice(device);
|
||||
@@ -55,7 +55,7 @@ close_audio()
|
||||
}
|
||||
|
||||
static void
|
||||
open_audio()
|
||||
open_audio(void)
|
||||
{
|
||||
/* Initialize fillerup() variables */
|
||||
device = SDL_OpenAudioDevice(NULL, SDL_FALSE, &wave.spec, NULL, 0);
|
||||
@@ -70,7 +70,7 @@ open_audio()
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
static void reopen_audio()
|
||||
static void reopen_audio(void)
|
||||
{
|
||||
close_audio();
|
||||
open_audio();
|
||||
@@ -103,7 +103,7 @@ fillerup(void *unused, Uint8 *stream, int len)
|
||||
static int done = 0;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
if (done || (SDL_GetAudioDeviceStatus(device) != SDL_AUDIO_PLAYING)) {
|
||||
emscripten_cancel_main_loop();
|
||||
|
@@ -48,7 +48,7 @@ void poked(int sig)
|
||||
done = 1;
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done || (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)) {
|
||||
|
BIN
test/n3ds/logo48x48.png
Normal file
BIN
test/n3ds/logo48x48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
63
test/nacl/Makefile
Normal file
63
test/nacl/Makefile
Normal file
@@ -0,0 +1,63 @@
|
||||
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# GNU Makefile based on shared rules provided by the Native Client SDK.
|
||||
# See README.Makefiles for more details.
|
||||
|
||||
VALID_TOOLCHAINS := pnacl
|
||||
|
||||
# NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../../..)
|
||||
include $(NACL_SDK_ROOT)/tools/common.mk
|
||||
|
||||
|
||||
TARGET = sdl_app
|
||||
DEPS = ppapi_simple nacl_io
|
||||
# ppapi_simple and SDL2 end up being listed twice due to dependency solving issues -- Gabriel
|
||||
LIBS = SDL2_test SDL2 ppapi_simple SDL2main SDL2 $(DEPS) ppapi_gles2 ppapi_cpp ppapi pthread
|
||||
|
||||
CFLAGS := -Wall
|
||||
SOURCES ?= testgles2.c
|
||||
|
||||
# Build rules generated by macros from common.mk:
|
||||
# Overriden macro from NACL SDK to be able to customize the library search path -- Gabriel
|
||||
# Specific Link Macro
|
||||
#
|
||||
# $1 = Target Name
|
||||
# $2 = List of inputs
|
||||
# $3 = List of libs
|
||||
# $4 = List of deps
|
||||
# $5 = List of lib dirs
|
||||
# $6 = Other Linker Args
|
||||
#
|
||||
# For debugging, we translate the pre-finalized .bc file.
|
||||
#
|
||||
define LINKER_RULE
|
||||
all: $(1).pexe
|
||||
$(1)_x86_32.nexe : $(1).bc
|
||||
$(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-32 $$^ -o $$@)
|
||||
|
||||
$(1)_x86_64.nexe : $(1).bc
|
||||
$(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-64 $$^ -o $$@)
|
||||
|
||||
$(1)_arm.nexe : $(1).bc
|
||||
$(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch arm $$^ -o $$@)
|
||||
|
||||
$(1).pexe: $(1).bc
|
||||
$(call LOG,FINALIZE,$$@,$(PNACL_FINALIZE) -o $$@ $$^)
|
||||
|
||||
$(1).bc: $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
|
||||
$(call LOG,LINK,$$@,$(PNACL_LINK) -o $$@ $(2) $(PNACL_LDFLAGS) $(foreach path,$(5),-L$(path)/pnacl/$(CONFIG)) -L./lib $(foreach lib,$(3),-l$(lib)) $(6))
|
||||
endef
|
||||
|
||||
$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
|
||||
$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
|
||||
|
||||
ifeq ($(CONFIG),Release)
|
||||
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
|
||||
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
|
||||
else
|
||||
$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
|
||||
endif
|
||||
|
||||
$(eval $(call NMF_RULE,$(TARGET),))
|
40
test/nacl/background.js
Normal file
40
test/nacl/background.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
function makeURL(toolchain, config) {
|
||||
return 'index.html?tc=' + toolchain + '&config=' + config;
|
||||
}
|
||||
|
||||
function createWindow(url) {
|
||||
console.log('loading ' + url);
|
||||
chrome.app.window.create(url, {
|
||||
width: 1024,
|
||||
height: 800,
|
||||
frame: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
function onLaunched(launchData) {
|
||||
// Send and XHR to get the URL to load from a configuration file.
|
||||
// Normally you won't need to do this; just call:
|
||||
//
|
||||
// chrome.app.window.create('<your url>', {...});
|
||||
//
|
||||
// In the SDK we want to be able to load different URLs (for different
|
||||
// toolchain/config combinations) from the commandline, so we to read
|
||||
// this information from the file "run_package_config".
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'run_package_config', true);
|
||||
xhr.onload = function() {
|
||||
var toolchain_config = this.responseText.split(' ');
|
||||
createWindow(makeURL.apply(null, toolchain_config));
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
// Can't find the config file, just load the default.
|
||||
createWindow('index.html');
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
chrome.app.runtime.onLaunched.addListener(onLaunched);
|
474
test/nacl/common.js
Normal file
474
test/nacl/common.js
Normal file
@@ -0,0 +1,474 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Set to true when the Document is loaded IFF "test=true" is in the query
|
||||
// string.
|
||||
var isTest = false;
|
||||
|
||||
// Set to true when loading a "Release" NaCl module, false when loading a
|
||||
// "Debug" NaCl module.
|
||||
var isRelease = true;
|
||||
|
||||
// Javascript module pattern:
|
||||
// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces
|
||||
// In essence, we define an anonymous function which is immediately called and
|
||||
// returns a new object. The new object contains only the exported definitions;
|
||||
// all other definitions in the anonymous function are inaccessible to external
|
||||
// code.
|
||||
var common = (function() {
|
||||
|
||||
function isHostToolchain(tool) {
|
||||
return tool == 'win' || tool == 'linux' || tool == 'mac';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mime type for NaCl plugin.
|
||||
*
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @return {string} The mime-type for the kind of NaCl plugin matching
|
||||
* the given toolchain.
|
||||
*/
|
||||
function mimeTypeForTool(tool) {
|
||||
// For NaCl modules use application/x-nacl.
|
||||
var mimetype = 'application/x-nacl';
|
||||
if (isHostToolchain(tool)) {
|
||||
// For non-NaCl PPAPI plugins use the x-ppapi-debug/release
|
||||
// mime type.
|
||||
if (isRelease)
|
||||
mimetype = 'application/x-ppapi-release';
|
||||
else
|
||||
mimetype = 'application/x-ppapi-debug';
|
||||
} else if (tool == 'pnacl') {
|
||||
mimetype = 'application/x-pnacl';
|
||||
}
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the browser supports NaCl plugins.
|
||||
*
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @return {bool} True if the browser supports the type of NaCl plugin
|
||||
* produced by the given toolchain.
|
||||
*/
|
||||
function browserSupportsNaCl(tool) {
|
||||
// Assume host toolchains always work with the given browser.
|
||||
// The below mime-type checking might not work with
|
||||
// --register-pepper-plugins.
|
||||
if (isHostToolchain(tool)) {
|
||||
return true;
|
||||
}
|
||||
var mimetype = mimeTypeForTool(tool);
|
||||
return navigator.mimeTypes[mimetype] !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject a script into the DOM, and call a callback when it is loaded.
|
||||
*
|
||||
* @param {string} url The url of the script to load.
|
||||
* @param {Function} onload The callback to call when the script is loaded.
|
||||
* @param {Function} onerror The callback to call if the script fails to load.
|
||||
*/
|
||||
function injectScript(url, onload, onerror) {
|
||||
var scriptEl = document.createElement('script');
|
||||
scriptEl.type = 'text/javascript';
|
||||
scriptEl.src = url;
|
||||
scriptEl.onload = onload;
|
||||
if (onerror) {
|
||||
scriptEl.addEventListener('error', onerror, false);
|
||||
}
|
||||
document.head.appendChild(scriptEl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all tests for this example.
|
||||
*
|
||||
* @param {Object} moduleEl The module DOM element.
|
||||
*/
|
||||
function runTests(moduleEl) {
|
||||
console.log('runTests()');
|
||||
common.tester = new Tester();
|
||||
|
||||
// All NaCl SDK examples are OK if the example exits cleanly; (i.e. the
|
||||
// NaCl module returns 0 or calls exit(0)).
|
||||
//
|
||||
// Without this exception, the browser_tester thinks that the module
|
||||
// has crashed.
|
||||
common.tester.exitCleanlyIsOK();
|
||||
|
||||
common.tester.addAsyncTest('loaded', function(test) {
|
||||
test.pass();
|
||||
});
|
||||
|
||||
if (typeof window.addTests !== 'undefined') {
|
||||
window.addTests();
|
||||
}
|
||||
|
||||
common.tester.waitFor(moduleEl);
|
||||
common.tester.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Native Client <embed> element as a child of the DOM element
|
||||
* named "listener".
|
||||
*
|
||||
* @param {string} name The name of the example.
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @param {string} path Directory name where .nmf file can be found.
|
||||
* @param {number} width The width to create the plugin.
|
||||
* @param {number} height The height to create the plugin.
|
||||
* @param {Object} attrs Dictionary of attributes to set on the module.
|
||||
*/
|
||||
function createNaClModule(name, tool, path, width, height, attrs) {
|
||||
var moduleEl = document.createElement('embed');
|
||||
moduleEl.setAttribute('name', 'nacl_module');
|
||||
moduleEl.setAttribute('id', 'nacl_module');
|
||||
moduleEl.setAttribute('width', width);
|
||||
moduleEl.setAttribute('height', height);
|
||||
moduleEl.setAttribute('path', path);
|
||||
moduleEl.setAttribute('src', path + '/' + name + '.nmf');
|
||||
|
||||
// Add any optional arguments
|
||||
if (attrs) {
|
||||
for (var key in attrs) {
|
||||
moduleEl.setAttribute(key, attrs[key]);
|
||||
}
|
||||
}
|
||||
|
||||
var mimetype = mimeTypeForTool(tool);
|
||||
moduleEl.setAttribute('type', mimetype);
|
||||
|
||||
// The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
|
||||
// and a 'message' event listener attached. This wrapping method is used
|
||||
// instead of attaching the event listeners directly to the <EMBED> element
|
||||
// to ensure that the listeners are active before the NaCl module 'load'
|
||||
// event fires.
|
||||
var listenerDiv = document.getElementById('listener');
|
||||
listenerDiv.appendChild(moduleEl);
|
||||
|
||||
// Request the offsetTop property to force a relayout. As of Apr 10, 2014
|
||||
// this is needed if the module is being loaded on a Chrome App's
|
||||
// background page (see crbug.com/350445).
|
||||
moduleEl.offsetTop;
|
||||
|
||||
// Host plugins don't send a moduleDidLoad message. We'll fake it here.
|
||||
var isHost = isHostToolchain(tool);
|
||||
if (isHost) {
|
||||
window.setTimeout(function() {
|
||||
moduleEl.readyState = 1;
|
||||
moduleEl.dispatchEvent(new CustomEvent('loadstart'));
|
||||
moduleEl.readyState = 4;
|
||||
moduleEl.dispatchEvent(new CustomEvent('load'));
|
||||
moduleEl.dispatchEvent(new CustomEvent('loadend'));
|
||||
}, 100); // 100 ms
|
||||
}
|
||||
|
||||
// This is code that is only used to test the SDK.
|
||||
if (isTest) {
|
||||
var loadNaClTest = function() {
|
||||
injectScript('nacltest.js', function() {
|
||||
runTests(moduleEl);
|
||||
});
|
||||
};
|
||||
|
||||
// Try to load test.js for the example. Whether or not it exists, load
|
||||
// nacltest.js.
|
||||
injectScript('test.js', loadNaClTest, loadNaClTest);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the default "load" and "message" event listeners to the element with
|
||||
* id "listener".
|
||||
*
|
||||
* The "load" event is sent when the module is successfully loaded. The
|
||||
* "message" event is sent when the naclModule posts a message using
|
||||
* PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in
|
||||
* C++).
|
||||
*/
|
||||
function attachDefaultListeners() {
|
||||
var listenerDiv = document.getElementById('listener');
|
||||
listenerDiv.addEventListener('load', moduleDidLoad, true);
|
||||
listenerDiv.addEventListener('message', handleMessage, true);
|
||||
listenerDiv.addEventListener('error', handleError, true);
|
||||
listenerDiv.addEventListener('crash', handleCrash, true);
|
||||
if (typeof window.attachListeners !== 'undefined') {
|
||||
window.attachListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the NaCl module fails to load.
|
||||
*
|
||||
* This event listener is registered in createNaClModule above.
|
||||
*/
|
||||
function handleError(event) {
|
||||
// We can't use common.naclModule yet because the module has not been
|
||||
// loaded.
|
||||
var moduleEl = document.getElementById('nacl_module');
|
||||
updateStatus('ERROR [' + moduleEl.lastError + ']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Browser can not communicate with the Module
|
||||
*
|
||||
* This event listener is registered in attachDefaultListeners above.
|
||||
*/
|
||||
function handleCrash(event) {
|
||||
if (common.naclModule.exitStatus == -1) {
|
||||
updateStatus('CRASHED');
|
||||
} else {
|
||||
updateStatus('EXITED [' + common.naclModule.exitStatus + ']');
|
||||
}
|
||||
if (typeof window.handleCrash !== 'undefined') {
|
||||
window.handleCrash(common.naclModule.lastError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the NaCl module is loaded.
|
||||
*
|
||||
* This event listener is registered in attachDefaultListeners above.
|
||||
*/
|
||||
function moduleDidLoad() {
|
||||
common.naclModule = document.getElementById('nacl_module');
|
||||
updateStatus('RUNNING');
|
||||
|
||||
if (typeof window.moduleDidLoad !== 'undefined') {
|
||||
window.moduleDidLoad();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the NaCl module's embed element.
|
||||
*
|
||||
* We don't want to hide by default; if we do, it is harder to determine that
|
||||
* a plugin failed to load. Instead, call this function inside the example's
|
||||
* "moduleDidLoad" function.
|
||||
*
|
||||
*/
|
||||
function hideModule() {
|
||||
// Setting common.naclModule.style.display = "None" doesn't work; the
|
||||
// module will no longer be able to receive postMessages.
|
||||
common.naclModule.style.height = '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the NaCl module from the page.
|
||||
*/
|
||||
function removeModule() {
|
||||
common.naclModule.parentNode.removeChild(common.naclModule);
|
||||
common.naclModule = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true when |s| starts with the string |prefix|.
|
||||
*
|
||||
* @param {string} s The string to search.
|
||||
* @param {string} prefix The prefix to search for in |s|.
|
||||
*/
|
||||
function startsWith(s, prefix) {
|
||||
// indexOf would search the entire string, lastIndexOf(p, 0) only checks at
|
||||
// the first index. See: http://stackoverflow.com/a/4579228
|
||||
return s.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
/** Maximum length of logMessageArray. */
|
||||
var kMaxLogMessageLength = 20;
|
||||
|
||||
/** An array of messages to display in the element with id "log". */
|
||||
var logMessageArray = [];
|
||||
|
||||
/**
|
||||
* Add a message to an element with id "log".
|
||||
*
|
||||
* This function is used by the default "log:" message handler.
|
||||
*
|
||||
* @param {string} message The message to log.
|
||||
*/
|
||||
function logMessage(message) {
|
||||
logMessageArray.push(message);
|
||||
if (logMessageArray.length > kMaxLogMessageLength)
|
||||
logMessageArray.shift();
|
||||
|
||||
document.getElementById('log').textContent = logMessageArray.join('\n');
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
var defaultMessageTypes = {
|
||||
'alert': alert,
|
||||
'log': logMessage
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the NaCl module sends a message to JavaScript (via
|
||||
* PPB_Messaging.PostMessage())
|
||||
*
|
||||
* This event listener is registered in createNaClModule above.
|
||||
*
|
||||
* @param {Event} message_event A message event. message_event.data contains
|
||||
* the data sent from the NaCl module.
|
||||
*/
|
||||
function handleMessage(message_event) {
|
||||
if (typeof message_event.data === 'string') {
|
||||
for (var type in defaultMessageTypes) {
|
||||
if (defaultMessageTypes.hasOwnProperty(type)) {
|
||||
if (startsWith(message_event.data, type + ':')) {
|
||||
func = defaultMessageTypes[type];
|
||||
func(message_event.data.slice(type.length + 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window.handleMessage !== 'undefined') {
|
||||
window.handleMessage(message_event);
|
||||
return;
|
||||
}
|
||||
|
||||
logMessage('Unhandled message: ' + message_event.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the DOM content has loaded; i.e. the page's document is fully
|
||||
* parsed. At this point, we can safely query any elements in the document via
|
||||
* document.querySelector, document.getElementById, etc.
|
||||
*
|
||||
* @param {string} name The name of the example.
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @param {string} path Directory name where .nmf file can be found.
|
||||
* @param {number} width The width to create the plugin.
|
||||
* @param {number} height The height to create the plugin.
|
||||
* @param {Object} attrs Optional dictionary of additional attributes.
|
||||
*/
|
||||
function domContentLoaded(name, tool, path, width, height, attrs) {
|
||||
// If the page loads before the Native Client module loads, then set the
|
||||
// status message indicating that the module is still loading. Otherwise,
|
||||
// do not change the status message.
|
||||
updateStatus('Page loaded.');
|
||||
if (!browserSupportsNaCl(tool)) {
|
||||
updateStatus(
|
||||
'Browser does not support NaCl (' + tool + '), or NaCl is disabled');
|
||||
} else if (common.naclModule == null) {
|
||||
updateStatus('Creating embed: ' + tool);
|
||||
|
||||
// We use a non-zero sized embed to give Chrome space to place the bad
|
||||
// plug-in graphic, if there is a problem.
|
||||
width = typeof width !== 'undefined' ? width : 200;
|
||||
height = typeof height !== 'undefined' ? height : 200;
|
||||
attachDefaultListeners();
|
||||
createNaClModule(name, tool, path, width, height, attrs);
|
||||
} else {
|
||||
// It's possible that the Native Client module onload event fired
|
||||
// before the page's onload event. In this case, the status message
|
||||
// will reflect 'SUCCESS', but won't be displayed. This call will
|
||||
// display the current message.
|
||||
updateStatus('Waiting.');
|
||||
}
|
||||
}
|
||||
|
||||
/** Saved text to display in the element with id 'statusField'. */
|
||||
var statusText = 'NO-STATUSES';
|
||||
|
||||
/**
|
||||
* Set the global status message. If the element with id 'statusField'
|
||||
* exists, then set its HTML to the status message as well.
|
||||
*
|
||||
* @param {string} opt_message The message to set. If null or undefined, then
|
||||
* set element 'statusField' to the message from the last call to
|
||||
* updateStatus.
|
||||
*/
|
||||
function updateStatus(opt_message) {
|
||||
if (opt_message) {
|
||||
statusText = opt_message;
|
||||
}
|
||||
var statusField = document.getElementById('statusField');
|
||||
if (statusField) {
|
||||
statusField.innerHTML = statusText;
|
||||
}
|
||||
}
|
||||
|
||||
// The symbols to export.
|
||||
return {
|
||||
/** A reference to the NaCl module, once it is loaded. */
|
||||
naclModule: null,
|
||||
|
||||
attachDefaultListeners: attachDefaultListeners,
|
||||
domContentLoaded: domContentLoaded,
|
||||
createNaClModule: createNaClModule,
|
||||
hideModule: hideModule,
|
||||
removeModule: removeModule,
|
||||
logMessage: logMessage,
|
||||
updateStatus: updateStatus
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
// Listen for the DOM content to be loaded. This event is fired when parsing of
|
||||
// the page's document has finished.
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var body = document.body;
|
||||
|
||||
// The data-* attributes on the body can be referenced via body.dataset.
|
||||
if (body.dataset) {
|
||||
var loadFunction;
|
||||
if (!body.dataset.customLoad) {
|
||||
loadFunction = common.domContentLoaded;
|
||||
} else if (typeof window.domContentLoaded !== 'undefined') {
|
||||
loadFunction = window.domContentLoaded;
|
||||
}
|
||||
|
||||
// From https://developer.mozilla.org/en-US/docs/DOM/window.location
|
||||
var searchVars = {};
|
||||
if (window.location.search.length > 1) {
|
||||
var pairs = window.location.search.substr(1).split('&');
|
||||
for (var key_ix = 0; key_ix < pairs.length; key_ix++) {
|
||||
var keyValue = pairs[key_ix].split('=');
|
||||
searchVars[unescape(keyValue[0])] =
|
||||
keyValue.length > 1 ? unescape(keyValue[1]) : '';
|
||||
}
|
||||
}
|
||||
|
||||
if (loadFunction) {
|
||||
var toolchains = body.dataset.tools.split(' ');
|
||||
var configs = body.dataset.configs.split(' ');
|
||||
|
||||
var attrs = {};
|
||||
if (body.dataset.attrs) {
|
||||
var attr_list = body.dataset.attrs.split(' ');
|
||||
for (var key in attr_list) {
|
||||
var attr = attr_list[key].split('=');
|
||||
var key = attr[0];
|
||||
var value = attr[1];
|
||||
attrs[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
var tc = toolchains.indexOf(searchVars.tc) !== -1 ?
|
||||
searchVars.tc : toolchains[0];
|
||||
|
||||
// If the config value is included in the search vars, use that.
|
||||
// Otherwise default to Release if it is valid, or the first value if
|
||||
// Release is not valid.
|
||||
if (configs.indexOf(searchVars.config) !== -1)
|
||||
var config = searchVars.config;
|
||||
else if (configs.indexOf('Release') !== -1)
|
||||
var config = 'Release';
|
||||
else
|
||||
var config = configs[0];
|
||||
|
||||
var pathFormat = body.dataset.path;
|
||||
var path = pathFormat.replace('{tc}', tc).replace('{config}', config);
|
||||
|
||||
isTest = searchVars.test === 'true';
|
||||
isRelease = path.toLowerCase().indexOf('release') != -1;
|
||||
|
||||
loadFunction(body.dataset.name, tc, path, body.dataset.width,
|
||||
body.dataset.height, attrs);
|
||||
}
|
||||
}
|
||||
});
|
21
test/nacl/index.html
Normal file
21
test/nacl/index.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
Use of this source code is governed by a BSD-style license that can be
|
||||
found in the LICENSE file.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="-1">
|
||||
<title>SDL NACL Test</title>
|
||||
<script type="text/javascript" src="common.js"></script>
|
||||
</head>
|
||||
<body data-width="640" data-height="640" data-name="sdl_app" data-tools="pnacl" data-configs="Debug Release" data-path="{tc}/{config}">
|
||||
<h1>SDL NACL Test</h1>
|
||||
<h2>Status: <code id="statusField">NO-STATUS</code></h2>
|
||||
<!-- The NaCl plugin will be embedded inside the element with id "listener".
|
||||
See common.js.-->
|
||||
<div id="listener"></div>
|
||||
</body>
|
||||
</html>
|
22
test/nacl/manifest.json
Normal file
22
test/nacl/manifest.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "SDL testgles2",
|
||||
"version": "33.0.1750.117",
|
||||
"minimum_chrome_version": "33.0.1750.117",
|
||||
"manifest_version": 2,
|
||||
"description": "testgles2",
|
||||
"offline_enabled": true,
|
||||
"icons": {
|
||||
"128": "icon128.png"
|
||||
},
|
||||
"app": {
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
}
|
||||
},
|
||||
"key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMN716Qyu0l2EHNFqIJVqVysFcTR6urqhaGGqW4UK7slBaURz9+Sb1b4Ot5P1uQNE5c+CTU5Vu61wpqmSqMMxqHLWdPPMh8uRlyctsb2cxWwG6XoGSvpX29NsQVUFXd4v2tkJm3G9t+V0X8TYskrvWQmnyOW8OEIDvrBhUEfFxWQIDAQAB",
|
||||
"oauth2": {
|
||||
"client_id": "903965034255.apps.googleusercontent.com",
|
||||
"scopes": ["https://www.googleapis.com/auth/drive"]
|
||||
},
|
||||
"permissions": []
|
||||
}
|
@@ -31,7 +31,7 @@ tf(SDL_bool _tf)
|
||||
return f;
|
||||
}
|
||||
|
||||
static void RunBasicTest()
|
||||
static void RunBasicTest(void)
|
||||
{
|
||||
int value;
|
||||
SDL_SpinLock lock = 0;
|
||||
@@ -153,7 +153,7 @@ static void runAdder(void)
|
||||
SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
|
||||
}
|
||||
|
||||
static void RunEpicTest()
|
||||
static void RunEpicTest(void)
|
||||
{
|
||||
int b;
|
||||
atomicValue v;
|
||||
|
@@ -24,7 +24,7 @@ static SDL_AudioDeviceID devid_in = 0;
|
||||
static SDL_AudioDeviceID devid_out = 0;
|
||||
|
||||
static void
|
||||
loop()
|
||||
loop(void)
|
||||
{
|
||||
SDL_bool please_quit = SDL_FALSE;
|
||||
SDL_Event e;
|
||||
|
@@ -81,7 +81,7 @@ devtypestr(int iscapture)
|
||||
}
|
||||
|
||||
static void
|
||||
iteration()
|
||||
iteration(void)
|
||||
{
|
||||
SDL_Event e;
|
||||
SDL_AudioDeviceID dev;
|
||||
@@ -124,7 +124,7 @@ iteration()
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
if (done)
|
||||
emscripten_cancel_main_loop();
|
||||
|
@@ -19,29 +19,29 @@ print_devices(int iscapture)
|
||||
const char *typestr = ((iscapture) ? "capture" : "output");
|
||||
int n = SDL_GetNumAudioDevices(iscapture);
|
||||
|
||||
printf("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
|
||||
SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
|
||||
|
||||
if (n == -1) {
|
||||
printf(" Driver can't detect specific %s devices.\n\n", typestr);
|
||||
SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
|
||||
} else if (n == 0) {
|
||||
printf(" No %s devices found.\n\n", typestr);
|
||||
SDL_Log(" No %s devices found.\n\n", typestr);
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *name = SDL_GetAudioDeviceName(i, iscapture);
|
||||
if (name) {
|
||||
printf(" %d: %s\n", i, name);
|
||||
SDL_Log(" %d: %s\n", i, name);
|
||||
} else {
|
||||
printf(" %d Error: %s\n", i, SDL_GetError());
|
||||
SDL_Log(" %d Error: %s\n", i, SDL_GetError());
|
||||
}
|
||||
|
||||
if (SDL_GetAudioDeviceSpec(i, iscapture, &spec) == 0) {
|
||||
printf(" Sample Rate: %d\n", spec.freq);
|
||||
printf(" Channels: %d\n", spec.channels);
|
||||
printf(" SDL_AudioFormat: %X\n", spec.format);
|
||||
SDL_Log(" Sample Rate: %d\n", spec.freq);
|
||||
SDL_Log(" Channels: %d\n", spec.channels);
|
||||
SDL_Log(" SDL_AudioFormat: %X\n", spec.format);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
SDL_Log("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,39 +63,39 @@ int main(int argc, char **argv)
|
||||
/* Print available audio drivers */
|
||||
n = SDL_GetNumAudioDrivers();
|
||||
if (n == 0) {
|
||||
printf("No built-in audio drivers\n\n");
|
||||
SDL_Log("No built-in audio drivers\n\n");
|
||||
} else {
|
||||
int i;
|
||||
printf("Built-in audio drivers:\n");
|
||||
SDL_Log("Built-in audio drivers:\n");
|
||||
for (i = 0; i < n; ++i) {
|
||||
printf(" %d: %s\n", i, SDL_GetAudioDriver(i));
|
||||
SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i));
|
||||
}
|
||||
printf("Select a driver with the SDL_AUDIODRIVER environment variable.\n");
|
||||
SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n");
|
||||
}
|
||||
|
||||
printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
|
||||
SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
|
||||
|
||||
print_devices(0);
|
||||
print_devices(1);
|
||||
|
||||
if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 0) < 0) {
|
||||
printf("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
|
||||
SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
|
||||
} else {
|
||||
printf("Default Output Name: %s\n", deviceName ? deviceName : "unknown");
|
||||
SDL_Log("Default Output Name: %s\n", deviceName ? deviceName : "unknown");
|
||||
SDL_free(deviceName);
|
||||
printf("Sample Rate: %d\n", spec.freq);
|
||||
printf("Channels: %d\n", spec.channels);
|
||||
printf("SDL_AudioFormat: %X\n", spec.format);
|
||||
SDL_Log("Sample Rate: %d\n", spec.freq);
|
||||
SDL_Log("Channels: %d\n", spec.channels);
|
||||
SDL_Log("SDL_AudioFormat: %X\n", spec.format);
|
||||
}
|
||||
|
||||
if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 1) < 0) {
|
||||
printf("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
|
||||
SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
|
||||
} else {
|
||||
printf("Default Capture Name: %s\n", deviceName ? deviceName : "unknown");
|
||||
SDL_Log("Default Capture Name: %s\n", deviceName ? deviceName : "unknown");
|
||||
SDL_free(deviceName);
|
||||
printf("Sample Rate: %d\n", spec.freq);
|
||||
printf("Channels: %d\n", spec.channels);
|
||||
printf("SDL_AudioFormat: %X\n", spec.format);
|
||||
SDL_Log("Sample Rate: %d\n", spec.freq);
|
||||
SDL_Log("Channels: %d\n", spec.channels);
|
||||
SDL_Log("SDL_AudioFormat: %X\n", spec.format);
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
@@ -96,7 +96,7 @@ static SDL_bool DriverIsProblematic(const char *driver)
|
||||
* \sa https://wiki.libsdl.org/SDL_QuitSubSystem
|
||||
* \sa https://wiki.libsdl.org/SDL_InitSubSystem
|
||||
*/
|
||||
int audio_quitInitAudioSubSystem()
|
||||
int audio_quitInitAudioSubSystem(void)
|
||||
{
|
||||
/* Stop SDL audio subsystem */
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
@@ -114,7 +114,7 @@ int audio_quitInitAudioSubSystem()
|
||||
* \sa https://wiki.libsdl.org/SDL_InitAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_QuitAudio
|
||||
*/
|
||||
int audio_initQuitAudio()
|
||||
int audio_initQuitAudio(void)
|
||||
{
|
||||
int result;
|
||||
int i, iMax;
|
||||
@@ -195,7 +195,7 @@ int audio_initQuitAudio()
|
||||
* \sa https://wiki.libsdl.org/SDL_CloseAudio
|
||||
* \sa https://wiki.libsdl.org/SDL_QuitAudio
|
||||
*/
|
||||
int audio_initOpenCloseQuitAudio()
|
||||
int audio_initOpenCloseQuitAudio(void)
|
||||
{
|
||||
int result, expectedResult;
|
||||
int i, iMax, j, k;
|
||||
@@ -318,7 +318,7 @@ int audio_initOpenCloseQuitAudio()
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_PauseAudio
|
||||
*/
|
||||
int audio_pauseUnpauseAudio()
|
||||
int audio_pauseUnpauseAudio(void)
|
||||
{
|
||||
int result;
|
||||
int i, iMax, j, k, l;
|
||||
@@ -474,7 +474,7 @@ int audio_pauseUnpauseAudio()
|
||||
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
|
||||
*/
|
||||
int audio_enumerateAndNameAudioDevices()
|
||||
int audio_enumerateAndNameAudioDevices(void)
|
||||
{
|
||||
int t, tt;
|
||||
int i, n, nn;
|
||||
@@ -532,7 +532,7 @@ int audio_enumerateAndNameAudioDevices()
|
||||
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDevices
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioDeviceName
|
||||
*/
|
||||
int audio_enumerateAndNameAudioDevicesNegativeTests()
|
||||
int audio_enumerateAndNameAudioDevicesNegativeTests(void)
|
||||
{
|
||||
int t;
|
||||
int i, j, no, nc;
|
||||
@@ -578,7 +578,7 @@ int audio_enumerateAndNameAudioDevicesNegativeTests()
|
||||
* \sa https://wiki.libsdl.org/SDL_GetNumAudioDrivers
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioDriver
|
||||
*/
|
||||
int audio_printAudioDrivers()
|
||||
int audio_printAudioDrivers(void)
|
||||
{
|
||||
int i, n;
|
||||
const char *name;
|
||||
@@ -608,7 +608,7 @@ int audio_printAudioDrivers()
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_GetCurrentAudioDriver
|
||||
*/
|
||||
int audio_printCurrentAudioDriver()
|
||||
int audio_printCurrentAudioDriver(void)
|
||||
{
|
||||
/* Check current audio driver */
|
||||
const char *name = SDL_GetCurrentAudioDriver();
|
||||
@@ -639,7 +639,7 @@ int _audioFrequencies[] = { 11025, 22050, 44100, 48000 };
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
*/
|
||||
int audio_buildAudioCVT()
|
||||
int audio_buildAudioCVT(void)
|
||||
{
|
||||
int result;
|
||||
SDL_AudioCVT cvt;
|
||||
@@ -703,7 +703,7 @@ int audio_buildAudioCVT()
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
*/
|
||||
int audio_buildAudioCVTNegative()
|
||||
int audio_buildAudioCVTNegative(void)
|
||||
{
|
||||
const char *expectedError = "Parameter 'cvt' is invalid";
|
||||
const char *error;
|
||||
@@ -798,7 +798,7 @@ int audio_buildAudioCVTNegative()
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioStatus
|
||||
*/
|
||||
int audio_getAudioStatus()
|
||||
int audio_getAudioStatus(void)
|
||||
{
|
||||
SDL_AudioStatus result;
|
||||
|
||||
@@ -817,7 +817,7 @@ int audio_getAudioStatus()
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_GetAudioStatus
|
||||
*/
|
||||
int audio_openCloseAndGetAudioStatus()
|
||||
int audio_openCloseAndGetAudioStatus(void)
|
||||
{
|
||||
SDL_AudioStatus result;
|
||||
int i;
|
||||
@@ -878,7 +878,7 @@ int audio_openCloseAndGetAudioStatus()
|
||||
* \sa https://wiki.libsdl.org/SDL_LockAudioDevice
|
||||
* \sa https://wiki.libsdl.org/SDL_UnlockAudioDevice
|
||||
*/
|
||||
int audio_lockUnlockOpenAudioDevice()
|
||||
int audio_lockUnlockOpenAudioDevice(void)
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
@@ -942,7 +942,7 @@ int audio_lockUnlockOpenAudioDevice()
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
* \sa https://wiki.libsdl.org/SDL_ConvertAudio
|
||||
*/
|
||||
int audio_convertAudio()
|
||||
int audio_convertAudio(void)
|
||||
{
|
||||
int result;
|
||||
SDL_AudioCVT cvt;
|
||||
@@ -1043,7 +1043,7 @@ int audio_convertAudio()
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_AudioDeviceConnected
|
||||
*/
|
||||
int audio_openCloseAudioDeviceConnected()
|
||||
int audio_openCloseAudioDeviceConnected(void)
|
||||
{
|
||||
int result = -1;
|
||||
int i;
|
||||
@@ -1118,7 +1118,7 @@ static double sine_wave_sample(const Sint64 idx, const Sint64 rate, const Sint64
|
||||
* \sa https://wiki.libsdl.org/SDL_BuildAudioCVT
|
||||
* \sa https://wiki.libsdl.org/SDL_ConvertAudio
|
||||
*/
|
||||
int audio_resampleLoss()
|
||||
int audio_resampleLoss(void)
|
||||
{
|
||||
/* Note: always test long input time (>= 5s from experience) in some test
|
||||
* cases because an improper implementation may suffer from low resampling
|
||||
|
@@ -102,7 +102,7 @@ int keyboard_getKeyFromName(void *arg)
|
||||
/*
|
||||
* Local helper to check for the invalid scancode error message
|
||||
*/
|
||||
void _checkInvalidScancodeError()
|
||||
void _checkInvalidScancodeError(void)
|
||||
{
|
||||
const char *expectedError = "Parameter 'scancode' is invalid";
|
||||
const char *error;
|
||||
@@ -574,7 +574,7 @@ int keyboard_getScancodeFromName(void *arg)
|
||||
/*
|
||||
* Local helper to check for the invalid scancode error message
|
||||
*/
|
||||
void _checkInvalidNameError()
|
||||
void _checkInvalidNameError(void)
|
||||
{
|
||||
const char *expectedError = "Parameter 'name' is invalid";
|
||||
const char *error;
|
||||
|
@@ -21,7 +21,7 @@ static void EnableTestLog(int *message_count)
|
||||
SDL_LogSetOutputFunction(TestLogOutput, message_count);
|
||||
}
|
||||
|
||||
static void DisableTestLog()
|
||||
static void DisableTestLog(void)
|
||||
{
|
||||
SDL_LogSetOutputFunction(original_function, original_userdata);
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ static void subsystemsTearDown(void *arg)
|
||||
* \sa SDL_QuitSubSystem
|
||||
*
|
||||
*/
|
||||
static int subsystems_referenceCount()
|
||||
static int subsystems_referenceCount(void)
|
||||
{
|
||||
const int system = SDL_INIT_VIDEO;
|
||||
int result;
|
||||
@@ -90,7 +90,7 @@ static int subsystems_referenceCount()
|
||||
* \sa SDL_QuitSubSystem
|
||||
*
|
||||
*/
|
||||
static int subsystems_dependRefCountInitAllQuitByOne()
|
||||
static int subsystems_dependRefCountInitAllQuitByOne(void)
|
||||
{
|
||||
int result;
|
||||
/* Ensure that we start with reset subsystems. */
|
||||
@@ -128,7 +128,7 @@ static int subsystems_dependRefCountInitAllQuitByOne()
|
||||
* \sa SDL_QuitSubSystem
|
||||
*
|
||||
*/
|
||||
static int subsystems_dependRefCountInitByOneQuitAll()
|
||||
static int subsystems_dependRefCountInitByOneQuitAll(void)
|
||||
{
|
||||
int result;
|
||||
/* Ensure that we start with reset subsystems. */
|
||||
@@ -163,7 +163,7 @@ static int subsystems_dependRefCountInitByOneQuitAll()
|
||||
* \sa SDL_QuitSubSystem
|
||||
*
|
||||
*/
|
||||
static int subsystems_dependRefCountWithExtraInit()
|
||||
static int subsystems_dependRefCountWithExtraInit(void)
|
||||
{
|
||||
int result;
|
||||
/* Ensure that we start with reset subsystems. */
|
||||
|
@@ -81,7 +81,7 @@ void _surfaceTearDown(void *arg)
|
||||
/**
|
||||
* Helper that clears the test surface
|
||||
*/
|
||||
void _clearTestSurface()
|
||||
void _clearTestSurface(void)
|
||||
{
|
||||
int ret;
|
||||
Uint32 color;
|
||||
|
@@ -624,7 +624,7 @@ int video_getWindowDisplayMode(void *arg)
|
||||
}
|
||||
|
||||
/* Helper function that checks for an 'Invalid window' error */
|
||||
void _checkInvalidWindowError()
|
||||
void _checkInvalidWindowError(void)
|
||||
{
|
||||
const char *invalidWindowError = "Invalid window";
|
||||
char *lastError;
|
||||
@@ -1300,7 +1300,7 @@ int video_getSetWindowPosition(void *arg)
|
||||
}
|
||||
|
||||
/* Helper function that checks for an 'Invalid parameter' error */
|
||||
void _checkInvalidParameterError()
|
||||
void _checkInvalidParameterError(void)
|
||||
{
|
||||
const char *invalidParameterError = "Parameter";
|
||||
char *lastError;
|
||||
@@ -2181,6 +2181,76 @@ int video_setWindowCenteredOnDisplay(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests window surface functionality
|
||||
*/
|
||||
static int video_getWindowSurface(void *arg)
|
||||
{
|
||||
const char *title = "video_getWindowSurface Test Window";
|
||||
SDL_Window *window;
|
||||
SDL_Surface *surface;
|
||||
SDL_Renderer *renderer;
|
||||
Uint32 renderer_flags = SDL_RENDERER_ACCELERATED;
|
||||
int result;
|
||||
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
|
||||
renderer_flags = SDL_RENDERER_SOFTWARE;
|
||||
}
|
||||
|
||||
/* Make sure we're testing interaction with an accelerated renderer */
|
||||
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1");
|
||||
|
||||
window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 320, 0);
|
||||
SDLTest_AssertPass("Call to SDL_CreateWindow('%s', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 320, 0)", title);
|
||||
SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
|
||||
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
|
||||
SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL");
|
||||
SDLTest_AssertCheck(SDL_HasWindowSurface(window), "Validate that window has a surface");
|
||||
|
||||
result = SDL_UpdateWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_UpdateWindowSurface(window)");
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
|
||||
/* We shouldn't be able to create a renderer on a window with a surface */
|
||||
renderer = SDL_CreateRenderer(window, -1, renderer_flags);
|
||||
SDLTest_AssertPass("Call to SDL_CreateRenderer(window)");
|
||||
SDLTest_AssertCheck(renderer == NULL, "Validate that returned renderer is NULL");
|
||||
|
||||
result = SDL_DestroyWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_DestroyWindowSurface(window)");
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
SDLTest_AssertCheck(!SDL_HasWindowSurface(window), "Validate that window does not have a surface");
|
||||
|
||||
/* We should be able to create a renderer on the window now */
|
||||
renderer = SDL_CreateRenderer(window, -1, renderer_flags);
|
||||
SDLTest_AssertPass("Call to SDL_CreateRenderer(window)");
|
||||
SDLTest_AssertCheck(renderer != NULL, "Validate that returned renderer is not NULL");
|
||||
|
||||
/* We should not be able to create a window surface now, unless it was created by the renderer */
|
||||
if (!SDL_HasWindowSurface(window)) {
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
|
||||
SDLTest_AssertCheck(surface == NULL, "Validate that returned surface is NULL");
|
||||
}
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDLTest_AssertPass("Call to SDL_DestroyRenderer(renderer)");
|
||||
SDLTest_AssertCheck(!SDL_HasWindowSurface(window), "Validate that window does not have a surface");
|
||||
|
||||
/* We should be able to create a window surface again */
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
|
||||
SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL");
|
||||
SDLTest_AssertCheck(SDL_HasWindowSurface(window), "Validate that window has a surface");
|
||||
|
||||
/* Clean up */
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Video test cases */
|
||||
@@ -2265,13 +2335,17 @@ static const SDLTest_TestCaseReference videoTest23 =
|
||||
static const SDLTest_TestCaseReference videoTest24 =
|
||||
{ (SDLTest_TestCaseFp) video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference videoTest25 = {
|
||||
(SDLTest_TestCaseFp)video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of Video test cases */
|
||||
static const SDLTest_TestCaseReference *videoTests[] = {
|
||||
&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
|
||||
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
|
||||
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
|
||||
&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
|
||||
&videoTest23, &videoTest24, NULL
|
||||
&videoTest23, &videoTest24, &videoTest25, NULL
|
||||
};
|
||||
|
||||
/* Video test suite (global) */
|
||||
|
@@ -148,7 +148,7 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
@@ -174,7 +174,7 @@ void DrawRects(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
Uint32 now;
|
||||
int i;
|
||||
|
@@ -28,7 +28,7 @@ SDL_Renderer *renderer;
|
||||
SDL_Surface *surface;
|
||||
int done;
|
||||
|
||||
void DrawChessBoard()
|
||||
void DrawChessBoard(void)
|
||||
{
|
||||
int row = 0, column = 0, x = 0;
|
||||
SDL_Rect rect, darea;
|
||||
@@ -53,7 +53,7 @@ void DrawChessBoard()
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event e;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
|
@@ -107,7 +107,7 @@ static int virtual_axis_start_x;
|
||||
static int virtual_axis_start_y;
|
||||
static SDL_GameControllerButton virtual_button_active = SDL_CONTROLLER_BUTTON_INVALID;
|
||||
|
||||
static void UpdateWindowTitle()
|
||||
static void UpdateWindowTitle(void)
|
||||
{
|
||||
if (!window) {
|
||||
return;
|
||||
@@ -329,7 +329,7 @@ typedef struct
|
||||
Uint8 ucLedBlue; /* 46 */
|
||||
} DS5EffectsState_t;
|
||||
|
||||
static void CyclePS5TriggerEffect()
|
||||
static void CyclePS5TriggerEffect(void)
|
||||
{
|
||||
DS5EffectsState_t state;
|
||||
|
||||
@@ -351,7 +351,7 @@ static void CyclePS5TriggerEffect()
|
||||
SDL_GameControllerSendEffect(gamecontroller, &state, sizeof(state));
|
||||
}
|
||||
|
||||
static SDL_bool ShowingFront()
|
||||
static SDL_bool ShowingFront(void)
|
||||
{
|
||||
SDL_bool showing_front = SDL_TRUE;
|
||||
int i;
|
||||
@@ -394,7 +394,7 @@ static int SDLCALL VirtualControllerSetLED(void *userdata, Uint8 red, Uint8 gree
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void OpenVirtualController()
|
||||
static void OpenVirtualController(void)
|
||||
{
|
||||
SDL_VirtualJoystickDesc desc;
|
||||
int virtual_index;
|
||||
@@ -420,7 +420,7 @@ static void OpenVirtualController()
|
||||
}
|
||||
}
|
||||
|
||||
static void CloseVirtualController()
|
||||
static void CloseVirtualController(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@@ -62,7 +62,7 @@ int LoadSprite(const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
@@ -78,7 +78,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
static void
|
||||
Render()
|
||||
Render(void)
|
||||
{
|
||||
static float color[8][3] = {
|
||||
{ 1.0, 1.0, 0.0 },
|
||||
|
@@ -49,7 +49,7 @@ quit(int rc)
|
||||
}
|
||||
|
||||
static void
|
||||
Render()
|
||||
Render(void)
|
||||
{
|
||||
static GLubyte color[8][4] = { { 255, 0, 0, 0 },
|
||||
{ 255, 0, 0, 255 },
|
||||
|
@@ -569,7 +569,7 @@ render_thread_fn(void *render_ctx)
|
||||
}
|
||||
|
||||
static void
|
||||
loop_threaded()
|
||||
loop_threaded(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
@@ -598,7 +598,7 @@ loop_threaded()
|
||||
#endif
|
||||
|
||||
static void
|
||||
loop()
|
||||
loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
|
@@ -325,7 +325,7 @@ int done;
|
||||
Uint32 frames;
|
||||
shader_data *datas;
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
|
@@ -333,7 +333,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
|
||||
return unifontGlyph[codepoint].width;
|
||||
}
|
||||
|
||||
static void unifont_cleanup()
|
||||
static void unifont_cleanup(void)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
@@ -425,12 +425,12 @@ Uint32 utf8_decode(char *p, size_t len)
|
||||
return codepoint;
|
||||
}
|
||||
|
||||
void usage()
|
||||
void usage(void)
|
||||
{
|
||||
SDL_Log("usage: testime [--font fontfile]\n");
|
||||
}
|
||||
|
||||
void InitInput()
|
||||
void InitInput(void)
|
||||
{
|
||||
/* Prepare a rect for text input */
|
||||
textRect.x = textRect.y = 100;
|
||||
@@ -444,7 +444,7 @@ void InitInput()
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
|
||||
void CleanupVideo()
|
||||
void CleanupVideo(void)
|
||||
{
|
||||
SDL_StopTextInput();
|
||||
#ifdef HAVE_SDL_TTF
|
||||
@@ -597,7 +597,7 @@ void _Redraw(int rendererID)
|
||||
SDL_SetTextInputRect(&markedRect);
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
void Redraw(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
|
@@ -208,7 +208,7 @@ DrawRectRectIntersections(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
@@ -53,7 +53,7 @@ play_through_once(void *arg, Uint8 *stream, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
if (SDL_AtomicGet(&cbd[0].done)) {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
@@ -32,7 +32,7 @@ static int width = 640;
|
||||
static int height = 480;
|
||||
static unsigned int max_frames = 200;
|
||||
|
||||
void draw()
|
||||
void draw(void)
|
||||
{
|
||||
SDL_Rect Rect;
|
||||
|
||||
@@ -50,7 +50,7 @@ void draw()
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
void save_surface_to_bmp()
|
||||
void save_surface_to_bmp(void)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
Uint32 r_mask, g_mask, b_mask, a_mask;
|
||||
@@ -71,7 +71,7 @@ void save_surface_to_bmp()
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
|
@@ -178,7 +178,7 @@ PrintUsage(char *argv0)
|
||||
SDL_Log("\n");
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
|
@@ -35,7 +35,7 @@ DrawRects(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
static void
|
||||
loop()
|
||||
loop(void)
|
||||
{
|
||||
/* Check for events */
|
||||
while (SDL_PollEvent(&event)) {
|
||||
|
@@ -87,7 +87,7 @@ void Draw(DrawState *s)
|
||||
/* SDL_Delay(10); */
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
@@ -173,7 +173,7 @@ Draw(DrawState *s)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
@@ -78,7 +78,7 @@ void Draw(DrawState *s)
|
||||
SDL_RenderPresent(s->renderer);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
/* This is a simple example of using GLSL shaders with SDL */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "SDL.h"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
@@ -228,7 +229,7 @@ static void DestroyShaderProgram(ShaderData *data)
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool InitShaders()
|
||||
static SDL_bool InitShaders(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -282,7 +283,7 @@ static SDL_bool InitShaders()
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static void QuitShaders()
|
||||
static void QuitShaders(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@@ -392,7 +392,7 @@ void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
static void MoveAllSprites()
|
||||
static void MoveAllSprites(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -404,7 +404,7 @@ static void MoveAllSprites()
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
Uint32 now;
|
||||
SDL_Event event;
|
||||
|
@@ -43,7 +43,7 @@ quit(int rc)
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
void MoveSprites()
|
||||
void MoveSprites(void)
|
||||
{
|
||||
int i;
|
||||
int window_w = WINDOW_WIDTH;
|
||||
@@ -77,7 +77,7 @@ void MoveSprites()
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
|
@@ -94,7 +94,7 @@ void UpdateTexture(SDL_Texture *texture)
|
||||
SDL_UnlockTexture(texture);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
|
@@ -95,7 +95,7 @@ void DrawOnViewport(SDL_Renderer *renderer)
|
||||
SDL_RenderSetClipRect(renderer, NULL);
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int i;
|
||||
|
@@ -143,7 +143,7 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_Rect viewport)
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
void loop(void)
|
||||
{
|
||||
int i;
|
||||
SDL_Event event;
|
||||
|
Reference in New Issue
Block a user