├── orbis_gl_test ├── capture.jpg ├── .gitignore └── Makefile ├── orbis_es2texture_png_VBOs ├── scarfy.png ├── source │ ├── timing.c │ ├── png.c │ ├── shader_common.c │ ├── sprite.c │ └── icons.c ├── Makefile └── include │ ├── defines.h │ ├── sprite_shaders.h │ └── icons_shaders.h ├── orbis_MAPI_samples ├── MAPI_money │ ├── money.png │ ├── Makefile │ └── source │ │ └── png.c ├── MAPI_dna │ ├── texture_dna.png │ ├── Makefile │ └── source │ │ └── png.c ├── MAPI_transparency │ ├── source │ │ ├── cloud.png │ │ ├── frosted_glass.png │ │ └── png.c │ └── Makefile ├── MAPI_saturn │ ├── source │ │ ├── texture_saturn.png │ │ ├── texture_saturn_ring.png │ │ └── png.c │ └── Makefile ├── MAPI_rover │ └── Makefile ├── MAPI_snow │ └── Makefile ├── MAPI_quaternion │ └── Makefile ├── MAPI_breakout │ ├── Makefile │ └── source │ │ └── png.c ├── MAPI_demo_r3 │ ├── Makefile │ └── source │ │ └── png.c └── MAPI_demo_r2 │ ├── Makefile │ └── source │ ├── png.c │ └── vbo.c ├── samplenfs ├── nfsexport │ └── system │ │ ├── fonts │ │ └── Tahoma_bold.ttf │ │ ├── textures │ │ ├── credits.png │ │ ├── msxorbis.png │ │ ├── file_icon.png │ │ └── folder_icon.png │ │ └── shaders │ │ ├── texture1.vertexShader │ │ ├── texture1.fragmentShader │ │ ├── texture.fragmentShader │ │ ├── texture.vertexShader │ │ ├── v3f-t2f-c4f.frag │ │ └── v3f-t2f-c4f.vert ├── source │ ├── timing.c │ ├── user_nfs.c │ ├── credits.c │ ├── browser.c │ └── orbisGlText.c ├── include │ ├── orbisGlText.h │ ├── browser.h │ └── orbisGlTextureManager.h ├── Makefile └── README.md ├── orbis_ftgl2_samples ├── shaders │ ├── v3f-c4f.frag │ ├── distance-field-2.frag │ ├── v3f-c4f.vert │ ├── distance-field.vert │ ├── text.vert │ ├── distance-field.frag │ └── text.frag ├── orbis_es2ftgl-font │ ├── Makefile │ └── source │ │ └── main.c ├── orbis_es2ftgl-glyph │ ├── Makefile │ └── source │ │ └── main.c ├── orbis_es2ftgl-markup │ ├── Makefile │ └── source │ │ └── main.c ├── orbis_es2ftgl-distance-field │ ├── Makefile │ └── source │ │ └── main.c ├── orbis_es2ftgl-distance-field-2 │ └── Makefile └── orbis_es2ftgl-distance-field-3 │ └── Makefile ├── orbis_es2tri ├── Makefile └── source │ └── es2tri.c ├── orbis_es2gears └── Makefile ├── orbis_es2shaders ├── Makefile └── source │ └── egl.c ├── orbis_es2water └── Makefile ├── orbis_es2collisions └── Makefile ├── orbis_es2starfield └── Makefile ├── orbis_es2wavefront └── Makefile ├── orbis_es2opengles_demo ├── Makefile └── source │ └── opengles_demo.c ├── orbis_es2rotating_cube └── Makefile ├── orbis_es2sine_wave_lines ├── Makefile └── source │ └── sine_wave_lines.c ├── orbis_es2cube-smooth ├── Makefile ├── COPYING └── source │ ├── common.c │ ├── esUtil.c │ └── main.c ├── orbis_es2texture_png └── Makefile └── orbis_es2freetype-gl ├── Makefile ├── LICENSE ├── shaders ├── v3f-t2f-c4f.frag.ORIG ├── v3f-t2f-c4f.frag ├── v3f-t2f-c4f.vert.ORIG └── v3f-t2f-c4f.vert └── source └── main.c /orbis_gl_test/capture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_gl_test/capture.jpg -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/scarfy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_es2texture_png_VBOs/scarfy.png -------------------------------------------------------------------------------- /orbis_gl_test/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.elf 3 | *.self 4 | *.pkg 5 | *.o 6 | *.a 7 | *.d 8 | .DS_Store 9 | ._* 10 | 11 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_money/money.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_MAPI_samples/MAPI_money/money.png -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_dna/texture_dna.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_MAPI_samples/MAPI_dna/texture_dna.png -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/fonts/Tahoma_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/samplenfs/nfsexport/system/fonts/Tahoma_bold.ttf -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/textures/credits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/samplenfs/nfsexport/system/textures/credits.png -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/textures/msxorbis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/samplenfs/nfsexport/system/textures/msxorbis.png -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/textures/file_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/samplenfs/nfsexport/system/textures/file_icon.png -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_transparency/source/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_MAPI_samples/MAPI_transparency/source/cloud.png -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/textures/folder_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/samplenfs/nfsexport/system/textures/folder_icon.png -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_saturn/source/texture_saturn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_MAPI_samples/MAPI_saturn/source/texture_saturn.png -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_saturn/source/texture_saturn_ring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_MAPI_samples/MAPI_saturn/source/texture_saturn_ring.png -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_transparency/source/frosted_glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orbisdev/samples/HEAD/orbis_MAPI_samples/MAPI_transparency/source/frosted_glass.png -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/shaders/texture1.vertexShader: -------------------------------------------------------------------------------- 1 | attribute vec4 a_xyz; 2 | attribute vec2 a_uv; 3 | varying vec2 v_uv; 4 | 5 | void main() 6 | { 7 | gl_Position = a_xyz; 8 | v_uv = a_uv; 9 | } -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/shaders/texture1.fragmentShader: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | varying vec2 v_uv; 3 | uniform sampler2D s_texture; 4 | 5 | void main() 6 | { 7 | gl_FragColor = texture2D(s_texture, v_uv); 8 | } 9 | -------------------------------------------------------------------------------- /samplenfs/source/timing.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /// timing 4 | unsigned int get_time_ms(void) 5 | { 6 | struct timeval tv; 7 | gettimeofday(&tv, NULL); 8 | return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); 9 | } 10 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/source/timing.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /// timing 4 | unsigned int get_time_ms(void) 5 | { 6 | struct timeval tv; 7 | gettimeofday(&tv, NULL); 8 | return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); 9 | } 10 | -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/shaders/texture.fragmentShader: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | varying vec2 vTexCoord; 4 | 5 | uniform sampler2D textureSampler; 6 | 7 | void main() 8 | { 9 | gl_FragColor = vec4(1, 1, 1, texture2D(textureSampler, vTexCoord).a); 10 | } 11 | -------------------------------------------------------------------------------- /samplenfs/include/orbisGlText.h: -------------------------------------------------------------------------------- 1 | 2 | // then we can print them splitted 3 | typedef struct { 4 | int off; 5 | int len; 6 | } textline_t; 7 | 8 | 9 | 10 | void orbisGlTextInit(void); 11 | void orbisGlTextSetupBuffer(char *mytext,int x,int y,vec4 color); 12 | void orbisGlTextDraw(textline_t *text_to_draw); -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/v3f-c4f.frag: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | 8 | varying vec4 fragColor; 9 | 10 | void main() 11 | { 12 | gl_FragColor = fragColor; 13 | } 14 | -------------------------------------------------------------------------------- /orbis_gl_test/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | include $(Ps4Sdk)/make/ps4sdk.mk 17 | LinkerFlags+=-ldebugnet -lps4link -lelfloader -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub 18 | 19 | -------------------------------------------------------------------------------- /orbis_es2tri/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | include $(Ps4Sdk)/make/ps4sdk.mk 17 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 18 | 19 | -------------------------------------------------------------------------------- /orbis_es2gears/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | include $(Ps4Sdk)/make/ps4sdk.mk 17 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 18 | 19 | -------------------------------------------------------------------------------- /orbis_es2shaders/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | include $(Ps4Sdk)/make/ps4sdk.mk 17 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 18 | 19 | -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/shaders/texture.vertexShader: -------------------------------------------------------------------------------- 1 | uniform vec2 screenHalfSize; 2 | 3 | attribute vec2 vertPosition_screenspace; 4 | attribute vec2 texCoord0; 5 | 6 | varying vec2 vTexCoord; 7 | 8 | void main() 9 | { 10 | // map screen coordinates to [-1..1][-1..1] 11 | vec2 vertPosition_clipspace = (vertPosition_screenspace / screenHalfSize) - vec2(1,1); 12 | // invert Y coordinate, because screenspace has its origin at the upper-left instead of lower-left 13 | gl_Position = vec4(vertPosition_clipspace.x,-vertPosition_clipspace.y,0,1); 14 | 15 | vTexCoord = texCoord0; 16 | } -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/distance-field-2.frag: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | 8 | uniform sampler2D u_texture; 9 | 10 | varying vec2 vTexCoord; 11 | varying vec4 fragColor; 12 | 13 | void main(void) 14 | { 15 | float dist = texture2D(u_texture, vTexCoord).a; 16 | float width = fwidth(dist); 17 | float alpha = smoothstep(0.5-width, 0.5+width, dist); 18 | gl_FragColor = vec4(fragColor.rgb, alpha*fragColor.a); 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/v3f-c4f.vert: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | uniform mat4 model; 8 | uniform mat4 view; 9 | uniform mat4 projection; 10 | 11 | attribute vec3 vertex; 12 | attribute vec4 color; 13 | 14 | //use your own output instead of gl_FrontColor 15 | varying vec4 fragColor; 16 | 17 | void main() 18 | { 19 | //gl_FrontColor = color; 20 | fragColor = color; 21 | gl_Position = projection*(view*(model*vec4(vertex,1.0))); 22 | } 23 | -------------------------------------------------------------------------------- /samplenfs/include/browser.h: -------------------------------------------------------------------------------- 1 | #ifndef _BROWSER_H_ 2 | #define _BROWSER_H_ 3 | 4 | enum SCREEN_STATUS 5 | { 6 | SCREEN_EMU, 7 | SCREEN_BROWSER, 8 | SCREEN_SETTINGS, 9 | SCREEN_CREDITS, 10 | 11 | }; 12 | 13 | //void showBrowser(); 14 | #define NFSEXPORT "nfs://ip/pathforyourexport" 15 | #define BROWSER_BACKGROUND_FILE_PATH "system/textures/msxorbis.png" 16 | #define FILE_ICON_PATH "system/textures/file_icon.png" 17 | #define FOLDER_ICON_PATH "system/textures/folder_icon.png" 18 | #define SETTINGS_BACKGROUND_FILE_PATH "system/textures/settings.png" 19 | #define CREDITS_BACKGROUND_FILE_PATH "system/textures/credits.png" 20 | 21 | 22 | #endif -------------------------------------------------------------------------------- /orbis_es2water/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2collisions/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2starfield/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2wavefront/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2opengles_demo/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2rotating_cube/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2sine_wave_lines/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+=-ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | -------------------------------------------------------------------------------- /orbis_es2cube-smooth/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | CompilerFlags += -mavx 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /orbis_es2texture_png/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | CompilerFlags += -D_DEMO_ -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_rover/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -mavx -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_snow/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -mavx -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_quaternion/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -mavx -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/distance-field.vert: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | 8 | uniform mat4 u_model; 9 | uniform mat4 u_view; 10 | uniform mat4 u_projection; 11 | uniform vec4 u_color; 12 | 13 | attribute vec3 vertex; 14 | attribute vec2 tex_coord; 15 | attribute vec4 color; 16 | 17 | varying vec2 vTexCoord; 18 | 19 | //use your own output instead of gl_FragColor 20 | varying vec4 fragColor; 21 | 22 | void main(void) 23 | { 24 | vTexCoord.xy = tex_coord.xy; 25 | fragColor = color * u_color; 26 | gl_Position = u_projection*(u_view*(u_model*vec4(vertex,1.0))); 27 | } 28 | -------------------------------------------------------------------------------- /orbis_es2freetype-gl/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_dna/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -D_MAPI_ -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_money/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -D_MAPI_ -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_breakout/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -D_MAPI_ -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_saturn/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -D_MAPI_ -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-font/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_transparency/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI 23 | 24 | CompilerFlags += -D_MAPI_ -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-glyph/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-markup/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-distance-field/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-distance-field-2/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-distance-field-3/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags+= -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbisGl -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub 21 | 22 | 23 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/text.vert: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | 8 | uniform sampler2D tex; 9 | uniform vec3 pixel; 10 | uniform mat4 model; 11 | uniform mat4 view; 12 | uniform mat4 projection; 13 | 14 | attribute vec3 vertex; 15 | attribute vec4 color; 16 | attribute vec2 tex_coord; 17 | attribute float ashift; 18 | attribute float agamma; 19 | 20 | varying vec4 vcolor; 21 | varying vec2 vtex_coord; 22 | varying float vshift; 23 | varying float vgamma; 24 | 25 | void main() 26 | { 27 | vshift = ashift; 28 | vgamma = agamma; 29 | vcolor = color; 30 | vtex_coord = tex_coord; 31 | gl_Position = projection*(view*(model*vec4(vertex,1.0))); 32 | } 33 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_demo_r3/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lfreetype-gl2 -lfreetype -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 23 | 24 | CompilerFlags += -D_MAPI_ 25 | 26 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_demo_r2/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | ################################### 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | LinkerFlags += -lfreetype-gl2 -lfreetype -lMiniAPI -ldebugnet -lps4link -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lorbisGl -lScePigletv2VSH_stub -lSceIme_stub -lSceSysmodule_stub -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub -lpng -lz 21 | 22 | IncludePath += -I$(Ps4Sdk)/include/MiniAPI -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 23 | 24 | 25 | CompilerFlags += -D_MAPI_ 26 | 27 | -------------------------------------------------------------------------------- /samplenfs/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target ?= ps4_elf 14 | TargetFile=homebrew.elf 15 | 16 | include $(Ps4Sdk)/make/ps4sdk.mk 17 | 18 | LinkerFlags+=-lPs4SystemCall_stub -lorbisNfs -lfreetype-gl2 -lfreetype -ldebugnet -lps4link -lelfloader -lorbisKeyboard -lpng -lz -lorbisGl -lorbisFile -lorbisPad -lorbisAudio -lmod -lorbisFileBrowser -lorbisXbmFont -lsxmlc -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceGnmDriver_stub -lSceIme_stub -lSceSysmodule_stub 19 | 20 | #CompilerFlags += -DNDEBUG -I$(Ps4Sdk)/include/nfsc 21 | IncludePath += -I$(Ps4Sdk)/include/freetype2 -I$(Ps4Sdk)/include/freetype-gl2 22 | install: 23 | @cp $(OutPath)/homebrew.elf /usr/local/orbisdev/git/ps4sh/bin 24 | @echo "Installed!" -------------------------------------------------------------------------------- /orbis_es2cube-smooth/COPYING: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a 2 | copy of this software and associated documentation files (the "Software"), 3 | to deal in the Software without restriction, including without limitation 4 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 5 | and/or sell copies of the Software, and to permit persons to whom the 6 | Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice (including the next 9 | paragraph) shall be included in all copies or substantial portions of the 10 | Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | SOFTWARE. 19 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/include/defines.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #define HAVE_SHACC // main switch: undefined to use embedded .sb 5 | 6 | 7 | #define NUM_OF_TEXTURES (6) 8 | 9 | #ifdef HAVE_SHACC 10 | #include "icons_shaders.h" 11 | #include "sprite_shaders.h" 12 | #else 13 | #include "icons_binary_shaders.h" 14 | #include "sprite_binary_shaders.h" 15 | #endif 16 | 17 | 18 | // Clang Extended Vectors 19 | typedef float vec2 __attribute__((ext_vector_type(2))); 20 | typedef float vec4 __attribute__((ext_vector_type(4))); 21 | 22 | 23 | // from shader_common.c 24 | GLuint create_vbo(const GLsizeiptr size, const GLvoid* data, const GLenum usage); 25 | #ifdef HAVE_SHACC 26 | GLuint BuildProgram(const char *vShader, const char *fShader); 27 | #else 28 | GLuint CreateProgramFromBinary(unsigned int i) ; 29 | #endif 30 | 31 | // from png.c 32 | extern vec2 tex_size; // last loaded png size as (w, h) 33 | GLuint load_png_asset_into_texture(const char* relative_path); 34 | 35 | // from timing.c 36 | unsigned int get_time_ms(void); 37 | 38 | // from VBOs.c 39 | void on_GLES2_Init(int view_w, int view_h); 40 | void on_GLES2_Size(int view_w, int view_h); 41 | void on_GLES2_Render(int num); 42 | void on_GLES2_Update(int frame); 43 | void on_GLES2_Final(void); 44 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/include/sprite_shaders.h: -------------------------------------------------------------------------------- 1 | /* 2 | sprite_shaders.h 3 | 4 | shaders used in sprite.c 5 | 6 | - one shared vertex shader 7 | locations for added: u_offset, u_p1_pos, u_time (unused) 8 | u_offset to displace UVs to select one rectangle from a bigger one (spritesheet) 9 | u_p1_pos to displace the rendered sprite 10 | 11 | - one fragment shader 12 | 1. use default texture color (no change) 13 | */ 14 | 15 | 16 | /// 1. Vertex shaders 17 | static const char *vs = 18 | /// 1. use u_offset to select one sprite from one texture 19 | "precision mediump float; \ 20 | attribute vec4 a_Position; \ 21 | attribute vec2 a_TextureCoordinates; \ 22 | varying vec2 v_TextureCoordinates; \ 23 | uniform vec2 u_offset; \ 24 | uniform vec2 u_p1_pos; \ 25 | uniform float u_time; \ 26 | void main(void) \ 27 | { \ 28 | v_TextureCoordinates = a_TextureCoordinates; \ 29 | v_TextureCoordinates += u_offset; \ 30 | gl_Position = a_Position \ 31 | + vec4(u_p1_pos.x + 1., u_p1_pos.y - 0.5, 0., 0.); \ 32 | }"; 33 | 34 | 35 | /// 2. Fragment shaders 36 | static const char *fs = 37 | /// 1. default, use texture color 38 | "precision mediump float; \ 39 | uniform sampler2D u_TextureUnit; \ 40 | varying vec2 v_TextureCoordinates; \ 41 | void main(void) \ 42 | { \ 43 | gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates); \ 44 | }"; 45 | 46 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/distance-field.frag: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | 8 | uniform sampler2D u_texture; 9 | 10 | varying vec2 vTexCoord; 11 | 12 | vec3 glyph_color = vec3(1.0,1.0,1.0); 13 | const float glyph_center = 0.50; 14 | vec3 outline_color = vec3(0.0,0.0,0.0); 15 | const float outline_center = 0.55; 16 | vec3 glow_color = vec3(1.0,1.0,1.0); 17 | const float glow_center = 1.25; 18 | 19 | void main(void) 20 | { 21 | vec4 color = texture2D(u_texture, vTexCoord); 22 | float dist = color.a; 23 | float width = fwidth(dist); 24 | float alpha = smoothstep(glyph_center-width, glyph_center+width, dist); 25 | 26 | // Smooth 27 | // gl_FragColor = vec4(glyph_color, alpha); 28 | 29 | // Outline 30 | // float mu = smoothstep(outline_center-width, outline_center+width, dist); 31 | // vec3 rgb = mix(outline_color, glyph_color, mu); 32 | // gl_FragColor = vec4(rgb, max(alpha,mu)); 33 | 34 | // Glow 35 | //vec3 rgb = mix(glow_color, glyph_color, alpha); 36 | //float mu = smoothstep(glyph_center, glow_center, sqrt(dist)); 37 | //gl_FragColor = vec4(rgb, max(alpha,mu)); 38 | 39 | // Glow + outline 40 | vec3 rgb = mix(glow_color, glyph_color, alpha); 41 | float mu = smoothstep(glyph_center, glow_center, sqrt(dist)); 42 | color = vec4(rgb, max(alpha,mu)); 43 | float beta = smoothstep(outline_center-width, outline_center+width, dist); 44 | rgb = mix(outline_color, color.rgb, beta); 45 | gl_FragColor = vec4(rgb, max(color.a,beta)); 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/include/icons_shaders.h: -------------------------------------------------------------------------------- 1 | /* 2 | icons_shaders.h 3 | 4 | shaders used in icons.c 5 | 6 | - one shared vertex shader: 7 | locations for added: offset (unused), u_time 8 | 9 | - two fragments shaders: 10 | 1. use default texture color (no change) 11 | 2. use time to apply glow effect to all color components (fade in/out effect) 12 | */ 13 | 14 | 15 | /// 1. Vertex shaders 16 | static const char *simpleVertexShader = 17 | /// 1. shared between 2 SL programs 18 | "precision mediump float;" 19 | "attribute vec4 a_Position;" 20 | "attribute vec2 a_TextureCoordinates;" 21 | "varying vec2 v_TextureCoordinates;" 22 | "uniform vec2 u_offset;" 23 | "uniform float u_time;" 24 | "void main(void)" 25 | "{" 26 | " v_TextureCoordinates = a_TextureCoordinates;" 27 | " gl_Position = a_Position;" 28 | // " gl_Position.xy *= vec2(abs(sin(u_time)));" /* zoom in/out effect */ 29 | "} "; 30 | 31 | 32 | /// 2. Fragment shaders 33 | static const char *simpleFragmentShader[2] = 34 | { 35 | /// 1. default textured fragment 36 | "precision mediump float;" 37 | "uniform sampler2D u_TextureUnit;" 38 | "varying vec2 v_TextureCoordinates;" 39 | "void main(void)" 40 | "{" 41 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" 42 | "}" 43 | , 44 | /// 2. fade in/out effect by time, like glowing 45 | "precision mediump float;" 46 | "uniform sampler2D u_TextureUnit;" 47 | "varying vec2 v_TextureCoordinates;" 48 | "uniform float u_time;" 49 | "void main(void)" 50 | "{" 51 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates)" 52 | " * vec4(abs(sin(u_time)));" /* fade in/out effect */ 53 | "}" 54 | } ; 55 | 56 | -------------------------------------------------------------------------------- /samplenfs/README.md: -------------------------------------------------------------------------------- 1 | Sample for liborbisNfs a libnfs port for PlayStation 4 2 | ====================== 3 | 4 | What does this do? 5 | =================== 6 | 7 | liborbisNfs is a homebrew user land library based in libnfs and it is part of LIBORBIS for PlayStation 4 8 | 9 | You must use only ip, name resolution not implemented call orbisNfsInit(nfs:ip/pathofyourexport) 10 | 11 | change in browser.h NFSEXPORT to your configuration 12 | 13 | copy content inside nfsexport to your nfs export path 14 | 15 | LIBORBIS was created while i was working in MSX emulator for firmware 1.76 so more than 4 years now 16 | 17 | It is open source and it can be ported easily to others sdks 18 | 19 | 20 | 21 | Change log 22 | =========================== 23 | - 25/01/2020 Initial public release 24 | 25 | 26 | Credits 27 | =========================== 28 | 29 | - All homebrew developers who are sharing source code because It is the way. For example Ronnie Sahlberg libnfs 30 | - Hitodama for his incredible work with PS4SDK the one and only 31 | - flatz to bring us a lot of fun with gl stuff 32 | - @frangar, @xerpi @theflow0 and rest of people involved in vitasdk for their incredible work on Vita, it helped me a lot 33 | Some parts of liborbis are based on their work so forgive me for stealing parts like icons and code from vitashell :P 34 | - @masterzorag for freetype and orbisfreetype-gl port and all samples for orbisgl and liborbis 35 | - All people who have been using liborbis 36 | - All ps3dev and ps2dev old comrades 37 | - @ZiL0G80 and @notzecoxao for sharing some stuff with me 38 | - All MSX users,special mention to ASUR MSX members 39 | - Hideo Kojima and Sony source of inspiration and dreams and for more than 35 years of playing and coding with Sony devices 40 | - The best is yet to come... It's time Developers... Assemble 41 | 42 | 43 | -------------------------------------------------------------------------------- /orbis_es2freetype-gl/LICENSE: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | -------------------------------------------------------------------------------- /orbis_es2freetype-gl/shaders/v3f-t2f-c4f.frag.ORIG: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | uniform sampler2D texture; 34 | void main() 35 | { 36 | float a = texture2D(texture, gl_TexCoord[0].xy).a; 37 | gl_FragColor = vec4(gl_Color.rgb, gl_Color.a*a); 38 | } 39 | -------------------------------------------------------------------------------- /orbis_es2freetype-gl/shaders/v3f-t2f-c4f.frag: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | #version 100 34 | precision mediump float; 35 | uniform sampler2D texture; 36 | 37 | varying vec2 vTexCoord; 38 | varying vec4 fragColor; 39 | 40 | void main() 41 | { 42 | float a = texture2D(texture, vTexCoord).a; 43 | gl_FragColor = vec4(fragColor.rgb, fragColor.a*a); 44 | } 45 | -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/shaders/v3f-t2f-c4f.frag: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | #version 100 34 | precision mediump float; 35 | uniform sampler2D texture; 36 | 37 | varying vec2 vTexCoord; 38 | varying vec4 fragColor; 39 | 40 | void main() 41 | { 42 | float a = texture2D(texture, vTexCoord).a; 43 | gl_FragColor = vec4(fragColor.rgb, fragColor.a*a); 44 | } 45 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_demo_r2/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | 13 | static GLuint load_texture( 14 | const GLsizei width, const GLsizei height, 15 | const GLenum type, const GLvoid *pixels) 16 | { 17 | // create new OpenGL texture 18 | GLuint texture_object_id; 19 | glGenTextures(1, &texture_object_id); 20 | assert(texture_object_id != 0); 21 | 22 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 23 | 24 | #if defined _DEMO_ 25 | // set texture filtering 26 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 27 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 28 | 29 | // generate texture from bitmap data 30 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 31 | 32 | // when using VBOs, we use this: 33 | glGenerateMipmap(GL_TEXTURE_2D); 34 | 35 | #elif defined _MAPI_ 36 | // set texture filtering 37 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 38 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 39 | 40 | // set texture wrapping mode 41 | /*glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 42 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/ 43 | 44 | // generate texture from bitmap data 45 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 46 | 47 | #endif 48 | glBindTexture(GL_TEXTURE_2D, 0); 49 | 50 | return texture_object_id; 51 | } 52 | 53 | GLuint load_png_asset_into_texture(const char* relative_path) 54 | { 55 | assert(relative_path != NULL); 56 | 57 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 58 | 59 | GLenum format = GL_RGBA; 60 | if (texture_raw->depth == 8) format = GL_RGB; 61 | 62 | const GLuint texture_object_id = load_texture( 63 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 64 | 65 | // delete buffers 66 | if(texture_raw) 67 | orbis2dDestroyTexture(texture_raw); 68 | 69 | return texture_object_id; 70 | } 71 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_demo_r3/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | 13 | static GLuint load_texture( 14 | const GLsizei width, const GLsizei height, 15 | const GLenum type, const GLvoid *pixels) 16 | { 17 | // create new OpenGL texture 18 | GLuint texture_object_id; 19 | glGenTextures(1, &texture_object_id); 20 | assert(texture_object_id != 0); 21 | 22 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 23 | 24 | #if defined _DEMO_ 25 | // set texture filtering 26 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 27 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 28 | 29 | // generate texture from bitmap data 30 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 31 | 32 | // when using VBOs, we use this: 33 | glGenerateMipmap(GL_TEXTURE_2D); 34 | 35 | #elif defined _MAPI_ 36 | // set texture filtering 37 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 38 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 39 | 40 | // set texture wrapping mode 41 | /*glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 42 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/ 43 | 44 | // generate texture from bitmap data 45 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 46 | 47 | #endif 48 | 49 | glBindTexture(GL_TEXTURE_2D, 0); 50 | 51 | return texture_object_id; 52 | } 53 | 54 | GLuint load_png_asset_into_texture(const char* relative_path) 55 | { 56 | assert(relative_path != NULL); 57 | 58 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 59 | 60 | GLenum format = GL_RGBA; 61 | if (texture_raw->depth == 8) format = GL_RGB; 62 | 63 | const GLuint texture_object_id = load_texture( 64 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 65 | 66 | // delete buffers 67 | if(texture_raw) 68 | orbis2dDestroyTexture(texture_raw); 69 | 70 | return texture_object_id; 71 | } 72 | -------------------------------------------------------------------------------- /samplenfs/include/orbisGlTextureManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017,2018 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/orbisdev/liborbis 5 | */ 6 | #ifndef _ORBISGLTEXTUREMANAGER_H_ 7 | #define _ORBISGLTEXTUREMANAGER_H_ 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define TEXTURE_VERTEX_SHADER "system/shaders/texture1.vertexShader" 16 | #define TEXTURE_FRAGMENT_SHADER "system/shaders/texture1.fragmentShader" 17 | 18 | #define ORBISGL_MAX_PROGRAMS 10 19 | #define ORBISGL_MAX_TEXTURES 10 20 | 21 | typedef struct OrbisRawTexture 22 | { 23 | uint32_t *datap; 24 | unsigned short width; 25 | unsigned short height; 26 | unsigned short depth; 27 | }OrbisRawTexture __attribute__ ((aligned (16))); 28 | 29 | typedef struct OrbisGlTexture 30 | { 31 | char name[255]; 32 | GLuint textureId; 33 | GLuint width; 34 | GLuint height; 35 | }OrbisGlTexture; 36 | 37 | typedef struct OrbisGlProgram 38 | { 39 | char name[255]; 40 | GLuint programId; 41 | }OrbisGlProgram; 42 | 43 | typedef struct OrbisGlVertexInfo 44 | { 45 | float x; 46 | float y; 47 | float u; 48 | float v; 49 | }OrbisGlVertexInfo; 50 | 51 | typedef struct OrbisGlTextureState 52 | { 53 | uint32_t screenWidth, screenHeight; 54 | OrbisGlTexture *texture; 55 | GLuint bufferId; 56 | OrbisGlProgram *program; 57 | GLuint s_xyz_loc; 58 | GLuint s_uv_loc; 59 | GLuint s_sampler_loc; 60 | OrbisGlVertexInfo* bufferData; 61 | uint32_t count; 62 | }OrbisGlTextureState; 63 | 64 | GLuint orbisGlGetProgramId(OrbisGlProgram *program); 65 | OrbisGlProgram *orbisGlGetProgram(char *name); 66 | GLuint orbisGlGetTextureId(OrbisGlTexture* text); 67 | OrbisGlTexture * orbisGlGetTexture(char* name); 68 | OrbisGlTextureState * orbisGlInitTexture(char *name,char *path,OrbisGlProgram *program,int x, int y); 69 | void orbisGlFinishTexture(OrbisGlTextureState *p); 70 | void orbisGlTextureAdd(OrbisGlTextureState *p, int x, int y,int w,int h); 71 | void orbisGlDrawTexture(OrbisGlTextureState *p); 72 | 73 | OrbisGlTexture * orbistGlTextureManagerRegisterTextureFromBuffer(char* name,int width,int height,int format,void *buf); 74 | OrbisGlTexture * orbisGlTextureManagerRegisterPngTexture(char* name, char* path); 75 | OrbisGlProgram * orbisGlTextureManagerInit(); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif 80 | 81 | #endif -------------------------------------------------------------------------------- /orbis_es2freetype-gl/shaders/v3f-t2f-c4f.vert.ORIG: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | uniform mat4 model; 34 | uniform mat4 view; 35 | uniform mat4 projection; 36 | 37 | attribute vec3 vertex; 38 | attribute vec2 tex_coord; 39 | attribute vec4 color; 40 | void main() 41 | { 42 | gl_TexCoord[0].xy = tex_coord.xy; 43 | gl_FrontColor = color; 44 | gl_Position = projection*(view*(model*vec4(vertex,1.0))); 45 | } 46 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_dna/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | 13 | static GLuint load_texture( 14 | const GLsizei width, const GLsizei height, 15 | const GLenum type, const GLvoid *pixels) 16 | { 17 | // create new OpenGL texture 18 | GLuint texture_object_id; 19 | glGenTextures(1, &texture_object_id); 20 | assert(texture_object_id != 0); 21 | 22 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 23 | 24 | #if defined _DEMO_ 25 | // set texture filtering 26 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 27 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 28 | 29 | // generate texture from bitmap data 30 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 31 | 32 | // when using VBO, we use this: 33 | glGenerateMipmap(GL_TEXTURE_2D); 34 | glBindTexture(GL_TEXTURE_2D, 0); 35 | 36 | return texture_object_id; 37 | 38 | #elif defined _MAPI_ 39 | // set texture filtering 40 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 41 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 42 | 43 | // set texture wrapping mode 44 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 45 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 46 | 47 | // generate texture from bitmap data 48 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 49 | 50 | return texture_object_id; 51 | #endif 52 | } 53 | 54 | GLuint load_png_asset_into_texture(const char* relative_path) 55 | { 56 | assert(relative_path != NULL); 57 | 58 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 59 | 60 | GLenum format = GL_RGBA; 61 | if (texture_raw->depth == 8) format = GL_RGB; 62 | 63 | const GLuint texture_object_id = load_texture( 64 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 65 | 66 | // delete buffers 67 | if(texture_raw) 68 | orbis2dDestroyTexture(texture_raw); 69 | 70 | return texture_object_id; 71 | } 72 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_breakout/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | //#define assert "load_png_asset_into_texture" 13 | 14 | 15 | static GLuint load_texture( 16 | const GLsizei width, const GLsizei height, 17 | const GLenum type, const GLvoid *pixels) 18 | { 19 | // create new OpenGL texture 20 | GLuint texture_object_id; 21 | glGenTextures(1, &texture_object_id); 22 | //assert(texture_object_id != 0); 23 | 24 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 25 | 26 | #if defined _DEMO_ 27 | // set texture filtering 28 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 29 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 30 | 31 | // generate texture from bitmap data 32 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 33 | 34 | // when using VBO, we use this: 35 | glGenerateMipmap(GL_TEXTURE_2D); 36 | glBindTexture(GL_TEXTURE_2D, 0); 37 | 38 | return texture_object_id; 39 | 40 | #elif defined _MAPI_ 41 | // set texture filtering 42 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 43 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 44 | 45 | // set texture wrapping mode 46 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 47 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 48 | 49 | // generate texture from bitmap data 50 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 51 | 52 | return texture_object_id; 53 | #endif 54 | } 55 | 56 | GLuint load_png_asset_into_texture(const char* relative_path) 57 | { 58 | //assert(relative_path != NULL); 59 | 60 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 61 | 62 | GLenum format = GL_RGBA; 63 | if (texture_raw->depth == 8) format = GL_RGB; 64 | 65 | const GLuint texture_object_id = load_texture( 66 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 67 | 68 | // delete buffers 69 | if(texture_raw) 70 | orbis2dDestroyTexture(texture_raw); 71 | 72 | return texture_object_id; 73 | } 74 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_money/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | //#define assert "load_png_asset_into_texture" 13 | 14 | 15 | static GLuint load_texture( 16 | const GLsizei width, const GLsizei height, 17 | const GLenum type, const GLvoid *pixels) 18 | { 19 | // create new OpenGL texture 20 | GLuint texture_object_id; 21 | glGenTextures(1, &texture_object_id); 22 | //assert(texture_object_id != 0); 23 | 24 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 25 | 26 | #if defined _DEMO_ 27 | // set texture filtering 28 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 29 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 30 | 31 | // generate texture from bitmap data 32 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 33 | 34 | // when using VBO, we use this: 35 | glGenerateMipmap(GL_TEXTURE_2D); 36 | glBindTexture(GL_TEXTURE_2D, 0); 37 | 38 | return texture_object_id; 39 | 40 | #elif defined _MAPI_ 41 | // set texture filtering 42 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 43 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 44 | 45 | // set texture wrapping mode 46 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 47 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 48 | 49 | // generate texture from bitmap data 50 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 51 | 52 | return texture_object_id; 53 | #endif 54 | } 55 | 56 | GLuint load_png_asset_into_texture(const char* relative_path) 57 | { 58 | //assert(relative_path != NULL); 59 | 60 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 61 | 62 | GLenum format = GL_RGBA; 63 | if (texture_raw->depth == 8) format = GL_RGB; 64 | 65 | const GLuint texture_object_id = load_texture( 66 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 67 | 68 | // delete buffers 69 | if(texture_raw) 70 | orbis2dDestroyTexture(texture_raw); 71 | 72 | return texture_object_id; 73 | } 74 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_saturn/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | //#define assert "load_png_asset_into_texture" 13 | 14 | 15 | static GLuint load_texture( 16 | const GLsizei width, const GLsizei height, 17 | const GLenum type, const GLvoid *pixels) 18 | { 19 | // create new OpenGL texture 20 | GLuint texture_object_id; 21 | glGenTextures(1, &texture_object_id); 22 | //assert(texture_object_id != 0); 23 | 24 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 25 | 26 | #if defined _DEMO_ 27 | // set texture filtering 28 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 29 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 30 | 31 | // generate texture from bitmap data 32 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 33 | 34 | // when using VBO, we use this: 35 | glGenerateMipmap(GL_TEXTURE_2D); 36 | glBindTexture(GL_TEXTURE_2D, 0); 37 | 38 | return texture_object_id; 39 | 40 | #elif defined _MAPI_ 41 | // set texture filtering 42 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 43 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 44 | 45 | // set texture wrapping mode 46 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 47 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 48 | 49 | // generate texture from bitmap data 50 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 51 | 52 | return texture_object_id; 53 | #endif 54 | } 55 | 56 | GLuint load_png_asset_into_texture(const char* relative_path) 57 | { 58 | //assert(relative_path != NULL); 59 | 60 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 61 | 62 | GLenum format = GL_RGBA; 63 | if (texture_raw->depth == 8) format = GL_RGB; 64 | 65 | const GLuint texture_object_id = load_texture( 66 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 67 | 68 | // delete buffers 69 | if(texture_raw) 70 | orbis2dDestroyTexture(texture_raw); 71 | 72 | return texture_object_id; 73 | } 74 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_transparency/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | //#include 8 | 9 | #include 10 | #include 11 | 12 | //#define assert "load_png_asset_into_texture" 13 | 14 | 15 | static GLuint load_texture( 16 | const GLsizei width, const GLsizei height, 17 | const GLenum type, const GLvoid *pixels) 18 | { 19 | // create new OpenGL texture 20 | GLuint texture_object_id; 21 | glGenTextures(1, &texture_object_id); 22 | //assert(texture_object_id != 0); 23 | 24 | glBindTexture(GL_TEXTURE_2D, texture_object_id); 25 | 26 | #if defined _DEMO_ 27 | // set texture filtering 28 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 29 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 30 | 31 | // generate texture from bitmap data 32 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 33 | 34 | // when using VBO, we use this: 35 | glGenerateMipmap(GL_TEXTURE_2D); 36 | glBindTexture(GL_TEXTURE_2D, 0); 37 | 38 | return texture_object_id; 39 | 40 | #elif defined _MAPI_ 41 | // set texture filtering 42 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 43 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 44 | 45 | // set texture wrapping mode 46 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 47 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 48 | 49 | // generate texture from bitmap data 50 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 51 | 52 | return texture_object_id; 53 | #endif 54 | } 55 | 56 | GLuint load_png_asset_into_texture(const char* relative_path) 57 | { 58 | //assert(relative_path != NULL); 59 | 60 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v2(relative_path); 61 | 62 | GLenum format = GL_RGBA; 63 | if (texture_raw->depth == 8) format = GL_RGB; 64 | 65 | const GLuint texture_object_id = load_texture( 66 | texture_raw->width, texture_raw->height, format, orbis2dTextureGetDataPointer(texture_raw)); 67 | 68 | // delete buffers 69 | if(texture_raw) 70 | orbis2dDestroyTexture(texture_raw); 71 | 72 | return texture_object_id; 73 | } 74 | -------------------------------------------------------------------------------- /orbis_es2freetype-gl/shaders/v3f-t2f-c4f.vert: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | 34 | #version 100 35 | precision mediump float; 36 | uniform mat4 model; 37 | uniform mat4 view; 38 | uniform mat4 projection; 39 | 40 | attribute vec3 vertex; 41 | attribute vec2 tex_coord; 42 | attribute vec4 color; 43 | 44 | varying vec2 vTexCoord; 45 | 46 | //use your own output instead of gl_FragColor 47 | varying vec4 fragColor; 48 | 49 | void main() 50 | { 51 | vTexCoord.xy = tex_coord.xy; 52 | fragColor = color; 53 | gl_Position = projection*(view*(model*vec4(vertex,1.0))); 54 | } 55 | -------------------------------------------------------------------------------- /samplenfs/nfsexport/system/shaders/v3f-t2f-c4f.vert: -------------------------------------------------------------------------------- 1 | /* ========================================================================= 2 | * Freetype GL - A C OpenGL Freetype engine 3 | * Platform: Any 4 | * WWW: http://code.google.com/p/freetype-gl/ 5 | * ------------------------------------------------------------------------- 6 | * Copyright 2011 Nicolas P. Rougier. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright notice, 12 | * this list of conditions and the following disclaimer. 13 | * 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | * The views and conclusions contained in the software and documentation are 30 | * those of the authors and should not be interpreted as representing official 31 | * policies, either expressed or implied, of Nicolas P. Rougier. 32 | * ========================================================================= */ 33 | 34 | #version 100 35 | precision mediump float; 36 | uniform mat4 model; 37 | uniform mat4 view; 38 | uniform mat4 projection; 39 | 40 | attribute vec3 vertex; 41 | attribute vec2 tex_coord; 42 | attribute vec4 color; 43 | 44 | varying vec2 vTexCoord; 45 | 46 | //use your own output instead of gl_FragColor 47 | varying vec4 fragColor; 48 | 49 | void main() 50 | { 51 | vTexCoord.xy = tex_coord.xy; 52 | fragColor = color; 53 | gl_Position = projection*(view*(model*vec4(vertex,1.0))); 54 | } 55 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/source/png.c: -------------------------------------------------------------------------------- 1 | /* 2 | png to texture wrappers 3 | */ 4 | 5 | #include 6 | #include // reuse orbis2d png wrappers and Orbis2dTexture type 7 | #include 8 | 9 | #include "defines.h" 10 | 11 | 12 | static GLuint load_texture( 13 | const GLsizei width, const GLsizei height, 14 | const GLenum type, const GLvoid *pixels) 15 | { 16 | // create new OpenGL texture 17 | GLuint texture_object_id; 18 | glGenTextures(1, &texture_object_id); 19 | assert(texture_object_id != 0); 20 | 21 | glBindTexture(GL_TEXTURE_2D, texture_object_id); // bind texture 22 | 23 | #if defined _DEMO_ 24 | // set texture filtering 25 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 26 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 27 | 28 | // generate texture from bitmap data 29 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 30 | 31 | // create MipMaps, but size should be modulo(2) 32 | glGenerateMipmap(GL_TEXTURE_2D); 33 | 34 | #elif defined _MAPI_ 35 | // set texture filtering 36 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 37 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 38 | 39 | // set texture wrapping mode 40 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 41 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 42 | 43 | // generate texture from bitmap data 44 | glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels); 45 | 46 | #endif 47 | glBindTexture(GL_TEXTURE_2D, 0); // unbind texture 48 | 49 | return texture_object_id; 50 | } 51 | 52 | 53 | /* externed */ vec2 tex_size; // last loaded png size as (w, h) 54 | 55 | /// textures 56 | GLuint load_png_asset_into_texture(const char* relative_path) 57 | { 58 | assert(relative_path != NULL); 59 | 60 | Orbis2dTexture* texture_raw = orbis2dLoadPngFromHost_v3(relative_path); // _v3 rely on liborbisFile! 61 | 62 | GLenum format = GL_RGBA; 63 | if (texture_raw->depth == 8) format = GL_RGB; 64 | 65 | const GLuint texture_object_id = load_texture( texture_raw->width, texture_raw->height, 66 | format, 67 | orbis2dTextureGetDataPointer(texture_raw)); 68 | // take note of image resolution size to setup VBO in px size 69 | tex_size = (vec2){ texture_raw->width, texture_raw->height }; 70 | 71 | // delete buffers 72 | if(texture_raw) 73 | orbis2dDestroyTexture(texture_raw); 74 | 75 | return texture_object_id; 76 | } 77 | -------------------------------------------------------------------------------- /orbis_es2cube-smooth/source/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Rob Clark 3 | * Copyright © 2013 Intel Corporation 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a 6 | * copy of this software and associated documentation files (the "Software"), 7 | * to deal in the Software without restriction, including without limitation 8 | * the rights to use, copy, modify, merge, publish, distribute, sub license, 9 | * and/or sell copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice (including the 13 | * next paragraph) shall be included in all copies or substantial portions 14 | * of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "esUtil.h" 33 | 34 | 35 | int create_program(const char *vs_src, const char *fs_src) 36 | { 37 | GLuint vertex_shader, fragment_shader, program; 38 | GLint ret; 39 | 40 | vertex_shader = glCreateShader(GL_VERTEX_SHADER); 41 | 42 | glShaderSource(vertex_shader, 1, &vs_src, NULL); 43 | glCompileShader(vertex_shader); 44 | 45 | glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &ret); 46 | if (!ret) { 47 | char *log; 48 | 49 | debugNetPrintf(ERROR,"vertex shader compilation failed!:\n"); 50 | glGetShaderiv(vertex_shader, GL_INFO_LOG_LENGTH, &ret); 51 | if (ret > 1) { 52 | log = malloc(ret); 53 | glGetShaderInfoLog(vertex_shader, ret, NULL, log); 54 | debugNetPrintf(INFO,"%s", log); 55 | free(log); 56 | } 57 | 58 | return -1; 59 | } 60 | 61 | fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); 62 | 63 | glShaderSource(fragment_shader, 1, &fs_src, NULL); 64 | glCompileShader(fragment_shader); 65 | 66 | glGetShaderiv(fragment_shader, GL_COMPILE_STATUS, &ret); 67 | if (!ret) { 68 | char *log; 69 | 70 | debugNetPrintf(ERROR,"fragment shader compilation failed!:\n"); 71 | glGetShaderiv(fragment_shader, GL_INFO_LOG_LENGTH, &ret); 72 | 73 | if (ret > 1) { 74 | log = malloc(ret); 75 | glGetShaderInfoLog(fragment_shader, ret, NULL, log); 76 | debugNetPrintf(INFO,"%s", log); 77 | free(log); 78 | } 79 | 80 | return -1; 81 | } 82 | 83 | program = glCreateProgram(); 84 | 85 | glAttachShader(program, vertex_shader); 86 | glAttachShader(program, fragment_shader); 87 | 88 | return program; 89 | } 90 | 91 | int link_program(unsigned program) 92 | { 93 | GLint ret; 94 | 95 | glLinkProgram(program); 96 | 97 | glGetProgramiv(program, GL_LINK_STATUS, &ret); 98 | if (!ret) { 99 | char *log; 100 | 101 | debugNetPrintf(ERROR,"program linking failed!:\n"); 102 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &ret); 103 | 104 | if (ret > 1) { 105 | log = malloc(ret); 106 | glGetProgramInfoLog(program, ret, NULL, log); 107 | debugNetPrintf(INFO,"%s", log); 108 | free(log); 109 | } 110 | 111 | return -1; 112 | } 113 | 114 | return 0; 115 | } 116 | -------------------------------------------------------------------------------- /samplenfs/source/user_nfs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | int process_server(const char *server) 18 | { 19 | debugNetPrintf(DEBUG, "mount_getexports(%s):\n", server); 20 | struct exportnode *exports; 21 | struct exportnode *export; 22 | 23 | exports = mount_getexports(server); 24 | if (exports == NULL) { 25 | debugNetPrintf(ERROR, "Failed to get exports for server %s.\n", server); 26 | return -1; 27 | } 28 | for (export=exports; export; export = export->ex_next) { 29 | debugNetPrintf(INFO, "nfs://%s%s\n", server, export->ex_dir); 30 | } 31 | mount_free_export_list(exports); 32 | return 0; 33 | } 34 | 35 | 36 | // globals, just one at once 37 | struct nfs_context *nfs = NULL; 38 | struct nfs_url *url = NULL; 39 | struct nfsfh *fh = NULL; 40 | struct nfs_stat_64 st; 41 | static uint64_t off = 0; 42 | 43 | 44 | #define BUFSIZE /* (DRMP3_DATA_CHUNK_SIZE) */ ( 16 *1024 ) 45 | 46 | // read chunks of max BUFSIZE in bytes 47 | void user_refill_buffer(unsigned char *pData, int offinFixedBuffer) 48 | { 49 | if(off < st.nfs_size) 50 | { 51 | int count = st.nfs_size - off; 52 | if(count > BUFSIZE) count = BUFSIZE; 53 | 54 | count -= offinFixedBuffer; 55 | count = nfs_pread(nfs, fh, off, count, pData + offinFixedBuffer); 56 | 57 | if(count < 0) { fprintf(stderr, "Failed to read from file\n"); return; } 58 | //debugNetPrintf(DEBUG, "nfs readchunk: %lldb %db @ %p + %d\n", off, count, pData, offinFixedBuffer); 59 | off += count; 60 | } 61 | } 62 | 63 | 64 | /// setup nfs contex, mount export 65 | int user_init(void) 66 | { 67 | nfs = nfs_init_context(); 68 | 69 | nfs_set_debug(nfs, /*debug_level*/0); // quite down 70 | 71 | // optional, list server exports 72 | static const char *srv = "10.0.0.2"; 73 | int ret = process_server(srv); 74 | debugNetPrintf(DEBUG, "process_server(nfs://%s): %d\n", srv, ret); 75 | 76 | // parse url and mount export 77 | url = nfs_parse_url_dir(nfs, "nfs://10.0.0.2/hostapp"); 78 | ret = nfs_mount(nfs, url->server, url->path); 79 | debugNetPrintf(DEBUG, "nfs_mount return: %d\n", ret); 80 | 81 | return 1; 82 | } 83 | 84 | // we have opened just one file at once 85 | size_t user_stat(void) 86 | { 87 | if(nfs_fstat64(nfs, fh, &st)) 88 | { debugNetPrintf(DEBUG, "Failed to stat file : %s\n", nfs_get_error(nfs)); return -1; } 89 | return st.nfs_size; 90 | } 91 | 92 | // just open, don't read 93 | int user_open(char *filename) 94 | { 95 | int flags = 0; 96 | off = 0; 97 | flags |= O_RDONLY; 98 | if(nfs_open(nfs, filename, flags, &fh)) 99 | { debugNetPrintf(DEBUG, "Failed to open(%s)\n", nfs_get_error(nfs)); return -1; } 100 | return 1; 101 | } 102 | 103 | void user_close(void) 104 | { 105 | debugNetPrintf(DEBUG,"user_close, %p, %p, %p\n", nfs, url, fh); 106 | if(nfs_close(nfs, fh)) 107 | { debugNetPrintf(DEBUG, "Failed to close(): %s\n", nfs_get_error(nfs)); return; } 108 | } 109 | 110 | 111 | /// cleanup, umount export, destroy nfs context 112 | void user_end(void) 113 | { 114 | debugNetPrintf(DEBUG,"user_end, %p, %p, %p\n", nfs, url, fh); 115 | int ret = -1; 116 | goto finished; 117 | 118 | if(nfs && fh) 119 | { 120 | ret = nfs_close(nfs, fh); 121 | if(ret) 122 | { 123 | debugNetPrintf(DEBUG, "Failed to close(): %s\n", nfs_get_error(nfs)); 124 | } 125 | } 126 | 127 | finished: 128 | ret = nfs_umount(nfs); 129 | debugNetPrintf(DEBUG, "nfs_umount return: %x\n", ret); 130 | 131 | nfs_destroy_url(url); 132 | nfs_destroy_context(nfs); 133 | 134 | return; 135 | } 136 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/shaders/text.frag: -------------------------------------------------------------------------------- 1 | /* Freetype GL - A C OpenGL Freetype engine 2 | * 3 | * Distributed under the OSI-approved BSD 2-Clause License. See accompanying 4 | * file `LICENSE` for more details. 5 | */ 6 | precision mediump float; 7 | 8 | vec3 9 | energy_distribution( vec4 previous, vec4 current, vec4 next ) 10 | { 11 | float primary = 1.0/3.0; 12 | float secondary = 1.0/3.0; 13 | float tertiary = 0.0; 14 | 15 | // Energy distribution as explained on: 16 | // http://www.grc.com/freeandclear.htm 17 | // 18 | // .. v.. 19 | // RGB RGB RGB 20 | // previous.g + previous.b + current.r + current.g + current.b 21 | // 22 | // . .v. . 23 | // RGB RGB RGB 24 | // previous.b + current.r + current.g + current.b + next.r 25 | // 26 | // ..v .. 27 | // RGB RGB RGB 28 | // current.r + current.g + current.b + next.r + next.g 29 | 30 | float r = 31 | tertiary * previous.g + 32 | secondary * previous.b + 33 | primary * current.r + 34 | secondary * current.g + 35 | tertiary * current.b; 36 | 37 | float g = 38 | tertiary * previous.b + 39 | secondary * current.r + 40 | primary * current.g + 41 | secondary * current.b + 42 | tertiary * next.r; 43 | 44 | float b = 45 | tertiary * current.r + 46 | secondary * current.g + 47 | primary * current.b + 48 | secondary * next.r + 49 | tertiary * next.g; 50 | 51 | return vec3(r,g,b); 52 | } 53 | 54 | uniform sampler2D tex; 55 | uniform vec3 pixel; 56 | 57 | varying vec4 vcolor; 58 | varying vec2 vtex_coord; 59 | varying float vshift; 60 | varying float vgamma; 61 | 62 | void main() 63 | { 64 | // LCD Off 65 | if( pixel.z == 1.0) 66 | { 67 | float a = texture2D(tex, vtex_coord).r; 68 | gl_FragColor = vcolor * pow( a, 1.0/vgamma ); 69 | return; 70 | } 71 | 72 | // LCD On 73 | vec4 current = texture2D(tex, vtex_coord); 74 | vec4 previous= texture2D(tex, vtex_coord+vec2(-1.,0.)*pixel.xy); 75 | vec4 next = texture2D(tex, vtex_coord+vec2(+1.,0.)*pixel.xy); 76 | 77 | current = pow(current, vec4(1.0/vgamma)); 78 | previous= pow(previous, vec4(1.0/vgamma)); 79 | 80 | float r = current.r; 81 | float g = current.g; 82 | float b = current.b; 83 | 84 | if( vshift <= 0.333 ) 85 | { 86 | float z = vshift/0.333; 87 | r = mix(current.r, previous.b, z); 88 | g = mix(current.g, current.r, z); 89 | b = mix(current.b, current.g, z); 90 | } 91 | else if( vshift <= 0.666 ) 92 | { 93 | float z = (vshift-0.33)/0.333; 94 | r = mix(previous.b, previous.g, z); 95 | g = mix(current.r, previous.b, z); 96 | b = mix(current.g, current.r, z); 97 | } 98 | else if( vshift < 1.0 ) 99 | { 100 | float z = (vshift-0.66)/0.334; 101 | r = mix(previous.g, previous.r, z); 102 | g = mix(previous.b, previous.g, z); 103 | b = mix(current.r, previous.b, z); 104 | } 105 | 106 | float t = max(max(r,g),b); 107 | vec4 color = vec4(vcolor.rgb, (r+g+b)/3.0); 108 | color = t*color + (1.0-t)*vec4(r,g,b, min(min(r,g),b)); 109 | gl_FragColor = vec4( color.rgb, vcolor.a*color.a); 110 | 111 | 112 | // gl_FragColor = vec4(pow(vec3(r,g,b),vec3(1.0/vgamma)),a); 113 | 114 | /* 115 | vec3 color = energy_distribution(previous, vec4(r,g,b,1), next); 116 | color = pow( color, vec3(1.0/vgamma)); 117 | 118 | vec3 color = vec3(r,g,b); //pow( vec3(r,g,b), vec3(1.0/vgamma)); 119 | gl_FragColor.rgb = color; 120 | gl_FragColor.a = (color.r+color.g+color.b)/3.0 * vcolor.a; 121 | */ 122 | 123 | // gl_FragColor = vec4(pow(vec3(r,g,b),vec3(1.0/vgamma)),a); 124 | //gl_FragColor = vec4(r,g,b,a); 125 | } 126 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/source/shader_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | shader_common.c 3 | 4 | shaders facilities about building and loading shaders 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include "defines.h" 15 | 16 | 17 | GLuint create_vbo(const GLsizeiptr size, const GLvoid* data, const GLenum usage) 18 | { 19 | assert(data != NULL); 20 | GLuint vbo_object; 21 | glGenBuffers(1, &vbo_object); 22 | assert(vbo_object != 0); 23 | 24 | glBindBuffer(GL_ARRAY_BUFFER, vbo_object); 25 | glBufferData(GL_ARRAY_BUFFER, size, data, usage); 26 | glBindBuffer(GL_ARRAY_BUFFER, 0); 27 | 28 | return vbo_object; 29 | } 30 | 31 | static GLuint LinkProgram(GLuint vertexShader, GLuint fragmentShader) 32 | { 33 | GLuint programHandle = glCreateProgram(); 34 | glAttachShader(programHandle, vertexShader); 35 | glAttachShader(programHandle, fragmentShader); 36 | glLinkProgram (programHandle); 37 | 38 | GLint linkSuccess; 39 | glGetProgramiv(programHandle, GL_LINK_STATUS, &linkSuccess); 40 | if (linkSuccess == GL_FALSE) 41 | { debugNetPrintf(ERROR, "GL_LINK_STATUS error\n"); } 42 | 43 | if(vertexShader) { glDeleteShader(vertexShader), vertexShader = 0; } 44 | if(fragmentShader) { glDeleteShader(fragmentShader), fragmentShader = 0; } 45 | 46 | return programHandle; 47 | } 48 | 49 | #ifdef HAVE_SHACC 50 | 51 | static GLuint BuildShader(const char *source, GLenum shaderType) 52 | { 53 | GLuint shaderHandle = glCreateShader(shaderType); 54 | 55 | glShaderSource (shaderHandle, 1, &source, 0); 56 | glCompileShader(shaderHandle); 57 | GLint compileSuccess; 58 | glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess); 59 | if (compileSuccess == GL_FALSE) 60 | { 61 | GLchar messages[256]; 62 | glGetShaderInfoLog(shaderHandle, sizeof(messages), 0, &messages[0]); 63 | debugNetPrintf(DEBUG, "compile glsl error : %s\n", messages); 64 | } 65 | return shaderHandle; 66 | } 67 | 68 | GLuint BuildProgram(const char *vShader, const char *fShader) 69 | { 70 | GLuint vertexShader = BuildShader(vShader, GL_VERTEX_SHADER); 71 | GLuint fragmentShader = BuildShader(fShader, GL_FRAGMENT_SHADER); 72 | /* after built, dump those in .sb form 73 | DumpShader(vertexShader, "vShader"); 74 | DumpShader(fragmentShader, "fShader"); 75 | */ 76 | return LinkProgram(vertexShader, fragmentShader); 77 | } 78 | 79 | #else // HAVE_SHACC 80 | 81 | GLuint CreateProgramFromBinary(unsigned int i) //const char *vShader, const char *fShader) 82 | { 83 | GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); 84 | GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); 85 | GLuint programHandle = 0; 86 | int ret; 87 | 88 | if(!vertexShader) 89 | { ret = glGetError(); debugNetPrintf(ERROR, "glCreateShader(%d)", ret); goto err; } 90 | else 91 | if(!fragmentShader) 92 | { ret = glGetError(); debugNetPrintf(ERROR, "glCreateShader(%d)", ret); goto err; } 93 | 94 | const GLvoid *fShader; // use embedded .sb 95 | switch(i) 96 | { // select which fragment shader will be used, for program i //todo enums 97 | default: 98 | /* icons_binary_shaders.h */ 99 | case 0: fShader = &fShader0; break; 100 | case 1: fShader = &fShader1; break; 101 | /* sprite_binary_shaders.h */ 102 | case 2: fShader = &fShader2; break; 103 | /* more SL program pairs to add ! */ 104 | } 105 | glShaderBinary( 1, &vertexShader, 2, (const GLvoid*)&vShader, vShader_len[0]); 106 | glShaderBinary( 1, &fragmentShader, 2, fShader, fShader_len[i]); 107 | 108 | programHandle = LinkProgram(vertexShader, fragmentShader); 109 | err: 110 | return programHandle; 111 | } 112 | 113 | #endif // HAVE_SHACC 114 | -------------------------------------------------------------------------------- /samplenfs/source/credits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017,2018 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/orbisdev/liborbis 5 | */ 6 | #include 7 | #include 8 | #include // links against libfreetype-gl 9 | 10 | 11 | #include "orbisGlText.h" 12 | #include "orbisGlTextureManager.h" 13 | #include "browser.h" 14 | extern OrbisGlTextureState *creditsTexture; 15 | //extern OrbisGlTextureState *browserTexture; 16 | 17 | extern int screenStatus; 18 | 19 | // just called once, we are setting up vertexes positions and textures 20 | 21 | vec4 color = {{ 1., 1., 1., 1. }}; 22 | 23 | void footerDrawText(void) 24 | { 25 | orbisGlTextSetupBuffer("Credits",30,52+15,color); 26 | orbisGlTextSetupBuffer("Back",90-22,1000+34,color); 27 | orbisGlTextSetupBuffer("Browser",100+90-22+64,1000+34,color); 28 | orbisGlTextSetupBuffer("Credits",220+90-22+64+79,1000+34,color); 29 | orbisGlTextSetupBuffer("Select",340+90-22+64+79+79,1000+34,color); 30 | } 31 | 32 | void creditsDrawText(void) 33 | { 34 | int i=0; 35 | orbisGlTextSetupBuffer("libOrbisNfs is a homebrew library based in libnfs and it is part of LIBORBIS for PlayStation 4",60,90+i*30+1+67,color);i++; 36 | orbisGlTextSetupBuffer("LIBORBIS was created while i was working in MSX emulator for firmware 1.76 so more than 4 years now",60,90+i*30+1+67,color);i++; 37 | orbisGlTextSetupBuffer("It is open source and it can be ported easily to others sdks",60,90+i*30+1+67,color);i++; 38 | orbisGlTextSetupBuffer("Source code of LIBORBIS is available at:",60,90+i*30+1+67,color);i++; 39 | orbisGlTextSetupBuffer("https://github.com/orbisdev/liborbis",60,90+i*30+1+67,color);i++; 40 | orbisGlTextSetupBuffer("This software have been done using the following open source tools:",60,90+i*30+1+67,color);i++; 41 | orbisGlTextSetupBuffer("- Hitodama's PS4SDK with lasted addons check:",60,90+i*30+1+67,color);i++; 42 | orbisGlTextSetupBuffer("https://github.com/psxdev/ps4sdk/tree/firmware505",60,90+i*30+1+67,color);i++; 43 | orbisGlTextSetupBuffer("- Open Source Toolchain based on LLVM/Clang and gnu binutils compiled on MacOS",60,90+i*30+1+67,color);i++; 44 | orbisGlTextSetupBuffer("- This sample is available at",60,90+i*30+1+67,color);i++; 45 | orbisGlTextSetupBuffer("https://github.com/orbisdev/samples/samplenfs",60,90+i*30+1+67,color);i++; 46 | orbisGlTextSetupBuffer("- Gimp for all graphic stuff",60,90+i*30+1+67,color);i++; 47 | orbisGlTextSetupBuffer("Special thanks goes to:",60,90+i*30+1+67,color);i++; 48 | orbisGlTextSetupBuffer("- All homebrew developers who are sharing source code because It is the way. For example Ronnie Sahlberg libnfs author",60,90+i*30+1+67,color);i++; 49 | orbisGlTextSetupBuffer("- Hitodama for his incredible work with PS4SDK the one and only",60,90+i*30+1+67,color);i++; 50 | orbisGlTextSetupBuffer("- flatz to bring us a lot of fun with gl stuff",60,90+i*30+1+67,color);i++; 51 | orbisGlTextSetupBuffer("- @frangar, @xerpi @theflow0 and rest of people involved in vitasdk for their incredible work on Vita, it helped me a lot :P",60,90+i*30+1+67,color);i++; 52 | orbisGlTextSetupBuffer("Some parts of liborbis are based on their work so forgive me for stealing parts like icons and code from vitashell :P",60,90+i*30+1+67,color);i++; 53 | orbisGlTextSetupBuffer("- @masterzorag for freetype and orbisfreetype-gl port and all samples for orbisgl and liborbis",60,90+i*30+1+67,color);i++; 54 | orbisGlTextSetupBuffer("- All people who have been using liborbis all these years",60,90+i*30+1+67,color);i++; 55 | orbisGlTextSetupBuffer("- All ps3dev and ps2dev old comrades",60,90+i*30+1+67,color);i++; 56 | orbisGlTextSetupBuffer("- @ZiL0G80 and @notzecoxao for sharing some stuff with me",60,90+i*30+1+67,color);i++; 57 | orbisGlTextSetupBuffer("- All MSX users, special mention to ASUR MSX members",60,90+i*30+1+67,color);i++; 58 | orbisGlTextSetupBuffer("- Hideo Kojima and Sony source of inspiration and dreams and thanks for more than 35 years of playing and coding with Sony devices",60,90+i*30+1+67,color);i++; 59 | orbisGlTextSetupBuffer("If you want contact with me you can do at @psxdev on twitter",60,90+i*30+1+67,color);i++;i++; 60 | orbisGlTextSetupBuffer("Antonio Jose Ramos Marquez aka bigboss",60,90+i*30+1+67,color);i++; 61 | orbisGlTextSetupBuffer("The best is yet to come... It's time Developers... Assemble",60,90+i*30+1+67,color);i++;i++; 62 | 63 | debugNetPrintf(DEBUG,"creditsDrawText\n"); 64 | } 65 | -------------------------------------------------------------------------------- /samplenfs/source/browser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017,2018 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/orbisdev/liborbis 5 | */ 6 | #include 7 | #include 8 | 9 | #include // links against libfreetype-gl 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | #include "browser.h" 17 | //int posy=0; 18 | //int posx=0; 19 | vec4 color; 20 | int flagfolder=0; 21 | 22 | OrbisNfsBrowserListEntry *currentEntry; 23 | 24 | #include "orbisGlTextureManager.h" 25 | extern OrbisGlTextureState *folderTexture, *fileTexture; 26 | 27 | 28 | void getSizeString(char string[8],char string1[3], uint64_t size) 29 | { 30 | double double_size = (double)size; 31 | 32 | int i = 0; 33 | static char *units[] = { "B ", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; 34 | while (double_size >= 1024.0) { 35 | double_size /= 1024.0; 36 | i++; 37 | } 38 | //char string1[16]; 39 | snprintf(string, 8, "%.*f",(i == 0) ? 0 : 2, double_size); 40 | snprintf(string1, 3, "%s",units[i]); 41 | //debugNetPrintf(DEBUG,"%s %d\n",string,strlen(string)); 42 | //debugNetPrintf(DEBUG,"%s %d\n",string1,strlen(string1)); 43 | 44 | //snprintf(string, 16, "%.*f %s", 2, double_size, units[i]); 45 | 46 | } 47 | 48 | void selected_entry(char *tmp) 49 | { 50 | int i = orbisNfsBrowserGetRelPos(); 51 | currentEntry = orbisNfsBrowserListGetNthEntry(i); 52 | debugNetPrintf(DEBUG,"orbisNfsBrowserGetRelPos: %d, '%s'\n", i, currentEntry->dir->name); 53 | if(tmp) 54 | strcpy(tmp, currentEntry->dir->name); 55 | } 56 | 57 | #include "orbisGlText.h" 58 | 59 | void browserDrawText(void) 60 | { 61 | int i=0; 62 | char dateString[20]; 63 | char sizeString[8]; 64 | char unitString[3]; 65 | char mypath[256]; 66 | 67 | if(flagfolder==1 && currentEntry) 68 | { 69 | if(strcmp(currentEntry->dir->name,".")!=0) 70 | { 71 | debugNetPrintf(DEBUG,"go to new directory %s\n",currentEntry->dir->name); 72 | //char rootpath[256]; 73 | //sprintf(rootpath,"%s/%s",orbisNfsBrowserGetListPath(),currentEntry->dir->name); 74 | //debugNetPrintf(DEBUG,"go to new directory %s\n",rootpath); 75 | if(strcmp(currentEntry->dir->name,"..")!=0) 76 | { 77 | orbisNfsBrowserDirLevelUp(currentEntry->dir->name); 78 | } 79 | else 80 | { 81 | orbisNfsBrowserDirLevelDown(); 82 | } 83 | debugNetPrintf(DEBUG,"after orbisNfsBrowserDirLevelUp\n"); 84 | } 85 | else 86 | { 87 | orbisNfsBrowserListRefresh(); 88 | } 89 | flagfolder=0; 90 | } 91 | OrbisNfsBrowserListEntry *entry=orbisNfsBrowserListGetNthEntry(orbisNfsBrowserGetBasePos()); 92 | 93 | /// header 94 | color = (vec4){{ 1., .6, .1, 1. }}; 95 | char *aux=orbisNfsBrowserGetListPath(); 96 | if(aux[0]=='.' && strlen(aux)<=2) 97 | { 98 | snprintf(mypath,256,"%s","nfs:/"); 99 | } 100 | else 101 | { 102 | char *aux1=orbisNfsBrowserGetListPath(); 103 | snprintf(mypath,256,"%s%s","nfs:/",&aux1[2]); 104 | } 105 | orbisGlTextSetupBuffer(mypath,30,52+76-30+2,color); 106 | 107 | /// iterate entries 108 | while(entry && idir->customtype==FILE_TYPE_FOLDER) 111 | { 112 | if(folderTexture) 113 | { 114 | //orbisGlDraw(programTextureId,folderTextureId,30,90+i*20); 115 | orbisGlDrawTextureSpecial(folderTexture,30,90+i*30+1+67-30-15); 116 | 117 | } 118 | //sprintf(sizeString,"%s","FOLDER"); 119 | getSizeString(sizeString,unitString,entry->dir->size); 120 | } 121 | else 122 | { 123 | if(fileTexture) 124 | { 125 | //orbisGlDraw(programTextureId,fileTextureId,30,90+i*20+2); 126 | orbisGlDrawTextureSpecial(fileTexture,30,90+i*30+1+67-30-15); 127 | 128 | } 129 | getSizeString(sizeString,unitString,entry->dir->size); 130 | } 131 | //debugNetPrintf(DEBUG,("%s %d\n",entry->name,entry->type); 132 | 133 | // this color mark has to be done in render pass! 134 | if(i==orbisNfsBrowserGetRelPos()) 135 | { 136 | color = (vec4){{ 1., .2, .9, 1. }}; // selected entry 137 | } 138 | else 139 | { 140 | color = (vec4){{ 1., 1., 1., 1. }}; 141 | } 142 | //print_text(50+posx,90+i*20+posy,entry->dir->name); 143 | orbisGlTextSetupBuffer(entry->dir->name,60,90+i*30+1+67-30,color); 144 | 145 | sprintf(dateString,"%02d/%02d/%04d %02d:%02d %s", 146 | entry->dir->mtime.day, 147 | entry->dir->mtime.month, 148 | entry->dir->mtime.year, 149 | entry->dir->mtime.hour>12?entry->dir->mtime.hour-12:entry->dir->mtime.hour, 150 | entry->dir->mtime.minute, 151 | entry->dir->mtime.hour>=12? "PM" : "AM"); 152 | orbisGlTextSetupBuffer(dateString,740+960+8-15-35,90+i*30+1+67-30,color); 153 | //orbisGlTextDraw(" hello world",740+960+8-15-35,90+i*30+1+67-30,color); 154 | 155 | orbisGlTextSetupBuffer(unitString,740+960-8-15-35-22*2,90+i*30+1+67-30,color); 156 | orbisGlTextSetupBuffer(sizeString,740+960-8-15-35-22*7,90+i*30+1+67-30,color); 157 | 158 | entry=entry->next; 159 | i++; 160 | 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /orbis_MAPI_samples/MAPI_demo_r2/source/vbo.c: -------------------------------------------------------------------------------- 1 | /* 2 | GLES2 texture from png using shaders and VBO 3 | 2019, masterzorag 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | 16 | GLuint simpleProgram; 17 | static GLuint texture; 18 | static GLuint buffer; 19 | #define BUFFER_OFFSET(i) ((void*)(i)) 20 | 21 | static GLint a_position_location; 22 | static GLint a_texture_coordinates_location; 23 | static GLint u_texture_unit_location; 24 | 25 | // position X, Y, texture S, T 26 | static const float rect[] = {-1.0f, -1.0f, 0.0f, 0.0f, 27 | -1.0f, 1.0f, 0.0f, 1.0f, 28 | 1.0f, -1.0f, 1.0f, 0.0f, 29 | 1.0f, 1.0f, 1.0f, 1.0f}; 30 | 31 | GLuint create_vbo(const GLsizeiptr size, const GLvoid* data, const GLenum usage) 32 | { 33 | assert(data != NULL); 34 | GLuint vbo_object; 35 | glGenBuffers(1, &vbo_object); 36 | assert(vbo_object != 0); 37 | 38 | glBindBuffer(GL_ARRAY_BUFFER, vbo_object); 39 | glBufferData(GL_ARRAY_BUFFER, size, data, usage); 40 | glBindBuffer(GL_ARRAY_BUFFER, 0); 41 | 42 | return vbo_object; 43 | } 44 | 45 | GLuint BuildShader(const char *source, GLenum shaderType) 46 | { 47 | GLuint shaderHandle = glCreateShader(shaderType); 48 | glShaderSource(shaderHandle, 1, &source, 0); 49 | glCompileShader(shaderHandle); 50 | GLint compileSuccess; 51 | glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess); 52 | 53 | if (compileSuccess == GL_FALSE) 54 | { 55 | GLchar messages[256]; 56 | glGetShaderInfoLog(shaderHandle, sizeof(messages), 0, &messages[0]); 57 | debugNetPrintf(DEBUG, "compile glsl error : %s\n", messages); 58 | } 59 | 60 | return shaderHandle; 61 | } 62 | 63 | GLuint BuildProgram(const char *vShader, const char *fShader) 64 | { 65 | GLuint vertexShader = BuildShader(vShader, GL_VERTEX_SHADER); 66 | GLuint fragmentShader = BuildShader(fShader, GL_FRAGMENT_SHADER); 67 | 68 | GLuint programHandle = glCreateProgram(); 69 | glAttachShader(programHandle, vertexShader); 70 | glAttachShader(programHandle, fragmentShader); 71 | glLinkProgram(programHandle); 72 | 73 | GLint linkSuccess; 74 | glGetProgramiv(programHandle, GL_LINK_STATUS, &linkSuccess); 75 | if (linkSuccess == GL_FALSE) 76 | { 77 | GLchar messages[256]; 78 | glGetProgramInfoLog(programHandle, sizeof(messages), 0, &messages[0]); 79 | debugNetPrintf(DEBUG, "compile glsl error : %s\n", messages); 80 | } 81 | 82 | if(vertexShader) { glDeleteShader(vertexShader), vertexShader = 0; } 83 | if(fragmentShader) { glDeleteShader(fragmentShader), fragmentShader = 0; } 84 | 85 | return programHandle; 86 | } 87 | 88 | //https://github.com/learnopengles/airhockey/commit/228ce050da304258feca8d82690341cb50c27532 89 | //OpenGLES2 handlers : init , final , update , render , touch-input 90 | void on_GLES2_Init(int view_w, int view_h) 91 | { 92 | const char *simpleVertexShader = 93 | "attribute vec4 a_Position;" 94 | "attribute vec2 a_TextureCoordinates;" 95 | "varying vec2 v_TextureCoordinates;" 96 | "void main()" 97 | "{" 98 | "v_TextureCoordinates = a_TextureCoordinates;" 99 | "gl_Position = a_Position;" 100 | "} "; 101 | 102 | const char *simpleFragmentShader = 103 | "precision mediump float;" 104 | "uniform sampler2D u_TextureUnit;" 105 | "varying vec2 v_TextureCoordinates;" 106 | "void main(void)" 107 | "{" 108 | " gl_FragColor = texture2D(u_TextureUnit, v_TextureCoordinates);" 109 | "}"; 110 | 111 | texture = load_png_asset_into_texture("host0:tentacle.png"); 112 | debugNetPrintf(DEBUG, "load_png_asset_into_texture ret: %d\n", texture); 113 | 114 | buffer = create_vbo(sizeof(rect), rect, GL_STATIC_DRAW); 115 | 116 | simpleProgram = BuildProgram(simpleVertexShader, simpleFragmentShader); 117 | glUseProgram(simpleProgram); 118 | 119 | a_position_location = glGetAttribLocation (simpleProgram, "a_Position"); 120 | a_texture_coordinates_location = glGetAttribLocation (simpleProgram, "a_TextureCoordinates"); 121 | u_texture_unit_location = glGetUniformLocation(simpleProgram, "u_TextureUnit"); 122 | } 123 | 124 | void on_GLES2_Final() 125 | { 126 | if(simpleProgram) 127 | glDeleteProgram(simpleProgram), simpleProgram = 0; 128 | } 129 | 130 | void on_GLES2_Size(int view_w, int view_h) 131 | { 132 | glViewport(0, 0, view_w, view_h); 133 | } 134 | 135 | void on_GLES2_Update(float timeStep_sec) 136 | { 137 | // nothing 138 | } 139 | 140 | void on_GLES2_Render() 141 | { 142 | // we already clean 143 | 144 | glUseProgram(simpleProgram); 145 | 146 | // select requested texture 147 | glActiveTexture(GL_TEXTURE0); 148 | glBindTexture(GL_TEXTURE_2D, texture); 149 | glUniform1i(u_texture_unit_location, 0); 150 | glBindBuffer(GL_ARRAY_BUFFER, buffer); // bind VBO 151 | 152 | // setup attr 153 | glVertexAttribPointer(a_position_location, 154 | 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(0)); 155 | glVertexAttribPointer(a_texture_coordinates_location, 156 | 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(2 * sizeof(GL_FLOAT))); 157 | 158 | // pin variables 159 | glEnableVertexAttribArray(a_position_location); 160 | glEnableVertexAttribArray(a_texture_coordinates_location); 161 | 162 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // draw binded VBO buffer 163 | 164 | // release VBO, texture and program 165 | glBindBuffer(GL_ARRAY_BUFFER, 0); 166 | //glActiveTexture(0); // error on piglet !! 167 | glUseProgram(0); 168 | 169 | // we already flip/swap 170 | } 171 | -------------------------------------------------------------------------------- /orbis_es2sine_wave_lines/source/sine_wave_lines.c: -------------------------------------------------------------------------------- 1 | //Authors : Lee Jeong Seop 2 | //CC BY-NC-SA 4.0 3 | 4 | #if CCR_FORCE_LLVM_INTERPRETER 5 | #error "Clang/LLVM interpreter does not support native to script callback function yet. Consider using CPP built-in compiler or turn on 'Use JIT execution' compiler option in app options menu." 6 | #endif 7 | 8 | // std 9 | #include 10 | #include 11 | 12 | // OpenGL 13 | #include 14 | #include 15 | 16 | //------------------------------------------------------------------------------ 17 | 18 | #define SAMPLE_POINT_COUNT 200 19 | 20 | GLuint simpleProgram; 21 | 22 | struct Vertex 23 | { 24 | float Position[2]; 25 | float Color[4]; 26 | }; 27 | 28 | void ApplyOrtho(float maxX, float maxY) 29 | { 30 | float a = 1.0f / maxX; 31 | float b = 1.0f / maxY; 32 | float ortho[16] = 33 | { 34 | a,0,0,0, 35 | 0,b,0,0, 36 | 0,0,-1,0, 37 | 0,0,0,1 38 | }; 39 | 40 | GLint projectionUniform = glGetUniformLocation(simpleProgram, "Projection"); 41 | glUniformMatrix4fv(projectionUniform, 1, 0, &ortho[0]); 42 | } 43 | //------------------------------------------------------------------------------ 44 | GLuint BuildShader(const char *source, GLenum shaderType) 45 | { 46 | GLuint shaderHandle = glCreateShader(shaderType); 47 | glShaderSource(shaderHandle, 1, &source, 0); 48 | glCompileShader(shaderHandle); 49 | GLint compileSuccess; 50 | glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess); 51 | 52 | if (compileSuccess == GL_FALSE) 53 | { 54 | GLchar messages[256]; 55 | glGetShaderInfoLog(shaderHandle, sizeof(messages), 0, &messages[0]); 56 | printf("compile glsl error : %s\n", messages); 57 | } 58 | 59 | return shaderHandle; 60 | } 61 | //------------------------------------------------------------------------------ 62 | GLuint BuildProgram(const char *vShader, const char *fShader) 63 | { 64 | GLuint vertexShader = BuildShader(vShader, GL_VERTEX_SHADER); 65 | GLuint fragmentShader = BuildShader(fShader, GL_FRAGMENT_SHADER); 66 | 67 | GLuint programHandle = glCreateProgram(); 68 | glAttachShader(programHandle, vertexShader); 69 | glAttachShader(programHandle, fragmentShader); 70 | glLinkProgram(programHandle); 71 | 72 | GLint linkSuccess; 73 | glGetProgramiv(programHandle, GL_LINK_STATUS, &linkSuccess); 74 | if (linkSuccess == GL_FALSE) 75 | { 76 | GLchar messages[256]; 77 | glGetProgramInfoLog(programHandle, sizeof(messages), 0, &messages[0]); 78 | printf("compile glsl error : %s\n", messages); 79 | } 80 | 81 | return programHandle; 82 | } 83 | //------------------------------------------------------------------------------ 84 | void on_GLES2_Size(int view_w, int view_h) 85 | { 86 | glViewport(0, 0, view_w, view_h); 87 | ApplyOrtho(1, 1); 88 | } 89 | 90 | 91 | //OpenGLES2 handlers : init , final , update , render , touch-input 92 | void on_GLES2_Init(int view_w, int view_h) 93 | { 94 | const char *simpleVertexShader = 95 | "attribute vec4 Position;" 96 | "attribute vec4 SourceColor;" 97 | "varying vec4 DestinationColor;" 98 | "uniform mat4 Modelview;" 99 | "uniform mat4 Projection;" 100 | "void main(void)" 101 | "{" 102 | " DestinationColor=SourceColor;" 103 | " gl_Position=Projection*Modelview*Position;" 104 | "}"; 105 | 106 | const char *simpleFragmentShader = 107 | "varying lowp vec4 DestinationColor;" 108 | "void main(void)" 109 | "{" 110 | " gl_FragColor=DestinationColor;" 111 | "}"; 112 | 113 | simpleProgram = BuildProgram(simpleVertexShader, simpleFragmentShader); 114 | glUseProgram(simpleProgram); 115 | 116 | // set viewport 117 | on_GLES2_Size(view_w, view_h); 118 | } 119 | //------------------------------------------------------------------------------ 120 | void on_GLES2_Final() 121 | { 122 | if (simpleProgram) 123 | glDeleteProgram(simpleProgram); 124 | 125 | simpleProgram = 0; 126 | } 127 | 128 | //------------------------------------------------------------------------------ 129 | void on_GLES2_Update(float timeStep_sec) 130 | {} 131 | //------------------------------------------------------------------------------ 132 | void on_GLES2_Render() 133 | { 134 | glClearColor(0.3f, 0.3f, 0.3f, 1); 135 | glClear(GL_COLOR_BUFFER_BIT); 136 | 137 | float modelViewMatrix[16] = 138 | { 139 | 1,0,0,0, 140 | 0,1,0,0, 141 | 0,0,1,0, 142 | 0,0,0,1 143 | }; 144 | GLint modelviewUniform = glGetUniformLocation(simpleProgram, "Modelview"); 145 | glUniformMatrix4fv(modelviewUniform, 1, 0, &modelViewMatrix[0]); 146 | 147 | GLuint positionSlot = glGetAttribLocation(simpleProgram, "Position"); 148 | GLuint colorSlot = glGetAttribLocation(simpleProgram, "SourceColor"); 149 | 150 | glEnableVertexAttribArray(positionSlot); 151 | glEnableVertexAttribArray(colorSlot); 152 | 153 | struct Vertex vertices[SAMPLE_POINT_COUNT]; 154 | for (int i = 0; i < SAMPLE_POINT_COUNT; i++) 155 | { 156 | float x = -1.0f + (i / (float)(SAMPLE_POINT_COUNT - 1))*2.0f; 157 | vertices[i].Position[0] = x;//x 158 | vertices[i].Position[1] = sinf(x * 20) / 3 + sinf(x * 40) / 4 + sinf(x * 60) / 5;//y 159 | 160 | vertices[i].Color[0] = 0.0f;//r 161 | vertices[i].Color[1] = 1.0f;//g 162 | vertices[i].Color[2] = 0.0f;//b 163 | vertices[i].Color[3] = 1.0f;//a 164 | } 165 | 166 | GLsizei stride = sizeof(struct Vertex); 167 | const GLvoid *pCoords = &vertices[0].Position[0]; 168 | const GLvoid *pColors = &vertices[0].Color[0]; 169 | 170 | glVertexAttribPointer(positionSlot, 2, GL_FLOAT, GL_FALSE, stride, pCoords); 171 | glVertexAttribPointer(colorSlot, 4, GL_FLOAT, GL_FALSE, stride, pColors); 172 | 173 | GLsizei vertexCount = sizeof(vertices) / sizeof(struct Vertex); 174 | glDrawArrays(GL_LINE_STRIP, 0, vertexCount); 175 | 176 | glDisableVertexAttribArray(positionSlot); 177 | glDisableVertexAttribArray(colorSlot); 178 | } 179 | //------------------------------------------------------------------------------ 180 | void on_GLES2_TouchBegin(float x, float y) 181 | { 182 | printf("on_GLES2_TouchBegin(x=%f,y=%f);\n", x, y); 183 | } 184 | //------------------------------------------------------------------------------ 185 | void on_GLES2_TouchEnd(float x, float y) 186 | { 187 | printf("on_GLES2_TouchEnd(x=%f,y=%f);\n", x, y); 188 | } 189 | //------------------------------------------------------------------------------ 190 | void on_GLES2_TouchMove(float prev_x, float prev_y, float x, float y) 191 | { 192 | printf("on_GLES2_TouchMove(prev_x=%f,prev_y=%f,x=%f,y=%f);\n", 193 | prev_x, prev_y, x, y); 194 | } 195 | 196 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/source/sprite.c: -------------------------------------------------------------------------------- 1 | /* 2 | GLES2 texture from png using shaders and VBO 3 | 4 | spritessheet concept, one texture - one VBO; 5 | address sprite by UVs offset in shader code 6 | 7 | based on the texture rectangle sample from: 8 | https://www.raylib.com/examples/web/textures/loader.html?name=textures_rectangle 9 | 10 | 2019, masterzorag 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "defines.h" 20 | 21 | /* 22 | we setup one SL program: 23 | - use default color from texture 24 | - apply UVs offset on passed num 25 | */ 26 | #define NUM_OF_SPRITES (6) 27 | 28 | 29 | static GLuint simpleProgram; 30 | 31 | 32 | static GLuint texture; 33 | static GLuint buffer; 34 | #define BUFFER_OFFSET(i) ((void*)(i)) 35 | 36 | 37 | // the png we turn into VBO + texture 38 | char *png = 39 | { 40 | /* 41 | [Scarfy spritesheet](scarfy.png) by [Eiden Marsal] 42 | (https://www.artstation.com/artist/marshall_z), 43 | licensed as [Creative Commons Attribution-NonCommercial 3.0] 44 | (https://creativecommons.org/licenses/by-nc/3.0/legalcode) 45 | */ 46 | "host0:scarfy.png" 47 | //"host0:tentacle.png", // fullscreen background 48 | //"/app0/sce_sys/pic0.png", // OL fullscreen background 49 | //"host0:sce_sys/pic0.png", 50 | }; 51 | 52 | // shaders locations 53 | static GLint a_position_location; 54 | static GLint a_texture_coordinates_location; 55 | static GLint u_texture_unit_location; 56 | static GLint u_offset_location; // to address each sprite in texture displacing UVs 57 | static GLint u_p1_pos_location; // to offset position 58 | 59 | static vec2 resolution; // (constant) 60 | 61 | static void setup_sprite_position(int num, vec2 pos, const float scale_f) 62 | { 63 | tex_size *= scale_f; 64 | tex_size.x /= NUM_OF_SPRITES; // split texture horizontally 65 | 66 | /*p = pixel_to_normalized(pos, tex_size);*/ 67 | 68 | vec4 p; // 2 points .xy pair: (x, y), (x + texture.w, y + texture.h) 69 | 70 | p.xy = -1. + 2. / resolution * pos; // (-1,-1) is BOTTOMLEFT, (1,1) is UPRIGHT 71 | p.zw = -1. + 2. / resolution * (pos + tex_size); 72 | p.yw *= -1.; // flip Y axis 73 | 74 | /* setup VBO from texture position, use 75 | orig_texture_size_in_px * scale_f for rendered size, 76 | but render just one of NUM_OF_SPRITES width */ 77 | const float vertexes[] = { p.x, p.y, 0.f, 0.f, // TPLF 78 | p.x, p.w, 0.f, 1.f, // BTLF 79 | p.z, p.y, 1.f /NUM_OF_SPRITES, 0.f, // BTRG 80 | p.z, p.w, 1.f /NUM_OF_SPRITES, 1.f }; // TPRG 81 | // setup triangle positions to draw 82 | buffer = create_vbo(sizeof(vertexes), vertexes, GL_STATIC_DRAW); 83 | } 84 | 85 | 86 | //https://github.com/learnopengles/airhockey/commit/228ce050da304258feca8d82690341cb50c27532 87 | //OpenGLES2 handlers : init , final , update , render , touch-input 88 | void on_GLES2_Init_sprite(int view_w, int view_h) 89 | { 90 | resolution = (vec2){ view_w, view_h }; // setup resolution for next setup_texture_position() 91 | 92 | texture = load_png_asset_into_texture(png); 93 | if(!texture) 94 | debugNetPrintf(ERROR, "load_png_asset_into_texture '%s' ret: %d\n", png, texture); 95 | 96 | /// setup triangle positions to draw 97 | setup_sprite_position( 0, (vec2){ 0, 0 }, 1.f /* scale_f */); 98 | 99 | #ifdef HAVE_SHACC 100 | simpleProgram = BuildProgram(vs, fs); 101 | #else 102 | simpleProgram = CreateProgramFromBinary(2); // todo: enums for "the Nth SL program" 103 | #endif 104 | debugNetPrintf(DEBUG, "simpleProgram: %u\n", simpleProgram); 105 | 106 | glUseProgram(simpleProgram); 107 | a_position_location = glGetAttribLocation (simpleProgram, "a_Position"); 108 | a_texture_coordinates_location = glGetAttribLocation (simpleProgram, "a_TextureCoordinates"); 109 | u_texture_unit_location = glGetUniformLocation(simpleProgram, "u_TextureUnit"); 110 | u_offset_location = glGetUniformLocation(simpleProgram, "u_offset"); 111 | u_p1_pos_location = glGetUniformLocation(simpleProgram, "u_p1_pos"); 112 | } 113 | 114 | void on_GLES2_Final_sprite(void) 115 | { 116 | if(simpleProgram) glDeleteProgram(simpleProgram), simpleProgram = 0; 117 | } 118 | 119 | void on_GLES2_Size_sprite(int view_w, int view_h) 120 | { 121 | glViewport(0, 0, view_w, view_h); 122 | } 123 | 124 | static vec2 uv = { 0.f }; 125 | vec2 p1_pos = { 0.f }; 126 | 127 | void on_GLES2_Update_sprite(int frame) 128 | { 129 | #define FRAME_NUM (10) 130 | if(!(frame %FRAME_NUM)) // update UVs 131 | { 132 | uv = (vec2){ 1. /NUM_OF_SPRITES * ((frame /FRAME_NUM) %NUM_OF_SPRITES), 0. }; 133 | /*debugNetPrintf(DEBUG, "frame:%d sprite:%d uv(%.3f %.3f)\n", 134 | frame, (frame /FRAME_NUM) %NUM_OF_SPRITES, uv.x, uv.y);*/ 135 | } 136 | glUseProgram(simpleProgram); 137 | // write the values to the shaders 138 | glUniform2f(u_offset_location, uv.x, uv.y ); 139 | glUniform2f(u_p1_pos_location, p1_pos.x, p1_pos.y ); 140 | } 141 | 142 | void on_GLES2_Render_sprite(int frame) // which sprite to draw (?!) 143 | { 144 | // we already clean 145 | 146 | glUseProgram(simpleProgram); 147 | 148 | glDisable(GL_CULL_FACE); 149 | 150 | // enable alpha for png textures 151 | glEnable(GL_BLEND); 152 | glBlendEquation(GL_FUNC_ADD); 153 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 154 | 155 | // select requested texture 156 | glActiveTexture(GL_TEXTURE0); 157 | glBindTexture(GL_TEXTURE_2D, texture); 158 | glUniform1i(u_texture_unit_location, 0); // tell to shader 159 | glBindBuffer(GL_ARRAY_BUFFER, buffer); // bind requested VBO 160 | 161 | // setup attr 162 | glVertexAttribPointer(a_position_location, 163 | 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(0)); 164 | glVertexAttribPointer(a_texture_coordinates_location, 165 | 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(2 * sizeof(GL_FLOAT))); 166 | 167 | // pin variables 168 | glEnableVertexAttribArray(a_position_location); 169 | glEnableVertexAttribArray(a_texture_coordinates_location); 170 | 171 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // draw binded VBO buffer 172 | 173 | // revert state back 174 | glDisable(GL_BLEND); 175 | 176 | // release VBO, texture and program 177 | glBindBuffer(GL_ARRAY_BUFFER, 0); 178 | //glActiveTexture(0); // error on piglet !! 179 | glUseProgram(0); 180 | 181 | // we already flip/swap 182 | } 183 | -------------------------------------------------------------------------------- /orbis_es2texture_png_VBOs/source/icons.c: -------------------------------------------------------------------------------- 1 | /* 2 | GLES2 texture from png using shaders and VBOs 3 | 4 | basic direct correlation: buffer[num] positions texture[num] 5 | 6 | 2019, masterzorag 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "defines.h" 16 | /* 17 | we setup two SL programs: 18 | 0. use default color from texture 19 | 1. use glowing effect on passed time 20 | */ 21 | #define NUM_OF_PROGRAMS (2) 22 | 23 | 24 | static GLuint slProgram[NUM_OF_PROGRAMS]; 25 | static GLuint simpleProgram; // the current one 26 | 27 | static GLuint texture[NUM_OF_TEXTURES]; 28 | static GLuint buffer [NUM_OF_TEXTURES]; 29 | #define BUFFER_OFFSET(i) ((void*)(i)) 30 | 31 | 32 | // the pngs we turn into VBOs + textures 33 | char *pngs[NUM_OF_TEXTURES] = 34 | { 35 | "host0:tentacle.png", // fullscreen background 36 | "host0:fames/game-icon.png", 37 | "host0:fames/music-icon.png", 38 | "host0:fames/themes-icon.png", 39 | "host0:fames/settings-icon.png", 40 | "host0:fames/emu-icon.png" 41 | }; 42 | 43 | // the png we apply glowing effect by switching shader 44 | int selected_icon = 1; 45 | 46 | // shaders locations 47 | static GLint a_position_location; 48 | static GLint a_texture_coordinates_location; 49 | static GLint u_texture_unit_location; 50 | static GLint u_time_location; 51 | 52 | // a fullscreen texture: position (X, Y), texture (S, T) (... or UVs) 53 | static const float rect[] = { -1.0f, -1.0f, 0.0f, 1.0f, 54 | -1.0f, 1.0f, 0.0f, 0.0f, 55 | 1.0f, -1.0f, 1.0f, 1.0f, 56 | 1.0f, 1.0f, 1.0f, 0.0f}; // not Y flipped! 57 | static vec2 resolution; // (constant) 58 | 59 | static void setup_texture_position(int num, vec2 pos, const float scale_f) 60 | { 61 | tex_size *= scale_f; 62 | 63 | /*p = pixel_to_normalized(pos, tex_size);*/ 64 | 65 | vec4 p; // 2 points .xy pair: (x, y), (x + texture.w, y + texture.h) 66 | 67 | p.xy = -1. + 2. / resolution * pos; // (-1,-1) is BOTTOMLEFT, (1,1) is UPRIGHT 68 | p.zw = -1. + 2. / resolution * (pos + tex_size); 69 | p.yw *= -1.; // flip Y axis 70 | 71 | /* setup VBO from texture position, use 72 | orig_texture_size_in_px * scale_f for rendered size */ 73 | const float vertexes[] = { p.x, p.y, 0.f, 0.f, // TPLF 74 | p.x, p.w, 0.f, 1.f, // BTLF 75 | p.z, p.y, 1.f, 0.f, // BTRG 76 | p.z, p.w, 1.f, 1.f }; // TPRG 77 | // setup triangle positions to draw 78 | buffer[num] = create_vbo(sizeof(vertexes), vertexes, GL_STATIC_DRAW); 79 | } 80 | 81 | //https://github.com/learnopengles/airhockey/commit/228ce050da304258feca8d82690341cb50c27532 82 | //OpenGLES2 handlers : init , final , update , render , touch-input 83 | void on_GLES2_Init(int view_w, int view_h) 84 | { 85 | resolution = (vec2){ view_w, view_h }; // setup resolution for next setup_texture_position() 86 | 87 | for(int i = 0; i < NUM_OF_TEXTURES; i++) 88 | { 89 | texture[i] = load_png_asset_into_texture(pngs[i]); 90 | if(!texture[i]) 91 | debugNetPrintf(DEBUG, "load_png_asset_into_texture '%s' ret: %d\n", pngs[i], texture[i]); 92 | 93 | // setup triangle positions to draw 94 | if(i) 95 | setup_texture_position( i, (vec2){ i *100, ATTR_ORBISGL_HEIGHT /2 }, 0.25 /* scale_f */); 96 | else 97 | buffer[i] = create_vbo(sizeof(rect), rect, GL_STATIC_DRAW); // background 98 | } 99 | 100 | for(int i = 0; i < NUM_OF_PROGRAMS; i++) 101 | { 102 | slProgram[i] = 103 | #ifdef HAVE_SHACC 104 | BuildProgram(simpleVertexShader, simpleFragmentShader[i]); 105 | #else 106 | CreateProgramFromBinary(i); 107 | #endif 108 | debugNetPrintf(DEBUG, "slProgram[%d]: %u\n", i, slProgram[i]); 109 | simpleProgram = slProgram[i]; 110 | 111 | glUseProgram(simpleProgram); 112 | a_position_location = glGetAttribLocation (simpleProgram, "a_Position"); 113 | a_texture_coordinates_location = glGetAttribLocation (simpleProgram, "a_TextureCoordinates"); 114 | u_texture_unit_location = glGetUniformLocation(simpleProgram, "u_TextureUnit"); 115 | u_time_location = glGetUniformLocation(simpleProgram, "u_time"); 116 | } 117 | // reset to first one 118 | simpleProgram = slProgram[0]; 119 | } 120 | 121 | void on_GLES2_Final(void) 122 | { 123 | for(int i = 0; i < NUM_OF_PROGRAMS; ++i) 124 | { if(slProgram[i]) glDeleteProgram(slProgram[i]), slProgram[i] = 0; } 125 | } 126 | 127 | void on_GLES2_Size(int view_w, int view_h) 128 | { 129 | glViewport(0, 0, view_w, view_h); 130 | } 131 | 132 | 133 | void on_GLES2_Update(int frame) 134 | { 135 | float t = (float)frame /10.; // slow down 136 | 137 | for(int i = 0; i < NUM_OF_PROGRAMS; ++i) 138 | { 139 | glUseProgram(slProgram[i]); 140 | // write the value to the shaders 141 | glUniform1f(glGetUniformLocation(slProgram[i], "u_time"), t); 142 | } 143 | } 144 | 145 | void on_GLES2_Render(int num) // which texture to draw 146 | { 147 | // we already clean 148 | 149 | simpleProgram = slProgram[0]; // default 150 | 151 | if(num == selected_icon) simpleProgram = slProgram[1]; // glowing effect 152 | 153 | glUseProgram(simpleProgram); 154 | 155 | glDisable(GL_CULL_FACE); 156 | 157 | // enable alpha for png textures 158 | glEnable(GL_BLEND); 159 | glBlendEquation(GL_FUNC_ADD); 160 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 161 | 162 | // select requested texture 163 | glActiveTexture(GL_TEXTURE0 + num); 164 | glBindTexture(GL_TEXTURE_2D, texture[num]); 165 | glUniform1i(u_texture_unit_location, num); // tell to shader 166 | glBindBuffer(GL_ARRAY_BUFFER, buffer[num]); // bind requested VBO 167 | 168 | // setup attr 169 | glVertexAttribPointer(a_position_location, 170 | 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(0)); 171 | glVertexAttribPointer(a_texture_coordinates_location, 172 | 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GL_FLOAT), BUFFER_OFFSET(2 * sizeof(GL_FLOAT))); 173 | 174 | // pin variables 175 | glEnableVertexAttribArray(a_position_location); 176 | glEnableVertexAttribArray(a_texture_coordinates_location); 177 | 178 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); // draw binded VBO buffer 179 | 180 | // revert state back 181 | glDisable(GL_BLEND); 182 | 183 | // release VBO, texture and program 184 | glBindBuffer(GL_ARRAY_BUFFER, 0); 185 | //glActiveTexture(0); // error on piglet !! 186 | glUseProgram(0); 187 | 188 | // we already flip/swap 189 | } 190 | 191 | -------------------------------------------------------------------------------- /orbis_es2opengles_demo/source/opengles_demo.c: -------------------------------------------------------------------------------- 1 | //Original source code found at : book, iPhone 3D Programming 2010 by O'Reilly Media, Inc. 2 | 3 | // supported platforms check. NOTE iOS, Android and Windows only, but may works on other platforms ;-) 4 | 5 | #ifdef CCR_FORCE_LLVM_INTERPRETER 6 | #error "Clang/LLVM on iOS does not support function pointer yet. Consider using CPP built-in compiler." 7 | #endif 8 | 9 | // std 10 | #include 11 | 12 | // OpenGL 13 | #include 14 | #include 15 | 16 | //------------------------------------------------------------------------------ 17 | 18 | GLuint simpleProgram; 19 | //------------------------------------------------------------------------------ 20 | struct Vertex 21 | { 22 | float Position[2]; 23 | float Color[4]; 24 | }; 25 | //------------------------------------------------------------------------------ 26 | const struct Vertex Vertices[6] = 27 | { 28 | {{-0.5,-0.866},{1,1,0.5f,1}}, 29 | {{0.5,-0.866},{1,1,0.5f,1}}, 30 | {{0,1},{1,1,0.5f,1}}, 31 | {{-0.5,-0.866},{0.7f,0.7f,0.7f,1}}, 32 | {{0.5,-0.866},{0.7f,0.7f,0.7f,1}}, 33 | {{0,-0.4f},{0.7f,0.7f,0.7f,1}}, 34 | }; 35 | //------------------------------------------------------------------------------ 36 | void ApplyOrtho(float maxX, float maxY) 37 | { 38 | float a = 1.0f / maxX; 39 | float b = 1.0f / maxY; 40 | float ortho[16] = 41 | { 42 | a,0,0,0, 43 | 0,b,0,0, 44 | 0,0,-1,0, 45 | 0,0,0,1 46 | }; 47 | 48 | GLint projectionUniform = glGetUniformLocation(simpleProgram, "Projection"); 49 | glUniformMatrix4fv(projectionUniform, 1, 0, &ortho[0]); 50 | } 51 | //------------------------------------------------------------------------------ 52 | GLuint BuildShader(const char *source, GLenum shaderType) 53 | { 54 | GLuint shaderHandle = glCreateShader(shaderType); 55 | glShaderSource(shaderHandle, 1, &source, 0); 56 | glCompileShader(shaderHandle); 57 | 58 | // get compiler result 59 | GLint compileSuccess; 60 | glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess); 61 | 62 | // succeeded? 63 | if (compileSuccess == GL_FALSE) 64 | { 65 | // show error message (in console) 66 | GLchar messages[256]; 67 | glGetShaderInfoLog(shaderHandle, sizeof(messages), 0, &messages[0]); 68 | printf("compile glsl error : %s\n", messages); 69 | } 70 | 71 | return shaderHandle; 72 | } 73 | //------------------------------------------------------------------------------ 74 | GLuint BuildProgram(const char *vShader, const char *fShader) 75 | { 76 | // create and compile vertex and fragment shaders programs 77 | GLuint vertexShader = BuildShader(vShader, GL_VERTEX_SHADER); 78 | GLuint fragmentShader = BuildShader(fShader, GL_FRAGMENT_SHADER); 79 | 80 | // link shader programs 81 | GLuint programHandle = glCreateProgram(); 82 | glAttachShader(programHandle, vertexShader); 83 | glAttachShader(programHandle, fragmentShader); 84 | glLinkProgram(programHandle); 85 | 86 | // get linker result 87 | GLint linkSuccess; 88 | glGetProgramiv(programHandle, GL_LINK_STATUS, &linkSuccess); 89 | // succeeded? 90 | if (linkSuccess == GL_FALSE) 91 | { 92 | // show error message (in console) 93 | GLchar messages[256]; 94 | glGetProgramInfoLog(programHandle, sizeof(messages), 0, &messages[0]); 95 | printf("compile glsl error : %s\n", messages); 96 | } 97 | 98 | return programHandle; 99 | } 100 | //------------------------------------------------------------------------------ 101 | void on_GLES2_Size(int view_w, int view_h) 102 | { 103 | glViewport(0, 0, view_w, view_h); 104 | ApplyOrtho(2, 3); 105 | } 106 | //------------------------------------------------------------------------------ 107 | //OpenGLES2 handlers : init , final , update , render , touch-input 108 | void on_GLES2_Init(int view_w, int view_h) 109 | { 110 | const char *simpleVertexShader = 111 | "attribute vec4 Position;" 112 | "attribute vec4 SourceColor;" 113 | "varying vec4 DestinationColor;" 114 | "uniform mat4 Modelview;" 115 | "uniform mat4 Projection;" 116 | "void main(void)" 117 | "{" 118 | " DestinationColor=SourceColor;" 119 | " gl_Position=Projection*Modelview*Position;" 120 | "}"; 121 | 122 | const char *simpleFragmentShader = 123 | "varying lowp vec4 DestinationColor;" 124 | "void main(void)" 125 | "{" 126 | " gl_FragColor=DestinationColor;" 127 | "}"; 128 | 129 | simpleProgram = BuildProgram(simpleVertexShader, simpleFragmentShader); 130 | glUseProgram(simpleProgram); 131 | 132 | // set viewport 133 | on_GLES2_Size(view_w, view_h); 134 | } 135 | //------------------------------------------------------------------------------ 136 | void on_GLES2_Final() 137 | { 138 | if (simpleProgram) 139 | glDeleteProgram(simpleProgram); 140 | simpleProgram = 0; 141 | } 142 | 143 | 144 | //------------------------------------------------------------------------------ 145 | void on_GLES2_Update(float timeStep_sec) 146 | { 147 | } 148 | 149 | //------------------------------------------------------------------------------ 150 | void on_GLES2_Render() 151 | { 152 | // clear scene background and depth buffer 153 | glClearColor(0.7f, 0.7f, 0.7f, 1); 154 | glClear(GL_COLOR_BUFFER_BIT); 155 | 156 | float modelViewMatrix[16] = 157 | { 158 | 1,0,0,0, 159 | 0,1,0,0, 160 | 0,0,1,0, 161 | 0,0,0,1 162 | }; 163 | GLint modelviewUniform = glGetUniformLocation(simpleProgram, "Modelview"); 164 | glUniformMatrix4fv(modelviewUniform, 1, 0, &modelViewMatrix[0]); 165 | 166 | GLuint positionSlot = glGetAttribLocation(simpleProgram, "Position"); 167 | GLuint colorSlot = glGetAttribLocation(simpleProgram, "SourceColor"); 168 | 169 | glEnableVertexAttribArray(positionSlot); 170 | glEnableVertexAttribArray(colorSlot); 171 | 172 | GLsizei stride = sizeof(struct Vertex); 173 | const GLvoid *pCoords = &Vertices[0].Position[0]; 174 | const GLvoid *pColors = &Vertices[0].Color[0]; 175 | 176 | glVertexAttribPointer(positionSlot, 2, GL_FLOAT, GL_FALSE, stride, pCoords); 177 | glVertexAttribPointer(colorSlot, 4, GL_FLOAT, GL_FALSE, stride, pColors); 178 | 179 | GLsizei vertexCount = sizeof(Vertices) / sizeof(struct Vertex); 180 | glDrawArrays(GL_TRIANGLES, 0, vertexCount); 181 | 182 | // disconnect slots from shader 183 | glDisableVertexAttribArray(positionSlot); 184 | glDisableVertexAttribArray(colorSlot); 185 | } 186 | //------------------------------------------------------------------------------ 187 | void on_GLES2_TouchBegin(float x, float y) 188 | { 189 | printf("on_GLES2_TouchBegin(x=%f,y=%f);\n", x, y); 190 | } 191 | //------------------------------------------------------------------------------ 192 | void on_GLES2_TouchEnd(float x, float y) 193 | { 194 | printf("on_GLES2_TouchEnd(x=%f,y=%f);\n", x, y); 195 | } 196 | //------------------------------------------------------------------------------ 197 | void on_GLES2_TouchMove(float prev_x, float prev_y, float x, float y) 198 | { 199 | printf("on_GLES2_TouchMove(prev_x=%f,prev_y=%f,x=%f,y=%f);\n", 200 | prev_x, prev_y, x, y); 201 | } 202 | 203 | -------------------------------------------------------------------------------- /samplenfs/source/orbisGlText.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017,2018 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/orbisdev/liborbis 5 | */ 6 | #include 7 | #include 8 | 9 | #include // links against libfreetype-gl 10 | 11 | #include 12 | #include 13 | #include 14 | typedef struct vertex_t 15 | { 16 | float x, y, z; //position 17 | float s, t; //texture 18 | float r, g, b, a; //color 19 | }vertex_t; 20 | 21 | 22 | #include "orbisGlText.h" 23 | textline_t t_credits, 24 | t_footer, 25 | t_browser; 26 | 27 | GLuint shader; 28 | vertex_buffer_t *buffer; 29 | mat4 model, view, projection; 30 | texture_font_t *font=0; 31 | texture_atlas_t *atlas; 32 | int orbisGlTextEnabled=0; 33 | 34 | void orbisGlTextClearBuffer() 35 | { 36 | vertex_buffer_clear(buffer); 37 | } 38 | 39 | void orbisGlTextDraw(textline_t *text_to_draw) 40 | { 41 | //glClearColor( 0.3, 0.1, 0.9, 1 ); // BGRA 42 | //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 43 | glEnable( GL_BLEND ); 44 | glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 45 | 46 | glUseProgram( shader ); 47 | 48 | glBindTexture( GL_TEXTURE_2D, atlas->id ); 49 | glUniform1i( glGetUniformLocation( shader, "texture" ),0 ); 50 | glUniformMatrix4fv( glGetUniformLocation( shader, "model" ),1, 0, model.data); 51 | glUniformMatrix4fv( glGetUniformLocation( shader, "view" ),1, 0, view.data); 52 | glUniformMatrix4fv( glGetUniformLocation( shader, "projection" ),1, 0, projection.data); 53 | 54 | if(0) /* draw whole VBO (storing all added texts) */ 55 | { 56 | vertex_buffer_render( buffer, GL_TRIANGLES ); // all vbo 57 | } 58 | else /* draw a range/selection of indexes (= glyph) */ 59 | { 60 | vertex_buffer_render_setup( buffer, GL_TRIANGLES ); // start draw 61 | 62 | // follow indexed textline_t 63 | for(int i = text_to_draw->off; 64 | i < text_to_draw->off + text_to_draw->len; 65 | i += 1) 66 | { // glyph by one (2 triangles: 6 indices, 4 vertices) 67 | vertex_buffer_render_item ( buffer, i ); 68 | } 69 | 70 | vertex_buffer_render_finish( buffer ); // end draw 71 | } 72 | 73 | glUseProgram(0); 74 | glBindTexture(GL_TEXTURE_2D, 0); 75 | glDisable(GL_BLEND); 76 | } 77 | 78 | void orbisGlTextSetupBuffer(char *mytext,int x,int y,vec4 color) 79 | { 80 | //if(orbisGlTextEnabled==0){ return; } ??? 81 | 82 | size_t i; 83 | vec2 ppen={{x,1080-y}}; 84 | vec2 *pen=&ppen; 85 | float r = color.red, g = color.green, b = color.blue, a = color.alpha; 86 | for( i=0; iwidth %d glyph->advance_x %d\n",mytext[i],i,glyph->width,glyph->advance_x); 92 | float kerning = 0.0f; 93 | if( i > 0) 94 | { 95 | kerning = texture_glyph_get_kerning( glyph, mytext + i - 1 ); 96 | } 97 | pen->x += kerning; 98 | int x0 = (int)( pen->x + glyph->offset_x ); 99 | int y0 = (int)( pen->y + glyph->offset_y ); 100 | int x1 = (int)( x0 + glyph->width ); 101 | int y1 = (int)( y0 - glyph->height ); 102 | float s0 = glyph->s0; 103 | float t0 = glyph->t0; 104 | float s1 = glyph->s1; 105 | float t1 = glyph->t1; 106 | GLuint indices[6] = {0,1,2, 0,2,3}; 107 | vertex_t vertices[4] = {{ x0,y0,0, s0,t0, r,g,b,a }, 108 | { x0,y1,0, s0,t1, r,g,b,a }, 109 | { x1,y1,0, s1,t1, r,g,b,a }, 110 | { x1,y0,0, s1,t0, r,g,b,a } }; 111 | vertex_buffer_push_back( buffer, vertices, 4, indices, 6 ); 112 | pen->x += glyph->advance_x; 113 | } 114 | } 115 | } 116 | 117 | void orbisGlTextFinish() 118 | { 119 | texture_atlas_delete(atlas); 120 | texture_font_delete(font); 121 | vertex_buffer_delete(buffer); 122 | orbisGlDestroyProgram(shader); 123 | orbisGlTextEnabled=0; 124 | } 125 | 126 | void reshape(int width, int height) 127 | { 128 | glViewport(0, 0, width, height); 129 | mat4_set_orthographic( &projection, 0, width, 0, height, -1, 1); 130 | } 131 | 132 | extern int _orbisNfs_lastopenFile_size; 133 | 134 | void orbisGlTextInit() 135 | { 136 | 137 | size_t h; // text size in pt 138 | atlas = texture_atlas_new( 512, 512, 1 ); 139 | //const char * filename = "host0:hostapp/system/fonts/Tahoma_bold.ttf"; 140 | //const char * filename = "host0:hostapp/system/fonts/NewYork.ttf"; 141 | 142 | const char *filename = "system/fonts/Tahoma_bold.ttf"; 143 | void *ttf = orbisNfsGetFileContent( filename ); 144 | 145 | buffer = vertex_buffer_new( "vertex:3f,tex_coord:2f,color:4f" ); 146 | debugNetPrintf(DEBUG,"[ORBISGL] %s before texture_font_new \n",__FUNCTION__); 147 | 148 | font = texture_font_new_from_memory(atlas, 22, ttf, _orbisNfs_lastopenFile_size); 149 | debugNetPrintf(DEBUG,"[ORBISGL] %s after texture_font_new \n",__FUNCTION__); 150 | 151 | // setup vertex positions for all the text we will draw: 152 | 153 | // 1. a title 154 | orbisGlTextSetupBuffer(filename, 10, 50, 155 | (vec4){{ 1.f, 1.f, 1.f, 1.f }}); 156 | //debugNetPrintf(INFO, "%d, %d\n", vector_size( buffer->items ), vector_size( buffer->items )); 157 | 158 | // 2. many lines 159 | t_credits.off = vector_size( buffer->items ); 160 | creditsDrawText(); 161 | t_credits.len = vector_size( buffer->items ) - t_credits.off; 162 | debugNetPrintf(INFO, "t_credits(%d, %d)\n", t_credits.off, t_credits.len); 163 | 164 | t_footer.off = vector_size( buffer->items ); 165 | footerDrawText(); 166 | t_footer.len = vector_size( buffer->items ) - t_footer.off; 167 | debugNetPrintf(INFO, "t_footer(%d, %d)\n", t_footer.off, t_footer.len); 168 | 169 | t_browser.off = vector_size( buffer->items ); 170 | browserDrawText(); 171 | t_browser.len = vector_size( buffer->items ) - t_browser.off; 172 | debugNetPrintf(INFO, "t_browser(%d, %d)\n", t_browser.off, t_browser.len); 173 | 174 | /* create texture and upload atlas into gpu memory */ 175 | glGenTextures ( 1, &atlas->id ); 176 | glBindTexture ( GL_TEXTURE_2D, atlas->id ); 177 | glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); 178 | glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); 179 | glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 180 | glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 181 | glTexImage2D ( GL_TEXTURE_2D, 0, GL_ALPHA, atlas->width, atlas->height, 182 | 0, GL_ALPHA, GL_UNSIGNED_BYTE, atlas->data ); 183 | 184 | shader = orbisGlCreateProgramFromNfs("system/shaders/v3f-t2f-c4f.vert","system/shaders/v3f-t2f-c4f.frag"); 185 | if(!shader) 186 | { 187 | debugNetPrintf(ERROR,"[ORBISGL] %s program creation failed\n",__FUNCTION__); 188 | orbisGlTextEnabled=0; 189 | sleep(2); 190 | } 191 | 192 | 193 | mat4_set_identity( &projection ); 194 | mat4_set_identity( &model ); 195 | mat4_set_identity( &view ); 196 | 197 | reshape(1920, 1080); 198 | orbisGlTextEnabled=1; 199 | } 200 | 201 | -------------------------------------------------------------------------------- /orbis_es2tri/source/es2tri.c: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * 3 | * Copyright 2008 VMware, Inc. 4 | * All Rights Reserved. 5 | * 6 | **************************************************************************/ 7 | 8 | /* 9 | * Draw a triangle with EGL and OpenGL ES 2.x 10 | */ 11 | 12 | #define USE_FULL_GL 0 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #if USE_FULL_GL 23 | #include "gl_wrap.h" /* use full OpenGL */ 24 | #else 25 | #include /* use OpenGL ES 2.x */ 26 | #endif 27 | #include 28 | 29 | 30 | 31 | #define FLOAT_TO_FIXED(X) ((X) * 65535.0) 32 | 33 | 34 | 35 | static GLfloat view_rotx = 0.0, view_roty = 0.0; 36 | 37 | static GLint u_matrix = -1; 38 | static GLint attr_pos = 0, attr_color = 1; 39 | 40 | 41 | static void 42 | make_z_rot_matrix(GLfloat angle, GLfloat *m) 43 | { 44 | float c = cos(angle * M_PI / 180.0); 45 | float s = sin(angle * M_PI / 180.0); 46 | int i; 47 | for (i = 0; i < 16; i++) 48 | m[i] = 0.0; 49 | m[0] = m[5] = m[10] = m[15] = 1.0; 50 | 51 | m[0] = c; 52 | m[1] = s; 53 | m[4] = -s; 54 | m[5] = c; 55 | } 56 | 57 | static void 58 | make_scale_matrix(GLfloat xs, GLfloat ys, GLfloat zs, GLfloat *m) 59 | { 60 | int i; 61 | for (i = 0; i < 16; i++) 62 | m[i] = 0.0; 63 | m[0] = xs; 64 | m[5] = ys; 65 | m[10] = zs; 66 | m[15] = 1.0; 67 | } 68 | 69 | 70 | static void 71 | mul_matrix(GLfloat *prod, const GLfloat *a, const GLfloat *b) 72 | { 73 | #define A(row,col) a[(col<<2)+row] 74 | #define B(row,col) b[(col<<2)+row] 75 | #define P(row,col) p[(col<<2)+row] 76 | GLfloat p[16]; 77 | GLint i; 78 | for (i = 0; i < 4; i++) { 79 | const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); 80 | P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); 81 | P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); 82 | P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); 83 | P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); 84 | } 85 | memcpy(prod, p, sizeof(p)); 86 | #undef A 87 | #undef B 88 | #undef PROD 89 | } 90 | 91 | 92 | void 93 | render(void) 94 | { 95 | static const GLfloat verts[3][2] = { 96 | { -1, -1 }, 97 | { 1, -1 }, 98 | { 0, 1 } 99 | }; 100 | static const GLfloat colors[3][3] = { 101 | { 1, 0, 0 }, 102 | { 0, 1, 0 }, 103 | { 0, 0, 1 } 104 | }; 105 | GLfloat mat[16], rot[16], scale[16]; 106 | 107 | /* Set modelview/projection matrix */ 108 | make_z_rot_matrix(view_rotx, rot); 109 | make_scale_matrix(0.5, 0.5, 0.5, scale); 110 | mul_matrix(mat, rot, scale); 111 | glUniformMatrix4fv(u_matrix, 1, GL_FALSE, mat); 112 | 113 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 114 | 115 | { 116 | glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, verts); 117 | glVertexAttribPointer(attr_color, 3, GL_FLOAT, GL_FALSE, 0, colors); 118 | glEnableVertexAttribArray(attr_pos); 119 | glEnableVertexAttribArray(attr_color); 120 | 121 | glDrawArrays(GL_TRIANGLES, 0, 3); 122 | 123 | glDisableVertexAttribArray(attr_pos); 124 | glDisableVertexAttribArray(attr_color); 125 | } 126 | } 127 | 128 | 129 | /** 130 | * Handles a new window size or exposure. 131 | * 132 | * @param width the window width 133 | * @param height the window height 134 | */ 135 | static void 136 | reshape(int width, int height) 137 | { 138 | /* Set the viewport */ 139 | glViewport(0, 0, (GLint) width, (GLint) height); 140 | } 141 | 142 | 143 | static void 144 | create_shaders(void) 145 | { 146 | static const char *fragShaderText = 147 | "precision mediump float;\n" 148 | "varying vec4 v_color;\n" 149 | "void main() {\n" 150 | " gl_FragColor = v_color;\n" 151 | "}\n"; 152 | static const char *vertShaderText = 153 | "uniform mat4 modelviewProjection;\n" 154 | "attribute vec4 pos;\n" 155 | "attribute vec4 color;\n" 156 | "varying vec4 v_color;\n" 157 | "void main() {\n" 158 | " gl_Position = modelviewProjection * pos;\n" 159 | " v_color = color;\n" 160 | "}\n"; 161 | 162 | GLuint fragShader, vertShader, program; 163 | GLint stat; 164 | 165 | fragShader = glCreateShader(GL_FRAGMENT_SHADER); 166 | glShaderSource(fragShader, 1, (const char **) &fragShaderText, NULL); 167 | glCompileShader(fragShader); 168 | glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat); 169 | if (!stat) { 170 | debugNetPrintf(INFO,"Error: fragment shader did not compile!\n"); 171 | exit(1); 172 | } 173 | 174 | vertShader = glCreateShader(GL_VERTEX_SHADER); 175 | glShaderSource(vertShader, 1, (const char **) &vertShaderText, NULL); 176 | glCompileShader(vertShader); 177 | glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat); 178 | if (!stat) { 179 | debugNetPrintf(INFO,"Error: vertex shader did not compile!\n"); 180 | exit(1); 181 | } 182 | 183 | program = glCreateProgram(); 184 | glAttachShader(program, fragShader); 185 | glAttachShader(program, vertShader); 186 | glLinkProgram(program); 187 | 188 | glGetProgramiv(program, GL_LINK_STATUS, &stat); 189 | if (!stat) { 190 | char log[1000]; 191 | GLsizei len; 192 | glGetProgramInfoLog(program, 1000, &len, log); 193 | debugNetPrintf(INFO,"Error: linking:\n%s\n", log); 194 | exit(1); 195 | } 196 | 197 | glUseProgram(program); 198 | 199 | if (1) { 200 | /* test setting attrib locations */ 201 | glBindAttribLocation(program, attr_pos, "pos"); 202 | glBindAttribLocation(program, attr_color, "color"); 203 | glLinkProgram(program); /* needed to put attribs into effect */ 204 | } 205 | else { 206 | /* test automatic attrib locations */ 207 | attr_pos = glGetAttribLocation(program, "pos"); 208 | attr_color = glGetAttribLocation(program, "color"); 209 | } 210 | 211 | u_matrix = glGetUniformLocation(program, "modelviewProjection"); 212 | debugNetPrintf(INFO,"Uniform modelviewProjection at %d\n", u_matrix); 213 | debugNetPrintf(INFO,"Attrib pos at %d\n", attr_pos); 214 | debugNetPrintf(INFO,"Attrib color at %d\n", attr_color); 215 | } 216 | 217 | 218 | static void 219 | init(void) 220 | { 221 | glClearColor(0.4, 0.4, 0.4, 0.0); 222 | 223 | create_shaders(); 224 | } 225 | 226 | 227 | void 228 | pad_special(int special) 229 | { 230 | switch (special) { 231 | case 0: //_KEY_LEFT: 232 | view_roty += 5.0; 233 | break; 234 | case 1: //_KEY_RIGHT: 235 | view_roty -= 5.0; 236 | break; 237 | case 2: //_KEY_UP: 238 | view_rotx += 5.0; 239 | break; 240 | case 3: //_KEY_DOWN: 241 | view_rotx -= 5.0; 242 | break; 243 | } 244 | } 245 | 246 | 247 | int 248 | es2sample_init(int argc, char *argv[]) 249 | { 250 | init(); 251 | 252 | /* Set initial projection/viewing transformation. 253 | * We can't be sure we'll get a ConfigureNotify event when the window 254 | * first appears. 255 | */ 256 | reshape(ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 257 | 258 | return 0; 259 | } 260 | -------------------------------------------------------------------------------- /orbis_es2shaders/source/egl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * https://github.com/leokwu/OpenGLES-sample 3 | * ------------------------------------------ 4 | * 5 | * 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | const char vertex_src [] = 16 | " \ 17 | attribute vec4 position; \ 18 | varying mediump vec2 pos; \ 19 | uniform vec4 offset; \ 20 | \ 21 | void main() \ 22 | { \ 23 | gl_Position = position + offset; \ 24 | pos = position.xy; \ 25 | } \ 26 | "; 27 | 28 | 29 | const char fragment_src [] = 30 | " \ 31 | varying mediump vec2 pos; \ 32 | uniform mediump float phase; \ 33 | \ 34 | void main() \ 35 | { \ 36 | gl_FragColor = vec4( 1., 0.9, 0.7, 1.0 ) * \ 37 | cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y) \ 38 | + atan(pos.y,pos.x) - phase ); \ 39 | } \ 40 | "; 41 | // some more formulas to play with... 42 | // cos( 20.*(pos.x*pos.x + pos.y*pos.y) - phase ); 43 | // cos( 20.*sqrt(pos.x*pos.x + pos.y*pos.y) + atan(pos.y,pos.x) - phase ); 44 | // cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y - 1.8*pos.x*pos.y*pos.y) 45 | // + atan(pos.y,pos.x) - phase ); 46 | 47 | 48 | void 49 | print_shader_info_log ( 50 | GLuint shader // handle to the shader 51 | ) 52 | { 53 | GLint length; 54 | 55 | glGetShaderiv ( shader , GL_INFO_LOG_LENGTH , &length ); 56 | 57 | if ( length ) { 58 | char* buffer = malloc(length); 59 | glGetShaderInfoLog ( shader , length , NULL , buffer ); 60 | 61 | free(buffer); 62 | 63 | GLint success; 64 | glGetShaderiv( shader, GL_COMPILE_STATUS, &success ); 65 | if ( success != GL_TRUE ) exit ( 1 ); 66 | } 67 | } 68 | 69 | 70 | GLuint 71 | load_shader ( 72 | const char *shader_source, 73 | GLenum type 74 | ) 75 | { 76 | GLuint shader = glCreateShader( type ); 77 | 78 | glShaderSource ( shader , 1 , &shader_source , NULL ); 79 | glCompileShader ( shader ); 80 | 81 | print_shader_info_log ( shader ); 82 | 83 | return shader; 84 | } 85 | 86 | 87 | GLfloat 88 | norm_x = 0.0, 89 | norm_y = 0.0, 90 | offset_x = 0.0, 91 | offset_y = 0.0, 92 | p1_pos_x = 0.0, 93 | p1_pos_y = 0.0; 94 | 95 | GLint 96 | phase_loc, 97 | offset_loc, 98 | position_loc; 99 | 100 | 101 | bool update_pos = false; 102 | 103 | const float vertexArray[] = { 104 | 0.0, 0.5, 0.0, 105 | -0.5, 0.0, 0.0, 106 | 0.0, -0.5, 0.0, 107 | 0.5, 0.0, 0.0, 108 | 0.0, 0.5, 0.0 109 | }; 110 | 111 | //// this is needed for time measuring --> frames per second 112 | static struct timezone tz; 113 | static struct timeval t1, t2; 114 | static int num_frames = 0; 115 | 116 | void 117 | render(void) 118 | { 119 | static float phase = 0; 120 | 121 | //// draw 122 | 123 | glClearColor ( 0.08 , 0.06 , 0.07 , 1.); // background color 124 | glClear ( GL_COLOR_BUFFER_BIT ); 125 | 126 | glUniform1f ( phase_loc , phase ); // write the value of phase to the shaders phase 127 | phase = fmodf( phase + 0.5f , 2.f * 3.141f ); // and update the local variable 128 | if ( update_pos ) { // if the position of the texture has changed due to user action 129 | GLfloat old_offset_x = offset_x; 130 | GLfloat old_offset_y = offset_y; 131 | 132 | offset_x = norm_x - p1_pos_x; 133 | offset_y = norm_y - p1_pos_y; 134 | 135 | p1_pos_x = norm_x; 136 | p1_pos_y = norm_y; 137 | 138 | offset_x += old_offset_x; 139 | offset_y += old_offset_y; 140 | 141 | update_pos = false; 142 | 143 | debugNetPrintf(INFO,"offset_x : %.3f, offset_y :%.3f\n", offset_x, offset_y); 144 | } 145 | 146 | glUniform4f ( offset_loc, offset_x, offset_y, 0.0, 0.0 ); 147 | 148 | glVertexAttribPointer ( position_loc, 3, GL_FLOAT, false, 0, vertexArray ); 149 | glEnableVertexAttribArray ( position_loc ); 150 | glDrawArrays ( GL_TRIANGLE_STRIP, 0, 5 ); 151 | 152 | if ( ++num_frames % 1000 == 0 ) { 153 | gettimeofday( &t2, &tz ); 154 | float dt = t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6; 155 | debugNetPrintf(INFO,"fps: %f\n",num_frames / dt); 156 | num_frames = 0; 157 | t1 = t2; 158 | } 159 | // we swapbuffer egl in main() 160 | } 161 | 162 | void 163 | pad_special(int special) 164 | { 165 | switch (special) { 166 | case 0: //_KEY_LEFT: 167 | offset_x -= 0.05; 168 | break; 169 | case 1: //_KEY_RIGHT: 170 | offset_x += 0.05; 171 | break; 172 | case 2: //_KEY_UP: 173 | offset_y += 0.05; 174 | break; 175 | case 3: //_KEY_DOWN: 176 | offset_y -= 0.05; 177 | break; 178 | } 179 | update_pos = true; 180 | } 181 | 182 | //////////////////////////////////////////////////////////////////////////////////////////// 183 | 184 | static int init() 185 | { 186 | /////// the egl part ////////////////////////////////////////////////////////////////// 187 | // egl provides an interface to connect the graphics related functionality of openGL ES 188 | // with the windowing interface and functionality of the native operation system (X11 189 | // was our case. 190 | 191 | //// egl-contexts collect all state descriptions needed required for operation 192 | 193 | //// associate the egl-context with the egl-surface 194 | //eglMakeCurrent( egl_display, egl_surface, egl_surface, egl_context ); 195 | 196 | /////// the openGL part /////////////////////////////////////////////////////////////// 197 | 198 | GLuint vertexShader = load_shader ( vertex_src , GL_VERTEX_SHADER ); // load vertex shader 199 | GLuint fragmentShader = load_shader ( fragment_src , GL_FRAGMENT_SHADER ); // load fragment shader 200 | 201 | GLuint shaderProgram = glCreateProgram (); // create program object 202 | glAttachShader ( shaderProgram, vertexShader ); // and attach both... 203 | glAttachShader ( shaderProgram, fragmentShader ); // ... shaders to it 204 | 205 | glLinkProgram ( shaderProgram ); // link the program 206 | glUseProgram ( shaderProgram ); // and select it for usage 207 | 208 | //// now get the locations (kind of handle) of the shaders variables 209 | position_loc = glGetAttribLocation ( shaderProgram , "position" ); 210 | phase_loc = glGetUniformLocation ( shaderProgram , "phase" ); 211 | offset_loc = glGetUniformLocation ( shaderProgram , "offset" ); 212 | if ( position_loc < 0 || phase_loc < 0 || offset_loc < 0 ) { 213 | debugNetPrintf(INFO,"Unable to get uniform location\n"); 214 | return 1; 215 | } 216 | 217 | gettimeofday ( &t1 , &tz ); 218 | 219 | return 0; 220 | } 221 | 222 | 223 | int 224 | es2sample_init(int argc, char *argv[]) 225 | { 226 | init(); 227 | 228 | /* Set initial projection/viewing transformation. 229 | * We can't be sure we'll get an event when the window 230 | * first appears. 231 | */ 232 | glViewport ( 0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 233 | 234 | return 0; 235 | } 236 | -------------------------------------------------------------------------------- /orbis_es2cube-smooth/source/esUtil.c: -------------------------------------------------------------------------------- 1 | // 2 | // Book: OpenGL(R) ES 2.0 Programming Guide 3 | // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner 4 | // ISBN-10: 0321502795 5 | // ISBN-13: 9780321502797 6 | // Publisher: Addison-Wesley Professional 7 | // URLs: http://safari.informit.com/9780321563835 8 | // http://www.opengles-book.com 9 | // 10 | 11 | /* 12 | * (c) 2009 Aaftab Munshi, Dan Ginsburg, Dave Shreiner 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining a 15 | * copy of this software and associated documentation files (the "Software"), 16 | * to deal in the Software without restriction, including without limitation 17 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | * and/or sell copies of the Software, and to permit persons to whom the 19 | * Software is furnished to do so, subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be included 22 | * in all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 30 | * DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | // ESUtil.c 34 | // 35 | // A utility library for OpenGL ES. This library provides a 36 | // basic common framework for the example applications in the 37 | // OpenGL ES 2.0 Programming Guide. 38 | // 39 | 40 | /// 41 | // Includes 42 | // 43 | #include "esUtil.h" 44 | #include 45 | #include 46 | 47 | #define PI 3.1415926535897932384626433832795f 48 | 49 | void ESUTIL_API 50 | esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz) 51 | { 52 | result->m[0][0] *= sx; 53 | result->m[0][1] *= sx; 54 | result->m[0][2] *= sx; 55 | result->m[0][3] *= sx; 56 | 57 | result->m[1][0] *= sy; 58 | result->m[1][1] *= sy; 59 | result->m[1][2] *= sy; 60 | result->m[1][3] *= sy; 61 | 62 | result->m[2][0] *= sz; 63 | result->m[2][1] *= sz; 64 | result->m[2][2] *= sz; 65 | result->m[2][3] *= sz; 66 | } 67 | 68 | void ESUTIL_API 69 | esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz) 70 | { 71 | result->m[3][0] += (result->m[0][0] * tx + result->m[1][0] * ty + result->m[2][0] * tz); 72 | result->m[3][1] += (result->m[0][1] * tx + result->m[1][1] * ty + result->m[2][1] * tz); 73 | result->m[3][2] += (result->m[0][2] * tx + result->m[1][2] * ty + result->m[2][2] * tz); 74 | result->m[3][3] += (result->m[0][3] * tx + result->m[1][3] * ty + result->m[2][3] * tz); 75 | } 76 | 77 | void ESUTIL_API 78 | esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) 79 | { 80 | GLfloat sinAngle, cosAngle; 81 | GLfloat mag = sqrtf(x * x + y * y + z * z); 82 | 83 | sinAngle = sinf ( angle * PI / 180.0f ); 84 | cosAngle = cosf ( angle * PI / 180.0f ); 85 | if ( mag > 0.0f ) 86 | { 87 | GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs; 88 | GLfloat oneMinusCos; 89 | ESMatrix rotMat; 90 | 91 | x /= mag; 92 | y /= mag; 93 | z /= mag; 94 | 95 | xx = x * x; 96 | yy = y * y; 97 | zz = z * z; 98 | xy = x * y; 99 | yz = y * z; 100 | zx = z * x; 101 | xs = x * sinAngle; 102 | ys = y * sinAngle; 103 | zs = z * sinAngle; 104 | oneMinusCos = 1.0f - cosAngle; 105 | 106 | rotMat.m[0][0] = (oneMinusCos * xx) + cosAngle; 107 | rotMat.m[0][1] = (oneMinusCos * xy) - zs; 108 | rotMat.m[0][2] = (oneMinusCos * zx) + ys; 109 | rotMat.m[0][3] = 0.0F; 110 | 111 | rotMat.m[1][0] = (oneMinusCos * xy) + zs; 112 | rotMat.m[1][1] = (oneMinusCos * yy) + cosAngle; 113 | rotMat.m[1][2] = (oneMinusCos * yz) - xs; 114 | rotMat.m[1][3] = 0.0F; 115 | 116 | rotMat.m[2][0] = (oneMinusCos * zx) - ys; 117 | rotMat.m[2][1] = (oneMinusCos * yz) + xs; 118 | rotMat.m[2][2] = (oneMinusCos * zz) + cosAngle; 119 | rotMat.m[2][3] = 0.0F; 120 | 121 | rotMat.m[3][0] = 0.0F; 122 | rotMat.m[3][1] = 0.0F; 123 | rotMat.m[3][2] = 0.0F; 124 | rotMat.m[3][3] = 1.0F; 125 | 126 | esMatrixMultiply( result, &rotMat, result ); 127 | } 128 | } 129 | 130 | void ESUTIL_API 131 | esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ) 132 | { 133 | float deltaX = right - left; 134 | float deltaY = top - bottom; 135 | float deltaZ = farZ - nearZ; 136 | ESMatrix frust; 137 | 138 | if ( (nearZ <= 0.0f) || (farZ <= 0.0f) || 139 | (deltaX <= 0.0f) || (deltaY <= 0.0f) || (deltaZ <= 0.0f) ) 140 | return; 141 | 142 | frust.m[0][0] = 2.0f * nearZ / deltaX; 143 | frust.m[0][1] = frust.m[0][2] = frust.m[0][3] = 0.0f; 144 | 145 | frust.m[1][1] = 2.0f * nearZ / deltaY; 146 | frust.m[1][0] = frust.m[1][2] = frust.m[1][3] = 0.0f; 147 | 148 | frust.m[2][0] = (right + left) / deltaX; 149 | frust.m[2][1] = (top + bottom) / deltaY; 150 | frust.m[2][2] = -(nearZ + farZ) / deltaZ; 151 | frust.m[2][3] = -1.0f; 152 | 153 | frust.m[3][2] = -2.0f * nearZ * farZ / deltaZ; 154 | frust.m[3][0] = frust.m[3][1] = frust.m[3][3] = 0.0f; 155 | 156 | esMatrixMultiply(result, &frust, result); 157 | } 158 | 159 | 160 | void ESUTIL_API 161 | esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ) 162 | { 163 | GLfloat frustumW, frustumH; 164 | 165 | frustumH = tanf( fovy / 360.0f * PI ) * nearZ; 166 | frustumW = frustumH * aspect; 167 | 168 | esFrustum( result, -frustumW, frustumW, -frustumH, frustumH, nearZ, farZ ); 169 | } 170 | 171 | void ESUTIL_API 172 | esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ) 173 | { 174 | float deltaX = right - left; 175 | float deltaY = top - bottom; 176 | float deltaZ = farZ - nearZ; 177 | ESMatrix ortho; 178 | 179 | if ( (deltaX == 0.0f) || (deltaY == 0.0f) || (deltaZ == 0.0f) ) 180 | return; 181 | 182 | esMatrixLoadIdentity(&ortho); 183 | ortho.m[0][0] = 2.0f / deltaX; 184 | ortho.m[3][0] = -(right + left) / deltaX; 185 | ortho.m[1][1] = 2.0f / deltaY; 186 | ortho.m[3][1] = -(top + bottom) / deltaY; 187 | ortho.m[2][2] = -2.0f / deltaZ; 188 | ortho.m[3][2] = -(nearZ + farZ) / deltaZ; 189 | 190 | esMatrixMultiply(result, &ortho, result); 191 | } 192 | 193 | 194 | void ESUTIL_API 195 | esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB) 196 | { 197 | ESMatrix tmp; 198 | int i; 199 | 200 | for (i=0; i<4; i++) 201 | { 202 | tmp.m[i][0] = (srcA->m[i][0] * srcB->m[0][0]) + 203 | (srcA->m[i][1] * srcB->m[1][0]) + 204 | (srcA->m[i][2] * srcB->m[2][0]) + 205 | (srcA->m[i][3] * srcB->m[3][0]) ; 206 | 207 | tmp.m[i][1] = (srcA->m[i][0] * srcB->m[0][1]) + 208 | (srcA->m[i][1] * srcB->m[1][1]) + 209 | (srcA->m[i][2] * srcB->m[2][1]) + 210 | (srcA->m[i][3] * srcB->m[3][1]) ; 211 | 212 | tmp.m[i][2] = (srcA->m[i][0] * srcB->m[0][2]) + 213 | (srcA->m[i][1] * srcB->m[1][2]) + 214 | (srcA->m[i][2] * srcB->m[2][2]) + 215 | (srcA->m[i][3] * srcB->m[3][2]) ; 216 | 217 | tmp.m[i][3] = (srcA->m[i][0] * srcB->m[0][3]) + 218 | (srcA->m[i][1] * srcB->m[1][3]) + 219 | (srcA->m[i][2] * srcB->m[2][3]) + 220 | (srcA->m[i][3] * srcB->m[3][3]) ; 221 | } 222 | memcpy(result, &tmp, sizeof(ESMatrix)); 223 | } 224 | 225 | 226 | void ESUTIL_API 227 | esMatrixLoadIdentity(ESMatrix *result) 228 | { 229 | memset(result, 0x0, sizeof(ESMatrix)); 230 | result->m[0][0] = 1.0f; 231 | result->m[1][1] = 1.0f; 232 | result->m[2][2] = 1.0f; 233 | result->m[3][3] = 1.0f; 234 | } 235 | 236 | -------------------------------------------------------------------------------- /orbis_es2cube-smooth/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GL ES 2.0 liborbisGl sample 3 | * ---------------------------- 4 | * 5 | * whole EGL setup/cleanup is internally managed by liborbisGL; 6 | * main render loop calls 2 functions: draw and update controller; 7 | 8 | * includes playing of .mod files and controller input; 9 | * main skeleton results in a very basic and clean code. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | bool flag=true; 31 | 32 | Orbis2dConfig *conf; 33 | OrbisPadConfig *confPad; 34 | 35 | typedef struct OrbisGlobalConf 36 | { 37 | Orbis2dConfig *conf; 38 | OrbisPadConfig *confPad; 39 | OrbisAudioConfig *confAudio; 40 | OrbisKeyboardConfig *confKeyboard; 41 | ps4LinkConfiguration *confLink; 42 | int orbisLinkFlag; 43 | }OrbisGlobalConf; 44 | 45 | OrbisGlobalConf *myConf; 46 | 47 | void updateController() 48 | { 49 | int ret; 50 | unsigned int buttons=0; 51 | ret=orbisPadUpdate(); 52 | if(ret==0) 53 | { 54 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 55 | { 56 | debugNetPrintf(DEBUG,"Combo L2R2 pressed\n"); 57 | buttons=orbisPadGetCurrentButtonsPressed(); 58 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 59 | orbisPadSetCurrentButtonsPressed(buttons); 60 | } 61 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 62 | { 63 | debugNetPrintf(DEBUG,"Combo L1R1 pressed\n"); 64 | buttons=orbisPadGetCurrentButtonsPressed(); 65 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 66 | orbisPadSetCurrentButtonsPressed(buttons); 67 | } 68 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 69 | { 70 | debugNetPrintf(DEBUG,"Combo L1R2 pressed\n"); 71 | buttons=orbisPadGetCurrentButtonsPressed(); 72 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 73 | orbisPadSetCurrentButtonsPressed(buttons); 74 | } 75 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 76 | { 77 | debugNetPrintf(DEBUG,"Combo L2R1 pressed\n"); 78 | buttons=orbisPadGetCurrentButtonsPressed(); 79 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 80 | orbisPadSetCurrentButtonsPressed(buttons); 81 | } 82 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 83 | { 84 | debugNetPrintf(DEBUG,"Up pressed\n"); 85 | //pad_special(2); 86 | } 87 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 88 | { 89 | debugNetPrintf(DEBUG,"Down pressed\n"); 90 | //pad_special(3); 91 | } 92 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 93 | { 94 | debugNetPrintf(DEBUG,"Right pressed\n"); 95 | //pad_special(1); 96 | } 97 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 98 | { 99 | debugNetPrintf(DEBUG,"Left pressed\n"); 100 | //pad_special(0); 101 | } 102 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 103 | { 104 | debugNetPrintf(DEBUG,"Triangle pressed exit\n"); 105 | flag=0; 106 | } 107 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 108 | { 109 | debugNetPrintf(DEBUG,"Circle pressed\n"); 110 | orbisAudioResume(0); 111 | } 112 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 113 | { 114 | debugNetPrintf(DEBUG,"Cross pressed rand color\n"); 115 | //orbisAudioStop(); 116 | } 117 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 118 | { 119 | debugNetPrintf(DEBUG,"Square pressed\n"); 120 | orbisAudioPause(0); 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 123 | { 124 | debugNetPrintf(DEBUG,"L1 pressed\n"); 125 | } 126 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 127 | { 128 | debugNetPrintf(DEBUG,"L2 pressed\n"); 129 | } 130 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 131 | { 132 | debugNetPrintf(DEBUG,"R1 pressed\n"); 133 | } 134 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 135 | { 136 | debugNetPrintf(DEBUG,"R2 pressed\n"); 137 | } 138 | } 139 | } 140 | 141 | 142 | void finishApp() 143 | { 144 | orbisAudioFinish(); 145 | orbisKeyboardFinish(); 146 | orbisGlFinish(); 147 | orbisPadFinish(); 148 | orbisFileFinish(); 149 | ps4LinkFinish(); 150 | } 151 | 152 | 153 | static bool initAppGl() 154 | { 155 | int ret; 156 | ret=orbisGlInit(ATTR_ORBISGL_WIDTH,ATTR_ORBISGL_HEIGHT); 157 | if(ret>0) 158 | { 159 | glViewport(0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 160 | ret=glGetError(); 161 | if(ret) 162 | { 163 | debugNetPrintf(ERROR,"glViewport failed: 0x%08X\n",ret); 164 | return false; 165 | } 166 | glClearColor(0.0f, 0.0f, 1.0f, 1.0f); //blue RGBA 167 | ret=glGetError(); 168 | if(ret) 169 | { 170 | debugNetPrintf(ERROR,"glClearColor failed: 0x%08X\n",ret); 171 | return false; 172 | } 173 | return true; 174 | } 175 | return false; 176 | } 177 | 178 | 179 | bool initApp() 180 | { 181 | int ret; 182 | sceSystemServiceHideSplashScreen(); 183 | //more library initialiazation here pad,filebroser,audio,keyboard, etc 184 | //.... 185 | orbisFileInit(); 186 | ret=orbisPadInitWithConf(myConf->confPad); 187 | if(ret) 188 | { 189 | confPad=orbisPadGetConf(); 190 | ret=orbisAudioInitWithConf(myConf->confAudio); 191 | if(ret==1) 192 | { 193 | ret=orbisKeyboardInitWithConf(myConf->confKeyboard); 194 | if(ret!=1) 195 | return false; 196 | } 197 | } 198 | else 199 | { 200 | return false; 201 | } 202 | if(!initAppGl()) 203 | return false; 204 | 205 | return true; 206 | } 207 | 208 | 209 | /// main rendering loop 210 | int frame = 0; 211 | static bool main_loop(void) 212 | { 213 | int ret; 214 | 215 | while (flag) 216 | { 217 | updateController(); 218 | 219 | glClear(GL_COLOR_BUFFER_BIT); 220 | ret = glGetError(); 221 | if (ret) { 222 | debugNetPrintf(ERROR,"[ORBIS_GL] glClear failed: 0x%08X\n", ret); 223 | goto err; 224 | } 225 | 226 | /// draw 227 | render(); 228 | 229 | // flip frame 230 | orbisGlSwapBuffers(); 231 | } 232 | return true; 233 | 234 | err: 235 | return false; 236 | } 237 | 238 | 239 | 240 | int main(int argc, char *argv[]) 241 | { 242 | int ret; 243 | 244 | uintptr_t intptr=0; 245 | sscanf(argv[1],"%p",&intptr); 246 | myConf=(OrbisGlobalConf *)intptr; 247 | ret=ps4LinkInitWithConf(myConf->confLink); 248 | if(!ret) 249 | { 250 | ps4LinkFinish(); 251 | return 0; 252 | } 253 | debugNetPrintf(INFO,"[ORBIS_GL] Hello from GL ES sample with hitodama's sdk and liborbis\n"); 254 | sleep(1); 255 | 256 | // init libraries 257 | flag=initApp(); 258 | 259 | Mod_Init(0); 260 | ret = Mod_Load("host0:main.mod"); 261 | if(ret) 262 | Mod_Play(); 263 | 264 | orbisAudioResume(0); 265 | 266 | // build shaders, setup initial state, etc. 267 | es2sample_init(); 268 | 269 | // enter main render loop 270 | if (!main_loop()) 271 | { 272 | debugNetPrintf(ERROR,"[ORBIS_GL] Main loop stopped.\n"); 273 | goto err; 274 | } 275 | 276 | err: 277 | 278 | orbisAudioPause(0); 279 | Mod_End(); 280 | 281 | // finish libraries 282 | finishApp(); 283 | 284 | exit(EXIT_SUCCESS); 285 | } 286 | -------------------------------------------------------------------------------- /orbis_es2freetype-gl/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GL ES 2.0 liborbisGl sample 3 | * ---------------------------- 4 | * 5 | * whole EGL setup/cleanup is internally managed by liborbisGL; 6 | * main render loop calls 2 functions: draw and eventually update rotations by controller; 7 | 8 | * includes playing of .mod files and controller input; 9 | * main skeleton results in a very basic and clean code. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | bool flag=true; 31 | 32 | Orbis2dConfig *conf; 33 | OrbisPadConfig *confPad; 34 | 35 | typedef struct OrbisGlobalConf 36 | { 37 | Orbis2dConfig *conf; 38 | OrbisPadConfig *confPad; 39 | OrbisAudioConfig *confAudio; 40 | OrbisKeyboardConfig *confKeyboard; 41 | ps4LinkConfiguration *confLink; 42 | int orbisLinkFlag; 43 | }OrbisGlobalConf; 44 | 45 | OrbisGlobalConf *myConf; 46 | 47 | void updateController() 48 | { 49 | int ret; 50 | unsigned int buttons=0; 51 | ret=orbisPadUpdate(); 52 | if(ret==0) 53 | { 54 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 55 | { 56 | debugNetPrintf(DEBUG,"Combo L2R2 pressed\n"); 57 | buttons=orbisPadGetCurrentButtonsPressed(); 58 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 59 | orbisPadSetCurrentButtonsPressed(buttons); 60 | } 61 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 62 | { 63 | debugNetPrintf(DEBUG,"Combo L1R1 pressed\n"); 64 | buttons=orbisPadGetCurrentButtonsPressed(); 65 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 66 | orbisPadSetCurrentButtonsPressed(buttons); 67 | } 68 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 69 | { 70 | debugNetPrintf(DEBUG,"Combo L1R2 pressed\n"); 71 | buttons=orbisPadGetCurrentButtonsPressed(); 72 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 73 | orbisPadSetCurrentButtonsPressed(buttons); 74 | } 75 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 76 | { 77 | debugNetPrintf(DEBUG,"Combo L2R1 pressed\n"); 78 | buttons=orbisPadGetCurrentButtonsPressed(); 79 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 80 | orbisPadSetCurrentButtonsPressed(buttons); 81 | } 82 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 83 | { 84 | debugNetPrintf(DEBUG,"Up pressed\n"); 85 | //pad_special(2); 86 | } 87 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 88 | { 89 | debugNetPrintf(DEBUG,"Down pressed\n"); 90 | //pad_special(3); 91 | } 92 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 93 | { 94 | debugNetPrintf(DEBUG,"Right pressed\n"); 95 | //pad_special(1); 96 | } 97 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 98 | { 99 | debugNetPrintf(DEBUG,"Left pressed\n"); 100 | //pad_special(0); 101 | } 102 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 103 | { 104 | debugNetPrintf(DEBUG,"Triangle pressed exit\n"); 105 | flag=0; 106 | } 107 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 108 | { 109 | debugNetPrintf(DEBUG,"Circle pressed\n"); 110 | orbisAudioResume(0); 111 | } 112 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 113 | { 114 | debugNetPrintf(DEBUG,"Cross pressed rand color\n"); 115 | //orbisAudioStop(); 116 | } 117 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 118 | { 119 | debugNetPrintf(DEBUG,"Square pressed\n"); 120 | orbisAudioPause(0); 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 123 | { 124 | debugNetPrintf(DEBUG,"L1 pressed\n"); 125 | } 126 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 127 | { 128 | debugNetPrintf(DEBUG,"L2 pressed\n"); 129 | } 130 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 131 | { 132 | debugNetPrintf(DEBUG,"R1 pressed\n"); 133 | } 134 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 135 | { 136 | debugNetPrintf(DEBUG,"R2 pressed\n"); 137 | } 138 | } 139 | } 140 | 141 | 142 | void finishApp() 143 | { 144 | orbisAudioFinish(); 145 | orbisKeyboardFinish(); 146 | orbisGlFinish(); 147 | orbisPadFinish(); 148 | orbisFileFinish(); 149 | ps4LinkFinish(); 150 | } 151 | 152 | 153 | static bool initAppGl() 154 | { 155 | int ret; 156 | ret=orbisGlInit(ATTR_ORBISGL_WIDTH,ATTR_ORBISGL_HEIGHT); 157 | if(ret>0) 158 | { 159 | glViewport(0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 160 | ret=glGetError(); 161 | if(ret) 162 | { 163 | debugNetPrintf(ERROR,"glViewport failed: 0x%08X\n",ret); 164 | return false; 165 | } 166 | glClearColor(0.0f, 0.0f, 1.0f, 1.0f); //blue RGBA 167 | ret=glGetError(); 168 | if(ret) 169 | { 170 | debugNetPrintf(ERROR,"glClearColor failed: 0x%08X\n",ret); 171 | return false; 172 | } 173 | return true; 174 | } 175 | return false; 176 | } 177 | 178 | 179 | bool initApp() 180 | { 181 | int ret; 182 | sceSystemServiceHideSplashScreen(); 183 | //more library initialiazation here pad,filebroser,audio,keyboard, etc 184 | //.... 185 | orbisFileInit(); 186 | ret=orbisPadInitWithConf(myConf->confPad); 187 | if(ret) 188 | { 189 | confPad=orbisPadGetConf(); 190 | ret=orbisAudioInitWithConf(myConf->confAudio); 191 | if(ret==1) 192 | { 193 | ret=orbisKeyboardInitWithConf(myConf->confKeyboard); 194 | if(ret!=1) 195 | return false; 196 | } 197 | } 198 | else 199 | { 200 | return false; 201 | } 202 | if(!initAppGl()) 203 | return false; 204 | 205 | return true; 206 | } 207 | 208 | 209 | /// main rendering loop 210 | int frame = 0; 211 | static bool main_loop(void) 212 | { 213 | int ret; 214 | 215 | while (flag) 216 | { 217 | updateController(); 218 | 219 | glClear(GL_COLOR_BUFFER_BIT); 220 | ret = glGetError(); 221 | if (ret) { 222 | debugNetPrintf(ERROR,"[ORBIS_GL] glClear failed: 0x%08X\n", ret); 223 | goto err; 224 | } 225 | 226 | /// draw 227 | render(); 228 | 229 | // flip frame 230 | orbisGlSwapBuffers(); 231 | } 232 | return true; 233 | 234 | err: 235 | return false; 236 | } 237 | 238 | 239 | 240 | int main(int argc, char *argv[]) 241 | { 242 | int ret; 243 | 244 | uintptr_t intptr=0; 245 | sscanf(argv[1],"%p",&intptr); 246 | myConf=(OrbisGlobalConf *)intptr; 247 | ret=ps4LinkInitWithConf(myConf->confLink); 248 | if(!ret) 249 | { 250 | ps4LinkFinish(); 251 | return 0; 252 | } 253 | debugNetPrintf(INFO,"[ORBIS_GL] Hello from GL ES sample with hitodama's sdk and liborbis\n"); 254 | sleep(1); 255 | 256 | // init libraries 257 | flag=initApp(); 258 | 259 | Mod_Init(0); 260 | ret = Mod_Load("host0:main.mod"); 261 | if(ret) 262 | Mod_Play(); 263 | 264 | orbisAudioResume(0); 265 | 266 | // build shaders, setup initial state, etc. 267 | es2sample_init(); 268 | 269 | // enter main render loop 270 | if (!main_loop()) 271 | { 272 | debugNetPrintf(ERROR,"[ORBIS_GL] Main loop stopped.\n"); 273 | goto err; 274 | } 275 | 276 | err: 277 | 278 | orbisAudioPause(0); 279 | Mod_End(); 280 | 281 | // finish libraries 282 | finishApp(); 283 | 284 | exit(EXIT_SUCCESS); 285 | } 286 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-distance-field/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GL ES 2.0 liborbisGl sample 3 | * ---------------------------- 4 | * 5 | * whole EGL setup/cleanup is internally managed by liborbisGL; 6 | * main render loop calls 2 functions: draw and eventually update rotations by controller; 7 | 8 | * includes playing of .mod files and controller input; 9 | * main skeleton results in a very basic and clean code. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | bool flag=true; 31 | 32 | Orbis2dConfig *conf; 33 | OrbisPadConfig *confPad; 34 | 35 | typedef struct OrbisGlobalConf 36 | { 37 | Orbis2dConfig *conf; 38 | OrbisPadConfig *confPad; 39 | OrbisAudioConfig *confAudio; 40 | OrbisKeyboardConfig *confKeyboard; 41 | ps4LinkConfiguration *confLink; 42 | int orbisLinkFlag; 43 | }OrbisGlobalConf; 44 | 45 | OrbisGlobalConf *myConf; 46 | 47 | void updateController() 48 | { 49 | int ret; 50 | unsigned int buttons=0; 51 | ret=orbisPadUpdate(); 52 | if(ret==0) 53 | { 54 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 55 | { 56 | debugNetPrintf(DEBUG,"Combo L2R2 pressed\n"); 57 | buttons=orbisPadGetCurrentButtonsPressed(); 58 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 59 | orbisPadSetCurrentButtonsPressed(buttons); 60 | } 61 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 62 | { 63 | debugNetPrintf(DEBUG,"Combo L1R1 pressed\n"); 64 | buttons=orbisPadGetCurrentButtonsPressed(); 65 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 66 | orbisPadSetCurrentButtonsPressed(buttons); 67 | } 68 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 69 | { 70 | debugNetPrintf(DEBUG,"Combo L1R2 pressed\n"); 71 | buttons=orbisPadGetCurrentButtonsPressed(); 72 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 73 | orbisPadSetCurrentButtonsPressed(buttons); 74 | } 75 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 76 | { 77 | debugNetPrintf(DEBUG,"Combo L2R1 pressed\n"); 78 | buttons=orbisPadGetCurrentButtonsPressed(); 79 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 80 | orbisPadSetCurrentButtonsPressed(buttons); 81 | } 82 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 83 | { 84 | debugNetPrintf(DEBUG,"Up pressed\n"); 85 | pad_special(2); 86 | } 87 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 88 | { 89 | debugNetPrintf(DEBUG,"Down pressed\n"); 90 | pad_special(3); 91 | } 92 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 93 | { 94 | debugNetPrintf(DEBUG,"Right pressed\n"); 95 | pad_special(1); 96 | } 97 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 98 | { 99 | debugNetPrintf(DEBUG,"Left pressed\n"); 100 | pad_special(0); 101 | } 102 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 103 | { 104 | debugNetPrintf(DEBUG,"Triangle pressed exit\n"); 105 | flag=0; 106 | } 107 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 108 | { 109 | debugNetPrintf(DEBUG,"Circle pressed\n"); 110 | orbisAudioResume(0); 111 | } 112 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 113 | { 114 | debugNetPrintf(DEBUG,"Cross pressed rand color\n"); 115 | //orbisAudioStop(); 116 | } 117 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 118 | { 119 | debugNetPrintf(DEBUG,"Square pressed\n"); 120 | orbisAudioPause(0); 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 123 | { 124 | debugNetPrintf(DEBUG,"L1 pressed\n"); 125 | } 126 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 127 | { 128 | debugNetPrintf(DEBUG,"L2 pressed\n"); 129 | } 130 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 131 | { 132 | debugNetPrintf(DEBUG,"R1 pressed\n"); 133 | } 134 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 135 | { 136 | debugNetPrintf(DEBUG,"R2 pressed\n"); 137 | } 138 | } 139 | } 140 | 141 | 142 | void finishApp() 143 | { 144 | orbisAudioFinish(); 145 | orbisKeyboardFinish(); 146 | orbisGlFinish(); 147 | orbisPadFinish(); 148 | orbisFileFinish(); 149 | ps4LinkFinish(); 150 | } 151 | 152 | 153 | static bool initAppGl() 154 | { 155 | int ret; 156 | ret=orbisGlInit(ATTR_ORBISGL_WIDTH,ATTR_ORBISGL_HEIGHT); 157 | if(ret>0) 158 | { 159 | glViewport(0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 160 | ret=glGetError(); 161 | if(ret) 162 | { 163 | debugNetPrintf(ERROR,"glViewport failed: 0x%08X\n",ret); 164 | return false; 165 | } 166 | glClearColor(0.0f, 0.0f, 1.0f, 1.0f); //blue RGBA 167 | ret=glGetError(); 168 | if(ret) 169 | { 170 | debugNetPrintf(ERROR,"glClearColor failed: 0x%08X\n",ret); 171 | return false; 172 | } 173 | return true; 174 | } 175 | return false; 176 | } 177 | 178 | 179 | bool initApp() 180 | { 181 | int ret; 182 | sceSystemServiceHideSplashScreen(); 183 | //more library initialiazation here pad,filebroser,audio,keyboard, etc 184 | //.... 185 | orbisFileInit(); 186 | ret=orbisPadInitWithConf(myConf->confPad); 187 | if(ret) 188 | { 189 | confPad=orbisPadGetConf(); 190 | ret=orbisAudioInitWithConf(myConf->confAudio); 191 | if(ret==1) 192 | { 193 | ret=orbisKeyboardInitWithConf(myConf->confKeyboard); 194 | if(ret!=1) 195 | return false; 196 | } 197 | } 198 | else 199 | { 200 | return false; 201 | } 202 | if(!initAppGl()) 203 | return false; 204 | 205 | return true; 206 | } 207 | 208 | 209 | /// main rendering loop 210 | int frame = 0; 211 | static bool main_loop(void) 212 | { 213 | int ret; 214 | 215 | while (flag) 216 | { 217 | updateController(); 218 | 219 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 220 | ret = glGetError(); 221 | if (ret) { 222 | debugNetPrintf(ERROR,"[ORBIS_GL] glClear failed: 0x%08X\n", ret); 223 | goto err; 224 | } 225 | 226 | /// draw 227 | render(); 228 | 229 | // flip frame 230 | orbisGlSwapBuffers(); 231 | 232 | sceKernelUsleep(10000); 233 | } 234 | return true; 235 | 236 | err: 237 | return false; 238 | } 239 | 240 | 241 | 242 | int main(int argc, char *argv[]) 243 | { 244 | int ret; 245 | 246 | uintptr_t intptr=0; 247 | sscanf(argv[1],"%p",&intptr); 248 | myConf=(OrbisGlobalConf *)intptr; 249 | ret=ps4LinkInitWithConf(myConf->confLink); 250 | if(!ret) 251 | { 252 | ps4LinkFinish(); 253 | return 0; 254 | } 255 | debugNetPrintf(INFO,"[ORBIS_GL] Hello from GL ES sample with hitodama's sdk and liborbis\n"); 256 | 257 | // init libraries 258 | flag=initApp(); 259 | 260 | Mod_Init(0); 261 | ret = Mod_Load("host0:main.mod"); 262 | if(ret) 263 | Mod_Play(); 264 | 265 | orbisAudioResume(0); 266 | 267 | // build shaders, setup initial state, etc. 268 | es2sample_init(); 269 | 270 | // enter main render loop 271 | if (!main_loop()) 272 | { 273 | debugNetPrintf(ERROR,"[ORBIS_GL] Main loop stopped.\n"); 274 | goto err; 275 | } 276 | 277 | err: 278 | // finish libraries 279 | es2sample_end(); 280 | 281 | orbisAudioPause(0); 282 | Mod_End(); 283 | 284 | finishApp(); 285 | 286 | exit(EXIT_SUCCESS); 287 | } 288 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-font/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GL ES 2.0 liborbisGl sample 3 | * ---------------------------- 4 | * 5 | * whole EGL setup/cleanup is internally managed by liborbisGL; 6 | * main render loop calls 2 functions: draw and eventually update rotations by controller; 7 | 8 | * includes playing of .mod files and controller input; 9 | * main skeleton results in a very basic and clean code. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | bool flag=true; 31 | 32 | Orbis2dConfig *conf; 33 | OrbisPadConfig *confPad; 34 | 35 | typedef struct OrbisGlobalConf 36 | { 37 | Orbis2dConfig *conf; 38 | OrbisPadConfig *confPad; 39 | OrbisAudioConfig *confAudio; 40 | OrbisKeyboardConfig *confKeyboard; 41 | ps4LinkConfiguration *confLink; 42 | int orbisLinkFlag; 43 | }OrbisGlobalConf; 44 | 45 | OrbisGlobalConf *myConf; 46 | 47 | void updateController() 48 | { 49 | int ret; 50 | unsigned int buttons=0; 51 | ret=orbisPadUpdate(); 52 | if(ret==0) 53 | { 54 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 55 | { 56 | debugNetPrintf(DEBUG,"Combo L2R2 pressed\n"); 57 | buttons=orbisPadGetCurrentButtonsPressed(); 58 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 59 | orbisPadSetCurrentButtonsPressed(buttons); 60 | } 61 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 62 | { 63 | debugNetPrintf(DEBUG,"Combo L1R1 pressed\n"); 64 | buttons=orbisPadGetCurrentButtonsPressed(); 65 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 66 | orbisPadSetCurrentButtonsPressed(buttons); 67 | } 68 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 69 | { 70 | debugNetPrintf(DEBUG,"Combo L1R2 pressed\n"); 71 | buttons=orbisPadGetCurrentButtonsPressed(); 72 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 73 | orbisPadSetCurrentButtonsPressed(buttons); 74 | } 75 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 76 | { 77 | debugNetPrintf(DEBUG,"Combo L2R1 pressed\n"); 78 | buttons=orbisPadGetCurrentButtonsPressed(); 79 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 80 | orbisPadSetCurrentButtonsPressed(buttons); 81 | } 82 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 83 | { 84 | debugNetPrintf(DEBUG,"Up pressed\n"); 85 | //pad_special(2); 86 | } 87 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 88 | { 89 | debugNetPrintf(DEBUG,"Down pressed\n"); 90 | //pad_special(3); 91 | } 92 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 93 | { 94 | debugNetPrintf(DEBUG,"Right pressed\n"); 95 | //pad_special(1); 96 | } 97 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 98 | { 99 | debugNetPrintf(DEBUG,"Left pressed\n"); 100 | //pad_special(0); 101 | } 102 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 103 | { 104 | debugNetPrintf(DEBUG,"Triangle pressed exit\n"); 105 | flag=0; 106 | } 107 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 108 | { 109 | debugNetPrintf(DEBUG,"Circle pressed\n"); 110 | orbisAudioResume(0); 111 | } 112 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 113 | { 114 | debugNetPrintf(DEBUG,"Cross pressed rand color\n"); 115 | //orbisAudioStop(); 116 | } 117 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 118 | { 119 | debugNetPrintf(DEBUG,"Square pressed\n"); 120 | orbisAudioPause(0); 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 123 | { 124 | debugNetPrintf(DEBUG,"L1 pressed\n"); 125 | } 126 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 127 | { 128 | debugNetPrintf(DEBUG,"L2 pressed\n"); 129 | } 130 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 131 | { 132 | debugNetPrintf(DEBUG,"R1 pressed\n"); 133 | } 134 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 135 | { 136 | debugNetPrintf(DEBUG,"R2 pressed\n"); 137 | } 138 | } 139 | } 140 | 141 | 142 | void finishApp() 143 | { 144 | orbisAudioFinish(); 145 | orbisKeyboardFinish(); 146 | orbisGlFinish(); 147 | orbisPadFinish(); 148 | orbisFileFinish(); 149 | ps4LinkFinish(); 150 | } 151 | 152 | 153 | static bool initAppGl() 154 | { 155 | int ret; 156 | ret=orbisGlInit(ATTR_ORBISGL_WIDTH,ATTR_ORBISGL_HEIGHT); 157 | if(ret>0) 158 | { 159 | glViewport(0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 160 | ret=glGetError(); 161 | if(ret) 162 | { 163 | debugNetPrintf(ERROR,"glViewport failed: 0x%08X\n",ret); 164 | return false; 165 | } 166 | glClearColor(0.0f, 0.0f, 1.0f, 1.0f); //blue RGBA 167 | ret=glGetError(); 168 | if(ret) 169 | { 170 | debugNetPrintf(ERROR,"glClearColor failed: 0x%08X\n",ret); 171 | return false; 172 | } 173 | return true; 174 | } 175 | return false; 176 | } 177 | 178 | 179 | bool initApp() 180 | { 181 | int ret; 182 | sceSystemServiceHideSplashScreen(); 183 | //more library initialiazation here pad,filebroser,audio,keyboard, etc 184 | //.... 185 | orbisFileInit(); 186 | ret=orbisPadInitWithConf(myConf->confPad); 187 | if(ret) 188 | { 189 | confPad=orbisPadGetConf(); 190 | ret=orbisAudioInitWithConf(myConf->confAudio); 191 | if(ret==1) 192 | { 193 | ret=orbisKeyboardInitWithConf(myConf->confKeyboard); 194 | if(ret!=1) 195 | return false; 196 | } 197 | } 198 | else 199 | { 200 | return false; 201 | } 202 | if(!initAppGl()) 203 | return false; 204 | 205 | return true; 206 | } 207 | 208 | 209 | /// main rendering loop 210 | int frame = 0; 211 | static bool main_loop(void) 212 | { 213 | int ret; 214 | 215 | while (flag) 216 | { 217 | updateController(); 218 | 219 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 220 | ret = glGetError(); 221 | if (ret) { 222 | debugNetPrintf(ERROR,"[ORBIS_GL] glClear failed: 0x%08X\n", ret); 223 | goto err; 224 | } 225 | 226 | /// draw 227 | render(); 228 | 229 | // flip frame 230 | orbisGlSwapBuffers(); 231 | 232 | sceKernelUsleep(10000); 233 | } 234 | return true; 235 | 236 | err: 237 | return false; 238 | } 239 | 240 | 241 | 242 | int main(int argc, char *argv[]) 243 | { 244 | int ret; 245 | 246 | uintptr_t intptr=0; 247 | sscanf(argv[1],"%p",&intptr); 248 | myConf=(OrbisGlobalConf *)intptr; 249 | ret=ps4LinkInitWithConf(myConf->confLink); 250 | if(!ret) 251 | { 252 | ps4LinkFinish(); 253 | return 0; 254 | } 255 | debugNetPrintf(INFO,"[ORBIS_GL] Hello from GL ES sample with hitodama's sdk and liborbis\n"); 256 | 257 | // init libraries 258 | flag=initApp(); 259 | 260 | Mod_Init(0); 261 | ret = Mod_Load("host0:main.mod"); 262 | if(ret) 263 | Mod_Play(); 264 | 265 | orbisAudioResume(0); 266 | 267 | // build shaders, setup initial state, etc. 268 | es2sample_init(); 269 | 270 | // enter main render loop 271 | if (!main_loop()) 272 | { 273 | debugNetPrintf(ERROR,"[ORBIS_GL] Main loop stopped.\n"); 274 | goto err; 275 | } 276 | 277 | err: 278 | // finish libraries 279 | es2sample_end(); 280 | 281 | orbisAudioPause(0); 282 | Mod_End(); 283 | 284 | finishApp(); 285 | 286 | exit(EXIT_SUCCESS); 287 | } 288 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-glyph/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GL ES 2.0 liborbisGl sample 3 | * ---------------------------- 4 | * 5 | * whole EGL setup/cleanup is internally managed by liborbisGL; 6 | * main render loop calls 2 functions: draw and eventually update rotations by controller; 7 | 8 | * includes playing of .mod files and controller input; 9 | * main skeleton results in a very basic and clean code. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | bool flag=true; 31 | 32 | Orbis2dConfig *conf; 33 | OrbisPadConfig *confPad; 34 | 35 | typedef struct OrbisGlobalConf 36 | { 37 | Orbis2dConfig *conf; 38 | OrbisPadConfig *confPad; 39 | OrbisAudioConfig *confAudio; 40 | OrbisKeyboardConfig *confKeyboard; 41 | ps4LinkConfiguration *confLink; 42 | int orbisLinkFlag; 43 | }OrbisGlobalConf; 44 | 45 | OrbisGlobalConf *myConf; 46 | 47 | void updateController() 48 | { 49 | int ret; 50 | unsigned int buttons=0; 51 | ret=orbisPadUpdate(); 52 | if(ret==0) 53 | { 54 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 55 | { 56 | debugNetPrintf(DEBUG,"Combo L2R2 pressed\n"); 57 | buttons=orbisPadGetCurrentButtonsPressed(); 58 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 59 | orbisPadSetCurrentButtonsPressed(buttons); 60 | } 61 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 62 | { 63 | debugNetPrintf(DEBUG,"Combo L1R1 pressed\n"); 64 | buttons=orbisPadGetCurrentButtonsPressed(); 65 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 66 | orbisPadSetCurrentButtonsPressed(buttons); 67 | } 68 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 69 | { 70 | debugNetPrintf(DEBUG,"Combo L1R2 pressed\n"); 71 | buttons=orbisPadGetCurrentButtonsPressed(); 72 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 73 | orbisPadSetCurrentButtonsPressed(buttons); 74 | } 75 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 76 | { 77 | debugNetPrintf(DEBUG,"Combo L2R1 pressed\n"); 78 | buttons=orbisPadGetCurrentButtonsPressed(); 79 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 80 | orbisPadSetCurrentButtonsPressed(buttons); 81 | } 82 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 83 | { 84 | debugNetPrintf(DEBUG,"Up pressed\n"); 85 | //pad_special(2); 86 | } 87 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 88 | { 89 | debugNetPrintf(DEBUG,"Down pressed\n"); 90 | //pad_special(3); 91 | } 92 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 93 | { 94 | debugNetPrintf(DEBUG,"Right pressed\n"); 95 | //pad_special(1); 96 | } 97 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 98 | { 99 | debugNetPrintf(DEBUG,"Left pressed\n"); 100 | //pad_special(0); 101 | } 102 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 103 | { 104 | debugNetPrintf(DEBUG,"Triangle pressed exit\n"); 105 | flag=0; 106 | } 107 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 108 | { 109 | debugNetPrintf(DEBUG,"Circle pressed\n"); 110 | orbisAudioResume(0); 111 | } 112 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 113 | { 114 | debugNetPrintf(DEBUG,"Cross pressed rand color\n"); 115 | //orbisAudioStop(); 116 | } 117 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 118 | { 119 | debugNetPrintf(DEBUG,"Square pressed\n"); 120 | orbisAudioPause(0); 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 123 | { 124 | debugNetPrintf(DEBUG,"L1 pressed\n"); 125 | } 126 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 127 | { 128 | debugNetPrintf(DEBUG,"L2 pressed\n"); 129 | } 130 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 131 | { 132 | debugNetPrintf(DEBUG,"R1 pressed\n"); 133 | } 134 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 135 | { 136 | debugNetPrintf(DEBUG,"R2 pressed\n"); 137 | } 138 | } 139 | } 140 | 141 | 142 | void finishApp() 143 | { 144 | orbisAudioFinish(); 145 | orbisKeyboardFinish(); 146 | orbisGlFinish(); 147 | orbisPadFinish(); 148 | orbisFileFinish(); 149 | ps4LinkFinish(); 150 | } 151 | 152 | 153 | static bool initAppGl() 154 | { 155 | int ret; 156 | ret=orbisGlInit(ATTR_ORBISGL_WIDTH,ATTR_ORBISGL_HEIGHT); 157 | if(ret>0) 158 | { 159 | glViewport(0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 160 | ret=glGetError(); 161 | if(ret) 162 | { 163 | debugNetPrintf(ERROR,"glViewport failed: 0x%08X\n",ret); 164 | return false; 165 | } 166 | glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // white RGBA 167 | ret=glGetError(); 168 | if(ret) 169 | { 170 | debugNetPrintf(ERROR,"glClearColor failed: 0x%08X\n",ret); 171 | return false; 172 | } 173 | return true; 174 | } 175 | return false; 176 | } 177 | 178 | 179 | bool initApp() 180 | { 181 | int ret; 182 | sceSystemServiceHideSplashScreen(); 183 | //more library initialiazation here pad,filebroser,audio,keyboard, etc 184 | //.... 185 | orbisFileInit(); 186 | ret=orbisPadInitWithConf(myConf->confPad); 187 | if(ret) 188 | { 189 | confPad=orbisPadGetConf(); 190 | ret=orbisAudioInitWithConf(myConf->confAudio); 191 | if(ret==1) 192 | { 193 | ret=orbisKeyboardInitWithConf(myConf->confKeyboard); 194 | if(ret!=1) 195 | return false; 196 | } 197 | } 198 | else 199 | { 200 | return false; 201 | } 202 | if(!initAppGl()) 203 | return false; 204 | 205 | return true; 206 | } 207 | 208 | 209 | /// main rendering loop 210 | int frame = 0; 211 | static bool main_loop(void) 212 | { 213 | int ret; 214 | 215 | while (flag) 216 | { 217 | updateController(); 218 | 219 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 220 | ret = glGetError(); 221 | if (ret) { 222 | debugNetPrintf(ERROR,"[ORBIS_GL] glClear failed: 0x%08X\n", ret); 223 | goto err; 224 | } 225 | 226 | /// draw 227 | render(); 228 | 229 | // flip frame 230 | orbisGlSwapBuffers(); 231 | 232 | sceKernelUsleep(10000); 233 | } 234 | return true; 235 | 236 | err: 237 | return false; 238 | } 239 | 240 | 241 | 242 | int main(int argc, char *argv[]) 243 | { 244 | int ret; 245 | 246 | uintptr_t intptr=0; 247 | sscanf(argv[1],"%p",&intptr); 248 | myConf=(OrbisGlobalConf *)intptr; 249 | ret=ps4LinkInitWithConf(myConf->confLink); 250 | if(!ret) 251 | { 252 | ps4LinkFinish(); 253 | return 0; 254 | } 255 | debugNetPrintf(INFO,"[ORBIS_GL] Hello from GL ES sample with hitodama's sdk and liborbis\n"); 256 | 257 | // init libraries 258 | flag=initApp(); 259 | 260 | Mod_Init(0); 261 | ret = Mod_Load("host0:main.mod"); 262 | if(ret) 263 | Mod_Play(); 264 | 265 | orbisAudioResume(0); 266 | 267 | // build shaders, setup initial state, etc. 268 | es2sample_init(); 269 | 270 | // enter main render loop 271 | if (!main_loop()) 272 | { 273 | debugNetPrintf(ERROR,"[ORBIS_GL] Main loop stopped.\n"); 274 | goto err; 275 | } 276 | 277 | err: 278 | // finish libraries 279 | es2sample_end(); 280 | 281 | orbisAudioPause(0); 282 | Mod_End(); 283 | 284 | finishApp(); 285 | 286 | exit(EXIT_SUCCESS); 287 | } 288 | -------------------------------------------------------------------------------- /orbis_ftgl2_samples/orbis_es2ftgl-markup/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * GL ES 2.0 liborbisGl sample 3 | * ---------------------------- 4 | * 5 | * whole EGL setup/cleanup is internally managed by liborbisGL; 6 | * main render loop calls 2 functions: draw and eventually update rotations by controller; 7 | 8 | * includes playing of .mod files and controller input; 9 | * main skeleton results in a very basic and clean code. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | 30 | bool flag=true; 31 | 32 | Orbis2dConfig *conf; 33 | OrbisPadConfig *confPad; 34 | 35 | typedef struct OrbisGlobalConf 36 | { 37 | Orbis2dConfig *conf; 38 | OrbisPadConfig *confPad; 39 | OrbisAudioConfig *confAudio; 40 | OrbisKeyboardConfig *confKeyboard; 41 | ps4LinkConfiguration *confLink; 42 | int orbisLinkFlag; 43 | }OrbisGlobalConf; 44 | 45 | OrbisGlobalConf *myConf; 46 | 47 | void updateController() 48 | { 49 | int ret; 50 | unsigned int buttons=0; 51 | ret=orbisPadUpdate(); 52 | if(ret==0) 53 | { 54 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 55 | { 56 | debugNetPrintf(DEBUG,"Combo L2R2 pressed\n"); 57 | buttons=orbisPadGetCurrentButtonsPressed(); 58 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 59 | orbisPadSetCurrentButtonsPressed(buttons); 60 | } 61 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 62 | { 63 | debugNetPrintf(DEBUG,"Combo L1R1 pressed\n"); 64 | buttons=orbisPadGetCurrentButtonsPressed(); 65 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 66 | orbisPadSetCurrentButtonsPressed(buttons); 67 | } 68 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 69 | { 70 | debugNetPrintf(DEBUG,"Combo L1R2 pressed\n"); 71 | buttons=orbisPadGetCurrentButtonsPressed(); 72 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 73 | orbisPadSetCurrentButtonsPressed(buttons); 74 | } 75 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 76 | { 77 | debugNetPrintf(DEBUG,"Combo L2R1 pressed\n"); 78 | buttons=orbisPadGetCurrentButtonsPressed(); 79 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 80 | orbisPadSetCurrentButtonsPressed(buttons); 81 | } 82 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 83 | { 84 | debugNetPrintf(DEBUG,"Up pressed\n"); 85 | //pad_special(2); 86 | } 87 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 88 | { 89 | debugNetPrintf(DEBUG,"Down pressed\n"); 90 | //pad_special(3); 91 | } 92 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 93 | { 94 | debugNetPrintf(DEBUG,"Right pressed\n"); 95 | //pad_special(1); 96 | } 97 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 98 | { 99 | debugNetPrintf(DEBUG,"Left pressed\n"); 100 | //pad_special(0); 101 | } 102 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 103 | { 104 | debugNetPrintf(DEBUG,"Triangle pressed exit\n"); 105 | flag=0; 106 | } 107 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 108 | { 109 | debugNetPrintf(DEBUG,"Circle pressed\n"); 110 | orbisAudioResume(0); 111 | } 112 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 113 | { 114 | debugNetPrintf(DEBUG,"Cross pressed rand color\n"); 115 | //orbisAudioStop(); 116 | } 117 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 118 | { 119 | debugNetPrintf(DEBUG,"Square pressed\n"); 120 | orbisAudioPause(0); 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 123 | { 124 | debugNetPrintf(DEBUG,"L1 pressed\n"); 125 | } 126 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 127 | { 128 | debugNetPrintf(DEBUG,"L2 pressed\n"); 129 | } 130 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 131 | { 132 | debugNetPrintf(DEBUG,"R1 pressed\n"); 133 | } 134 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 135 | { 136 | debugNetPrintf(DEBUG,"R2 pressed\n"); 137 | } 138 | } 139 | } 140 | 141 | 142 | void finishApp() 143 | { 144 | orbisAudioFinish(); 145 | orbisKeyboardFinish(); 146 | orbisGlFinish(); 147 | orbisPadFinish(); 148 | orbisFileFinish(); 149 | ps4LinkFinish(); 150 | } 151 | 152 | 153 | static bool initAppGl() 154 | { 155 | int ret; 156 | ret=orbisGlInit(ATTR_ORBISGL_WIDTH,ATTR_ORBISGL_HEIGHT); 157 | if(ret>0) 158 | { 159 | glViewport(0, 0, ATTR_ORBISGL_WIDTH, ATTR_ORBISGL_HEIGHT); 160 | ret=glGetError(); 161 | if(ret) 162 | { 163 | debugNetPrintf(ERROR,"glViewport failed: 0x%08X\n",ret); 164 | return false; 165 | } 166 | glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // white RGBA 167 | ret=glGetError(); 168 | if(ret) 169 | { 170 | debugNetPrintf(ERROR,"glClearColor failed: 0x%08X\n",ret); 171 | return false; 172 | } 173 | return true; 174 | } 175 | return false; 176 | } 177 | 178 | 179 | bool initApp() 180 | { 181 | int ret; 182 | sceSystemServiceHideSplashScreen(); 183 | //more library initialiazation here pad,filebroser,audio,keyboard, etc 184 | //.... 185 | orbisFileInit(); 186 | ret=orbisPadInitWithConf(myConf->confPad); 187 | if(ret) 188 | { 189 | confPad=orbisPadGetConf(); 190 | ret=orbisAudioInitWithConf(myConf->confAudio); 191 | if(ret==1) 192 | { 193 | ret=orbisKeyboardInitWithConf(myConf->confKeyboard); 194 | if(ret!=1) 195 | return false; 196 | } 197 | } 198 | else 199 | { 200 | return false; 201 | } 202 | if(!initAppGl()) 203 | return false; 204 | 205 | return true; 206 | } 207 | 208 | 209 | /// main rendering loop 210 | int frame = 0; 211 | static bool main_loop(void) 212 | { 213 | int ret; 214 | 215 | while (flag) 216 | { 217 | updateController(); 218 | 219 | glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 220 | ret = glGetError(); 221 | if (ret) { 222 | debugNetPrintf(ERROR,"[ORBIS_GL] glClear failed: 0x%08X\n", ret); 223 | goto err; 224 | } 225 | 226 | /// draw 227 | render(); 228 | 229 | // flip frame 230 | orbisGlSwapBuffers(); 231 | 232 | sceKernelUsleep(10000); 233 | } 234 | return true; 235 | 236 | err: 237 | return false; 238 | } 239 | 240 | 241 | 242 | int main(int argc, char *argv[]) 243 | { 244 | int ret; 245 | 246 | uintptr_t intptr=0; 247 | sscanf(argv[1],"%p",&intptr); 248 | myConf=(OrbisGlobalConf *)intptr; 249 | ret=ps4LinkInitWithConf(myConf->confLink); 250 | if(!ret) 251 | { 252 | ps4LinkFinish(); 253 | return 0; 254 | } 255 | debugNetPrintf(INFO,"[ORBIS_GL] Hello from GL ES sample with hitodama's sdk and liborbis\n"); 256 | 257 | // init libraries 258 | flag=initApp(); 259 | 260 | Mod_Init(0); 261 | ret = Mod_Load("host0:main.mod"); 262 | if(ret) 263 | Mod_Play(); 264 | 265 | orbisAudioResume(0); 266 | 267 | // build shaders, setup initial state, etc. 268 | es2sample_init(); 269 | 270 | // enter main render loop 271 | if (!main_loop()) 272 | { 273 | debugNetPrintf(ERROR,"[ORBIS_GL] Main loop stopped.\n"); 274 | goto err; 275 | } 276 | 277 | err: 278 | // finish libraries 279 | es2sample_end(); 280 | 281 | orbisAudioPause(0); 282 | Mod_End(); 283 | 284 | finishApp(); 285 | 286 | exit(EXIT_SUCCESS); 287 | } 288 | --------------------------------------------------------------------------------