gs_ffmpeg

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README

commit 1653030857b162fc8218b44c2080f3a56230bf2b
Author: Samdal <samdal@protonmail.com>
Date:   Thu,  1 Dec 2022 22:38:53 +0100

initial commit

Diffstat:
A.gitignore | 5+++++
A.gitmodules | 3+++
AREADME.md | 35+++++++++++++++++++++++++++++++++++
Abin/.obj/gs.d | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Abin/.obj/gs.o | 0
Abin/.obj/main.d | 1+
Abin/.obj/main.o | 0
Abin/.obj/main2.d | 1+
Abin/.obj/main2.o | 0
Abin/App | 0
Aproc/html5/emcc.sh | 33+++++++++++++++++++++++++++++++++
Aproc/linux/Makefile | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aproc/linux/gcc.sh | 27+++++++++++++++++++++++++++
Aproc/linux/gcc_dbg.sh | 28++++++++++++++++++++++++++++
Aproc/linux/gcc_rdbg.sh | 28++++++++++++++++++++++++++++
Aproc/linux/gcc_rel.sh | 28++++++++++++++++++++++++++++
Aproc/osx/gcc.sh | 39+++++++++++++++++++++++++++++++++++++++
Aproc/osx/gcc_dbg.sh | 40++++++++++++++++++++++++++++++++++++++++
Aproc/osx/gcc_rdbg.sh | 40++++++++++++++++++++++++++++++++++++++++
Aproc/osx/gcc_rel.sh | 40++++++++++++++++++++++++++++++++++++++++
Aproc/scons/SConstruct | 155+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aproc/sublime_text/gs_project.sublime-project | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aproc/sublime_text/gs_project.sublime-workspace | 1112+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aproc/win/cl.bat | 35+++++++++++++++++++++++++++++++++++
Aproc/win/mingw.sh | 40++++++++++++++++++++++++++++++++++++++++
Aproc/win/mingw_cross_platform.sh | 39+++++++++++++++++++++++++++++++++++++++
Aproc/win/mingw_dbg.sh | 41+++++++++++++++++++++++++++++++++++++++++
Aproc/win/mingw_rdbg.sh | 41+++++++++++++++++++++++++++++++++++++++++
Aproc/win/mingw_rel.sh | 41+++++++++++++++++++++++++++++++++++++++++
Asource/gs.c | 8++++++++
Asource/gs_avdecode.h | 288+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asource/main.c | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Athird_party/include/gs | 1+
33 files changed, 2410 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,5 @@ +*.mp4 +*.mkv +*.mov +*.m4v +*.webm diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "third_party/include/gs"] + path = third_party/include/gs + url = https://github.com/mrfrenik/gunslinger diff --git a/README.md b/README.md @@ -0,0 +1,35 @@ +Maybe more stuff will come here.... + + + +### The following is the license of Gunslinger and its project template and examples + +BSD 3-Clause License + +Copyright (c) 2021, John Jackson +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/bin/.obj/gs.d b/bin/.obj/gs.d @@ -0,0 +1,70 @@ +../../bin/.obj/gs.o: ../../source/gs.c ../../source/../third_party/include/gs/gs.h \ + ../../source/../third_party/include/gs/external/minicoro/minicoro.h \ + ../../source/../third_party/include/gs/impl/gs_platform_impl.h \ + ../../source/../third_party/include/gs/impl/../external/glad/glad_impl.h \ + ../../source/../third_party/include/gs/impl/../external/glad/glad.h \ + ../../source/../third_party/include/gs/impl/../external/glad/../KHR/khrplatform.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/glfw_impl.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/glfw3.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/context.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/internal.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/x11_platform.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/posix_thread.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/posix_time.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/xkb_unicode.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/glx_context.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/egl_context.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/osmesa_context.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/linux_joystick.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/init.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/mappings.h \ + ../../source/../third_party/include/gs/impl/../external/glfw/input.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/monitor.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/vulkan.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/window.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/x11_init.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/x11_monitor.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/x11_window.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/glx_context.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/linux_joystick.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/posix_thread.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/posix_time.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/xkb_unicode.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/egl_context.c \ + ../../source/../third_party/include/gs/impl/../external/glfw/osmesa_context.c \ + ../../source/../third_party/include/gs/impl/gs_graphics_impl.h \ + ../../source/../third_party/include/gs/impl/gs_audio_impl.h \ + ../../source/../third_party/include/gs/impl/../external/stb/stb_vorbis.c \ + ../../source/../third_party/include/gs/impl/../external/dr_libs/dr_wav.h \ + ../../source/../third_party/include/gs/impl/../external/dr_libs/dr_mp3.h \ + ../../source/../third_party/include/gs/impl/../external/miniaudio/miniaudio.h \ + ../../source/../third_party/include/gs/external/sg_noise/sg_noise.h \ + ../../source/../third_party/include/gs/external/stb/stb_truetype.h \ + ../../source/../third_party/include/gs/external/stb/stb_image.h \ + ../../source/../third_party/include/gs/external/cgltf/cgltf.h \ + ../../source/../third_party/include/gs/util/gs_idraw.h \ + ../../source/../third_party/include/gs/util/gs_gui.h \ + ../../source/../third_party/include/gs/util/gs_physics.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_vec3.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_compiler.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_config.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_export.h \ + ../../source/../third_party/include/gs/util/../external/ccd/libccd.c \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_vec3.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_quat.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_vec3.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_vec3.c \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_vec3.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_dbg.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_support.c \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_support.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_polytope.c \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_polytope.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_list.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd/ccd_compiler.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_alloc.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_mpr.c \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd_simplex.h \ + ../../source/../third_party/include/gs/util/../external/ccd/src/ccd.c diff --git a/bin/.obj/gs.o b/bin/.obj/gs.o Binary files differ. diff --git a/bin/.obj/main.d b/bin/.obj/main.d @@ -0,0 +1 @@ +../../bin/.obj/main.o: ../../source/main.c ../../source/gs_avdecode.h diff --git a/bin/.obj/main.o b/bin/.obj/main.o Binary files differ. diff --git a/bin/.obj/main2.d b/bin/.obj/main2.d @@ -0,0 +1 @@ +../../bin/.obj/main2.o: ../../source/main2.c diff --git a/bin/.obj/main2.o b/bin/.obj/main2.o Binary files differ. diff --git a/bin/App b/bin/App Binary files differ. diff --git a/proc/html5/emcc.sh b/proc/html5/emcc.sh @@ -0,0 +1,33 @@ +#!bin/sh + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -w -s WASM=1 -s USE_WEBGL2=1 -s ASYNCIFY=1 -O1 +) + +# Include directories +inc=( + -I ../third_party/include/ # Gunslinger includes +) + +# Source files +src=( + ../source/*.c +) + +libs=( +) + +# Build +emcc ${inc[*]} ${src[*]} ${flags[*]} -o $proj_name.html + +cd .. + + + diff --git a/proc/linux/Makefile b/proc/linux/Makefile @@ -0,0 +1,55 @@ +# Makefile for C projects + +# options +CC = gcc +LINKER = $(CC) +CFLAGS = -O0 -pthread -g -std=gnu99 +LFLAGS = -ldl -lX11 -lXi -lm -lpthread -lavcodec -lavformat -lavcodec -lswresample -lswscale -lavutil -lm + +TARGET = App + +# directories +SRC_DIR = ../../source +BIN_DIR = ../../bin +INCLUDE = -I../../third_party/include +OBJ_DIR = $(BIN_DIR)/.obj + +# finds source files two directories deep +SOURCES = $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/*/*.c) +OBJECTS = $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) +DEPENDS = $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.d) + +.PHONY: all build run clean + +all: build + +build: $(BIN_DIR) $(DEPENDS) $(BIN_DIR)/$(TARGET) + +$(BIN_DIR): + mkdir -p $@ + +# update dependencies +$(OBJ_DIR)/%.d : $(SRC_DIR)/%.c + @mkdir -p $(@D) + @echo -n "$(@D)/" > $@ + @$(CC) $(CFLAGS) -MM $< | sed "s/ /\t/" >> $@; + @echo "Updating dependencies for $<" + +# add dependencies +include $(DEPENDS) + +# compile +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + @mkdir -p $(@D) + $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@ + +# link +$(BIN_DIR)/$(TARGET): $(OBJECTS) + $(LINKER) $(OBJECTS) $(LFLAGS) -o $@ + +run: build + ./$(BIN_DIR)/$(TARGET) + +clean: + rm -f $(OBJECTS) $(GS_OBJ) + rm -f $(BIN_DIR)/$(TARGET) diff --git a/proc/linux/gcc.sh b/proc/linux/gcc.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w -ldl -lGL -lX11 -pthread -lXi +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/*.c +) + +# Build +gcc ${inc[*]} -g -O0 ${src[*]} ${flags[*]} -lm -o ${proj_name} + +cd .. diff --git a/proc/linux/gcc_dbg.sh b/proc/linux/gcc_dbg.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w -ldl -lGL -lX11 -pthread -lXi +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +# Build +echo gcc -O0 ${inc[*]} ${src[*]} ${flags[*]} -lm -o ${proj_name} +gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} -lm -o ${proj_name} + +cd .. diff --git a/proc/linux/gcc_rdbg.sh b/proc/linux/gcc_rdbg.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w -ldl -lGL -lX11 -pthread -lXi +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +# Build +echo gcc -O1 ${inc[*]} ${src[*]} ${flags[*]} -lm -o ${proj_name} +gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} -lm -o ${proj_name} + +cd .. diff --git a/proc/linux/gcc_rel.sh b/proc/linux/gcc_rel.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w -ldl -lGL -lX11 -pthread -lXi +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +# Build +echo gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} -lm -o ${proj_name} +gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} -lm -o ${proj_name} + +cd .. diff --git a/proc/osx/gcc.sh b/proc/osx/gcc.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=c99 -x objective-c -O0 -w +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +fworks=( + -framework OpenGL + -framework CoreFoundation + -framework CoreVideo + -framework IOKit + -framework Cocoa + -framework Carbon +) + +# Build +gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} + +cd .. + + + diff --git a/proc/osx/gcc_dbg.sh b/proc/osx/gcc_dbg.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=c99 -x objective-c -O0 -w +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +fworks=( + -framework OpenGL + -framework CoreFoundation + -framework CoreVideo + -framework IOKit + -framework Cocoa + -framework Carbon +) + +# Build +echo gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} +gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} + +cd .. + + + diff --git a/proc/osx/gcc_rdbg.sh b/proc/osx/gcc_rdbg.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=c99 -x objective-c -O1 -w +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +fworks=( + -framework OpenGL + -framework CoreFoundation + -framework CoreVideo + -framework IOKit + -framework Cocoa + -framework Carbon +) + +# Build +echo gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} +gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} + +cd .. + + + diff --git a/proc/osx/gcc_rel.sh b/proc/osx/gcc_rel.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=c99 -x objective-c -O3 -w +) + +# Include directories +inc=( + -I ../third_party/include/ +) + +# Source files +src=( + ../source/main.c +) + +fworks=( + -framework OpenGL + -framework CoreFoundation + -framework CoreVideo + -framework IOKit + -framework Cocoa + -framework Carbon +) + +# Build +echo gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} +gcc ${flags[*]} ${fworks[*]} ${inc[*]} ${src[*]} -o ${proj_name} + +cd .. + + + diff --git a/proc/scons/SConstruct b/proc/scons/SConstruct @@ -0,0 +1,155 @@ +#!/usr/bin/env python +import os +import sys + +# Try to detect the host platform automatically. +# This is used if no `platform` argument is passed +if sys.platform.startswith("linux"): + host_platform = "linux" +elif sys.platform == "darwin": + host_platform = "osx" +elif sys.platform == "win32" or sys.platform == "msys": + host_platform = "windows" +else: + raise ValueError( + "Could not detect platform automatically, please specify with " + "platform=<platform>" + ) + +env = Environment(ENV=os.environ) + +is64 = sys.maxsize > 2 ** 32 +if (env["TARGET_ARCH"] == "amd64" + or env["TARGET_ARCH"] == "emt64" + or env["TARGET_ARCH"] == "x86_64" + or env["TARGET_ARCH"] == "arm64-v8a"): + is64 = True + +opts = Variables([], ARGUMENTS) + +opts.Add( + EnumVariable( + "platform", + "Target platform", + host_platform, + allowed_values=("linux", "osx", "windows"), + ignorecase=2, + ) +) + +opts.Add( + EnumVariable( + "target", + "Compilation target", + "release", + allowed_values=("debug", "release"), + ignorecase=2, + ) +) +opts.Add( + PathVariable("target_path", "The path where the app will be installed", "../../bin/") +) + +opts.Add( + PathVariable("source_path", "The path where the source files lay", "../../source/") +) + +opts.Add( + PathVariable("include_path", "Where your includes are", "../../third_party/include") +) + +opts.Add( + PathVariable("target_name", "The name of the app", "App", PathVariable.PathAccept) +) + +opts.Add( + EnumVariable("bits", "Target platform bits", "64" if is64 else "32", ("32", "64")) +) + +opts.Add( + EnumVariable( + "OpenGL", + "If using OpenGL as backend", + "false", + allowed_values=("false", "true"), + ignorecase=2, + ) +) + +# Create bin folder if it does not exist, it will throw an error +# if any of the paths above is not an actual path. Since the project +# template does not actually have the bin folder, it won't work if you use +# the default unless you create it manually. +# +# feel free to remove this if you don't want the bin folder +os.system("mkdir -p ../../bin/") + +# update options +opts.Update(env) + + +if host_platform == "windows": + env.Append(ENV=os.environ) + if env["bits"] == "64": + env = Environment(TARGET_ARCH="amd64") + elif env["bits"] == "32": + env = Environment(TARGET_ARCH="x86") + opts.Update(env) + +env.Append(CPPPATH=env['include_path']) + +if env["platform"] == "linux": + if env["target"] == "debug": + env.Append(CCFLAGS=["-fPIC", "-g3", "-Og", "-std=gnu99"]) + else: + env.Append(CCFLAGS=["-fPIC", "-O3", "-std=gnu99"]) + env.Append(LINKFLAGS=["-s"]) + + env.Append(LINKFLAGS=["-ldl", "-lX11", "-lXi", "-lm", "-pthread"]) + if env["OpenGL"] == "true": + env.Append(CCFLAGS=["-lGL"]) + +elif env["platform"] == "osx": + if env["target"] == "debug": + env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64", "-std=gnu99", "-objective-c"]) + else: + env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64", "-std=gnu99", "-objective-c"]) + + env.Append(LINKFLAGS=["-arch", "x86_64", "-framework", "CoreFoundation", "-framework", + "CoreVide", "-framework", "IOKit", "-framework", "Cocoa", "-framework", "Carbon"]) + if env["OpenGL"] == "true": + env.Append(CCFLAGS=["-framework", "OpenGL"]) + +elif env["platform"] == "windows": + env.Append(CPPDEFINES=["WIN32", "_WIN32", "_WINDOWS", "_CRT_SECURE_NO_WARNINGS"]) + if env["target"] == "debug": + env.Append(CPPDEFINES=["_DEBUG"]) + env.Append(CCFLAGS=["-MD", "-std=gnu99"]) + env.Append(LINKFLAGS=["-DEBUG"]) + else: + env.Append(CPPDEFINES=["NDEBUG"]) + env.Append(CCFLAGS=["-O2", "-MD", "-std=gnu99"]) + + if env["bits"] == "32" and host_platform == "windows": + env.Append(LINKFLAGS=["kernel32.lib", "user32.lib", "shell32.lib", "vcruntime.lib", "msvcrt.lib", "gdi32.lib", "Advapi32.lib", "winmm.lib"]) + if env["OpenGL"] == "true": + env.Append(LINKFLAGS=["opengl32.lib"]) + else: + env.Append(LINKFLAGS=["-mwindows", "-lkernel32", "-luser32", "-lshell32", "-lgdi32", "-lAdvapi32", "-lwinmm"]) + if env["OpenGL"] == "true": + env.Append(LINKFLAGS=["-lopengl32"]) + + +# Source Files +sources = Glob(f"{env['source_path']}/*.c") +sources += Glob(f"{env['source_path']}/*/*.c") +sources += Glob(f"{env['source_path']}/*.cpp") +sources += Glob(f"{env['source_path']}/*/*.cpp") + +app = env.Program( + target=f"{env['target_path']}{env['platform']}/{env['target_name']}", source=sources +) +Default(app) + +# Generates help for the -h scons option. +Help(opts.GenerateHelpText(env)) diff --git a/proc/sublime_text/gs_project.sublime-project b/proc/sublime_text/gs_project.sublime-project @@ -0,0 +1,63 @@ +{ + "folders": + [ + { + "path": "./../../../gs_project_template" + } + ], + "build_systems": + [ + { + "name": "GS: Build Debug (GCC/MINGW)", + "osx": { + "cmd": ["echo Building... && cd $folder && bash ./proc/osx/gcc_dbg.sh"], + "shell": true + }, + "linux": { + "cmd": ["echo Building... && cd $folder && bash ./proc/linux/gcc_dbg.sh"], + "shell": true + }, + "windows": { + "cmd": ["echo Building... && cd $folder && bash ./proc/win/mingw_dbg.sh"], + "shell": true + } + }, + { + "name": "GS: Build Release (GCC/MINGW)", + "osx": { + "cmd": ["echo Building... && cd $folder && bash ./proc/osx/gcc_rel.sh"], + "shell": true + }, + "linux": { + "cmd": ["echo Building... && cd $folder && bash ./proc/linux/gcc_rel.sh"], + "shell": true + }, + "windows": { + "cmd": ["echo Building... && cd $folder && bash ./proc/win/mingw_rel.sh"], + "shell": true + } + }, + { + "name": "GS: Build Rel-Debug (GCC/MINGW)", + "osx": { + "cmd": ["echo Building... && cd $folder && bash ./proc/osx/gcc_rdbg.sh"], + "shell": true + }, + "linux": { + "cmd": ["echo Building... && cd $folder && bash ./proc/linux/gcc_rdbg.sh"], + "shell": true + }, + "windows": { + "cmd": ["echo Building... && cd $folder && bash ./proc/win/mingw_rdbg.sh"], + "shell": true + } + }, + { + "name": "GS: Run", + "osx": { + "cmd": ["cd $folder && ./bin/App"], + "shell": true + } + } + ] +} diff --git a/proc/sublime_text/gs_project.sublime-workspace b/proc/sublime_text/gs_project.sublime-workspace @@ -0,0 +1,1112 @@ +{ + "auto_complete": + { + "selected_items": + [ + [ + "gs_physics_stackal", + "gs_physics_stack_allocator_t" + ], + [ + "gs_Gfxtpipe", + "gs_gfxt_pipeline_t" + ], + [ + "gs_gfxtrawpip", + "gs_gfxt_raw_pipeline_func_desc_t" + ], + [ + "MOVEMEN", + "ANALOG_HAND_MOVEMENT_QUARTZ" + ], + [ + "MOVMENT", + "ANALOG_HAND_MOVEMENT_QUARTZ" + ], + [ + "GSGRPAH", + "GS_GRAPHICS_PRIMITIVE_TRIANGLES" + ], + [ + "GS_GRAPHICS_SHAD", + "GS_GRAPHICS_SHADER_STAGE_FRAGMENT" + ], + [ + "GS_SHAD", + "GS_SHADERPROGRAM_GEOMETRY" + ], + [ + "GS_SHADER", + "GS_SHADERPROGRAM_FRAGMENT" + ], + [ + "gsrsou", + "gs_resource_cache_get_ptr" + ], + [ + "gs_resour", + "gs_declare_resource_type" + ], + [ + "gs_face_cul", + "gs_face_culling_disabled" + ], + [ + "gs_window", + "gs_winding_order_ccw" + ], + [ + "openglimediated", + "__get_opengl_immediate_data" + ], + [ + "vertex_", + "vertex_3fv" + ], + [ + "gs_slothand", + "gs_slot_array_invalid_handle" + ], + [ + "glfwframebuffersi", + "glfw_frame_buffer_size" + ], + [ + "ENJONDI", + "ENJON_DIR" + ], + [ + "Roboto-Medium", + "Roboto-MediumItalic_14" + ], + [ + "format", + "texture_format" + ], + [ + "gs_asset_sub", + "gs_asset_subsystem_get_raw" + ], + [ + "render_te", + "gui_render_test" + ], + [ + "gs_component_data_ind", + "gs_component_data_index_pool_gs_rotation_component_system" + ], + [ + "gs_component_data_poollist", + "gs_component_data_pool_list" + ], + [ + "gs_component_datapoli", + "gs_component_data_pool_list" + ], + [ + "gs_componentdatast", + "gs_component_data_storage" + ], + [ + "gscomp", + "gs_component" + ], + [ + "gscomponentd", + "gs_component_data_storage" + ], + [ + "gscomponentdat", + "gs_component_data_storage_ptr" + ], + [ + "gs_componetndat", + "gs_component_data_storage_ptr" + ], + [ + "deseri", + "deserialized_texture" + ], + [ + "transform_c", + "transform_component_system_ctor" + ], + [ + "mat4_tra", + "__mat4_translate_impl" + ], + [ + "lexer_require", + "lexer_require_token_type" + ], + [ + "object_seri", + "object_serialize_pod_type" + ], + [ + "data_ch", + "data_chunk" + ], + [ + "data_c", + "data_chunk" + ], + [ + "if", + "ifmain\tif __name__ == '__main__'" + ], + [ + "GetPRoxy", + "GetProxyData" + ], + [ + "HealthCompoe", + "HealthComponentProxy" + ], + [ + "Healthcompr", + "HealthComponentProxy" + ], + [ + "Healthc", + "HealthComponentProxy" + ], + [ + "mRegenra", + "mRegenRate" + ], + [ + "Haelthcom", + "HealthComponentProxy" + ], + [ + "mregenra", + "mRegenRate_InstanceData" + ], + [ + "mregenrate", + "mRegenRate" + ], + [ + "mRegenr", + "mRegenRate" + ], + [ + "attribute", + "attributes" + ], + [ + "mPosion", + "mPosition_InstanceData" + ], + [ + "mHelath", + "mHealth_InstanceData" + ], + [ + "HealthCompon", + "HealthComponent_InstanceData" + ], + [ + "mEntityInst", + "mEntityID_InstanceData" + ], + [ + "Healthcom", + "HealthComponent" + ], + [ + "Healthcompo", + "HealthComponent_InstanceData" + ], + [ + "uno", + "unordered_map\tstandard header (since c++11)" + ], + [ + "tfi", + "tfidfVectors" + ], + [ + "tf", + "tfidfVectors" + ], + [ + "orin", + "originalDocs" + ], + [ + "WFCLAS", + "WF_CLASS_NAME_WatchFace" + ] + ] + }, + "buffers": + [ + ], + "build_system": "", + "build_system_choices": + [ + [ + [ + [ + "Packages/C++ & C Single File Builder - Minghang Yang/C Builder-Minghang Yang.sublime-build", + "" + ], + [ + "Packages/C++ & C Single File Builder - Minghang Yang/C Builder-Minghang Yang.sublime-build", + "Run" + ], + [ + "Packages/C++ & C Single File Builder - Minghang Yang/C Builder-Minghang Yang.sublime-build", + "Build and Run" + ] + ], + [ + "Packages/C++ & C Single File Builder - Minghang Yang/C Builder-Minghang Yang.sublime-build", + "Build and Run" + ] + ], + [ + [ + [ + "Packages/C++/C++ Single File.sublime-build", + "" + ], + [ + "Packages/C++/C++ Single File.sublime-build", + "Run" + ] + ], + [ + "Packages/C++/C++ Single File.sublime-build", + "" + ] + ], + [ + [ + [ + "Packages/C++11/C++11.sublime-build", + "" + ], + [ + "Packages/C++11/C++11.sublime-build", + "Run" + ] + ], + [ + "Packages/C++11/C++11.sublime-build", + "" + ] + ] + ], + "build_varint": "", + "command_palette": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + [ + "pack", + "Package Control: List Packages" + ], + [ + "package", + "Package Control: Install Package" + ], + [ + "package con", + "Package Control: Install Package" + ] + ], + "width": 0.0 + }, + "console": + { + "height": 136.0, + "history": + [ + ] + }, + "distraction_free": + { + "menu_visible": true, + "show_minimap": false, + "show_open_files": false, + "show_tabs": false, + "side_bar_visible": false, + "status_bar_visible": false + }, + "expanded_folders": + [ + "/Users/127885/Documents/gs_projects/gs_project_template" + ], + "file_history": + [ + "/Users/127885/Documents/gs_projects/physics_api_test/third_party/include/gs/util/gs_idraw.h", + "/Users/127885/Documents/gs_projects/physics_api_test/third_party/include/gs/util/gs_physics.h", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/core/fs_complication.h", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/gs_wear_os_platform.h", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/fs_watchface.c", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/fs_entity.c", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/fs_complication.h", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/fs_complication.c", + "/Users/127885/Documents/Work/WatchFaces/fossil-engine/UDroid/app/src/main/cpp/fs_entity.h", + "/Users/127885/Downloads/gs_project_template-main/third_party/include/tinyobj/tinyobj.h", + "/Users/127885/Downloads/gs_project_template-main/assets/ribbon.gltf", + "/Users/127885/Downloads/gs_project_template-main/assets/ribbon.glb", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/util/gs_gfxt.h", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/util/gs_idraw.h", + "/Users/127885/Documents/gs_projects/gs_examples/24_test/source/main.c", + "/Users/127885/Documents/gs_projects/EP01_SandSim/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/24_udroid/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/24_udroid/external/nanovgXC/src/nanovg.c", + "/Users/127885/Documents/gs_projects/gs_examples/24_udroid/external/nanovgXC/src/nanovg.h", + "/Users/127885/Documents/gs_projects/gs_examples/24_udroid/external/nanovgXC/src/nanovg_sw.h", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/impl/gs_platform_impl.h", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/cgltf/cgltf.h", + "/Users/127885/Documents/gs_projects/gs_examples/24_udroid/external/nanovgXC/src/fontstash.h", + "/Users/127885/Documents/gs_projects/gs_examples/24_udroid/proc/osx/gcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/gs.h", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/impl/gs_graphics_impl.h", + "/Users/127885/Documents/gs_projects/test_example/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/14_immediate_draw/source/main.c", + "/Users/127885/Documents/gs_projects/analog_hand_example/proc/osx/gcc.sh", + "/Users/127885/Documents/gs_projects/analog_hand_example/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/analog_hand_example/third_party/include/gs/gs.h", + "/Users/127885/Documents/gs_projects/analog_hand_example/test.bin", + "/Users/127885/Documents/gs_projects/gs_examples/23_marching_cubes/source/tinycthread/source/tinycthread.h", + "/Users/127885/Documents/gs_projects/gs_examples/13_imgui/src/gs_imgui.h", + "/Users/127885/Documents/gs_projects/gs_examples/10_non_interleave_instancing/proc/osx/gcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/01_gs_cpp/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/16_nuklear_gui/source/gs_nuklear.h", + "/Users/127885/Documents/gs_projects/gs_examples/23_marching_cubes/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/23_marching_cubes/source/data.c", + "/Users/127885/Documents/gs_projects/gs_examples/10_non_interleave_instancing/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/21_stencil_test/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/20_uniforms_advanced/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/18_flecs/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/16_nuklear_gui/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/15_meta_class/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/14_immediate_draw/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/10_non_interleave_instancing/proc/html5/emcc.sh", + "/Users/127885/Documents/Development/opengl-canvas-wasm/main.cpp", + "/Users/127885/Documents/gs_projects/gs_examples/22_emscripten/proc/emsc/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/22_emscripten/source/platform_impl_emsc.c", + "/Users/127885/Documents/gs_projects/gs_examples/22_emscripten/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/19_uniform_buffers/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/00_hello_gs/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/02_simple_triangle/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/03_uniforms/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/04_simple_texture/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/05_containers/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/06_non_interleaved_data/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/07_instancing/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/09_frame_buffer/proc/html5/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/22_emscripten/source/platform_emsc_impl.h", + "/Users/127885/Documents/gs_projects/gs_examples/22_emscripten/proc/osx/emcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/21_stencil_test/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/04_simple_texture/source/main.c", + "/Users/127885/Documents/gs_projects/gs_raycast/third_party/include/gs/util/gs_idraw.h", + "/Users/127885/Documents/gs_projects/gs_examples/06_non_interleaved_data/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/03_uniforms/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/02_simple_triangle/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/13_imgui/src/impl.cpp", + "/Users/127885/Documents/gs_projects/gs_examples/12_asset_manager/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/19_uniform_blocks/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/18_flecs/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/18_flecs/proc/osx/gcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/09_frame_buffer/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/18_flecs/external/flecs/flecs.c", + "/Users/127885/Documents/gs_projects/gs_examples/18_flecs/proc/linux/gcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/07_instancing/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/15_meta_class/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/11_compute_shader/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/00_hello_gs/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/simple_texture/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/uniforms/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/asset_manager/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/simple_triangle/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/imgui/src/gs_imgui.h", + "/Users/127885/Documents/gs_projects/gs_examples/imgui/external/imgui/imgui.h", + "/Users/127885/Documents/gs_projects/gs_examples/containers/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/frame_buffer/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/imgui/src/main.cpp", + "/Users/127885/Documents/gs_projects/gs_examples/hello_gs/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/glfw/win32_joystick.c", + "/Users/127885/Documents/gs_projects/gs_examples/hello_gs/proc/osx/gcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/immediate_draw/source/main.c", + "/Users/127885/Documents/gs_projects/gs_examples/gs_cpp/src/main.cpp", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/source/gs_nuklear.h", + "/Users/127885/Documents/gs_projects/gs_examples/imgui/proc/osx/gpp.sh", + "/Users/127885/Documents/gs_projects/gs_examples/gs_cpp/proc/osx/gpp.sh", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/glfw/cocoa_init.m", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/glfw/cocoa_joystick.m", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/glfw/cocoa_monitor.m", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/glfw/cocoa_window.m", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/external/glfw/nsgl_context.m", + "/Users/127885/Documents/gs_projects/gs_examples/gs_cpp/output.txt", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/external/Nuklear/src/nuklear.h", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/external/Nuklear/nuklear.h", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/source/impl.c", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/external/Nuklear/src/nuklear_edit.c", + "/Users/127885/Documents/gs_projects/gs_examples/nuklear_gui/proc/osx/gcc.sh", + "/Users/127885/Documents/gs_projects/gs_examples/third_party/include/gs/util/gs_meta.h", + "/Users/127885/Documents/gs_projects/rewind/assets/anims/idle/idle_meta.json", + "/Users/127885/Documents/gs_projects/rewind/third_party/gs/gs.h", + "/Users/127885/Documents/gs_projects/rewind/third_party/gs/util/gs_asset.h", + "/Users/127885/Documents/gs_projects/rewind/proc/linux/gcc.sh", + "/Users/127885/Documents/gs_projects/rewind/proc/osx/gcc.sh", + "/Users/127885/Documents/Random/gunslinger/third_party/include/stb/stb_vorbis.c", + "/Users/127885/Documents/Random/gunslinger/source/graphics/gs_graphics.c", + "/Users/127885/Documents/Random/gunslinger/source/graphics/opengl/gs_graphics_opengl.c", + "/Users/127885/Documents/Random/gunslinger/include/gs.h", + "/Users/127885/Documents/Random/gunslinger/include/graphics/gs_graphics.h", + "/Users/127885/Documents/Random/gunslinger/include/platform/gs_platform.h", + "/Users/127885/Documents/Random/gunslinger/examples/hello_gs/proc/osx/compile_osx_gcc.sh", + "/Users/127885/Documents/Random/gunslinger/source/base/gs_engine.c", + "/Users/127885/Documents/Random/gunslinger/source/audio/gs_audio.c", + "/Users/127885/Documents/Random/gunslinger/source/audio/miniaudio/gs_miniaudio.c", + "/Users/127885/Documents/Random/gunslinger/include/common/gs_types.h", + "/Users/127885/Documents/Random/gunslinger/examples/pong/source/main.c", + "/Users/127885/Documents/Random/gunslinger/include/serialize/gs_byte_buffer.h" + ], + "find": + { + "height": 54.0 + }, + "find_in_files": + { + "height": 239.0, + "where_history": + [ + ] + }, + "find_state": + { + "case_sensitive": false, + "find_history": + [ + ], + "highlight": true, + "in_selection": false, + "preserve_case": false, + "regex": false, + "replace_history": + [ + ], + "reverse": false, + "show_context": true, + "use_buffer2": true, + "whole_word": false, + "wrap": true + }, + "groups": + [ + { + "sheets": + [ + ] + } + ], + "incremental_find": + { + "height": 24.0 + }, + "input": + { + "height": 66.0 + }, + "layout": + { + "cells": + [ + [ + 0, + 0, + 1, + 1 + ] + ], + "cols": + [ + 0.0, + 1.0 + ], + "rows": + [ + 0.0, + 1.0 + ] + }, + "menu_visible": true, + "output.exec": + { + "height": 49.0 + }, + "output.find_results": + { + "height": 0.0 + }, + "pinned_build_system": "Packages/User/c_build_mac.sublime-build", + "project": "gs_project.sublime-project", + "replace": + { + "height": 44.0 + }, + "save_all_on_build": true, + "select_file": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + [ + "gs.h", + "third_party/include/gs/gs.h" + ], + [ + "physics.h", + "third_party/include/gs/util/gs_physics.h" + ], + [ + "main.c", + "source/main.c" + ], + [ + "phy", + "third_party/include/gs/util/gs_physics.h" + ], + [ + "smmian.c", + "source/sm_main.c" + ], + [ + "enity.h", + "source/sm_entity.h" + ], + [ + "smcomponenth", + "source/sm_component.h" + ], + [ + "gsidraw.h", + "app/src/main/cpp/third_party/gs/util/gs_idraw.h" + ], + [ + "gsplatformimpl", + "app/src/main/cpp/third_party/gs/impl/gs_platform_impl.h" + ], + [ + "platformipml", + "app/src/main/cpp/third_party/gs/impl/gs_platform_impl.h" + ], + [ + "platformimpl", + "app/src/main/cpp/third_party/gs/impl/gs_platform_impl.h" + ], + [ + "gs_gfxt", + "util/gs_gfxt.h" + ], + [ + "gltf", + "gs_project_template-main/third_party/include/gs/external/cgltf/cgltf.h" + ], + [ + "tinyobj", + "third_party/include/tinyobj/tinyobj.h" + ], + [ + "gf", + "third_party/include/gs/util/gs_gfxt.h" + ], + [ + "cgltf", + "third_party/include/gs/external/cgltf/cgltf.h" + ], + [ + "platformipl", + "third_party/include/gs/impl/gs_platform_impl.h" + ], + [ + "nanovg", + "24_udroid/external/nanovgXC/src/nanovg.c" + ], + [ + "nanovg.c", + "24_udroid/external/nanovgXC/src/nanovg.c" + ], + [ + "gsi", + "third_party/include/gs/util/gs_idraw.h" + ], + [ + "nvg.h", + "24_udroid/external/nanovgXC/src/nanovg.h" + ], + [ + "nanovg.h", + "24_udroid/external/nanovgXC/src/nanovg.h" + ], + [ + "nanovgsw", + "24_udroid/external/nanovgXC/src/nanovg_sw.h" + ], + [ + "nvgsw", + "24_udroid/external/nanovgXC/src/nanovg_sw.h" + ], + [ + "nvg", + "24_udroid/external/nanovgXC/src/nanovg.h" + ], + [ + "idraw.h", + "third_party/include/gs/util/gs_idraw.h" + ], + [ + "graphicsimpl", + "third_party/include/gs/impl/gs_graphics_impl.h" + ], + [ + "platformim", + "third_party/include/gs/impl/gs_platform_impl.h" + ], + [ + "gsidraw", + "third_party/include/gs/util/gs_idraw.h" + ], + [ + "audioimpl", + "third_party/include/gs/impl/gs_audio_impl.h" + ], + [ + "gs", + "third_party/include/gs/util/gs_idraw.h" + ], + [ + "graphicsi", + "third_party/include/gs/impl/gs_graphics_impl.h" + ], + [ + "gsidarw", + "third_party/include/gs/util/gs_idraw.h" + ], + [ + "asset.h", + "third_party/include/gs/util/gs_asset.h" + ], + [ + "gas", + "third_party/include/gs/util/gs_asset.h" + ], + [ + "gsasset.h", + "third_party/include/gs/util/gs_asset.h" + ], + [ + "tiny", + "23_marching_cubes/source/tinycthread/source/tinycthread.h" + ], + [ + "graphicsimp", + "third_party/include/gs/impl/gs_graphics_impl.h" + ], + [ + "simpletexture.c", + "04_simple_texture/source/main.c" + ], + [ + "flecsmain.c", + "18_flecs/source/main.c" + ], + [ + "unif.c", + "03_uniforms/source/main.c" + ], + [ + "gsnuk", + "16_nuklear_gui/source/gs_nuklear.h" + ], + [ + "gsigui.h", + "13_imgui/src/gs_imgui.h" + ], + [ + "graphics.h", + "third_party/include/gs/impl/gs_graphics_impl.h" + ], + [ + "uniform.c", + "03_uniforms/source/main.c" + ], + [ + "idraw", + "third_party/include/gs/util/gs_idraw.h" + ], + [ + "grpahicsimp", + "third_party/include/gs/impl/gs_graphics_impl.h" + ], + [ + "impl", + "13_imgui/src/impl.cpp" + ], + [ + "assetmanager.c", + "12_asset_manager/source/main.c" + ], + [ + "felcsmain.c", + "18_flecs/source/main.c" + ], + [ + "felcs.c", + "18_flecs/external/flecs/flecs.c" + ], + [ + "flecsg", + "18_flecs/proc/osx/gcc.sh" + ], + [ + "flecsgcc", + "18_flecs/proc/linux/gcc.sh" + ], + [ + "09framebufer.c", + "09_frame_buffer/source/main.c" + ], + [ + "uniforms.c", + "03_uniforms/source/main.c" + ], + [ + "compute.c", + "11_compute_shader/source/main.c" + ], + [ + "metamain.c", + "15_meta_class/source/main.c" + ], + [ + "gsgrpahicsimp", + "third_party/include/gs/impl/gs_graphics_impl.h" + ], + [ + "flecs.c", + "18_flecs/external/flecs/flecs.c" + ], + [ + "triangle.c", + "simple_triangle/source/main.c" + ], + [ + "assetmanger.c", + "asset_manager/source/main.c" + ], + [ + "framebuffer.c", + "frame_buffer/source/main.c" + ], + [ + "gs.", + "third_party/include/gs/gs.h" + ], + [ + "conatiners.c", + "containers/source/main.c" + ], + [ + "imgui.h", + "imgui/external/imgui/imgui.h" + ], + [ + "gsimgui.h", + "imgui/src/gs_imgui.h" + ], + [ + "imgui.cp", + "imgui/src/main.cpp" + ], + [ + "win32jo", + "third_party/include/gs/external/glfw/win32_joystick.c" + ], + [ + "immediatedraw.c", + "immediate_draw/source/main.c" + ], + [ + "nsglcon.m", + "third_party/include/gs/external/glfw/nsgl_context.m" + ], + [ + "cocawin", + "third_party/include/gs/external/glfw/cocoa_window.m" + ], + [ + "mo", + "third_party/include/gs/external/glfw/cocoa_monitor.m" + ], + [ + "cocoa_jo.m", + "third_party/include/gs/external/glfw/cocoa_joystick.m" + ], + [ + "out", + "gs_cpp/output.txt" + ], + [ + "cocai", + "third_party/include/gs/external/glfw/cocoa_init.m" + ], + [ + "nuklear.h", + "nuklear_gui/external/Nuklear/nuklear.h" + ], + [ + "src/nuklear.h", + "nuklear_gui/external/Nuklear/src/nuklear.h" + ], + [ + "src/nuke", + "nuklear_gui/external/Nuklear/src/nuklear_edit.c" + ], + [ + "gsnu", + "nuklear_gui/source/gs_nuklear.h" + ], + [ + "nuk", + "nuklear_gui/external/Nuklear/nuklear.h" + ], + [ + "gs_nu", + "nuklear_gui/source/gs_nuklear.h" + ], + [ + "mai.c", + "containers/source/main.c" + ], + [ + "gsmeta.h", + "third_party/include/gs/util/gs_meta.h" + ], + [ + "meta.h", + "third_party/include/gs/util/gs_meta.h" + ], + [ + "meta", + "third_party/include/gs/util/gs_meta.h" + ], + [ + "gsa", + "third_party/gs/util/gs_asset.h" + ], + [ + "gcc", + "proc/osx/gcc.sh" + ], + [ + "gladimpl", + "external/glad/glad_impl.h" + ], + [ + "procosx", + "proc/osx/compile_osx_gcc.sh" + ], + [ + "graphics.c", + "source/graphics/gs_graphics.c" + ], + [ + "grpahics.h", + "include/graphics/gs_graphics.h" + ], + [ + "opengl", + "source/graphics/opengl/gs_graphics_opengl.c" + ], + [ + "opengl.c", + "source/graphics/opengl/gs_graphics_opengl.c" + ], + [ + "immediate.c", + "examples/simple_immediate_rend/source/main.c" + ], + [ + "simpletriangle.c", + "examples/simple_triangle/source/main.c" + ], + [ + "simpletri.c", + "examples/simple_triangle/source/main.c" + ], + [ + "simpletr", + "examples/simple_triangle/source/main.c" + ], + [ + "engine.c", + "source/base/gs_engine.c" + ], + [ + "types.h", + "include/common/gs_types.h" + ], + [ + "ut", + "include/common/gs_util.h" + ], + [ + "audio.c", + "source/audio/gs_audio.c" + ], + [ + "miniaudio.c", + "source/audio/miniaudio/gs_miniaudio.c" + ], + [ + "vorbis.c", + "third_party/include/stb/stb_vorbis.c" + ], + [ + "vor", + "third_party/include/stb/stb_vorbis.c" + ], + [ + "containers.h", + "include/common/gs_containers.h" + ], + [ + "platform.c", + "source/platform/gs_platform.c" + ], + [ + "glfw.c", + "source/platform/glfw/gs_platform_glfw.c" + ], + [ + "hellgs.c", + "examples/hello_gs/source/main.c" + ], + [ + "engine.h", + "include/base/gs_engine.h" + ], + [ + "math.h", + "include/math/gs_math.h" + ], + [ + "bytebuffer.h", + "include/serialize/gs_byte_buffer.h" + ], + [ + "simpelconta.c", + "examples/simple_containers/source/main.c" + ], + [ + "containers", + "include/common/gs_containers.h" + ], + [ + "platform.h", + "include/platform/gs_platform.h" + ], + [ + "bytebuffer.c", + "source/serialize/gs_byte_buffer.c" + ], + [ + "util.h", + "include/common/gs_util.h" + ], + [ + "pong.c", + "examples/pong/source/main.c" + ], + [ + "material.c", + "source/graphics/gs_material.c" + ], + [ + "opeg", + "source/graphics/opengl/gs_graphics_opengl.c" + ], + [ + "simpleim.c", + "examples/simple_immediate_rend/source/main.c" + ], + [ + "miniaudi.c", + "source/audio/miniaudio/gs_miniaudio.c" + ], + [ + "minaudio.c", + "source/audio/miniaudio/gs_miniaudio.c" + ], + [ + "maaudio.c", + "source/audio/miniaudio/gs_miniaudio.c" + ], + [ + "audio.h", + "include/audio/gs_audio.h" + ], + [ + "simpleconat.c", + "examples/simple_containers/source/main.c" + ], + [ + "customquadbatch.c", + "examples/custom_quad_batch/source/main.c" + ], + [ + "quadbatch.c", + "source/graphics/gs_quad_batch.c" + ], + [ + "quadbatch.h", + "include/graphics/gs_quad_batch.h" + ] + ], + "width": 0.0 + }, + "select_project": + { + "height": 0.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 0.0 + }, + "select_symbol": + { + "height": 354.0, + "last_filter": "", + "selected_items": + [ + ], + "width": 635.0 + }, + "selected_group": 0, + "settings": + { + }, + "show_minimap": false, + "show_open_files": false, + "show_tabs": true, + "side_bar_visible": true, + "side_bar_width": 163.0, + "status_bar_visible": true, + "template_settings": + { + } +} diff --git a/proc/win/cl.bat b/proc/win/cl.bat @@ -0,0 +1,35 @@ +@echo off +rmdir /Q /S bin +mkdir bin +pushd bin + +rem Name +set name=App + +rem Include directories +set inc=/I ..\third_party\include\ + +rem Source files +set src_main=..\source\*.c + +rem All source together +set src_all=%src_main% + +rem OS Libraries +set os_libs= opengl32.lib kernel32.lib user32.lib ^ +shell32.lib vcruntime.lib msvcrt.lib gdi32.lib Winmm.lib Advapi32.lib + +rem Link options +set l_options=/EHsc /link /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib + +rem Compile Release +rem cl /MP /FS /Ox /W0 /Fe%name%.exe %src_all% %inc% ^ +rem /EHsc /link /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:LIBCMT ^ +rem %os_libs% + +rem Compile Debug +cl /w /MP -Zi /DEBUG:FULL /Fe%name%.exe %src_all% %inc% ^ +/EHsc /link /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:LIBCMT ^ +%os_libs% + +popd diff --git a/proc/win/mingw.sh b/proc/win/mingw.sh @@ -0,0 +1,40 @@ +#!bin/sh + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w +) + +# Include directories +inc=( + -I ../third_party/include/ # Gunslinger includes +) + +# Source files +src=( + ../source/main.c +) + +libs=( + -lopengl32 + -lkernel32 + -luser32 + -lshell32 + -lgdi32 + -lWinmm + -lAdvapi32 +) + +# Build +gcc -O0 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} + +cd .. + + + diff --git a/proc/win/mingw_cross_platform.sh b/proc/win/mingw_cross_platform.sh @@ -0,0 +1,39 @@ +#!bin/bash + +# Make sure you have mingw-w64 installed for this to work. +# It should be available in most linux package managers and with brew(MacOS). + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w +) + +# Include directories +inc=( + -I ../third_party/include/ # Gunslinger includes +) + +# Source files +src=( + ../source/main.c +) + +libs=( + -lopengl32 + -lkernel32 + -luser32 + -lshell32 + -lgdi32 + -lwinmm +) + +# Build +x86_64-w64-mingw32-gcc -O0 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} + +cd .. diff --git a/proc/win/mingw_dbg.sh b/proc/win/mingw_dbg.sh @@ -0,0 +1,41 @@ +#!bin/sh + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w +) + +# Include directories +inc=( + -I ../third_party/include/ # Gunslinger includes +) + +# Source files +src=( + ../source/main.c +) + +libs=( + -lopengl32 + -lkernel32 + -luser32 + -lshell32 + -lgdi32 + -lWinmm + -lAdvapi32 +) + +# Build +echo gcc -O0 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} +gcc -O0 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} + +cd .. + + + diff --git a/proc/win/mingw_rdbg.sh b/proc/win/mingw_rdbg.sh @@ -0,0 +1,41 @@ +#!bin/sh + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w +) + +# Include directories +inc=( + -I ../third_party/include/ # Gunslinger includes +) + +# Source files +src=( + ../source/main.c +) + +libs=( + -lopengl32 + -lkernel32 + -luser32 + -lshell32 + -lgdi32 + -lWinmm + -lAdvapi32 +) + +# Build +echo gcc -O1 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} +gcc -O1 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} + +cd .. + + + diff --git a/proc/win/mingw_rel.sh b/proc/win/mingw_rel.sh @@ -0,0 +1,41 @@ +#!bin/sh + +rm -rf bin +mkdir bin +cd bin + +proj_name=App +proj_root_dir=$(pwd)/../ + +flags=( + -std=gnu99 -w +) + +# Include directories +inc=( + -I ../third_party/include/ # Gunslinger includes +) + +# Source files +src=( + ../source/main.c +) + +libs=( + -lopengl32 + -lkernel32 + -luser32 + -lshell32 + -lgdi32 + -lWinmm + -lAdvapi32 +) + +# Build +echo gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} +gcc -O3 ${inc[*]} ${src[*]} ${flags[*]} ${libs[*]} -lm -o ${proj_name} + +cd .. + + + diff --git a/source/gs.c b/source/gs.c @@ -0,0 +1,8 @@ +#define GS_IMPL +#include "../third_party/include/gs/gs.h" + +#define GS_IMMEDIATE_DRAW_IMPL +#include "../third_party/include/gs/util/gs_idraw.h" + +#define GS_GUI_IMPL +#include "../third_party/include/gs/util/gs_gui.h" diff --git a/source/gs_avdecode.h b/source/gs_avdecode.h @@ -0,0 +1,288 @@ +#ifndef GS_AVDECODE_H_ +#define GS_AVDECODE_H_ + +/* + * Header only style.... + * #define GS_AVDECODE_IMPL + * before including header in one and only one source file + * to implement declared functions. + * + * requirers linking with ffmpeg stuff. + * On linux that would for example be + * -lavcodec -lavformat -lavcodec -lswresample -lswscale -lavutil + * + */ + +#include <libavutil/imgutils.h> +#include <libavutil/samplefmt.h> +#include <libavutil/timestamp.h> +#include <libavcodec/avcodec.h> +#include <libavformat/avformat.h> + +#include <libswscale/swscale.h> + +#include <gs/gs.h> + +typedef struct gs_avdecode_ctx_s { + const char* src_filename; + int width, height; + int video_stream_idx, audio_stream_idx; + int read_next_packet; + int alpha; + enum AVPixelFormat pix_fmt; + + AVFormatContext *fmt_ctx; + AVCodecContext *video_dec_ctx, *audio_dec_ctx; + AVStream *video_stream, *audio_stream; + AVFrame *frame; + AVPacket *pkt; + struct SwsContext * sws; // TODO: FREE THE CONTEXT!!!!!!!! + + gs_asset_texture_t tex; +} gs_avdecode_ctx_t; + +// return zero on success +// TODO: specify weather <0 is error or if its just non-zero +extern int gs_avdecode_init(const char* path, gs_avdecode_ctx_t* ctx, gs_graphics_texture_desc_t* desc); +extern int gs_avdecode_next_frame(gs_avdecode_ctx_t* ctx); // -1 if all frames read +extern void gs_avdecode_destroy(gs_avdecode_ctx_t* ctx); + +#ifdef GS_AVDECODE_IMPL + +static int +gs_avdecode_decode_packet(gs_avdecode_ctx_t* ctx, AVCodecContext *dec, const AVPacket *pkt) +{ + int ret = 0; + + // submit the packet to the decoder + ret = avcodec_send_packet(dec, pkt); + if (ret < 0) { + fprintf(stderr, "gs_avdecode.h: Error submitting a packet for decoding (%s)\n", av_err2str(ret)); + return ret; + } + + // get all the available frames from the decoder + int valid_frame = 1; + do { + ret = avcodec_receive_frame(dec, ctx->frame); + if (ret < 0) { + // those two return values are special and mean there is no output + // frame available, but there were no errors during decoding + if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN)) + return 0; + + fprintf(stderr, "gs_avdecode.h: Error during decoding (%s)\n", av_err2str(ret)); + return ret; + } + if (dec->codec->type == AVMEDIA_TYPE_VIDEO) { + if (ctx->frame->width != ctx->width || + ctx->frame->height != ctx->height || + ctx->frame->format != ctx->pix_fmt) { + // No support for variable size videos... + // To do so you would have to reallocate img + valid_frame = 0; + } else { + sws_scale(ctx->sws, + (const uint8_t **)(ctx->frame->data), ctx->frame->linesize, + 0, ctx->height, (uint8_t**)ctx->tex.desc.data, (int[1]){ctx->width * (3 + ctx->alpha)} + ); + } + } + + av_frame_unref(ctx->frame); + } while (!valid_frame); + + return ret; +} + +static int +open_codec_context( + gs_avdecode_ctx_t* ctx, + int *stream_idx, + AVCodecContext **dec_ctx, + AVFormatContext *fmt_ctx, + enum AVMediaType type +) { + int ret, stream_index; + AVStream *st; + const AVCodec *dec = NULL; + + ret = av_find_best_stream(ctx->fmt_ctx, type, -1, -1, NULL, 0); + if (ret < 0) { + fprintf(stderr, "gs_avdecode.h: Could not find %s stream in input file '%s'\n", + av_get_media_type_string(type), ctx->src_filename); + return ret; + } else { + stream_index = ret; + st = ctx->fmt_ctx->streams[stream_index]; + + /* find decoder for the stream */ + dec = avcodec_find_decoder(st->codecpar->codec_id); + if (!dec) { + fprintf(stderr, "gs_avdecode.h: Failed to find %s codec\n", + av_get_media_type_string(type)); + return AVERROR(EINVAL); + } + + /* Allocate a codec context for the decoder */ + *dec_ctx = avcodec_alloc_context3(dec); + if (!*dec_ctx) { + fprintf(stderr, "gs_avdecode.h: Failed to allocate the %s codec context\n", + av_get_media_type_string(type)); + return AVERROR(ENOMEM); + } + + /* Copy codec parameters from input stream to output codec context */ + if ((ret = avcodec_parameters_to_context(*dec_ctx, st->codecpar)) < 0) { + fprintf(stderr, "gs_avdecode.h: Failed to copy %s codec parameters to decoder context\n", + av_get_media_type_string(type)); + return ret; + } + + // Init the decoders + if ((ret = avcodec_open2(*dec_ctx, dec, NULL)) < 0) { + fprintf(stderr, "gs_avdecode.h: Failed to open %s codec\n", + av_get_media_type_string(type)); + return ret; + } + *stream_idx = stream_index; + } + + return 0; +} + +int +gs_avdecode_init(const char* path, gs_avdecode_ctx_t* ctx, gs_graphics_texture_desc_t* desc) +{ + if (!ctx) return 2; + *ctx = (gs_avdecode_ctx_t){0}; + ctx->video_stream_idx = -1; + ctx->audio_stream_idx = -1; + ctx->src_filename = path; + ctx->read_next_packet = 1; + + /* open input file, and allocate format context */ + if (avformat_open_input(&ctx->fmt_ctx, ctx->src_filename, NULL, NULL) < 0) { + fprintf(stderr, "gs_avdecode.h: Could not open source file %s", ctx->src_filename); + return 1; + } + + /* retrieve stream information */ + if (avformat_find_stream_info(ctx->fmt_ctx, NULL) < 0) { + fprintf(stderr, "gs_avdecode.h: Could not find stream information"); + avformat_close_input(&ctx->fmt_ctx); + return 1; + } + + int ret = 0; + if (open_codec_context(ctx, &ctx->video_stream_idx, &ctx->video_dec_ctx, ctx->fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) { + ctx->video_stream = ctx->fmt_ctx->streams[ctx->video_stream_idx]; + ctx->width = ctx->video_dec_ctx->width; + ctx->height = ctx->video_dec_ctx->height; + ctx->pix_fmt = ctx->video_dec_ctx->pix_fmt; + if (ctx->pix_fmt == AV_PIX_FMT_YUVA420P || + ctx->pix_fmt == AV_PIX_FMT_ARGB || + ctx->pix_fmt == AV_PIX_FMT_RGBA) + ctx->alpha = 1; + ctx->sws = sws_getContext(ctx->width, ctx->height, ctx->pix_fmt, + ctx->width, ctx->height, ctx->alpha ? AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24, + SWS_BICUBIC, 0, 0, 0); + } + + if (open_codec_context(ctx, &ctx->audio_stream_idx, &ctx->audio_dec_ctx, ctx->fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) { + ctx->audio_stream = ctx->fmt_ctx->streams[ctx->audio_stream_idx]; + } + + // dump input information to stderr + av_dump_format(ctx->fmt_ctx, 0, ctx->src_filename, 0); + + if (!ctx->audio_stream && !ctx->video_stream) { + fprintf(stderr, "gs_avdecode.h: Could not find audio or video stream in the input, aborting\n"); + ret = 1; + goto end; + } + + ctx->frame = av_frame_alloc(); + if (!ctx->frame) { + fprintf(stderr, "gs_avdecode.h: Could not allocate frame\n"); + ret = AVERROR(ENOMEM); + goto end; + } + + ctx->pkt = av_packet_alloc(); + if (!ctx->pkt) { + fprintf(stderr, "gs_avdecode.h: Could not allocate packet\n"); + ret = AVERROR(ENOMEM); + goto end; + } + + //////////////////////////////////// + // asset_texture + + gs_asset_texture_t* t = &ctx->tex; + + if (desc) { + t->desc = *desc; + } else { + t->desc.format = ctx->alpha ? GS_GRAPHICS_TEXTURE_FORMAT_RGBA8 : GS_GRAPHICS_TEXTURE_FORMAT_RGB8; + t->desc.min_filter = GS_GRAPHICS_TEXTURE_FILTER_LINEAR; + t->desc.mag_filter = GS_GRAPHICS_TEXTURE_FILTER_LINEAR; + t->desc.wrap_s = GS_GRAPHICS_TEXTURE_WRAP_REPEAT; + t->desc.wrap_t = GS_GRAPHICS_TEXTURE_WRAP_REPEAT; + } + t->desc.width = ctx->width; + t->desc.height = ctx->height; + *t->desc.data = malloc(ctx->width * ctx->height * (3 + ctx->alpha) + 1); + ((char**)t->desc.data)[0][ctx->width * ctx->height * (3 + ctx->alpha)] = 0; + memset(*t->desc.data, 150, ctx->width * ctx->height * (3 + ctx->alpha)); + t->hndl = gs_graphics_texture_create(&t->desc); + + return 0; +end: + gs_avdecode_destroy(ctx); + return ret; +} + + +// TODO fix conflicting types in img.... +int +gs_avdecode_next_frame(gs_avdecode_ctx_t* ctx) +{ + int ret = 0; + if (ctx->read_next_packet) { + if (av_read_frame(ctx->fmt_ctx, ctx->pkt) < 0) return -1; + ctx->read_next_packet = 0; + } + + // check if the packet belongs to a stream we are interested in, otherwise skip it + if (ctx->pkt->stream_index == ctx->video_stream_idx) + ret = gs_avdecode_decode_packet(ctx, ctx->video_dec_ctx, ctx->pkt); + if (ctx->pkt->stream_index == ctx->audio_stream_idx) + ret = gs_avdecode_decode_packet(ctx, ctx->audio_dec_ctx, ctx->pkt); + if (ret >= 0) { + av_packet_unref(ctx->pkt); + ctx->read_next_packet = 1; + } + + return ret; +} + +void +gs_avdecode_destroy(gs_avdecode_ctx_t* ctx) +{ + // flush the decoders + if (ctx->video_dec_ctx) + gs_avdecode_decode_packet(ctx, ctx->video_dec_ctx, NULL); + if (ctx->audio_dec_ctx) + gs_avdecode_decode_packet(ctx, ctx->audio_dec_ctx, NULL); + + avcodec_free_context(&ctx->video_dec_ctx); + avcodec_free_context(&ctx->audio_dec_ctx); + avformat_close_input(&ctx->fmt_ctx); + av_packet_free(&ctx->pkt); + av_frame_free(&ctx->frame); +} + +#endif // GS_AVDECODE_IMPL + +#endif // GS_AVDECODE_H_ diff --git a/source/main.c b/source/main.c @@ -0,0 +1,73 @@ +#include <gs/gs.h> +#include <gs/util/gs_idraw.h> +#define GS_AVDECODE_IMPL +#include "gs_avdecode.h" + +static gs_avdecode_ctx_t video; +static gs_asset_texture_t tex = {0}; +static gs_immediate_draw_t gsi = {0}; +static gs_command_buffer_t cb = {0}; + +static const char* filename; + +void app_update() +{ + const gs_vec2 fb = gs_platform_framebuffer_sizev(gs_platform_main_window()); + + gsi_defaults(&gsi); + gsi_camera2D(&gsi, fb.x, fb.y); + const float t = gs_platform_elapsed_time() * 0.0001f; + + gsi_camera3D(&gsi, fb.x, fb.y); + gsi_rotatev(&gsi, gs_deg2rad(90.f), GS_ZAXIS); gsi_rotatev(&gsi, t, GS_YAXIS); + gsi_sphere(&gsi, 0.f, 0.f, 0.f, 1.f, 50, 150, 200, 50, GS_GRAPHICS_PRIMITIVE_LINES); + + gsi_defaults(&gsi); + gsi_camera2D(&gsi, fb.x, fb.y); + gsi_rectvd(&gsi, gs_v2s(0.0f), fb, gs_v2s(0.f), gs_v2s(1.f), GS_COLOR_WHITE, GS_GRAPHICS_PRIMITIVE_TRIANGLES); + + int res = gs_avdecode_next_frame(&video); + if (res) gs_quit(); + + gs_graphics_texture_request_update(&cb, video.tex.hndl, &video.tex.desc); + gsi_texture(&gsi, video.tex.hndl); + gsi_rectvd(&gsi, gs_v2s(0.0f), fb, gs_v2s(0.f), gs_v2s(1.f), GS_COLOR_WHITE, GS_GRAPHICS_PRIMITIVE_TRIANGLES); + + + gsi_renderpass_submit(&gsi, &cb, gs_v4(0, 0, fb.x, fb.y), gs_color(10, 10, 10, 255)); + gs_graphics_command_buffer_submit(&cb); +} + +void app_init() +{ + cb = gs_command_buffer_new(); + gsi = gs_immediate_draw_new(); + + int res = gs_avdecode_init(filename, &video, NULL); + + if (res) { + gs_println("Unable to initialize video '%s' (error code %d)", filename, res); + exit(1); + } +} + +gs_app_desc_t +gs_main(int32_t argc, char** argv) +{ + if (argc != 2) { + gs_println("----\nInvalid amount of arguments!\nUsage: ./App your-video"); + exit(1); + } + + filename = strdup(argv[1]);; + + return (gs_app_desc_t) { + .window = { + .width = 800, + .height = 600, + .frame_rate = 30, + }, + .init = app_init, + .update = app_update, + }; +} diff --git a/third_party/include/gs b/third_party/include/gs @@ -0,0 +1 @@ +Subproject commit cf60546189a1d51819979586351c2ed1332ad111