OpenAL is no more
This commit is contained in:
parent
275bcd3efc
commit
1923507276
25 changed files with 18868 additions and 1893 deletions
|
@ -19,8 +19,5 @@ install:
|
|||
- go version
|
||||
- go env
|
||||
|
||||
before_build:
|
||||
- bash -lc "pacman --noconfirm --needed -Sy mingw-w64-i686-openal"
|
||||
|
||||
build_script:
|
||||
- bash -lc "cd /c/gopath/src/github.com/gen2brain/raylib-go && go get -t ./... && make"
|
||||
|
|
|
@ -5,5 +5,5 @@ go:
|
|||
|
||||
install:
|
||||
- sudo apt-get update -y
|
||||
- sudo apt-get install libopenal-dev libxi-dev libxinerama-dev libxcursor-dev libxxf86vm-dev libxrandr-dev -y
|
||||
- sudo apt-get install libxi-dev libxinerama-dev libxcursor-dev libxxf86vm-dev libxrandr-dev -y
|
||||
- go get -t ./...
|
||||
|
|
21
README.md
21
README.md
|
@ -12,28 +12,24 @@ Golang bindings for [raylib](http://www.raylib.com/), a simple and easy-to-use l
|
|||
|
||||
### Requirements
|
||||
|
||||
* [OpenAL Soft](http://kcat.strangesoft.net/openal.html)
|
||||
NOTE: if you don't need audio you can use `-tags noaudio` during build, OpenAL will not be linked to binary, though none of the audio functions will be available.
|
||||
|
||||
* [GLFW](http://www.glfw.org/) is included as part of the Go package, but you need to make sure you have dependencies installed, see below.
|
||||
|
||||
##### Ubuntu
|
||||
|
||||
apt-get install libopenal-dev libgl1-mesa-dev libxi-dev libxinerama-dev libxcursor-dev libxxf86vm-dev libxrandr-dev
|
||||
apt-get install libgl1-mesa-dev libxi-dev libxinerama-dev libxcursor-dev libxxf86vm-dev libxrandr-dev
|
||||
|
||||
##### Fedora
|
||||
|
||||
dnf install openal-soft-devel mesa-libGL-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel
|
||||
dnf install mesa-libGL-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel
|
||||
|
||||
##### OS X
|
||||
##### macOS
|
||||
|
||||
On OS X system OpenAL framework is used, you need Xcode or Command Line Tools for Xcode.
|
||||
On macOS you need Xcode or Command Line Tools for Xcode.
|
||||
|
||||
##### Windows ([MSYS2](https://msys2.github.io/))
|
||||
##### Windows
|
||||
|
||||
pacman -S mingw-w64-x86_64-openal mingw-w64-x86_64-gcc mingw-w64-x86_64-go git
|
||||
|
||||
On Windows, build binary in MSYS2 shell.
|
||||
On Windows you need C compiler, like [https://mingw-w64.org](Mingw-w64) or [http://tdm-gcc.tdragon.net/](TDM-GCC).
|
||||
You can also build binary in [MSYS2](https://msys2.github.io/) shell.
|
||||
|
||||
##### Android
|
||||
|
||||
|
@ -49,11 +45,10 @@ On Windows, build binary in MSYS2 shell.
|
|||
|
||||
### Build tags
|
||||
|
||||
* `noaudio` - disables audio functions and doesn't link against OpenAL libraries
|
||||
* `noaudio` - disables audio functions
|
||||
* `opengl21` - uses OpenGL 2.1 backend (default is 3.3 on desktop)
|
||||
* `opengl11` - uses OpenGL 1.1 backend (pseudo OpenGL 1.1 style)
|
||||
* `wayland` - builds against Wayland libraries
|
||||
* `static` - links against OpenAL static libraries
|
||||
|
||||
### Documentation
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@ To compile example to shared library you will need [Android NDK](https://develop
|
|||
To build Android apk you will need [Android SDK](http://developer.android.com/sdk/index.html#Other).
|
||||
Download and unpack archives somewhere.
|
||||
|
||||
Go must be cross compiled for android. There is a bootstrap.sh script that you can use to compile Go and OpenAL for android/arm and android/arm64.
|
||||
Go must be cross compiled for android. There is a bootstrap.sh script that you can use to compile Go for android/arm and android/arm64.
|
||||
|
||||
Export path to Android NDK, point to location where you have unpacked archive:
|
||||
|
||||
export ANDROID_NDK_HOME=/opt/android-ndk
|
||||
|
||||
Compile Go, OpenAL and android_native_app_glue, /usr/local is prefix where Go and Android toolchains will be installed:
|
||||
Compile Go and android_native_app_glue, /usr/local is prefix where Go and Android toolchains will be installed:
|
||||
|
||||
./bootstrap.sh /usr/local
|
||||
|
||||
|
|
|
@ -37,10 +37,6 @@ if [[ -z "$GO_VERSION" ]]; then
|
|||
# go1.9.2
|
||||
GO_VERSION=`curl -s https://golang.org/dl/ | grep 'id="go' | head -n1 | awk -F'"' '{print $4}'`
|
||||
fi
|
||||
if [[ -z "$OPENAL_VERSION" ]]; then
|
||||
# 1.18.2
|
||||
OPENAL_VERSION=`curl -s http://kcat.strangesoft.net/openal.html | grep 'tar.bz2' | awk -F'"' '{print $2}' | awk -F'-' '{print $4}' | sed 's/.tar.bz2//'`
|
||||
fi
|
||||
if [[ -z "$NDK_VERSION" ]]; then
|
||||
# r15c
|
||||
NDK_VERSION=`curl -s https://developer.android.com/ndk/downloads/index.html | grep 'id="stable-downloads"' | awk -F'(' '{print $2}' | awk -F')' '{print $1}'`
|
||||
|
@ -114,50 +110,6 @@ cp -r -f ${BUILD_DIR}/go ${INSTALL_PREFIX}
|
|||
|
||||
###################################################
|
||||
|
||||
echo; echo "##### Download OpenAL ${OPENAL_VERSION}"
|
||||
|
||||
cd ${BUILD_DIR} && curl -L --progress-bar http://kcat.strangesoft.net/openal-releases/openal-soft-${OPENAL_VERSION}.tar.bz2 | tar -xj || exit 1
|
||||
|
||||
echo; echo "##### Compile OpenAL ${OPENAL_VERSION}"
|
||||
|
||||
cat << EOF > ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/android-arm.cmake
|
||||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_ANDROID_ARCH arm)
|
||||
set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a)
|
||||
set(TOOLCHAIN_PREFIX arm-linux-androideabi)
|
||||
set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-${MYCC})
|
||||
set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-${MYCXX})
|
||||
set(CMAKE_FIND_ROOT_PATH \${INSTALL_PREFIX}/android-arm)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
EOF
|
||||
|
||||
cat << EOF > ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/android-arm64.cmake
|
||||
set(CMAKE_SYSTEM_NAME Android)
|
||||
set(CMAKE_ANDROID_ARCH arm64)
|
||||
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
|
||||
set(TOOLCHAIN_PREFIX aarch64-linux-android)
|
||||
set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-${MYCC})
|
||||
set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-${MYCXX})
|
||||
set(CMAKE_FIND_ROOT_PATH \${INSTALL_PREFIX}/android-arm64)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
EOF
|
||||
|
||||
mkdir -p ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/build-arm
|
||||
cd ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/build-arm
|
||||
cmake -DLIBTYPE=STATIC -DCMAKE_TOOLCHAIN_FILE=../android-arm.cmake -DCMAKE_C_FLAGS="-DANDROID -D__ANDROID_API__=${API_VERSION_ARM}" -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/android-arm -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=${INSTALL_PREFIX}/android-arm -DALSOFT_NO_CONFIG_UTIL=ON -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF -DALSOFT_TESTS=OFF -DALSOFT_CONFIG=OFF -DALSOFT_HRTF_DEFS=OFF -DALSOFT_AMBDEC_PRESETS=OFF .. || exit 1
|
||||
make -j $(nproc) VERBOSE=1 && make install || exit 1
|
||||
|
||||
mkdir -p ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/build-arm64
|
||||
cd ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/build-arm64
|
||||
cmake -DLIBTYPE=STATIC -DCMAKE_TOOLCHAIN_FILE=../android-arm64.cmake -DCMAKE_C_FLAGS="-DANDROID -D__ANDROID_API__=${API_VERSION_ARM64}" -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/android-arm64 -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=${INSTALL_PREFIX}/android-arm64 -DALSOFT_NO_CONFIG_UTIL=ON -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF -DALSOFT_TESTS=OFF -DALSOFT_CONFIG=OFF -DALSOFT_HRTF_DEFS=OFF -DALSOFT_AMBDEC_PRESETS=OFF .. || exit 1
|
||||
make -j $(nproc) VERBOSE=1 && make install || exit 1
|
||||
|
||||
###################################################
|
||||
|
||||
echo; echo "##### Compile android_native_app_glue"
|
||||
mkdir -p ${BUILD_DIR}/native_app_glue/jni
|
||||
cp -r ${ANDROID_NDK_HOME}/sources/android/native_app_glue/* ${BUILD_DIR}/native_app_glue/jni/
|
||||
|
|
|
@ -9,8 +9,6 @@ GO_OS="linux"
|
|||
GO_ARCH="amd64"
|
||||
GO_VERSION=`curl -s https://golang.org/dl/ | grep 'id="go' | head -n1 | awk -F'"' '{print $4}'`
|
||||
|
||||
OPENAL_VERSION="1.17.2"
|
||||
|
||||
INSTALL_PREFIX="$1"
|
||||
export PATH=${INSTALL_PREFIX}/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:${PATH}
|
||||
|
||||
|
@ -39,23 +37,5 @@ GOROOT_BOOTSTRAP=${BUILD_DIR}/bootstrap/go CC_FOR_TARGET=arm-linux-gnueabihf-gcc
|
|||
|
||||
cp -r -f ${BUILD_DIR}/go ${INSTALL_PREFIX}
|
||||
|
||||
echo "##### Compile OpenAL"
|
||||
|
||||
cd ${BUILD_DIR} && curl -s -L http://kcat.strangesoft.net/openal-releases/openal-soft-${OPENAL_VERSION}.tar.bz2 | tar -xj
|
||||
|
||||
cat << EOF > ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/linux-rpi.cmake
|
||||
set(TOOLCHAIN_PREFIX arm-linux-gnueabihf)
|
||||
set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_FIND_ROOT_PATH \${INSTALL_PREFIX}/gcc-linaro-arm-linux-gnueabihf-raspbian-x64)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
EOF
|
||||
|
||||
mkdir -p ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/build-rpi
|
||||
cd ${BUILD_DIR}/openal-soft-${OPENAL_VERSION}/build-rpi
|
||||
cmake -DLIBTYPE=STATIC -DCMAKE_TOOLCHAIN_FILE=../linux-rpi.cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/gcc-linaro-arm-linux-gnueabihf-raspbian-x64 ..
|
||||
make -j $(nproc) && make install
|
||||
|
||||
echo "##### Remove build directory"
|
||||
rm -rf ${BUILD_DIR}
|
||||
|
|
910
raylib/audio.c
910
raylib/audio.c
File diff suppressed because it is too large
Load diff
|
@ -42,11 +42,11 @@ func NewWaveFromPointer(ptr unsafe.Pointer) Wave {
|
|||
|
||||
// Sound source type
|
||||
type Sound struct {
|
||||
// OpenAL audio source id
|
||||
// Audio source id
|
||||
Source uint32
|
||||
// OpenAL audio buffer id
|
||||
// Audio buffer id
|
||||
Buffer uint32
|
||||
// OpenAL audio format specifier
|
||||
// Audio format specifier
|
||||
Format int32
|
||||
}
|
||||
|
||||
|
@ -77,11 +77,11 @@ type AudioStream struct {
|
|||
SampleSize uint32
|
||||
// Number of channels (1-mono, 2-stereo)
|
||||
Channels uint32
|
||||
// OpenAL audio format specifier
|
||||
// Audio format specifier
|
||||
Format int32
|
||||
// OpenAL audio source id
|
||||
// Audio source id
|
||||
Source uint32
|
||||
// OpenAL audio buffers (double buffering)
|
||||
// Audio buffers (double buffering)
|
||||
Buffers [2]uint32
|
||||
}
|
||||
|
||||
|
@ -334,9 +334,9 @@ func SetMusicPitch(music Music, pitch float32) {
|
|||
|
||||
// SetMusicLoopCount - Set music loop count (loop repeats)
|
||||
// NOTE: If set to -1, means infinite loop
|
||||
func SetMusicLoopCount(music Music, count float32) {
|
||||
func SetMusicLoopCount(music Music, count int32) {
|
||||
cmusic := *(*C.Music)(unsafe.Pointer(&music))
|
||||
ccount := (C.float)(count)
|
||||
ccount := (C.int)(count)
|
||||
C.SetMusicLoopCount(cmusic, ccount)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// +build !noaudio
|
||||
|
||||
/**********************************************************************************************
|
||||
*
|
||||
* raylib.audio - Basic funtionality to work with audio
|
||||
|
|
|
@ -4,8 +4,6 @@ package raylib
|
|||
|
||||
/*
|
||||
#cgo android LDFLAGS: -llog -landroid -lEGL -lGLESv2 -lOpenSLES -lm -landroid_native_app_glue -u ANativeActivity_onCreate
|
||||
#cgo android CFLAGS: -DPLATFORM_ANDROID -DGRAPHICS_API_OPENGL_ES2
|
||||
|
||||
#cgo android,!noaudio LDFLAGS: -lopenal
|
||||
#cgo android CFLAGS: -DPLATFORM_ANDROID -DGRAPHICS_API_OPENGL_ES2 -Iexternal
|
||||
*/
|
||||
import "C"
|
||||
|
|
|
@ -16,14 +16,12 @@ package raylib
|
|||
#include "external/glfw/src/cocoa_time.c"
|
||||
#include "external/glfw/src/cocoa_window.m"
|
||||
#include "external/glfw/src/posix_thread.c"
|
||||
#include "external/glfw/src/posix_time.c"
|
||||
#include "external/glfw/src/nsgl_context.m"
|
||||
#include "external/glfw/src/egl_context.c"
|
||||
#include "external/glfw/src/osmesa_context.c"
|
||||
|
||||
#cgo darwin LDFLAGS: -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -framework CoreFoundation
|
||||
#cgo darwin CFLAGS: -x objective-c -Iexternal/glfw/include -D_GLFW_COCOA -D_GLFW_USE_CHDIR -D_GLFW_USE_MENUBAR -D_GLFW_USE_RETINA -Wno-deprecated-declarations -DPLATFORM_DESKTOP
|
||||
|
||||
#cgo darwin,!noaudio LDFLAGS: -framework OpenAL
|
||||
#cgo darwin CFLAGS: -x objective-c -Iexternal -Iexternal/glfw/include -D_GLFW_COCOA -D_GLFW_USE_CHDIR -D_GLFW_USE_MENUBAR -D_GLFW_USE_RETINA -Wno-deprecated-declarations -DPLATFORM_DESKTOP -DMAL_NO_COREAUDIO
|
||||
|
||||
#cgo darwin,opengl11 CFLAGS: -DGRAPHICS_API_OPENGL_11
|
||||
#cgo darwin,opengl21 CFLAGS: -DGRAPHICS_API_OPENGL_21
|
||||
|
|
|
@ -16,7 +16,6 @@ package raylib
|
|||
#include "external/glfw/src/wl_window.c"
|
||||
#include "external/glfw/src/wayland-pointer-constraints-unstable-v1-client-protocol.c"
|
||||
#include "external/glfw/src/wayland-relative-pointer-unstable-v1-client-protocol.c"
|
||||
#include "external/glfw/src/wayland-idle-inhibit-unstable-v1-client-protocol.c"
|
||||
#endif
|
||||
#ifdef _GLFW_X11
|
||||
#include "external/glfw/src/x11_init.c"
|
||||
|
@ -32,7 +31,7 @@ package raylib
|
|||
#include "external/glfw/src/egl_context.c"
|
||||
#include "external/glfw/src/osmesa_context.c"
|
||||
|
||||
#cgo linux CFLAGS: -Iexternal/glfw/include -DPLATFORM_DESKTOP
|
||||
#cgo linux CFLAGS: -Iexternal -Iexternal/glfw/include -DPLATFORM_DESKTOP
|
||||
|
||||
#cgo linux,!wayland LDFLAGS: -lGL -lm -pthread -ldl -lrt -lX11
|
||||
#cgo linux,wayland LDFLAGS: -lGL -lm -pthread -ldl -lrt -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
|
||||
|
@ -40,11 +39,6 @@ package raylib
|
|||
#cgo linux,!wayland CFLAGS: -D_GLFW_X11
|
||||
#cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND
|
||||
|
||||
#cgo linux,!noaudio LDFLAGS: -lopenal
|
||||
|
||||
#cgo linux,!static CFLAGS: -DSHARED_OPENAL
|
||||
#cgo linux,static CFLAGS: -DAL_LIBTYPE_STATIC
|
||||
|
||||
#cgo linux,opengl11 CFLAGS: -DGRAPHICS_API_OPENGL_11
|
||||
#cgo linux,opengl21 CFLAGS: -DGRAPHICS_API_OPENGL_21
|
||||
#cgo linux,!opengl11,!opengl21 CFLAGS: -DGRAPHICS_API_OPENGL_33
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
package raylib
|
||||
|
||||
/*
|
||||
#cgo linux,arm LDFLAGS: -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -lvcos -lvchiq_arm
|
||||
#cgo linux,arm CFLAGS: -DPLATFORM_RPI -DGRAPHICS_API_OPENGL_ES2 -I/opt/vc/include -I/opt/vc/include/interface/vcos -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
|
||||
|
||||
#cgo linux,arm,!noaudio LDFLAGS: -lopenal
|
||||
#cgo linux,arm LDFLAGS: -lbrcmGLESv2 -lbrcmEGL -lpthread -lrt -lm -lbcm_host -lvcos -lvchiq_arm -ldl
|
||||
#cgo linux,arm CFLAGS: -DPLATFORM_RPI -DGRAPHICS_API_OPENGL_ES2 -Iexternal -I/opt/vc/include -I/opt/vc/include/interface/vcos -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
|
||||
*/
|
||||
import "C"
|
||||
|
|
|
@ -21,12 +21,7 @@ package raylib
|
|||
#include "external/glfw/src/osmesa_context.c"
|
||||
|
||||
#cgo windows LDFLAGS: -lopengl32 -lgdi32 -lwinmm -lole32
|
||||
#cgo windows CFLAGS: -D_GLFW_WIN32 -Iexternal/glfw/include -Iexternal/glfw/deps/mingw -DPLATFORM_DESKTOP
|
||||
|
||||
#cgo windows,!noaudio LDFLAGS: -lopenal
|
||||
|
||||
#cgo windows,!static CFLAGS: -DSHARED_OPENAL
|
||||
#cgo windows,static CFLAGS: -DAL_LIBTYPE_STATIC
|
||||
#cgo windows CFLAGS: -D_GLFW_WIN32 -Iexternal -Iexternal/glfw/include -Iexternal/glfw/deps/mingw -DPLATFORM_DESKTOP
|
||||
|
||||
#cgo windows,opengl11 CFLAGS: -DGRAPHICS_API_OPENGL_11
|
||||
#cgo windows,opengl21 CFLAGS: -DGRAPHICS_API_OPENGL_21
|
||||
|
|
|
@ -3,18 +3,19 @@
|
|||
* raylib.core - Basic functions to manage windows, OpenGL context and input on multiple platforms
|
||||
*
|
||||
* PLATFORMS SUPPORTED:
|
||||
* - Windows (Win32, Win64)
|
||||
* - Linux (tested on Ubuntu)
|
||||
* - FreeBSD
|
||||
* - OSX/macOS
|
||||
* - Android (ARM, ARM64)
|
||||
* - Raspberry Pi (Raspbian)
|
||||
* - HTML5 (Chrome, Firefox)
|
||||
* PLATFORM_DESKTOP: Windows (Win32, Win64)
|
||||
* PLATFORM_DESKTOP: Linux (32 and 64 bit)
|
||||
* PLATFORM_DESKTOP: OSX/macOS
|
||||
* PLATFORM_DESKTOP: FreeBSD
|
||||
* PLATFORM_ANDROID: Android (ARM, ARM64)
|
||||
* PLATFORM_RPI: Raspberry Pi (Raspbian)
|
||||
* PLATFORM_WEB: HTML5 (Chrome, Firefox)
|
||||
* PLATFORM_UWP: Universal Windows Platform
|
||||
*
|
||||
* CONFIGURATION:
|
||||
*
|
||||
* #define PLATFORM_DESKTOP
|
||||
* Windowing and input system configured for desktop platforms: Windows, Linux, OSX, FreeBSD (managed by GLFW3 library)
|
||||
* Windowing and input system configured for desktop platforms: Windows, Linux, OSX, FreeBSD
|
||||
* NOTE: Oculus Rift CV1 requires PLATFORM_DESKTOP for mirror rendering - View [rlgl] module to enable it
|
||||
*
|
||||
* #define PLATFORM_ANDROID
|
||||
|
@ -22,8 +23,8 @@
|
|||
* NOTE: OpenGL ES 2.0 is required and graphic device is managed by EGL
|
||||
*
|
||||
* #define PLATFORM_RPI
|
||||
* Windowing and input system configured for Raspberry Pi (tested on Raspbian), graphic device is managed by EGL
|
||||
* and inputs are processed is raw mode, reading from /dev/input/
|
||||
* Windowing and input system configured for Raspberry Pi i native mode (no X.org required, tested on Raspbian),
|
||||
* graphic device is managed by EGL and inputs are processed is raw mode, reading from /dev/input/
|
||||
*
|
||||
* #define PLATFORM_WEB
|
||||
* Windowing and input system configured for HTML5 (run on browser), code converted from C to asm.js
|
||||
|
@ -49,15 +50,15 @@
|
|||
* Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* GLFW3 - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX)
|
||||
* raymath - 3D math functionality (Vector3, Matrix, Quaternion)
|
||||
* rglfw - Manage graphic device, OpenGL context and inputs on PLATFORM_DESKTOP (Windows, Linux, OSX. FreeBSD)
|
||||
* raymath - 3D math functionality (Vector2, Vector3, Matrix, Quaternion)
|
||||
* camera - Multiple 3D camera modes (free, orbital, 1st person, 3rd person)
|
||||
* gestures - Gestures system for touch-ready devices (or simulated from mouse inputs)
|
||||
*
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2014-2018 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* 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.
|
||||
|
@ -88,6 +89,11 @@
|
|||
|
||||
#include "raylib.h"
|
||||
|
||||
#if (defined(__linux__) || defined(PLATFORM_WEB)) && _POSIX_S_SOURCE < 199309L
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.
|
||||
#endif
|
||||
|
||||
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
|
||||
#include "utils.h" // Required for: fopen() Android mapping
|
||||
|
||||
|
@ -110,10 +116,6 @@
|
|||
#include "external/rgif.h" // Support GIF recording
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(PLATFORM_WEB)
|
||||
/*#define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.*/
|
||||
#endif
|
||||
|
||||
#include <stdio.h> // Standard input / output lib
|
||||
#include <stdlib.h> // Required for: malloc(), free(), rand(), atexit()
|
||||
#include <stdint.h> // Required for: typedef unsigned long long int uint64_t, used by hi-res timer
|
||||
|
@ -151,7 +153,6 @@
|
|||
//#define GLFW_DLL // Using GLFW DLL on Windows -> No, we use static version!
|
||||
|
||||
#if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
|
||||
// NOTE: Those functions require linking with winmm library
|
||||
__stdcall unsigned int timeBeginPeriod(unsigned int uPeriod);
|
||||
__stdcall unsigned int timeEndPeriod(unsigned int uPeriod);
|
||||
#endif
|
||||
|
@ -413,7 +414,7 @@ static void *GamepadThread(void *arg); // Mouse reading thread
|
|||
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
||||
void InitWindow(int width, int height, void *data)
|
||||
{
|
||||
TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
|
||||
TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
|
||||
|
||||
// Input data is window title char data
|
||||
windowTitle = (char *)data;
|
||||
|
@ -477,7 +478,7 @@ void InitWindow(int width, int height, void *data)
|
|||
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
||||
void InitWindow(int width, int height, void *data)
|
||||
{
|
||||
TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
|
||||
TraceLog(LOG_INFO, "Initializing raylib (v1.9-dev)");
|
||||
|
||||
screenWidth = width;
|
||||
screenHeight = height;
|
||||
|
|
4163
raylib/external/dr_flac.h
vendored
4163
raylib/external/dr_flac.h
vendored
File diff suppressed because it is too large
Load diff
3455
raylib/external/dr_wav.h
vendored
Normal file
3455
raylib/external/dr_wav.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
11601
raylib/external/mini_al.h
vendored
Normal file
11601
raylib/external/mini_al.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -140,17 +140,25 @@ float GetGesturePinchAngle(void); // Get gesture pinch ang
|
|||
|
||||
#if defined(GESTURES_IMPLEMENTATION)
|
||||
|
||||
#include <math.h> // Required for: atan2(), sqrt()
|
||||
#include <stdint.h> // Required for: uint64_t
|
||||
|
||||
#if defined(_WIN32)
|
||||
// Functions required to query time on Windows
|
||||
int __stdcall QueryPerformanceCounter(unsigned long long int *lpPerformanceCount);
|
||||
int __stdcall QueryPerformanceFrequency(unsigned long long int *lpFrequency);
|
||||
#elif defined(__linux__)
|
||||
//#define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.
|
||||
#if _POSIX_C_SOURCE < 199309L
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199309L // Required for CLOCK_MONOTONIC if compiled with c99 without gnu ext.
|
||||
#endif
|
||||
#include <sys/time.h> // Required for: timespec
|
||||
#include <time.h> // Required for: clock_gettime()
|
||||
|
||||
#include <math.h> // Required for: atan2(), sqrt()
|
||||
#include <stdint.h> // Required for: uint64_t
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) // macOS also defines __MACH__
|
||||
#include <mach/clock.h> // Required for: clock_get_time()
|
||||
#include <mach/mach.h> // Required for: mach_timespec_t
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -529,6 +537,22 @@ static double GetCurrentTime(void)
|
|||
time = ((double)nowTime/1000000.0); // Time in miliseconds
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
//#define CLOCK_REALTIME CALENDAR_CLOCK
|
||||
//#define CLOCK_MONOTONIC SYSTEM_CLOCK
|
||||
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t now;
|
||||
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
|
||||
|
||||
// NOTE: OS X does not have clock_gettime(), using clock_get_time()
|
||||
clock_get_time(cclock, &now);
|
||||
mach_port_deallocate(mach_task_self(), cclock);
|
||||
uint64_t nowTime = (uint64_t)now.tv_sec*1000000000LLU + (uint64_t)now.tv_nsec; // Time in nanoseconds
|
||||
|
||||
time = ((double)nowTime/1000000.0); // Time in miliseconds
|
||||
#endif
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
|
4
raylib/mini_al.c
Normal file
4
raylib/mini_al.c
Normal file
|
@ -0,0 +1,4 @@
|
|||
// The implementation of mini_al needs to #include windows.h which means it needs to go into
|
||||
// it's own translation unit. Not doing this will cause conflicts with CloseWindow(), etc.
|
||||
#define MAL_IMPLEMENTATION
|
||||
#include "mini_al.h"
|
|
@ -1,23 +1,23 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib v1.8.0
|
||||
* raylib v1.9-dev
|
||||
*
|
||||
* A simple and easy-to-use library to learn videogames programming (www.raylib.com)
|
||||
*
|
||||
* FEATURES:
|
||||
* - Written in plain C code (C99) in PascalCase/camelCase notation
|
||||
* - Multiple platforms support: Windows, Linux, Mac, Android, Raspberry Pi and HTML5
|
||||
* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES 2.0)
|
||||
* - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2 - choose at compile)
|
||||
* - Unique OpenGL abstraction layer (usable as standalone module): [rlgl]
|
||||
* - Powerful fonts module with SpriteFonts support (XNA bitmap fonts, AngelCode fonts, TTF)
|
||||
* - Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC)
|
||||
* - Basic 3d support for Geometrics, Models, Billboards, Heightmaps and Cubicmaps
|
||||
* - Powerful fonts module with SpriteFonts support (XNA fonts, AngelCode fonts, TTF)
|
||||
* - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC)
|
||||
* - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
|
||||
* - Flexible Materials system, supporting classic maps and PBR maps
|
||||
* - Shaders support, including Model shaders and Postprocessing shaders
|
||||
* - Powerful math module for Vector2, Vector3, Matrix and Quaternion operations: [raymath]
|
||||
* - Audio loading and playing with streaming support and mixing channels: [audio]
|
||||
* - VR stereo rendering support with configurable HMD device parameters
|
||||
* - Minimal external dependencies (GLFW3, OpenGL, OpenAL)
|
||||
* - Powerful math module for Vector, Matrix and Quaternion operations: [raymath]
|
||||
* - Audio loading and playing with streaming support (WAV, OGG, FLAC, XM, MOD)
|
||||
* - Multiple platforms support: Windows, Linux, FreeBSD, MacOS, UWP, Android, Raspberry Pi, HTML5.
|
||||
* - VR stereo rendering with configurable HMD device parameters
|
||||
* - NO external dependencies, all required libraries included with raylib
|
||||
* - Complete bindings to LUA (raylib-lua) and Go (raylib-go)
|
||||
*
|
||||
* NOTES:
|
||||
|
@ -25,17 +25,17 @@
|
|||
* If using OpenGL 3.3 or ES2, one default shader is loaded automatically (internally defined) [rlgl]
|
||||
* If using OpenGL 3.3 or ES2, several vertex buffers (VAO/VBO) are created to manage lines-triangles-quads
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* GLFW3 (www.glfw.org) for window/context management and input [core]
|
||||
* GLAD for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl]
|
||||
* OpenAL Soft for audio device/context management [audio]
|
||||
* DEPENDENCIES (included):
|
||||
* rglfw (github.com/glfw/glfw) for window/context management and input (only PLATFORM_DESKTOP) [core]
|
||||
* glad (github.com/Dav1dde/glad) for OpenGL extensions loading (3.3 Core profile, only PLATFORM_DESKTOP) [rlgl]
|
||||
* mini_al (github.com/dr-soft/mini_al) for audio device/context management [audio]
|
||||
*
|
||||
* OPTIONAL DEPENDENCIES:
|
||||
* stb_image (Sean Barret) for images loading (JPEG, PNG, BMP, TGA) [textures]
|
||||
* OPTIONAL DEPENDENCIES (included):
|
||||
* stb_image (Sean Barret) for images loading (BMP, TGA, PNG, JPEG, HDR...) [textures]
|
||||
* stb_image_resize (Sean Barret) for image resizing algorythms [textures]
|
||||
* stb_image_write (Sean Barret) for image writting (PNG) [utils]
|
||||
* stb_truetype (Sean Barret) for ttf fonts loading [text]
|
||||
* stb_vorbis (Sean Barret) for ogg audio loading [audio]
|
||||
* stb_vorbis (Sean Barret) for OGG audio loading [audio]
|
||||
* stb_perlin (Sean Barret) for Perlin noise image generation [textures]
|
||||
* par_shapes (Philip Rideout) for parametric 3d shapes generation [models]
|
||||
* jar_xm (Joshua Reisenauer) for XM audio module loading [audio]
|
||||
|
@ -50,7 +50,7 @@
|
|||
* raylib is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright (c) 2013-2017 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2013-2018 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* 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.
|
||||
|
@ -470,6 +470,8 @@ typedef struct Wave {
|
|||
|
||||
// Sound source type
|
||||
typedef struct Sound {
|
||||
void* audioBuffer; // A pointer to internal data used by the audio system.
|
||||
|
||||
unsigned int source; // OpenAL audio source id
|
||||
unsigned int buffer; // OpenAL audio buffer id
|
||||
int format; // OpenAL audio format specifier
|
||||
|
@ -486,6 +488,8 @@ typedef struct AudioStream {
|
|||
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
|
||||
unsigned int channels; // Number of channels (1-mono, 2-stereo)
|
||||
|
||||
void* audioBuffer; // A pointer to internal data used by the audio system.
|
||||
|
||||
int format; // OpenAL audio format specifier
|
||||
unsigned int source; // OpenAL audio source id
|
||||
unsigned int buffers[2]; // OpenAL audio buffers (double buffering)
|
||||
|
@ -1126,7 +1130,7 @@ RLAPI void ResumeMusicStream(Music music); // Resume
|
|||
RLAPI bool IsMusicPlaying(Music music); // Check if music is playing
|
||||
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
|
||||
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
|
||||
RLAPI void SetMusicLoopCount(Music music, float count); // Set music loop count (loop repeats)
|
||||
RLAPI void SetMusicLoopCount(Music music, int count); // Set music loop count (loop repeats)
|
||||
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
|
||||
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)
|
||||
|
||||
|
@ -1139,7 +1143,10 @@ RLAPI bool IsAudioBufferProcessed(AudioStream stream); // Check i
|
|||
RLAPI void PlayAudioStream(AudioStream stream); // Play audio stream
|
||||
RLAPI void PauseAudioStream(AudioStream stream); // Pause audio stream
|
||||
RLAPI void ResumeAudioStream(AudioStream stream); // Resume audio stream
|
||||
RLAPI bool IsAudioStreamPlaying(AudioStream stream); // Check if audio stream is playing
|
||||
RLAPI void StopAudioStream(AudioStream stream); // Stop audio stream
|
||||
RLAPI void SetAudioStreamVolume(AudioStream stream, float volume); // Set volume for audio stream (1.0 is max level)
|
||||
RLAPI void SetAudioStreamPitch(AudioStream stream, float pitch); // Set pitch for audio stream (1.0 is base level)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -191,8 +191,8 @@ RMDEF void QuaternionNormalize(Quaternion *q); // Normalize pro
|
|||
RMDEF void QuaternionInvert(Quaternion *quat); // Invert provided quaternion
|
||||
RMDEF Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2); // Calculate two quaternion multiplication
|
||||
RMDEF Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount); // Calculate linear interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount); // Calculates spherical linear interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount); // Calculate slerp-optimized interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount); // Calculates spherical linear interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to); // Calculate quaternion based on the rotation from one vector to another
|
||||
RMDEF Quaternion QuaternionFromMatrix(Matrix matrix); // Returns a quaternion for a given rotation matrix
|
||||
RMDEF Matrix QuaternionToMatrix(Quaternion q); // Returns a matrix for a given quaternion
|
||||
|
@ -1083,6 +1083,15 @@ RMDEF Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Calculate slerp-optimized interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
{
|
||||
Quaternion result = QuaternionLerp(q1, q2, amount);
|
||||
QuaternionNormalize(&result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Calculates spherical linear interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
{
|
||||
|
@ -1119,15 +1128,6 @@ RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Calculate slerp-optimized interpolation between two quaternions
|
||||
RMDEF Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount)
|
||||
{
|
||||
Quaternion result = QuaternionLerp(q1, q2, amount);
|
||||
QuaternionNormalize(&result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Calculate quaternion based on the rotation from one vector to another
|
||||
RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to)
|
||||
{
|
||||
|
|
|
@ -3362,8 +3362,8 @@ static void SetShaderDefaultLocations(Shader *shader)
|
|||
// Get handles to GLSL uniform locations (fragment shader)
|
||||
shader->locs[LOC_COLOR_DIFFUSE] = glGetUniformLocation(shader->id, "colDiffuse");
|
||||
shader->locs[LOC_MAP_DIFFUSE] = glGetUniformLocation(shader->id, "texture0");
|
||||
shader->locs[LOC_MAP_NORMAL] = glGetUniformLocation(shader->id, "texture1");
|
||||
shader->locs[LOC_MAP_SPECULAR] = glGetUniformLocation(shader->id, "texture2");
|
||||
shader->locs[LOC_MAP_SPECULAR] = glGetUniformLocation(shader->id, "texture1");
|
||||
shader->locs[LOC_MAP_NORMAL] = glGetUniformLocation(shader->id, "texture2");
|
||||
}
|
||||
|
||||
// Unload default shader
|
||||
|
|
|
@ -884,10 +884,9 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in
|
|||
stbtt_GetFontVMetrics(&fontInfo, &ascent, 0, 0);
|
||||
baseline = (int)(ascent*scale);
|
||||
|
||||
|
||||
if (fontChars[0] != 32) TraceLog(LOG_WARNING, "TTF spritefont loading: first character is not SPACE(32) character");
|
||||
|
||||
// NOTE: Using stb_truetype crappy packing method, no guarante the font fits the image...
|
||||
// NOTE: Using stb_truetype crappy packing method, no guarantee the font fits the image...
|
||||
// TODO: Replace this function by a proper packing method and support random chars order,
|
||||
// we already receive a list (fontChars) with the ordered expected characters
|
||||
int result = stbtt_BakeFontBitmap(ttfBuffer, 0, fontSize, dataBitmap, textureSize, textureSize, fontChars[0], charsCount, charData);
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
#define SUPPORT_FILEFORMAT_PNG
|
||||
#define SUPPORT_FILEFORMAT_DDS
|
||||
#define SUPPORT_FILEFORMAT_HDR
|
||||
#define SUPPORT_FILEFORMAT_KTX
|
||||
#define SUPPORT_FILEFORMAT_ASTC
|
||||
#define SUPPORT_IMAGE_MANIPULATION
|
||||
#define SUPPORT_IMAGE_GENERATION
|
||||
//-------------------------------------------------
|
||||
|
@ -536,14 +538,13 @@ Image GetTextureData(Texture2D texture)
|
|||
{
|
||||
image.width = texture.width;
|
||||
image.height = texture.height;
|
||||
image.format = texture.format;
|
||||
image.mipmaps = 1;
|
||||
|
||||
if (rlGetVersion() == OPENGL_ES_20)
|
||||
{
|
||||
// NOTE: Data retrieved on OpenGL ES 2.0 comes as RGBA (from framebuffer)
|
||||
image.format = UNCOMPRESSED_R8G8B8A8;
|
||||
}
|
||||
else image.format = texture.format;
|
||||
// NOTE: Data retrieved on OpenGL ES 2.0 should be RGBA
|
||||
// coming from FBO color buffer, but it seems original
|
||||
// texture format is retrieved on RPI... weird...
|
||||
//image.format = UNCOMPRESSED_R8G8B8A8;
|
||||
|
||||
TraceLog(LOG_INFO, "Texture pixel data obtained successfully");
|
||||
}
|
||||
|
@ -622,9 +623,9 @@ void ImageFormat(Image *image, int newFormat)
|
|||
|
||||
for (int i = 0; i < image->width*image->height; i++)
|
||||
{
|
||||
r = (unsigned char)(round((float)pixels[k].r*31/255));
|
||||
g = (unsigned char)(round((float)pixels[k].g*63/255));
|
||||
b = (unsigned char)(round((float)pixels[k].b*31/255));
|
||||
r = (unsigned char)(round((float)pixels[i].r*31.0f/255));
|
||||
g = (unsigned char)(round((float)pixels[i].g*63.0f/255));
|
||||
b = (unsigned char)(round((float)pixels[i].b*31.0f/255));
|
||||
|
||||
((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 5 | (unsigned short)b;
|
||||
}
|
||||
|
@ -655,9 +656,9 @@ void ImageFormat(Image *image, int newFormat)
|
|||
|
||||
for (int i = 0; i < image->width*image->height; i++)
|
||||
{
|
||||
r = (unsigned char)(round((float)pixels[i].r*31/255));
|
||||
g = (unsigned char)(round((float)pixels[i].g*31/255));
|
||||
b = (unsigned char)(round((float)pixels[i].b*31/255));
|
||||
r = (unsigned char)(round((float)pixels[i].r*31.0f/255));
|
||||
g = (unsigned char)(round((float)pixels[i].g*31.0f/255));
|
||||
b = (unsigned char)(round((float)pixels[i].b*31.0f/255));
|
||||
a = (pixels[i].a > ALPHA_THRESHOLD) ? 1 : 0;
|
||||
|
||||
((unsigned short *)image->data)[i] = (unsigned short)r << 11 | (unsigned short)g << 6 | (unsigned short)b << 1 | (unsigned short)a;
|
||||
|
@ -675,10 +676,10 @@ void ImageFormat(Image *image, int newFormat)
|
|||
|
||||
for (int i = 0; i < image->width*image->height; i++)
|
||||
{
|
||||
r = (unsigned char)(round((float)pixels[i].r*15/255));
|
||||
g = (unsigned char)(round((float)pixels[i].g*15/255));
|
||||
b = (unsigned char)(round((float)pixels[i].b*15/255));
|
||||
a = (unsigned char)(round((float)pixels[i].a*15/255));
|
||||
r = (unsigned char)(round((float)pixels[i].r*15.0f/255));
|
||||
g = (unsigned char)(round((float)pixels[i].g*15.0f/255));
|
||||
b = (unsigned char)(round((float)pixels[i].b*15.0f/255));
|
||||
a = (unsigned char)(round((float)pixels[i].a*15.0f/255));
|
||||
|
||||
((unsigned short *)image->data)[i] = (unsigned short)r << 12 | (unsigned short)g << 8 | (unsigned short)b << 4 | (unsigned short)a;
|
||||
}
|
||||
|
@ -801,7 +802,7 @@ void ImageToPOT(Image *image, Color fillColor)
|
|||
// Copy an image to a new image
|
||||
Image ImageCopy(Image image)
|
||||
{
|
||||
Image newImage;
|
||||
Image newImage = { 0 };
|
||||
|
||||
int byteSize = image.width*image.height;
|
||||
|
||||
|
@ -1087,7 +1088,8 @@ Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing
|
|||
ImageDraw(&imText, imFont, letter.rec, (Rectangle){ posX + letter.offsetX,
|
||||
letter.offsetY, letter.rec.width, letter.rec.height });
|
||||
|
||||
posX += letter.advanceX + spacing;
|
||||
if (letter.advanceX == 0) posX += letter.rec.width + spacing;
|
||||
else posX += letter.advanceX + spacing;
|
||||
}
|
||||
|
||||
UnloadImage(imFont);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue