Skip to content
Permalink
Browse files

Cleanup portability.md to only include cross-platform backends, add C…

…C_BUILD_NOAUDIO instead of hardcoding no audio only to web client
  • Loading branch information...
UnknownShadow200 committed Nov 4, 2019
1 parent 9b49b67 commit f0fc77351b522d606cb8d858c0d3143a2bf46ab4
Showing with 9 additions and 13 deletions.
  1. +4 −9 misc/portability.md
  2. +1 −1 src/Audio.c
  3. +2 −1 src/Core.h
  4. +2 −2 src/Window.c
@@ -61,6 +61,7 @@ I don't really test these platforms at all, only when I suspect some changes to

Listed below are the requirements for implementing each platform-dependent file.
You should try to take advantage of existing backends when porting to other platforms.
Only cross platform backends are listed below.

### Platform
General platform specific functionality.
@@ -76,7 +77,6 @@ General platform specific functionality.
- Encrypt/decrypt data, getting command line args

Define:
- ```CC_BUILD_WIN``` - Use Win32 API (Windows)
- ```CC_BUILD_POSIX``` - Use posix API

posix note: Some functions are not covered. (stopwatch, getting exe path, open url in browser)
@@ -88,20 +88,16 @@ Create a window, show a dialog window, set window contents, keyboard/mouse input
Also monitor size, clipboard, cursor, raw relative mouse movement (optional)

Define:
- ```CC_BUILD_WINGUI``` - Use Win32 API (Windows) (WGL)
- ```CC_BUILD_CARBON``` - Use Carbon (Mac OSX) (AGL)
- ```CC_BUILD_X11``` - Use X11/XLib (unix-ish) (glX)
- ```CC_BUILD_SDL``` - Use SDL library (SDL)
- ```CC_BUILD_WEBCANVAS``` - Use emscripten canvas (WebGL)

If using OpenGL, also OpenGL context management

### Logger
Dump registers and backtrace, log unhandled errors (e.g. invalid memory read)

Define:
- ```CC_BUILD_WIN``` - Use Win32 api
- ```CC_BUILD_POSIX``` - Use POSIX api
- ```CC_BUILD_POSIX``` - use POSIX api

posix note: Register access is highly dependent on OS and architecture.

@@ -111,8 +107,8 @@ posix note: Register access is highly dependent on OS and architecture.
Play multiple audio streams with varying sample rates

Define:
- ```CC_BUILD_WINMM``` - Use WinMM (Windows)
- ```CC_BUILD_OpenAL``` - Use OpenAL
- ```CC_BUILD_OPENAL``` - use OpenAL
- ```CC_BUILD_NOAUDIO``` - stub audio implementation (silent)

### 3D Graphics
Texturing, depth buffer, alpha, etc (See Graphics.h for full list)
@@ -128,7 +124,6 @@ Define:
HTTP, HTTPS, and setting request/getting response headers

Define:
- ```CC_BUILD_WININET``` - use WinINet for http (Windows)
- ```CC_BUILD_CURL``` - use libcurl for http

Supporting connection reuse is highly recommended. (but not required)
@@ -16,7 +16,7 @@
int Audio_SoundsVolume, Audio_MusicVolume;

/* TODO: Fix for android */
#if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID
#if defined CC_BUILD_NOAUDIO
/* Can't use mojang's sounds or music assets, so just stub everything out */
static void Audio_Init(void) { }
static void Audio_Free(void) { }
@@ -155,6 +155,7 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
#define CC_BUILD_GLMODERN
#define CC_BUILD_GLES
#define CC_BUILD_TOUCH
#define CC_BUILD_NOAUDIO
#elif defined __linux__
#define CC_BUILD_LINUX
#define CC_BUILD_POSIX
@@ -207,8 +208,8 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
#define CC_BUILD_GL
#define CC_BUILD_GLMODERN
#define CC_BUILD_GLES
#define CC_BUILD_WEBCANVAS
#define CC_BUILD_TOUCH
#define CC_BUILD_NOAUDIO
#endif
#endif

@@ -21,7 +21,7 @@ cc_bool Window_Exists, Window_Focused;
const void* Window_Handle;
cc_bool Window_SoftKeyboard;

#ifndef CC_BUILD_WEBCANVAS
#ifndef CC_BUILD_WEB
void Clipboard_RequestText(RequestClipboardCallback callback, void* obj) {
String text; char textBuffer[512];
String_InitArray(text, textBuffer);
@@ -2786,7 +2786,7 @@ void GLContext_SetFpsLimit(cc_bool vsync, float minFrameMs) {
/*########################################################################################################################*
*------------------------------------------------Emscripten canvas window-------------------------------------------------*
*#########################################################################################################################*/
#ifdef CC_BUILD_WEBCANVAS
#ifdef CC_BUILD_WEB
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>
#include <emscripten/key_codes.h>

0 comments on commit f0fc773

Please sign in to comment.
You can’t perform that action at this time.