├── YUV2RGBSample ├── Supportingfiles │ ├── makefile │ ├── YUV2RGBonGPUSample.vert │ └── YUV2RGBonGPUSample.frag ├── Yuv2rgb.png ├── Makefile ├── YUV2RGBonGPUSample.h └── YUV2RGBonGPUSample.cpp ├── EGLTextureVideoSample ├── Video_Texture.png ├── EGLVideo1.png ├── EGLVideo2.png ├── Videotexture.png └── makefile ├── MultiCubeSample ├── Supportingfiles │ ├── makefile │ ├── CubeSample.frag │ └── CubeSample.vert ├── CubesSample.png ├── makefile ├── CubeSample.h └── CubeSample.cpp ├── TriangleSample ├── Supportingfiles │ ├── makefile │ ├── TriangleSample.frag │ └── TriangleSample.vert ├── Triangle.png ├── makefile ├── TriangleSample.h └── TriangleSample.cpp ├── WaveformSample ├── Supportingfiles │ ├── makefile │ ├── WaverenderSample.vert │ └── WaverenderSample.frag ├── Waveform.png ├── makefile ├── WaverenderSample.h └── WaverenderSample.cpp ├── Alpha_DepthSample ├── Supportingfiles │ ├── makefile │ ├── DepthSamplebox.frag │ ├── DepthSamplebox.vert │ ├── DepthSamplevertical.vert │ ├── DepthSampleverticalExt.frag │ └── DepthSamplevertical.frag ├── Depth.png ├── makefile └── DepthSample.h ├── FrameBufferObject-FBOSample ├── Supportingfiles │ ├── makefile │ ├── FrameBufferObject_cube.frag │ └── FrameBufferObject_cube.vert ├── FBO.png ├── makefile ├── FBOSample.h └── FBOSample.cpp ├── ParticleRenderingSample ├── Supportingfiles │ ├── makefile │ ├── texture.raw │ ├── Molecule_system.frag │ └── Molecule_system.vert ├── Particles.png ├── makefile └── MoleculeSystemSample.h ├── EGLRenderingSample ├── EGL1.png ├── EGL2.png └── makefile ├── TextureMipMapSample ├── MIPMAP.png ├── Supportingfiles │ ├── xilinx.png │ ├── xilinx_mip_0.pkm │ ├── xilinx_mip_1.pkm │ ├── xilinx_mip_2.pkm │ ├── xilinx_mip_3.pkm │ ├── xilinx_mip_4.pkm │ ├── xilinx_mip_5.pkm │ ├── xilinx_mip_6.pkm │ ├── xilinx_mip_7.pkm │ ├── xilinx_mip_8.pkm │ ├── xilinx_mip_9.pkm │ ├── xilinx_mip_10.pkm │ ├── xilinx_mip_11.pkm │ ├── textureMipMap.frag │ ├── textureMipMap.vert │ └── makefile ├── makefile ├── MipMapSample.h └── MipMapSample.cpp ├── run_exports.sh ├── makefile ├── LICENSE ├── Coreframework ├── Xfbdev_window.h ├── XPodium.cpp ├── XGLSLCompile.h ├── XLinuxTarget.h ├── XTime.h ├── XPodium.h ├── XEGLIntf.h ├── XLinuxPodium.h ├── XCompressionTexture.h ├── XMathematics.h ├── XLinuxTarget.cpp ├── XTexture.h ├── XCompressionTexture.cpp ├── XCVector.h ├── XMatrixAPI.h ├── XGLSLCompile.cpp ├── XTime.cpp ├── XLinuxPodium.cpp └── XTexture.cpp ├── Matrix_Multiplication └── README.md └── readme.md /YUV2RGBSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /EGLTextureVideoSample/Video_Texture.png: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /MultiCubeSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TriangleSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /WaveformSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ParticleRenderingSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Depth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/Alpha_DepthSample/Depth.png -------------------------------------------------------------------------------- /EGLRenderingSample/EGL1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/EGLRenderingSample/EGL1.png -------------------------------------------------------------------------------- /EGLRenderingSample/EGL2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/EGLRenderingSample/EGL2.png -------------------------------------------------------------------------------- /TriangleSample/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TriangleSample/Triangle.png -------------------------------------------------------------------------------- /WaveformSample/Waveform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/WaveformSample/Waveform.png -------------------------------------------------------------------------------- /YUV2RGBSample/Yuv2rgb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/YUV2RGBSample/Yuv2rgb.png -------------------------------------------------------------------------------- /MultiCubeSample/CubesSample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/MultiCubeSample/CubesSample.png -------------------------------------------------------------------------------- /TextureMipMapSample/MIPMAP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/MIPMAP.png -------------------------------------------------------------------------------- /EGLTextureVideoSample/EGLVideo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/EGLTextureVideoSample/EGLVideo1.png -------------------------------------------------------------------------------- /EGLTextureVideoSample/EGLVideo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/EGLTextureVideoSample/EGLVideo2.png -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/FBO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/FrameBufferObject-FBOSample/FBO.png -------------------------------------------------------------------------------- /ParticleRenderingSample/Particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/ParticleRenderingSample/Particles.png -------------------------------------------------------------------------------- /EGLTextureVideoSample/Videotexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/EGLTextureVideoSample/Videotexture.png -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx.png -------------------------------------------------------------------------------- /ParticleRenderingSample/Supportingfiles/texture.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/ParticleRenderingSample/Supportingfiles/texture.raw -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_0.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_0.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_1.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_1.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_2.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_2.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_3.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_3.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_4.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_4.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_5.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_5.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_6.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_6.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_7.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_7.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_8.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_8.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_9.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_9.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_10.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_10.pkm -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/xilinx_mip_11.pkm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xilinx/SDKOpenGLES/HEAD/TextureMipMapSample/Supportingfiles/xilinx_mip_11.pkm -------------------------------------------------------------------------------- /MultiCubeSample/Supportingfiles/CubeSample.frag: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | varying vec4 vecColor; 3 | 4 | void main() 5 | { 6 | gl_FragColor = vecColor; 7 | } 8 | -------------------------------------------------------------------------------- /TriangleSample/Supportingfiles/TriangleSample.frag: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | varying vec4 v_v4FillColor; 3 | 4 | void main() 5 | { 6 | gl_FragColor = v_v4FillColor; 7 | } 8 | -------------------------------------------------------------------------------- /WaveformSample/Supportingfiles/WaverenderSample.vert: -------------------------------------------------------------------------------- 1 | attribute vec4 a_v4Position; 2 | uniform mat4 mvp; 3 | 4 | 5 | void main() 6 | { 7 | gl_Position = mvp * a_v4Position; 8 | } 9 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Supportingfiles/DepthSamplebox.frag: -------------------------------------------------------------------------------- 1 | precision lowp float; 2 | 3 | varying vec3 vv3color; 4 | 5 | void main() 6 | { 7 | gl_FragColor = vec4(vv3color, 1.0); 8 | } 9 | -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/textureMipMap.frag: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision mediump float; 3 | 4 | uniform sampler2D u_s2dTexture; 5 | 6 | varying vec2 v_v2TexCoord; 7 | 8 | void main() 9 | { 10 | gl_FragColor = texture2D(u_s2dTexture, v_v2TexCoord); 11 | } 12 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Supportingfiles/DepthSamplebox.vert: -------------------------------------------------------------------------------- 1 | attribute vec4 av4position; 2 | attribute vec3 av3color; 3 | 4 | uniform mat4 mvp; 5 | 6 | varying vec3 vv3color; 7 | 8 | void main() 9 | { 10 | vv3color = av3color; 11 | gl_Position = mvp * av4position; 12 | } 13 | -------------------------------------------------------------------------------- /MultiCubeSample/Supportingfiles/CubeSample.vert: -------------------------------------------------------------------------------- 1 | attribute vec4 a_v4Position; 2 | attribute vec4 a_v4FillColor; 3 | uniform mat4 mvp; 4 | 5 | varying vec4 vecColor; 6 | 7 | void main() 8 | { 9 | vecColor = a_v4FillColor; 10 | gl_Position = mvp * a_v4Position; 11 | } 12 | -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/textureMipMap.vert: -------------------------------------------------------------------------------- 1 | 2 | #version 100 3 | 4 | attribute vec4 a_v4Position; 5 | attribute vec2 a_v2TexCoord; 6 | 7 | varying vec2 v_v2TexCoord; 8 | 9 | void main() 10 | { 11 | v_v2TexCoord = a_v2TexCoord; 12 | gl_Position = a_v4Position; 13 | } 14 | -------------------------------------------------------------------------------- /TriangleSample/Supportingfiles/TriangleSample.vert: -------------------------------------------------------------------------------- 1 | attribute vec4 a_v4Position; 2 | attribute vec4 a_v4FillColor; 3 | uniform mat4 mvp; 4 | 5 | varying vec4 v_v4FillColor; 6 | 7 | void main() 8 | { 9 | v_v4FillColor = a_v4FillColor; 10 | gl_Position = mvp * a_v4Position; 11 | } 12 | -------------------------------------------------------------------------------- /YUV2RGBSample/Supportingfiles/YUV2RGBonGPUSample.vert: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | attribute vec4 av4position; 3 | attribute vec2 av3colour; 4 | uniform mat4 mvp; 5 | varying vec2 textureOut; 6 | void main() 7 | { 8 | textureOut = av3colour; 9 | gl_Position = mvp * av4position; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/Supportingfiles/FrameBufferObject_cube.frag: -------------------------------------------------------------------------------- 1 | #version 100 2 | precision mediump float; 3 | 4 | uniform sampler2D u_s2dTexture; 5 | uniform float u_fTex; 6 | 7 | varying vec4 v_v4FillColor; 8 | varying vec2 v_v2TexCoord; 9 | 10 | void main() 11 | { 12 | vec4 v4Texel = texture2D(u_s2dTexture, v_v2TexCoord); 13 | gl_FragColor = mix(v_v4FillColor, v4Texel, u_fTex); 14 | } 15 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Supportingfiles/DepthSamplevertical.vert: -------------------------------------------------------------------------------- 1 | attribute vec4 av4position; 2 | attribute vec4 av4color; 3 | 4 | uniform mat4 mvp; 5 | uniform mediump float far; 6 | 7 | varying vec4 vv4GlassColor; 8 | varying float vfGlassLinearDepth; 9 | 10 | void main() 11 | { 12 | vv4GlassColor = av4color; 13 | gl_Position = mvp * av4position; 14 | vfGlassLinearDepth = gl_Position.w / far; 15 | } 16 | -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/Supportingfiles/FrameBufferObject_cube.vert: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | attribute vec4 a_v4Position; 4 | attribute vec4 a_v4FillColor; 5 | attribute vec2 a_v2TexCoord; 6 | 7 | uniform mat4 u_m4Projection; 8 | uniform mat4 u_m4Modelview; 9 | 10 | varying vec4 v_v4FillColor; 11 | varying vec2 v_v2TexCoord; 12 | 13 | void main() 14 | { 15 | v_v4FillColor = a_v4FillColor; 16 | v_v2TexCoord = a_v2TexCoord; 17 | gl_Position = u_m4Projection * u_m4Modelview * a_v4Position; 18 | } 19 | -------------------------------------------------------------------------------- /run_exports.sh: -------------------------------------------------------------------------------- 1 | export MALI_LIBS=/sysroots/plnx_aarch64/usr/lib 2 | export MALI_INCLUDE=/scratch/ZCU102_PL/ZynqMP/build/tmp/sysroots/plnx_aarch64/usr/include 3 | export ARM_CROSS_COMPILER_PATH=/proj/petalinux/petalinux-v2023.1_daily_latest/petalinux-v2023.1-final/tools/linux-i386/aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ 4 | export ARM_CROSS_COMPILER_PATH_C=/proj/petalinux/petalinux-v2023.1_daily_latest/petalinux-v2023.1-final/tools/linux-i386/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc 5 | export CXXFLAGS=-DENABLE_FBDEV 6 | 7 | 8 | -------------------------------------------------------------------------------- /YUV2RGBSample/Supportingfiles/YUV2RGBonGPUSample.frag: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | varying vec2 textureOut; 3 | uniform sampler2D tex_y; 4 | uniform sampler2D tex_u; 5 | uniform sampler2D tex_v; 6 | const vec3 R_cf = vec3(1.164383, 0.000000, 1.596027); 7 | const vec3 G_cf = vec3(1.164383, -0.391762, -0.812968); 8 | const vec3 B_cf = vec3(1.164383, 2.017232, 0.000000); 9 | const vec3 offset = vec3(-0.0625, -0.5, -0.5); 10 | void main() 11 | { 12 | vec3 yuv; 13 | vec3 rgb; 14 | yuv.x = texture2D(tex_y, textureOut).r; 15 | yuv.y = texture2D(tex_u, textureOut).r; 16 | yuv.z = texture2D(tex_v, textureOut).r; 17 | yuv += offset; 18 | rgb.r = dot(yuv, R_cf); 19 | rgb.g = dot(yuv, G_cf); 20 | rgb.b = dot(yuv, B_cf); 21 | gl_FragColor = vec4(rgb, 1); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Supportingfiles/DepthSampleverticalExt.frag: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | uniform float near; 4 | uniform float far; 5 | uniform float glassMaterial; 6 | 7 | uniform vec2 viewportSize; 8 | uniform sampler2D cubeDepthTexture; 9 | 10 | varying lowp vec4 vv4GlassColor; 11 | varying float vfGlassLinearDepth; 12 | 13 | highp float z_eye_far_to_linear(highp float z, float n, float f) 14 | { 15 | return 2.0 * n / (f + n - z * (f - n)); 16 | } 17 | 18 | void main() 19 | { 20 | highp float fCubeZ = texture2D(cubeDepthTexture, gl_FragCoord.xy / viewportSize).r * 2.0 - 1.0; 21 | float fCubeLinearDepth = z_eye_far_to_linear(fCubeZ, near, far); 22 | 23 | 24 | float fator = clamp(vv4GlassColor.a + (fCubeLinearDepth - vfGlassLinearDepth) * glassMaterial, 0.0, 1.0); 25 | gl_FragColor = vec4(vv4GlassColor.rgb, fator); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Alpha_DepthSample/Supportingfiles/DepthSamplevertical.frag: -------------------------------------------------------------------------------- 1 | #extension GL_ARM_shader_framebuffer_fetch_depth_stencil : require 2 | precision mediump float; 3 | 4 | uniform float near; 5 | uniform float far; 6 | uniform float glassMaterial; 7 | 8 | varying lowp vec4 vv4GlassColor; 9 | varying float vfGlassLinearDepth; 10 | 11 | // converts exponential depth to a linear [0..1] range, assuming [eye..far] 12 | highp float z_eye_far_to_linear(highp float z, float n, float f) 13 | { 14 | return 2.0 * n / (f + n - z * (f - n)); 15 | } 16 | 17 | void main() 18 | { 19 | highp float fCubeZ = gl_LastFragDepthARM * 2.0 - 1.0; 20 | float fCubeLinearDepth = z_eye_far_to_linear(fCubeZ, near, far); 21 | 22 | float fator = clamp(vv4GlassColor.a + (fCubeLinearDepth - vfGlassLinearDepth) * glassMaterial, 0.0, 1.0); 23 | gl_FragColor = vec4(vv4GlassColor.rgb, fator); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /ParticleRenderingSample/Supportingfiles/Molecule_system.frag: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | varying float v_ageFactor; 4 | varying vec3 v_v3colour; 5 | uniform sampler2D s_texture; 6 | 7 | void main() 8 | { 9 | vec4 texColour; 10 | vec2 texCoords; 11 | float alphaFactor; 12 | 13 | texCoords = vec2(gl_PointCoord.x, gl_PointCoord.y); 14 | 15 | /* Define an alpha modulation factor depending of the particle's age. */ 16 | if(v_ageFactor <= 0.5) 17 | { 18 | alphaFactor = 0.14 * v_ageFactor; 19 | } 20 | else 21 | { 22 | alphaFactor = -0.14 * v_ageFactor + 0.14; 23 | } 24 | 25 | vec4 baseColour = vec4(v_v3colour.x, v_v3colour.y, v_v3colour.z, 1.0); 26 | texColour = texture2D(s_texture, texCoords); 27 | 28 | /* Modulate alpha component. */ 29 | texColour.a = texColour.r * alphaFactor; 30 | 31 | gl_FragColor = vec4(texColour.r, texColour.r, texColour.r, texColour.a) * baseColour; 32 | } 33 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | all: 2 | (cd YUV2RGBSample; make all) 3 | (cd WaveformSample; make all) 4 | (cd FrameBufferObject-FBOSample; make all) 5 | (cd TriangleSample; make all) 6 | (cd Alpha_DepthSample; make all) 7 | (cd TextureMipMapSample; make all) 8 | (cd ParticleRenderingSample; make all) 9 | (cd MultiCubeSample; make all) 10 | (cd EGLRenderingSample; make all) 11 | (cd EGLTextureVideoSample; make all) 12 | 13 | install: 14 | (cd YUV2RGBSample; make install) 15 | (cd WaveformSample; make install) 16 | (cd FrameBufferObject-FBOSample; make install) 17 | (cd TriangleSample; make install) 18 | (cd Alpha_DepthSample; make install) 19 | (cd TextureMipMapSample; make install) 20 | (cd ParticleRenderingSample; make install) 21 | (cd MultiCubeSample; make install) 22 | (cd EGLRenderingSample; make install) 23 | (cd EGLTextureVideoSample; make install) 24 | 25 | clean: 26 | (cd YUV2RGBSample; make clean) 27 | (cd FrameBufferObject-FBOSample; make clean) 28 | (cd TriangleSample; make clean) 29 | (cd Alpha_DepthSample; make clean) 30 | (cd TextureMipMapSample; make clean) 31 | (cd ParticleRenderingSample; make clean) 32 | (cd MultiCubeSample; make clean) 33 | (cd EGLRenderingSample; make clean) 34 | (cd EGLTextureVideoSample; make clean) 35 | (cd WaveformSample; make clean) 36 | -------------------------------------------------------------------------------- /EGLRenderingSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.c") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: EGLImageSample $(srcfiles) 13 | 14 | EGLImageSample $(objects) : EGLImageSample.c $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH_C) EGLImageSample.c $(CXXFLAGS) $(LD_FLAGS) -o EGLImageSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf EGLImageSample bin 17 | 18 | # The dependency file names. 19 | DEPS := $(objects:.o=.d) 20 | 21 | 22 | bin=bin_FBDEV 23 | 24 | install: EGLImageSample 25 | mkdir -p $(TOP_DIR)/../bin/$(bin)/EGLImageSample 26 | cp -rf EGLImageSample $(TOP_DIR)/../bin/$(bin)/EGLImageSample 27 | 28 | 29 | depend: .depend 30 | 31 | .depend: $(srcfiles) 32 | rm -f ./.depend 33 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 34 | 35 | clean: 36 | rm -f $(objects) 37 | -rm -rf bin 38 | -rm -rf EGLImageSample 39 | 40 | 41 | dist-clean: clean 42 | rm -f *~ .depend 43 | 44 | 45 | include .depend 46 | -------------------------------------------------------------------------------- /EGLTextureVideoSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.c") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: EGLImageVideoSample $(srcfiles) 13 | 14 | EGLImageVideoSample $(objects) : EGLImageVideoSample.c $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH_C) EGLImageVideoSample.c $(CXXFLAGS) $(LD_FLAGS) -o EGLImageVideoSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf EGLImageVideoSample bin 17 | 18 | # The dependency file names. 19 | DEPS := $(objects:.o=.d) 20 | 21 | 22 | bin=bin_FBDEV 23 | 24 | install: EGLImageVideoSample 25 | mkdir -p $(TOP_DIR)/../bin/$(bin)/EGLImageVideoSample 26 | cp -rf EGLImageVideoSample $(TOP_DIR)/../bin/$(bin)/EGLImageVideoSample 27 | 28 | 29 | depend: .depend 30 | 31 | .depend: $(srcfiles) 32 | rm -f ./.depend 33 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 34 | 35 | clean: 36 | rm -f $(objects) 37 | -rm -rf EGLImageVideoSample 38 | -rm -rf bin 39 | 40 | dist-clean: clean 41 | rm -f *~ .depend 42 | 43 | 44 | include .depend 45 | -------------------------------------------------------------------------------- /WaveformSample/Supportingfiles/WaverenderSample.frag: -------------------------------------------------------------------------------- 1 | precision lowp float; 2 | uniform float iGlobalTime; 3 | vec2 iResolution = vec2(160,160); 4 | vec2 iResolutionX = vec2(250,250); 5 | vec2 iResolutionY = vec2(350,350); 6 | vec4 fragColor; 7 | 8 | 9 | float plot(vec2 st, float pct){ 10 | return abs(smoothstep( pct-0.005, pct, st.y) - smoothstep( pct, pct+0.005, st.y)); 11 | } 12 | 13 | float ecg(float x) 14 | { 15 | 16 | x = x - ceil(x/2.8 - 0.5)*2.8; 17 | 18 | return 0.2*(exp((-pow(x + 1.4, 2.)) / (2.*0.02)) + exp((-pow(x - 1.4,2.)) / (2.*0.02))) + (1. - abs(x / 0.1) - x)*exp((-pow(7.*x,2.)) / 2.); 19 | } 20 | 21 | 22 | void main() 23 | { 24 | vec2 uv = gl_FragCoord.xy / iResolution.xy; 25 | vec2 uv2 = gl_FragCoord.xy / iResolutionX.xy; 26 | vec2 uv3 = gl_FragCoord.xy / iResolutionY.xy; 27 | uv2.y -= 0.4; 28 | uv3.y -= 0.6; 29 | gl_FragColor = vec4(0., step( 0.245,mod(uv.x, 1./4.)) , 0., 1.); 30 | gl_FragColor += vec4(0., step( 0.245,mod(uv.y, 1./4.)) , 0., 1.); 31 | gl_FragColor += plot(uv, ecg(uv.x*2. + (iGlobalTime) / 3.5)/2. + 0.5) * vec4(10.,10.,0., 1.); 32 | gl_FragColor += plot(uv2, ecg(uv2.x*2. + (iGlobalTime) / 3.5)/2. + 0.5) * vec4(10.,0.,0., 1.); 33 | gl_FragColor += plot(uv3, ecg(uv3.x*2. + (iGlobalTime) / 3.5)/2. + 0.5) * vec4(10.,0.,10., 1.); 34 | } 35 | -------------------------------------------------------------------------------- /ParticleRenderingSample/Supportingfiles/Molecule_system.vert: -------------------------------------------------------------------------------- 1 | attribute vec3 a_v3Position; 2 | attribute vec3 a_v3Velocity; 3 | attribute vec3 a_v3ParticleTimes; 4 | uniform mat4 mvp; 5 | uniform vec3 u_v3gravity; 6 | uniform vec3 u_v3colour; 7 | 8 | varying float v_ageFactor; 9 | varying vec3 v_v3colour; 10 | 11 | void main() 12 | { 13 | vec3 newPos; 14 | float ageFactor; 15 | float delay = a_v3ParticleTimes.x; 16 | float lifetime = a_v3ParticleTimes.y; 17 | float age = a_v3ParticleTimes.z; 18 | 19 | if( age > delay ) 20 | { 21 | float t = age - delay; 22 | /* Particle motion equation. */ 23 | newPos = a_v3Position + a_v3Velocity * t + 0.5 * u_v3gravity * t * t; 24 | 25 | ageFactor = 1.0 - (age / lifetime); 26 | ageFactor = clamp(ageFactor, 0.0, 1.0); 27 | 28 | /* The older the particle the smaller its size. */ 29 | gl_PointSize = ageFactor * 250.0; 30 | } 31 | else 32 | { 33 | newPos = a_v3Position; 34 | /* If null size particle will not be drawn. */ 35 | gl_PointSize = 0.0; 36 | ageFactor = 0.0; 37 | } 38 | 39 | /* Initializing varying. */ 40 | v_ageFactor = ageFactor; 41 | v_v3colour = u_v3colour; 42 | 43 | /* Particle position. */ 44 | gl_Position.xyz = newPos; 45 | gl_Position.w = 1.0; 46 | 47 | /* Apply matrix transformation. */ 48 | gl_Position = mvp * gl_Position; 49 | } 50 | -------------------------------------------------------------------------------- /MultiCubeSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: MultiCubeSample $(srcfiles) 13 | 14 | MultiCubeSample $(objects) : CubeSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) CubeSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o MultiCubeSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf MultiCubeSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | bin= 23 | bin_FBDEV=bin_FBDEV 24 | bin_X11=bin_X11 25 | 26 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 27 | bin=$(bin_FBDEV) 28 | else 29 | bin=$(bin_X11) 30 | endif 31 | 32 | install: MultiCubeSample 33 | mkdir -p $(TOP_DIR)/../bin/$(bin)/MultiCubeSample 34 | cp -rf MultiCubeSample $(TOP_DIR)/../bin/$(bin)/MultiCubeSample 35 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/MultiCubeSample 36 | 37 | 38 | depend: .depend 39 | 40 | .depend: $(srcfiles) 41 | rm -f ./.depend 42 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 43 | 44 | clean: 45 | rm -f $(objects) 46 | -rm -rf bin 47 | -rm -rf MultiCubeSample 48 | 49 | dist-clean: clean 50 | rm -f *~ .depend 51 | 52 | 53 | include .depend 54 | 55 | -------------------------------------------------------------------------------- /TextureMipMapSample/Supportingfiles/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../SDK 8 | 9 | srcfiles := $(shell find ../SDK -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: MipMapSample $(srfiles) 13 | 14 | MipMapSample $(objects) : MipMapSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) MipMapSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o MipMapSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf MipMapSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: MipMapSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/MipMapSample 36 | cp -rf MipMapSample $(TOP_DIR)/../bin/$(bin)/MipMapSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/MipMapSample 38 | 39 | 40 | 41 | depend: .depend 42 | 43 | .depend: $(srcfiles) 44 | rm -f ./.depend 45 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 46 | 47 | clean: 48 | rm -f $(objects) 49 | -rm -rf bin 50 | -rm -rf MipMapSample 51 | 52 | 53 | dist-clean: clean 54 | rm -f *~ .depend 55 | 56 | 57 | include .depend 58 | 59 | -------------------------------------------------------------------------------- /TriangleSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: TriangleSample $(srcfiles) 13 | 14 | TriangleSample $(objects) : TriangleSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) TriangleSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o TriangleSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf TriangleSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: TriangleSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/TriangleSample 36 | cp -rf TriangleSample $(TOP_DIR)/../bin/$(bin)/TriangleSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/TriangleSample 38 | 39 | 40 | depend: .depend 41 | 42 | .depend: $(srcfiles) 43 | rm -f ./.depend 44 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 45 | 46 | clean: 47 | rm -f $(objects) 48 | -rm -rf bin 49 | -rm -rf TriangleSample 50 | 51 | 52 | dist-clean: clean 53 | rm -f *~ .depend 54 | 55 | 56 | include .depend 57 | -------------------------------------------------------------------------------- /YUV2RGBSample/Makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: YUV2RGBSample $(srcfiles) 13 | 14 | YUV2RGBSample $(objects) : YUV2RGBonGPUSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) YUV2RGBonGPUSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o YUV2RGBSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf YUV2RGBSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | bin= 23 | bin_FBDEV=bin_FBDEV 24 | bin_X11=bin_X11 25 | 26 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 27 | bin=$(bin_FBDEV) 28 | else 29 | bin=$(bin_X11) 30 | endif 31 | 32 | 33 | install: YUV2RGBSample 34 | mkdir -p $(TOP_DIR)/../bin/$(bin)/YUV2RGBSample 35 | cp -rf YUV2RGBSample $(TOP_DIR)/../bin/$(bin)/YUV2RGBSample 36 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/YUV2RGBSample 37 | 38 | 39 | depend: .depend 40 | 41 | .depend: $(srcfiles) 42 | rm -f ./.depend 43 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 44 | 45 | clean: 46 | rm -f $(objects) 47 | -rm -rf bin 48 | -rm -rf YUV2RGBSample 49 | 50 | 51 | dist-clean: clean 52 | rm -f *~ .depend 53 | 54 | 55 | include .depend 56 | 57 | -------------------------------------------------------------------------------- /WaveformSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: WaveformSample $(srcfiles) 13 | 14 | WaveformSample $(objects) : WaverenderSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) WaverenderSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o WaveformSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf WaveformSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: WaveformSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/WaveformSample 36 | cp -rf WaveformSample $(TOP_DIR)/../bin/$(bin)/WaveformSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/WaveformSample 38 | 39 | 40 | 41 | depend: .depend 42 | 43 | .depend: $(srcfiles) 44 | rm -f ./.depend 45 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 46 | 47 | clean: 48 | rm -f $(objects) 49 | -rm -rf bin 50 | -rm -rf WaveformSample 51 | 52 | 53 | dist-clean: clean 54 | rm -f *~ .depend 55 | 56 | 57 | include .depend 58 | 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2023, AMD 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Alpha_DepthSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: Alpha_DepthSample $(srcfiles) 13 | 14 | Alpha_DepthSample $(objects) : DepthSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) DepthSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o Alpha_DepthSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf Alpha_DepthSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: Alpha_DepthSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/Alpha_DepthSample 36 | cp -rf Alpha_DepthSample $(TOP_DIR)/../bin/$(bin)/Alpha_DepthSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/Alpha_DepthSample 38 | 39 | 40 | depend: .depend 41 | 42 | .depend: $(srcfiles) 43 | rm -f ./.depend 44 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 45 | 46 | clean: 47 | rm -f $(objects) 48 | -rm -rf bin 49 | -rm -rf Alpha_DepthSample 50 | 51 | 52 | dist-clean: clean 53 | rm -f *~ .depend 54 | 55 | 56 | include .depend 57 | 58 | -------------------------------------------------------------------------------- /TextureMipMapSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: TextureMipMapSample $(srcfiles) 13 | 14 | TextureMipMapSample $(objects) : MipMapSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) MipMapSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o TextureMipMapSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf TextureMipMapSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: TextureMipMapSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/TextureMipMapSample 36 | cp -rf TextureMipMapSample $(TOP_DIR)/../bin/$(bin)/TextureMipMapSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/TextureMipMapSample 38 | 39 | 40 | 41 | depend: .depend 42 | 43 | .depend: $(srcfiles) 44 | rm -f ./.depend 45 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 46 | 47 | clean: 48 | rm -f $(objects) 49 | -rm -rf bin 50 | -rm -rf TextureMipMapSample 51 | 52 | 53 | dist-clean: clean 54 | rm -f *~ .depend 55 | 56 | 57 | include .depend 58 | 59 | -------------------------------------------------------------------------------- /ParticleRenderingSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: ParticleRenderingSample $(srcfiles) 13 | 14 | ParticleRenderingSample $(objects) : MoleculeSystemSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) MoleculeSystemSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o ParticleRenderingSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf ParticleRenderingSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: ParticleRenderingSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/ParticleRenderingSample 36 | cp -rf ParticleRenderingSample $(TOP_DIR)/../bin/$(bin)/ParticleRenderingSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/ParticleRenderingSample 38 | 39 | 40 | depend: .depend 41 | 42 | .depend: $(srcfiles) 43 | rm -f ./.depend 44 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 45 | 46 | clean: 47 | rm -f $(objects) 48 | -rm -rf bin 49 | -rm -rf ParticleRenderingSample 50 | 51 | 52 | dist-clean: clean 53 | rm -f *~ .depend 54 | 55 | 56 | include .depend 57 | 58 | -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR =$(shell pwd) 2 | export ARCH = arm64 3 | export OUTPUT_DIR =$(TOP_DIR)/../bin 4 | LD_FLAGS= -lm -lpthread -ldl -lX11 -lxcb -lXau -lXdmcp -ldrm -lXfixes -lXext -lXdamage -lexpat -lglapi -lX11-xcb -lxcb-glx -lxcb-dri2 -lEGL -lGLESv2 5 | LIB=-L$(MALI_LIBS) 6 | INC=-I$(MALI_INCLUDE) 7 | PROJ_INCLUDES=-I../Coreframework 8 | 9 | srcfiles := $(shell find ../Coreframework -maxdepth 1 -name "*.cpp") 10 | objects := $(patsubst %.cpp, %.o, $(srcfiles)) 11 | 12 | all: FrameBufferObject-FBOSample $(srcfiles) 13 | 14 | FrameBufferObject-FBOSample $(objects) : FBOSample.cpp $(srcfiles) 15 | $(ARM_CROSS_COMPILER_PATH) FBOSample.cpp $(srcfiles) $(CXXFLAGS) $(LD_FLAGS) -o FrameBufferObject-FBOSample $(INC) $(PROJ_INCLUDES) $(LIB) 16 | cp -rf Supportingfiles bin 17 | cp -rf FrameBufferObject-FBOSample bin 18 | 19 | # The dependency file names. 20 | DEPS := $(objects:.o=.d) 21 | 22 | 23 | bin= 24 | bin_FBDEV=bin_FBDEV 25 | bin_X11=bin_X11 26 | 27 | ifeq ($(CXXFLAGS),-DENABLE_FBDEV) 28 | bin=$(bin_FBDEV) 29 | else 30 | bin=$(bin_X11) 31 | endif 32 | 33 | 34 | install: FrameBufferObject-FBOSample 35 | mkdir -p $(TOP_DIR)/../bin/$(bin)/FrameBufferObject-FBOSample 36 | cp -rf FrameBufferObject-FBOSample $(TOP_DIR)/../bin/$(bin)/FrameBufferObject-FBOSample 37 | cp -rf Supportingfiles $(TOP_DIR)/../bin/$(bin)/FrameBufferObject-FBOSample 38 | 39 | 40 | depend: .depend 41 | 42 | .depend: $(srcfiles) 43 | rm -f ./.depend 44 | $(CXX) $(CXXFLAGS) -MM $^>>./.depend; 45 | 46 | clean: 47 | rm -f $(objects) 48 | -rm -rf bin 49 | -rm -rf FrameBufferObject-FBOSample 50 | 51 | 52 | dist-clean: clean 53 | rm -f *~ .depend 54 | 55 | 56 | include .depend 57 | 58 | -------------------------------------------------------------------------------- /Coreframework/Xfbdev_window.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file Xfbdev_window.h 36 | * 37 | * This file implements all the functions related to podium baseclass. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #ifndef _FBDEV_WINDOW_H_ 54 | #define _FBDEV_WINDOW_H_ 55 | 56 | #ifdef __cplusplus 57 | extern "C" { 58 | #endif 59 | 60 | typedef struct fbdev_window 61 | { 62 | unsigned short width; 63 | unsigned short height; 64 | } fbdev_window; 65 | 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /Coreframework/XPodium.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XPodium.cpp 36 | * 37 | * This file implements all the functions related to podium baseclass. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include "XPodium.h" 54 | 55 | #include 56 | #include 57 | 58 | XPodium* XPodium::getHandler() 59 | { 60 | #ifdef ENABLE_FBDEV 61 | return XLinuxMali::getHandler(); 62 | #endif 63 | 64 | #ifdef ENABLE_X11 65 | return XLinuxPodium::getHandler(); 66 | #endif 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /Coreframework/XGLSLCompile.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XGLSLCompile.h 36 | * 37 | * This file implements all the functions related to GLSL compilation. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #ifndef XGLSLCOMPILE_H 54 | #define XGLSLCOMPILE_H 55 | 56 | #include 57 | 58 | class Shader 59 | { 60 | private: 61 | static char *loadShader(const char *filename); 62 | public: 63 | static void processShader(GLuint *shader, const char *filename, GLint shaderType); 64 | }; 65 | #endif /* XGLSLCOMPILE_H */ 66 | -------------------------------------------------------------------------------- /YUV2RGBSample/YUV2RGBonGPUSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file yuv2rgbonGPU.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #define GLES_VERSION 2 54 | 55 | #include 56 | 57 | static const GLfloat vertexVertices[] = { 58 | 59 | -1.0f, -1.0f, 60 | 61 | 1.0f, -1.0f, 62 | 63 | -1.0f, 1.0f, 64 | 65 | 1.0f, 1.0f, 66 | 67 | }; 68 | 69 | static const GLfloat textureVertices[] = { 70 | 71 | 0.0f, 1.0f, 72 | 73 | 1.0f, 1.0f, 74 | 75 | 0.0f, 0.0f, 76 | 77 | 1.0f, 0.0f, 78 | 79 | }; 80 | 81 | 82 | -------------------------------------------------------------------------------- /ParticleRenderingSample/MoleculeSystemSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file MultiParticle.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #define GLES_VERSION 2 54 | 55 | #include 56 | 57 | 58 | /* Simple triangle. */ 59 | const float triangleVertices[] = 60 | { 61 | 0.0f, 0.5f, 0.0f, 62 | -0.5f, -0.5f, 0.0f, 63 | 0.5f, -0.5f, 0.0f, 64 | }; 65 | 66 | /* Per corner colors for the triangle (Red, Green, Green). */ 67 | const float triangleColors[] = 68 | { 69 | 1.0, 1.0, 0.0, 1.0, 70 | 0.0, 1.0, 1.0, 1.0, 71 | 1.0, 0.0, 1.0, 1.0, 72 | }; 73 | 74 | -------------------------------------------------------------------------------- /Coreframework/XLinuxTarget.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XLinuxTarget.h 36 | * 37 | * This file implements all the functions related to Linux XPodium class for application. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | 54 | #ifndef XLINUXTARGET_H 55 | #define XLINUXTARGET_H 56 | 57 | #include 58 | #include "XPodium.h" 59 | #include "Xfbdev_window.h" 60 | 61 | class XLinuxMali : public XPodium 62 | { 63 | private: 64 | static XPodium* instance; 65 | XLinuxMali(void); 66 | public: 67 | static XPodium* getHandler(void); 68 | virtual void prepareWindow(int width, int height); 69 | virtual void destroyWindow(void); 70 | virtual WindowStatus checkWindow(void); 71 | }; 72 | #endif /* XLINUXTARGET_H */ 73 | 74 | -------------------------------------------------------------------------------- /Matrix_Multiplication/README.md: -------------------------------------------------------------------------------- 1 | # GPU-Based Matrix Multiplication with OpenGL ES 2.0 2 | 3 | This implementation demonstrates how to leverage the shader's parallel processing capabilities to perform efficient matrix multiplication using OpenGL ES 2.0 vertex shaders. 4 | 5 | ## How It Works 6 | 7 | The implementation divides the computation between the CPU and GPU, with the heavy computational work offloaded to the GPU: 8 | 9 | ### Execution Flow 10 | 11 | ``` 12 | CPU Side | GPU Side (Vertex Shader) 13 | ------------------------------------------|------------------------------------------ 14 | Generate random matrices A & B | For each output element C[i][j]: 15 | | | | 16 | v | v 17 | Upload matrices as textures | Receive indices (j,i) as vertex attribute 18 | | | | 19 | v | v 20 | Create vertex array with (j,i) pairs | For k=0 to MATRIX_SIZE-1: 21 | (one vertex per output element) | | 22 | | | v 23 | v | Sample A[i][k] from textureA 24 | Set up OpenGL/EGL context | | 25 | | | v 26 | v | Sample B[k][j] from textureB 27 | Compile shaders | | 28 | | | v 29 | v | Accumulate: sum += A[i][k] * B[k][j] 30 | Pass matrices as textures | | 31 | | | v 32 | v | Normalize result (sum/MATRIX_SIZE) 33 | Draw points (one per matrix element) | | 34 | | | v 35 | v | Round to two decimal places 36 | Read back results from framebuffer | | 37 | | v 38 | | Set vertex position for rendering 39 | | | 40 | | v 41 | | Pass result to fragment shader 42 | | | 43 | | v 44 | | Fragment shader outputs result as color 45 | ``` 46 | 47 | 48 | - **Parallel Computation**: Each element of the output matrix is calculated simultaneously by a separate vertex shader invocation 49 | - **Texture-Based Storage**: Input matrices are stored as textures for efficient GPU access 50 | - **Vertex as Computation Unit**: Repurposes the vertex shader's parallel nature for general computation 51 | 52 | 53 | ## Requirements 54 | 55 | - OpenGL ES 2.0 compatible GPU 56 | - EGL and X11 support 57 | - C++ compiler with C++11 support 58 | -------------------------------------------------------------------------------- /Coreframework/XTime.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx Inc, All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file Xtime.h 36 | * 37 | * This file implements timer related API for SDK 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | 54 | #ifndef TIMER_H 55 | #define TIMER_H 56 | 57 | #include 58 | 59 | #if defined(_WIN32) 60 | #else 61 | #include 62 | #endif 63 | 64 | namespace SDKXilinx 65 | { 66 | 67 | class Timer 68 | { 69 | private: 70 | int frameCount; 71 | float fps; 72 | float lastTime; 73 | timeval startTime; 74 | timeval currentTime; 75 | float lastIntervalTime; 76 | float fpsTime; 77 | public: 78 | Timer(); 79 | void reset(); 80 | float getTime(); 81 | float getInterval(); 82 | float getFPS(); 83 | bool isTimePassed(float seconds = 1.0f); 84 | }; 85 | #endif /* TIMER_H */ 86 | } 87 | -------------------------------------------------------------------------------- /TriangleSample/TriangleSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file BasicTriangle.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #define GLES_VERSION 2 54 | 55 | #include 56 | #include 57 | 58 | using namespace std; 59 | 60 | #define SCENE_WIDTH 800 61 | #define SCENE_HEIGHT 600 62 | 63 | string resourceDirectory = "Supportingfiles/"; 64 | string vertexShaderFilename = "TriangleSample.vert"; 65 | string fragmentShaderFilename = "TriangleSample.frag"; 66 | 67 | GLuint programID; 68 | GLint iLocPosition = -1; 69 | GLint iLocFillColor = -1; 70 | GLint iLocMVP = -1; 71 | 72 | const float triangleVertices[] = 73 | { 74 | 0.0f, 0.5f, 0.0f, 75 | -0.5f, -0.5f, 0.0f, 76 | 0.5f, -0.5f, 0.0f, 77 | }; 78 | 79 | const float triangleColors[] = 80 | { 81 | 1.0, 1.0, 0.0, 1.0, 82 | 0.0, 1.0, 1.0, 1.0, 83 | 1.0, 0.0, 1.0, 1.0, 84 | }; 85 | 86 | -------------------------------------------------------------------------------- /Coreframework/XPodium.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XPodium.h 36 | * 37 | * This file implements all the functions related to podium baseclass. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #ifndef XPodium_H 54 | #define XPodium_H 55 | 56 | #include "XEGLIntf.h" 57 | #include "XCVector.h" 58 | #include 59 | #include "Xfbdev_window.h" 60 | 61 | class XPodium 62 | { 63 | public: 64 | enum WindowStatus { 65 | WINDOW_IDLE, 66 | WINDOW_EXIT, 67 | WINDOW_CLICK}; 68 | CVec2 mouseClick; 69 | fbdev_window *Fwindow; 70 | Window window; 71 | Display* display; 72 | virtual void prepareWindow(int width, int height) = 0; 73 | virtual WindowStatus checkWindow(void) = 0; 74 | virtual void destroyWindow(void) = 0; 75 | static void log(const char* format, ...); 76 | static XPodium* getHandler(); 77 | }; 78 | 79 | #ifdef ENABLE_FBDEV 80 | #include "XLinuxTarget.h" 81 | #endif 82 | 83 | #ifdef ENABLE_X11 84 | #include "XLinuxPodium.h" 85 | #endif 86 | 87 | 88 | #endif /* XPodium_H */ 89 | -------------------------------------------------------------------------------- /Coreframework/XEGLIntf.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XEGLIntf.h 36 | * 37 | * This file implements all the functions related to EGL bindings. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | #ifndef XEGLINTF_H 53 | #define XEGLINTF_H 54 | 55 | #include 56 | #include 57 | 58 | class CoreEGL 59 | { 60 | private: 61 | static EGLConfig findConfig(bool strictMatch); 62 | static EGLint configAttributes []; 63 | static EGLint contextAttributes []; 64 | static EGLint windowAttributes []; 65 | 66 | public: 67 | static void setEGLSamples(EGLint requiredEGLSamples); 68 | enum OpenGLESVersion {OPENGLES1, OPENGLES2, OPENGLES3, OPENGLES31}; 69 | static EGLDisplay display; 70 | static EGLContext context; 71 | static EGLConfig config; 72 | static EGLSurface surface; 73 | static void initializeEGL(OpenGLESVersion requestedAPIVersion); 74 | static void terminateEGL(void); 75 | }; 76 | 77 | #endif /* XEGLINTF_H */ 78 | -------------------------------------------------------------------------------- /Coreframework/XLinuxPodium.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XLinuxPodium.h 36 | * 37 | * This file implements all the functions related to Linux X11 windowing system API's for application. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | 54 | #ifndef XLINUXPODIUM_H 55 | #define XLINUXPODIUM_H 56 | 57 | #include 58 | #include 59 | 60 | #include "XPodium.h" 61 | 62 | class XLinuxPodium : public XPodium 63 | { 64 | private: 65 | 66 | int windowWidth; 67 | int windowHeight; 68 | Colormap colormap; 69 | XVisualInfo *visual; 70 | static XPodium* instance; 71 | XLinuxPodium(void); 72 | static Bool wait_for_map(Display *display, XEvent *event, char *windowPointer); 73 | public: 74 | static XPodium* getHandler(void); 75 | virtual void prepareWindow(int width, int height); 76 | virtual void destroyWindow(void); 77 | virtual WindowStatus checkWindow(void); 78 | bool createX11Window(void); 79 | }; 80 | #endif /* XLINUXPODIUM_H */ 81 | -------------------------------------------------------------------------------- /Coreframework/XCompressionTexture.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XCompressionTexture.h 36 | * 37 | * This file implements all the functions related to texture compression ETC. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | 54 | #ifndef XCOMPRESSIONTEXTURE_H 55 | #define XCOMPRESSIONTEXTURE_H 56 | 57 | #include 58 | 59 | class ETCHeaderforTexture 60 | { 61 | private: 62 | unsigned char paddedWidthMSB; 63 | unsigned char paddedWidthLSB; 64 | unsigned char paddedHeightMSB; 65 | unsigned char paddedHeightLSB; 66 | unsigned char widthMSB; 67 | unsigned char widthLSB; 68 | unsigned char heightMSB; 69 | unsigned char heightLSB; 70 | public: 71 | ETCHeaderforTexture(); 72 | ETCHeaderforTexture(unsigned char *data); 73 | unsigned short getWidth(void); 74 | unsigned short getHeight(void); 75 | unsigned short getPaddedWidth(void); 76 | unsigned short getPaddedHeight(void); 77 | GLsizei getSize(GLenum internalFormat); 78 | }; 79 | #endif /* XCOMPRESSIONTEXTURE_H */ 80 | -------------------------------------------------------------------------------- /Coreframework/XMathematics.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XMathOperations.h 36 | * 37 | * This file implements all the functions related to math operations. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who  		Date     	Changes
45 |  * ----- ---- 		-------- 	-----------------------------------------------
46 |  * 1.0   Alok G  	10/06/17 	Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | 54 | #ifndef XMATHOPERATIONS_H 55 | #define XMATHOPERATIONS_H 56 | #include "XCVector.h" 57 | #include 58 | #include 59 | 60 | #ifndef M_PI 61 | #define M_PI 3.14159265358979323846f 62 | #endif 63 | 64 | inline float distanceBetweenPoints(const CVec2f& point1, const CVec2f& point2) 65 | { 66 | return sqrtf((point2.x - point1.x) * (point2.x - point1.x) + (point2.y - point1.y) * (point2.y - point1.y)); 67 | } 68 | 69 | 70 | inline float degreesToRadians(float degrees) 71 | { 72 | return M_PI * degrees / 180.0f; 73 | } 74 | 75 | inline float signum(float f) 76 | { 77 | if (f > 0.0f) 78 | { 79 | return 1.0f; 80 | } 81 | 82 | if (f < 0.0f) 83 | { 84 | return -1.0f; 85 | } 86 | 87 | return 0.0f; 88 | } 89 | 90 | inline float uniformRandomNumber() 91 | { 92 | return rand() / float(RAND_MAX); 93 | } 94 | #endif /* MATHOPERATIONS_H */ 95 | -------------------------------------------------------------------------------- /Coreframework/XLinuxTarget.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XLinuxMali.cpp 36 | * 37 | * This file implements all the functions related to Linux XPodium class for application. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | 54 | #include 55 | #include 56 | #include 57 | 58 | #include "XLinuxTarget.h" 59 | 60 | XPodium* XLinuxMali::instance = NULL; 61 | 62 | XLinuxMali::XLinuxMali(void) 63 | { 64 | 65 | } 66 | 67 | XPodium* XLinuxMali::getHandler(void) 68 | { 69 | if (instance == NULL) 70 | { 71 | instance = new XLinuxMali(); 72 | } 73 | return instance; 74 | } 75 | 76 | void XLinuxMali::prepareWindow(int width, int height) 77 | { 78 | Fwindow = (fbdev_window *)calloc(1, sizeof(fbdev_window)); 79 | if(Fwindow == NULL) 80 | { 81 | printf("Out of memory at %s:%i\n", __FILE__, __LINE__); 82 | exit(1); 83 | } 84 | Fwindow->width = width; 85 | Fwindow->height = height; 86 | } 87 | 88 | void XLinuxMali::destroyWindow(void) 89 | { 90 | free(Fwindow); 91 | } 92 | 93 | XPodium::WindowStatus XLinuxMali::checkWindow(void) 94 | { 95 | return XPodium::WINDOW_IDLE; 96 | } 97 | -------------------------------------------------------------------------------- /Coreframework/XTexture.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XTexture.h 36 | * 37 | * This file implements all the functions related to texture compression techniques. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | 54 | #ifndef XTEXTURE_H 55 | #define XTEXTURE_H 56 | 57 | #include "XCompressionTexture.h" 58 | 59 | #include 60 | 61 | class XTexture 62 | { 63 | private: 64 | static void XgetCompressedTextureFormats(GLint **textureFormats, int* numberOfTextureFormats); 65 | public: 66 | static bool XisETCSupported(bool verbose = false); 67 | static void XcreateTexture(unsigned int width, unsigned int height, GLvoid **textureData); 68 | static void XcreateTexture(unsigned int width, unsigned int height, unsigned int red, GLvoid **textureData); 69 | static void XcreateTexture(unsigned int width, unsigned int height, short red, short **textureData); 70 | static void XdeleteTextureData(GLvoid **textureData); 71 | static void XloadData(const char *filename, unsigned char **textureData); 72 | static void XloadPKMData(const char *filename, ETCHeaderforTexture* etcHeader, unsigned char **textureData); 73 | static void XloadCompressedMipmaps(const char *filenameBase, const char *filenameSuffix, GLuint *textureID); 74 | static void XreversePixelLine(float* destination, const float* source, int lineWidth); 75 | }; 76 | #endif /* TEXTURE_H */ 77 | -------------------------------------------------------------------------------- /Coreframework/XCompressionTexture.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XCompressionTexture.cpp 36 | * 37 | * This file implements all the functions related to texture compression ETC. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include "XCompressionTexture.h" 54 | 55 | 56 | unsigned short ETCHeaderforTexture::getWidth(void) 57 | { 58 | return (widthMSB << 8) | widthLSB; 59 | } 60 | 61 | unsigned short ETCHeaderforTexture::getHeight(void) 62 | { 63 | return (heightMSB << 8) | heightLSB; 64 | } 65 | 66 | unsigned short ETCHeaderforTexture::getPaddedWidth(void) 67 | { 68 | return (paddedWidthMSB << 8) | paddedWidthLSB; 69 | } 70 | 71 | unsigned short ETCHeaderforTexture::getPaddedHeight(void) 72 | { 73 | return (paddedHeightMSB << 8) | paddedHeightLSB; 74 | } 75 | 76 | GLsizei ETCHeaderforTexture::getSize(GLenum internalFormat) 77 | { 78 | return (getPaddedWidth() * getPaddedHeight()); 79 | } 80 | 81 | 82 | ETCHeaderforTexture::ETCHeaderforTexture() 83 | { 84 | 85 | } 86 | 87 | ETCHeaderforTexture::ETCHeaderforTexture(unsigned char *data) 88 | { 89 | 90 | paddedWidthMSB = data[8]; 91 | paddedWidthLSB = data[9]; 92 | paddedHeightMSB = data[10]; 93 | paddedHeightLSB = data[11]; 94 | widthMSB = data[12]; 95 | widthLSB = data[13]; 96 | heightMSB = data[14]; 97 | heightLSB = data[15]; 98 | } 99 | -------------------------------------------------------------------------------- /Coreframework/XCVector.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file Xvector.h 36 | * 37 | * This file implements all basic Vector types 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #ifndef XVECTOR_H 54 | #define XVECTOR_H 55 | 56 | #include 57 | 58 | 59 | class CVec2 60 | { 61 | public: 62 | int x, y; 63 | }; 64 | 65 | 66 | class CVec3 67 | { 68 | public: 69 | int x, y, z; 70 | }; 71 | 72 | class CVec4 73 | { 74 | public: 75 | int x, y, z, w; 76 | }; 77 | 78 | class CVec2f 79 | { 80 | public: 81 | float x, y; 82 | }; 83 | 84 | class CVec3f 85 | { 86 | public: 87 | float x, y, z; 88 | 89 | void normalize(void) 90 | { 91 | float length = sqrt(x * x + y * y + z * z); 92 | 93 | x /= length; 94 | y /= length; 95 | z /= length; 96 | } 97 | 98 | static CVec3f cross(const CVec3f& vector1, const CVec3f& vector2) 99 | { 100 | CVec3f crossProduct; 101 | 102 | crossProduct.x = (vector1.y * vector2.z) - (vector1.z * vector2.y); 103 | crossProduct.y = (vector1.z * vector2.x) - (vector1.x * vector2.z); 104 | crossProduct.z = (vector1.x * vector2.y) - (vector1.y * vector2.x); 105 | 106 | return crossProduct; 107 | } 108 | 109 | 110 | static float dot(CVec3f& vector1, CVec3f& vector2) 111 | { 112 | return (vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z); 113 | } 114 | }; 115 | 116 | 117 | class CVec4f 118 | { 119 | public: 120 | float x, y, z, w; 121 | 122 | void normalize(void) 123 | { 124 | float length = sqrt(x * x + y * y + z * z + w * w); 125 | 126 | x /= length; 127 | y /= length; 128 | z /= length; 129 | w /= length; 130 | } 131 | }; 132 | #endif /* XVECTOR_H */ 133 | 134 | -------------------------------------------------------------------------------- /Coreframework/XMatrixAPI.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XMatrixAPI.h 36 | * 37 | * This file implements all the functions related to Matrix calculations for application. 38 | * 39 | * @note None. 40 | * 41 | *
42 |  * MODIFICATION HISTORY:
43 |  *
44 |  * Ver   Who            Date            Changes
45 |  * ----- ----           --------        -----------------------------------------------
46 |  * 1.0   Alok G         10/06/17        Initial release.
47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | #ifndef MATRIX_H 53 | #define MATRIX_H 54 | 55 | 56 | #include "XCVector.h" 57 | 58 | class XMatrixAPI 59 | { 60 | private: 61 | float elements[16]; 62 | static XMatrixAPI multiply(XMatrixAPI *left, XMatrixAPI *right); 63 | static const float identityArray[]; 64 | public: 65 | float* getAsArray(void); 66 | XMatrixAPI(void); 67 | float& operator[] (unsigned element); 68 | XMatrixAPI operator* (XMatrixAPI right); 69 | XMatrixAPI& operator=(const XMatrixAPI &another); 70 | XMatrixAPI(const float* array); 71 | static XMatrixAPI identityXMatrixAPI; 72 | static CVec4f vertexTransform(CVec4f *vector, XMatrixAPI *XMatrixAPI); 73 | static CVec3f vertexTransform(CVec3f *vector, XMatrixAPI *XMatrixAPI); 74 | static void XMatrixAPITranspose(XMatrixAPI *XMatrixAPI); 75 | static XMatrixAPI createRotationX(float angle); 76 | static XMatrixAPI createRotationY(float angle); 77 | static XMatrixAPI createRotationZ(float angle); 78 | static XMatrixAPI createTranslation(float x, float y, float z); 79 | static XMatrixAPI createScaling(float x, float y, float z); 80 | void print(void); 81 | static XMatrixAPI XMatrixAPIPerspective(float FOV, float ratio, float zNear, float zFar); 82 | static XMatrixAPI XMatrixAPICameraLookAt(CVec3f eye, CVec3f center, CVec3f up); 83 | static XMatrixAPI XMatrixAPIOrthographic(float left, float right, float bottom, float top, float zNear, float zFar); 84 | static XMatrixAPI XMatrixAPIInvert(XMatrixAPI *XMatrixAPI); 85 | static float XMatrixAPIDeterminant(float *XMatrixAPI); 86 | static float XMatrixAPIDeterminant(XMatrixAPI *XMatrixAPI); 87 | static XMatrixAPI XMatrixAPIScale(XMatrixAPI *XMatrixAPI, float scale); 88 | 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /WaveformSample/WaverenderSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file WaveFormrendering.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #define GLES_VERSION 2 54 | 55 | #include 56 | 57 | 58 | 59 | const float Colors[] = 60 | { 61 | 62 | 1.0, 0.0, 0.0, /* red */ 63 | 0.0, 0.0, 1.0, /* blue */ 64 | 0.0, 1.0, 0.0, /* green */ 65 | 1.0, 0.0, 0.0, /* red */ 66 | 1.0, 1.0, 0.0, /* yellow */ 67 | 0.0, 0.0, 1.0, /* blue */ 68 | 1.0, 1.0, 1.0, /* white */ 69 | 0.0, 1.0, 0.0, /* green */ 70 | 0.0, 1.0, 1.0, /* cyan */ 71 | 1.0, 1.0, 1.0, /* white */ 72 | 1.0, 0.0, 0.0, /* red */ 73 | 0.0, 1.0, 0.0, /* green */ 74 | 1.0, 1.0, 1.0, /* white */ 75 | 1.0, 1.0, 0.0, /* yellow */ 76 | 1.0, 0.0, 0.0, /* red */ 77 | 1.0, 1.0, 1.0, /* white */ 78 | 0.0, 0.0, 0.0, /* black */ 79 | 1.0, 1.0, 0.0, /* yellow */ 80 | 1.0, 1.0, 0.0, /* yellow */ 81 | 1.0, 0.0, 1.0, /* magenta */ 82 | 0.0, 0.0, 1.0, /* blue */ 83 | 1.0, 1.0, 0.0, /* yellow */ 84 | 0.0, 0.0, 0.0, /* black */ 85 | 1.0, 0.0, 1.0, /* magenta */ 86 | 0.0, 0.0, 0.0, /* black */ 87 | 0.0, 1.0, 1.0, /* cyan */ 88 | 1.0, 0.0, 1.0, /* magenta */ 89 | 0.0, 0.0, 0.0, /* black */ 90 | 1.0, 1.0, 1.0, /* white */ 91 | 0.0, 1.0, 1.0, /* cyan */ 92 | 0.0, 1.0, 0.0, /* green */ 93 | 1.0, 0.0, 1.0, /* magenta */ 94 | 0.0, 1.0, 1.0, /* cyan */ 95 | 0.0, 1.0, 0.0, /* green */ 96 | 0.0, 0.0, 1.0, /* blue */ 97 | 1.0, 0.0, 1.0, /* magenta */ 98 | 99 | }; 100 | 101 | 102 | 103 | const float Vertices[] = 104 | { 105 | -1.0, 1.0, -1.0, 106 | 1.0, -1.0, -1.0, 107 | -1.0, -1.0, -1.0, 108 | -1.0, 1.0, -1.0, 109 | 1.0, 1.0, -1.0, 110 | 1.0, -1.0, -1.0, 111 | -1.0, 1.0, 1.0, 112 | -1.0, -1.0, -1.0, 113 | -1.0, -1.0, 1.0, 114 | -1.0, 1.0, 1.0, 115 | -1.0, 1.0, -1.0, 116 | -1.0, -1.0, -1.0, 117 | -1.0, 1.0, 1.0, 118 | 1.0, 1.0, -1.0, 119 | -1.0, 1.0, -1.0, 120 | -1.0, 1.0, 1.0, 121 | 1.0, 1.0, 1.0, 122 | 1.0, 1.0, -1.0, 123 | 1.0, 1.0, -1.0, 124 | 1.0, -1.0, 1.0, 125 | 1.0, -1.0, -1.0, 126 | 1.0, 1.0, -1.0, 127 | 1.0, 1.0, 1.0, 128 | 1.0, -1.0, 1.0, 129 | 1.0, 1.0, 1.0, 130 | -1.0, -1.0, 1.0, 131 | 1.0, -1.0, 1.0, 132 | 1.0, 1.0, 1.0, 133 | -1.0, 1.0, 1.0, 134 | -1.0, -1.0, 1.0, 135 | -1.0, -1.0, -1.0, 136 | 1.0, -1.0, 1.0, 137 | -1.0, -1.0, 1.0, 138 | -1.0, -1.0, -1.0, 139 | 1.0, -1.0, -1.0, 140 | 1.0, -1.0, 1.0, 141 | 142 | 143 | }; 144 | -------------------------------------------------------------------------------- /Coreframework/XGLSLCompile.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XGLSLCompile.cpp 36 | * 37 | * This file implements all the functions related to GLSL compilation. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include "XGLSLCompile.h" 54 | #include "XPodium.h" 55 | 56 | #include 57 | #include 58 | 59 | 60 | 61 | char* Shader::loadShader(const char *filename) 62 | { 63 | FILE *file = fopen(filename, "rb"); 64 | if(file == NULL) 65 | { 66 | printf("Cannot read file '%s'\n", filename); 67 | exit(1); 68 | } 69 | fseek(file, 0, SEEK_END); 70 | long length = ftell(file); 71 | fseek(file, 0, SEEK_SET); 72 | char *shader = (char *)calloc(length + 1, sizeof(char)); 73 | if(shader == NULL) 74 | { 75 | printf("Out of memory at %s:%i\n", __FILE__, __LINE__); 76 | exit(1); 77 | } 78 | size_t numberOfBytesRead = fread(shader, sizeof(char), length, file); 79 | if (numberOfBytesRead != length) 80 | { 81 | printf("Error reading %s (read %d of %d)", filename, numberOfBytesRead, length); 82 | exit(1); 83 | } 84 | shader[length] = '\0'; 85 | fclose(file); 86 | 87 | return shader; 88 | } 89 | 90 | void Shader::processShader(GLuint *shader, const char *filename, GLint shaderType) 91 | { 92 | const char *strings[1] = { NULL }; 93 | 94 | *shader = glCreateShader(shaderType); 95 | strings[0] = loadShader(filename); 96 | glShaderSource(*shader, 1, strings, NULL); 97 | 98 | free((void *)(strings[0])); 99 | strings[0] = NULL; 100 | 101 | glCompileShader(*shader); 102 | GLint status; 103 | glGetShaderiv(*shader, GL_COMPILE_STATUS, &status); 104 | 105 | if(status != GL_TRUE) 106 | { 107 | GLint length; 108 | char *debugSource = NULL; 109 | char *errorLog = NULL; 110 | 111 | glGetShaderiv(*shader, GL_SHADER_SOURCE_LENGTH, &length); 112 | debugSource = (char *)malloc(length); 113 | glGetShaderSource(*shader, length, NULL, debugSource); 114 | printf("Debug source START:\n%s\nDebug source END\n\n", debugSource); 115 | free(debugSource); 116 | 117 | glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &length); 118 | errorLog = (char *)malloc(length); 119 | glGetShaderInfoLog(*shader, length, NULL, errorLog); 120 | printf("Log START:\n%s\nLog END\n\n", errorLog); 121 | free(errorLog); 122 | 123 | printf("Compilation FAILED!\n\n"); 124 | exit(1); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /MultiCubeSample/CubeSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file BasicCube.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #define GLES_VERSION 2 54 | 55 | #include 56 | 57 | 58 | /* Simple triangle. */ 59 | const float cubeVertices[] = 60 | { 61 | 62 | -0.7, 0.7, -0.7, 63 | 0.7, -0.7, -0.7, 64 | -0.7, -0.7, -0.7, 65 | -0.7, 0.7, -0.7, 66 | 0.7, 0.7, -0.7, 67 | 0.7, -0.7, -0.7, 68 | -0.7, 0.7, 0.7, 69 | -0.7, -0.7, -0.7, 70 | -0.7, -0.7, 0.7, 71 | -0.7, 0.7, 0.7, 72 | -0.7, 0.7, -0.7, 73 | -0.7, -0.7, -0.7, 74 | -0.7, 0.7, 0.7, 75 | 0.7, 0.7, -0.7, 76 | -0.7, 0.7, -0.7, 77 | -0.7, 0.7, 0.7, 78 | 0.7, 0.7, 0.7, 79 | 0.7, 0.7, -0.7, 80 | 0.7, 0.7, -0.7, 81 | 0.7, -0.7, 0.7, 82 | 0.7, -0.7, -0.7, 83 | 0.7, 0.7, -0.7, 84 | 0.7, 0.7, 0.7, 85 | 0.7, -0.7, 0.7, 86 | 0.7, 0.7, 0.7, 87 | -0.7, -0.7, 0.7, 88 | 0.7, -0.7, 0.7, 89 | 0.7, 0.7, 0.7, 90 | -0.7, 0.7, 0.7, 91 | -0.7, -0.7, 0.7, 92 | -0.7, -0.7, -0.7, 93 | 0.7, -0.7, 0.7, 94 | -0.7, -0.7, 0.7, 95 | -0.7, -0.7, -0.7, 96 | 0.7, -0.7, -0.7, 97 | 0.7, -0.7, 0.7, 98 | 99 | 100 | }; 101 | 102 | /* Per corner colors for the triangle (Red, Green, Green). */ 103 | const float cubeColors[] = 104 | { 105 | 1.0, 0.0, 0.0, /* red */ 106 | 1.0, 0.0, 1.0, /* blue */ 107 | 1.0, 0.0, 0.0, /* green */ 108 | 1.0, 0.0, 0.0, /* red */ 109 | 1.0, 0.0, 0.0, /* yellow */ 110 | 1.0, 0.0, 1.0, /* blue */ 111 | 1.0, 1.0, 0.0, /* white */ 112 | 1.0, 1.0, 0.0, /* green */ 113 | 1.0, 1.0, 0.0, /* cyan */ 114 | 1.0, 1.0, 0.0, /* white */ 115 | 1.0, 1.0, 0.0, /* red */ 116 | 1.0, 1.0, 0.0, /* green */ 117 | 1.0, 1.0, 1.0, /* white */ 118 | 1.0, 1.0, 0.0, /* yellow */ 119 | 1.0, 0.0, 0.0, /* red */ 120 | 1.0, 1.0, 1.0, /* white */ 121 | 0.0, 0.0, 0.0, /* black */ 122 | 1.0, 1.0, 0.0, /* yellow */ 123 | 1.0, 1.0, 0.0, /* yellow */ 124 | 1.0, 0.0, 1.0, /* magenta */ 125 | 0.0, 0.0, 1.0, /* blue */ 126 | 1.0, 1.0, 0.0, /* yellow */ 127 | 0.0, 0.0, 0.0, /* black */ 128 | 1.0, 0.0, 1.0, /* magenta */ 129 | 0.0, 0.0, 0.0, /* black */ 130 | 0.0, 1.0, 1.0, /* cyan */ 131 | 1.0, 0.0, 1.0, /* magenta */ 132 | 0.0, 0.0, 0.0, /* black */ 133 | 1.0, 1.0, 1.0, /* white */ 134 | 0.0, 1.0, 1.0, /* cyan */ 135 | 0.0, 1.0, 0.0, /* green */ 136 | 1.0, 0.0, 1.0, /* magenta */ 137 | 0.0, 1.0, 1.0, /* cyan */ 138 | 0.0, 1.0, 0.0, /* green */ 139 | 0.0, 0.0, 1.0, /* blue */ 140 | 1.0, 0.0, 1.0, /* magenta */ 141 | 142 | }; 143 | 144 | -------------------------------------------------------------------------------- /Coreframework/XTime.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file Xtime.cpp 36 | * 37 | * This file implements timer related API for SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include "XTime.h" 54 | 55 | #if defined(_WIN32) 56 | 57 | #include 58 | #include 59 | 60 | namespace SDKXilinx 61 | { 62 | Timer::Timer() 63 | { 64 | LARGE_INTEGER l; 65 | QueryPerformanceFrequency(&l); 66 | invFreq = 1.0f / l.QuadPart; 67 | lastInterval = 0.0f; 68 | frameCount = 0; 69 | lastFpsUpdate = 0.0f; 70 | reset(); 71 | fps = 0.0f; 72 | lastTime = 0.0f; 73 | } 74 | 75 | void Timer::reset() 76 | { 77 | LARGE_INTEGER l; 78 | QueryPerformanceCounter(&l); 79 | resetStamp = (((double)l.QuadPart) * invFreq); 80 | } 81 | 82 | float Timer::getTime() 83 | { 84 | LARGE_INTEGER l; 85 | QueryPerformanceCounter(&l); 86 | return (float)(((double)l.QuadPart) * invFreq - resetStamp); 87 | } 88 | 89 | float Timer::getInterval() 90 | { 91 | float time = getTime(); 92 | float interval = time - lastInterval; 93 | lastInterval = time; 94 | return interval; 95 | } 96 | 97 | float Timer::getFPS() 98 | { 99 | float time = getTime(); 100 | frameCount++; 101 | if (time-lastFpsUpdate > 1.0f) 102 | { 103 | fps = (float)frameCount / (time-lastFpsUpdate); 104 | lastFpsUpdate = time; 105 | frameCount = 0; 106 | } 107 | return fps; 108 | } 109 | } 110 | #else 111 | 112 | #include 113 | 114 | namespace SDKXilinx 115 | { 116 | 117 | Timer::Timer() 118 | : startTime() 119 | , currentTime() 120 | , lastIntervalTime(0.0f) 121 | , frameCount(0) 122 | , fpsTime(0.0f) 123 | , fps(0.0f) 124 | { 125 | startTime.tv_sec = 0; 126 | startTime.tv_usec = 0; 127 | currentTime.tv_sec = 0; 128 | currentTime.tv_usec = 0; 129 | 130 | reset(); 131 | } 132 | 133 | void Timer::reset() 134 | { 135 | gettimeofday(&startTime, NULL); 136 | lastIntervalTime = 0.0; 137 | 138 | frameCount = 0; 139 | fpsTime = 0.0f; 140 | } 141 | 142 | float Timer::getTime() 143 | { 144 | gettimeofday(¤tTime, NULL); 145 | float seconds = (currentTime.tv_sec - startTime.tv_sec); 146 | float milliseconds = (float(currentTime.tv_usec - startTime.tv_usec)) / 1000000.0f; 147 | return seconds + milliseconds; 148 | } 149 | 150 | float Timer::getInterval() 151 | { 152 | float time = getTime(); 153 | float interval = time - lastIntervalTime; 154 | lastIntervalTime = time; 155 | return interval; 156 | } 157 | 158 | float Timer::getFPS() 159 | { 160 | if (getTime() - fpsTime > 1.0f) 161 | { 162 | fps = static_cast(frameCount) / (getTime() - fpsTime); 163 | frameCount = 0; 164 | fpsTime = getTime(); 165 | } 166 | ++frameCount; 167 | return fps; 168 | } 169 | #endif 170 | 171 | bool Timer::isTimePassed(float seconds) 172 | { 173 | float time = getTime(); 174 | if (time - lastTime > seconds) 175 | { 176 | lastTime = time; 177 | return true; 178 | } 179 | return false; 180 | } 181 | 182 | } 183 | -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/FBOSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file BasicFBO.h 36 | * 37 | * This file implements test application for OpenGL rendering using SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | 54 | #ifndef FRAMEBUFFEROBJECT_H 55 | #define FRAMEBUFFEROBJECT_H 56 | 57 | #define GLES_VERSION 2 58 | 59 | #include 60 | 61 | 62 | 63 | static const float cubeColors[] = 64 | { 65 | 0.0f, 0.0f, 0.0f, 1.0f, /* 0 */ 66 | 1.0f, 0.0f, 0.0f, 1.0f, /* 1 */ 67 | 0.0f, 1.0f, 0.0f, 1.0f, /* 2 */ 68 | 1.0f, 1.0f, 0.0f, 1.0f, /* 3 */ 69 | 1.0f, 0.0f, 0.0f, 1.0f, /* 4 */ 70 | 0.0f, 0.0f, 1.0f, 1.0f, /* 5 */ 71 | 1.0f, 1.0f, 0.0f, 1.0f, /* 6 */ 72 | 0.0f, 1.0f, 1.0f, 1.0f, /* 7 */ 73 | 0.0f, 0.0f, 1.0f, 1.0f, /* 8 */ 74 | 1.0f, 0.0f, 1.0f, 1.0f, /* 9 */ 75 | 0.0f, 1.0f, 1.0f, 1.0f, /* 10 */ 76 | 1.0f, 1.0f, 1.0f, 1.0f, /* 11 */ 77 | 1.0f, 0.0f, 1.0f, 1.0f, /* 12 */ 78 | 0.0f, 0.0f, 0.0f, 1.0f, /* 13 */ 79 | 1.0f, 1.0f, 1.0f, 1.0f, /* 14 */ 80 | 0.0f, 1.0f, 0.0f, 1.0f, /* 15 */ 81 | 0.0f, 1.0f, 0.0f, 1.0f, /* 16 */ 82 | 1.0f, 1.0f, 0.0f, 1.0f, /* 17 */ 83 | 1.0f, 1.0f, 1.0f, 1.0f, /* 18 */ 84 | 0.0f, 1.0f, 1.0f, 1.0f, /* 19 */ 85 | 1.0f, 0.0f, 1.0f, 1.0f, /* 20 */ 86 | 0.0f, 0.0f, 1.0f, 1.0f, /* 21 */ 87 | 0.0f, 0.0f, 0.0f, 1.0f, /* 22 */ 88 | 1.0f, 0.0f, 0.0f, 1.0f, /* 23 */ 89 | }; 90 | 91 | static const float cubeVertices[] = 92 | { 93 | -0.5f, -0.5f, 0.5f, /* 0 */ 94 | 0.5f, -0.5f, 0.5f, /* 1 */ 95 | -0.5f, 0.5f, 0.5f, /* 2 */ 96 | 0.5f, 0.5f, 0.5f, /* 3 */ 97 | 0.5f, -0.5f, 0.5f, /* 4 */ 98 | 0.5f, -0.5f, -0.5f, /* 5 */ 99 | 0.5f, 0.5f, 0.5f, /* 6 */ 100 | 0.5f, 0.5f, -0.5f, /* 7 */ 101 | 0.5f, -0.5f, -0.5f, /* 8 */ 102 | -0.5f, -0.5f, -0.5f, /* 9 */ 103 | 0.5f, 0.5f, -0.5f, /* 10 */ 104 | -0.5f, 0.5f, -0.5f, /* 11 */ 105 | -0.5f, -0.5f, -0.5f, /* 12 */ 106 | -0.5f, -0.5f, 0.5f, /* 13 */ 107 | -0.5f, 0.5f, -0.5f, /* 14 */ 108 | -0.5f, 0.5f, 0.5f, /* 15 */ 109 | -0.5f, 0.5f, 0.5f, /* 16 */ 110 | 0.5f, 0.5f, 0.5f, /* 17 */ 111 | -0.5f, 0.5f, -0.5f, /* 18 */ 112 | 0.5f, 0.5f, -0.5f, /* 19 */ 113 | -0.5f, -0.5f, -0.5f, /* 20 */ 114 | 0.5f, -0.5f, -0.5f, /* 21 */ 115 | -0.5f, -0.5f, 0.5f, /* 22 */ 116 | 0.5f, -0.5f, 0.5f, /* 23 */ 117 | }; 118 | 119 | static const GLubyte cubeIndices[] = 120 | { 121 | 0, 1, 2, 3, 122 | 3, 4, 123 | 4, 5, 6, 7, 124 | 7, 8, 125 | 8, 9, 10, 11, 126 | 11, 12, 127 | 12, 13, 14, 15, 128 | 15, 16, 129 | 16, 17, 18, 19, 130 | 19, 20, 131 | 20, 21, 22, 23, 132 | }; 133 | 134 | 135 | static const float cubeTextureCoordinates[] = 136 | { 137 | 0.0f, 0.0f, /* 0 */ 138 | 1.0f, 0.0f, /* 1 */ 139 | 0.0f, 1.0f, /* 2 */ 140 | 1.0f, 1.0f, /* 3 */ 141 | 0.0f, 0.0f, /* 4 */ 142 | 1.0f, 0.0f, /* 5 */ 143 | 0.0f, 1.0f, /* 6 */ 144 | 1.0f, 1.0f, /* 7 */ 145 | 0.0f, 0.0f, /* 8 */ 146 | 1.0f, 0.0f, /* 9 */ 147 | 0.0f, 1.0f, /* 10 */ 148 | 1.0f, 1.0f, /* 11 */ 149 | 0.0f, 0.0f, /* 12 */ 150 | 1.0f, 0.0f, /* 13 */ 151 | 0.0f, 1.0f, /* 14 */ 152 | 1.0f, 1.0f, /* 15 */ 153 | 0.0f, 0.0f, /* 16 */ 154 | 1.0f, 0.0f, /* 17 */ 155 | 0.0f, 1.0f, /* 18 */ 156 | 1.0f, 1.0f, /* 19 */ 157 | 0.0f, 0.0f, /* 20 */ 158 | 1.0f, 0.0f, /* 21 */ 159 | 0.0f, 1.0f, /* 22 */ 160 | 1.0f, 1.0f, /* 23 */ 161 | 162 | }; 163 | 164 | 165 | #endif /* FRAMEBUFFEROBJECT_H */ 166 | -------------------------------------------------------------------------------- /Coreframework/XLinuxPodium.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file XLinuxPodium.cpp 36 | * 37 | * This file implements all the functions related to Linux X11 windowing system API's for application. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include "XLinuxPodium.h" 54 | 55 | XPodium* XLinuxPodium::instance = NULL; 56 | 57 | XLinuxPodium::XLinuxPodium(void) 58 | { 59 | 60 | } 61 | 62 | XPodium* XLinuxPodium::getHandler(void) 63 | { 64 | if (instance == NULL) 65 | { 66 | instance = new XLinuxPodium(); 67 | } 68 | return instance; 69 | } 70 | 71 | void XLinuxPodium::prepareWindow(int width, int height) 72 | { 73 | windowWidth = width; 74 | windowHeight = height; 75 | } 76 | 77 | bool XLinuxPodium::createX11Window(void) 78 | { 79 | XSetWindowAttributes windowAttributes; 80 | XSizeHints sizeHints; 81 | XEvent event; 82 | XVisualInfo visualInfoTemplate; 83 | 84 | unsigned long mask; 85 | long screen; 86 | 87 | int visualID, numberOfVisuals; 88 | 89 | display = XOpenDisplay(NULL); 90 | 91 | screen = DefaultScreen(display); 92 | 93 | eglGetConfigAttrib(CoreEGL::display, CoreEGL::config, EGL_NATIVE_VISUAL_ID, &visualID); 94 | visualInfoTemplate.visualid = visualID; 95 | visual = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &numberOfVisuals); 96 | 97 | if (visual == NULL) 98 | { 99 | printf("Couldn't get X visual info\n"); 100 | return false; 101 | } 102 | 103 | colormap = XCreateColormap(display, RootWindow(display, screen), visual->visual, AllocNone); 104 | 105 | windowAttributes.colormap = colormap; 106 | windowAttributes.background_pixel = 0xFFFFFFFF; 107 | windowAttributes.border_pixel = 0; 108 | windowAttributes.event_mask = StructureNotifyMask | ExposureMask; 109 | 110 | mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap; 111 | 112 | window = XCreateWindow(display, RootWindow(display, screen), 0, 0, windowWidth, windowHeight, 113 | 0, visual->depth, InputOutput, visual->visual, mask, &windowAttributes); 114 | sizeHints.flags = USPosition; 115 | sizeHints.x = 10; 116 | sizeHints.y = 10; 117 | 118 | XSetStandardProperties(display, window, "Xilinx OpenGL ES SDK", "", None, 0, 0, &sizeHints); 119 | XMapWindow(display, window); 120 | XIfEvent(display, &event, wait_for_map, (char*)&window); 121 | XSetWMColormapWindows(display, window, &window, 1); 122 | XFlush(display); 123 | 124 | XSelectInput(display, window, KeyPressMask | ExposureMask | EnterWindowMask 125 | | LeaveWindowMask | PointerMotionMask | VisibilityChangeMask | ButtonPressMask 126 | | ButtonReleaseMask | StructureNotifyMask); 127 | 128 | return true; 129 | } 130 | 131 | void XLinuxPodium::destroyWindow(void) 132 | { 133 | XDestroyWindow(display, window); 134 | XFreeColormap(display, colormap); 135 | XFree(visual); 136 | XCloseDisplay(display); 137 | } 138 | 139 | XPodium::WindowStatus XLinuxPodium::checkWindow(void) 140 | { 141 | XEvent event; 142 | 143 | while (XPending(display) > 0) 144 | { 145 | XNextEvent(display, &event); 146 | 147 | if (event.type == ButtonPress) 148 | { 149 | return XPodium::WINDOW_CLICK; 150 | } 151 | } 152 | return XPodium::WINDOW_IDLE; 153 | } 154 | 155 | Bool XLinuxPodium::wait_for_map(Display *display, XEvent *event, char *windowPointer) 156 | { 157 | return (event->type == MapNotify && event->xmap.window == (*((Window*)windowPointer))); 158 | } 159 | -------------------------------------------------------------------------------- /Alpha_DepthSample/DepthSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file Depth.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | #ifndef FETCH_DEPTH_H 53 | #define FETCH_DEPTH_H 54 | 55 | #define GLES_VERSION 2 56 | #include 57 | #include 58 | 59 | 60 | using namespace std; 61 | 62 | string resourceDirectory = "Supportingfiles/"; 63 | string vertexShaderCubeFilename = "DepthSamplebox.vert"; 64 | string fragmentShaderCubeFilename = "DepthSamplebox.frag"; 65 | string vertexShaderGlassFilename = "DepthSamplevertical.vert"; 66 | string fragmentShaderGlassFilename = "DepthSamplevertical.frag"; 67 | string fragmentShaderGlassRttFilename = "DepthSampleverticalExt.frag"; 68 | 69 | GLuint programCubeID; 70 | GLint iLocCubePosition; 71 | GLint iLocCubeColor; 72 | GLint iLocCubeMVP; 73 | 74 | GLuint programGlassID; 75 | GLint iLocGlassPosition; 76 | GLint iLocGlassColor; 77 | GLint iLocGlassMVP; 78 | GLint iLocNear; 79 | GLint iLocFar; 80 | GLint iLocGlassMaterial; 81 | 82 | int windowWidth = -1; 83 | int windowHeight = -1; 84 | 85 | 86 | const float colorsCube[] = 87 | { 88 | 1.0, 0.0, 0.0, /* red */ 89 | 1.0, 0.0, 0.0, /* red */ 90 | 1.0, 0.0, 0.0, /* red */ 91 | 1.0, 0.0, 0.0, /* red */ 92 | 1.0, 0.0, 0.0, /* red */ 93 | 1.0, 0.0, 0.0, /* red */ 94 | 95 | 0.0, 1.0, 1.0, /* blue */ 96 | 0.0, 1.0, 1.0, /* blue */ 97 | 0.0, 1.0, 1.0, /* blue */ 98 | 0.0, 0.0, 1.0, /* blue */ 99 | 0.0, 0.0, 1.0, /* blue */ 100 | 0.0, 0.0, 1.0, /* blue */ 101 | 102 | 1.0, 1.0, 1.0, /* white */ 103 | 1.0, 1.0, 1.0, /* white */ 104 | 1.0, 1.0, 1.0, /* white */ 105 | 1.0, 1.0, 1.0, /* white */ 106 | 1.0, 1.0, 1.0, /* white */ 107 | 1.0, 1.0, 1.0, /* white */ 108 | 109 | 1.0, 1.0, 0.0, /* yellow */ 110 | 1.0, 1.0, 0.0, /* yellow */ 111 | 1.0, 1.0, 0.0, /* yellow */ 112 | 1.0, 1.0, 0.0, /* yellow */ 113 | 1.0, 1.0, 0.0, /* yellow */ 114 | 1.0, 1.0, 0.0, /* yellow */ 115 | 116 | 1.0, 0.0, 1.0, /* cyan */ 117 | 1.0, 0.0, 1.0, /* cyan */ 118 | 1.0, 0.0, 1.0, /* cyan */ 119 | 0.0, 1.0, 1.0, /* cyan */ 120 | 0.0, 1.0, 1.0, /* cyan */ 121 | 0.0, 1.0, 1.0, /* cyan */ 122 | 123 | 1.0, 0.2, 1.0, /* magenta */ 124 | 1.0, 0.2, 1.0, /* magenta */ 125 | 1.0, 0.2, 1.0, /* magenta */ 126 | 1.0, 0.2, 1.0, /* magenta */ 127 | 1.0, 0.2, 1.0, /* magenta */ 128 | 1.0, 0.2, 1.0, /* magenta */ 129 | }; 130 | 131 | 132 | const float verticesGlass[] = 133 | { 134 | 0.3, -0.5, 0, 135 | 0.3, 0.8, 0, 136 | -0.3, -0.5, 0, 137 | -0.3, 0.8, 0, 138 | }; 139 | 140 | const float verticesCube[] = 141 | { 142 | -0.5, 0.5, -0.5, 143 | 0.5, -0.5, -0.5, 144 | -0.5, -0.5, -0.5, 145 | -0.5, 0.5, -0.5, 146 | 0.5, 0.5, -0.5, 147 | 0.5, -0.5, -0.5, 148 | -0.5, 0.5, 0.5, 149 | -0.5, -0.5, -0.5, 150 | -0.5, -0.5, 0.5, 151 | -0.5, 0.5, 0.5, 152 | -0.5, 0.5, -0.5, 153 | -0.5, -0.5, -0.5, 154 | -0.5, 0.5, 0.5, 155 | 0.5, 0.5, -0.5, 156 | -0.5, 0.5, -0.5, 157 | -0.5, 0.5, 0.5, 158 | 0.5, 0.5, 0.5, 159 | 0.5, 0.5, -0.5, 160 | 0.5, 0.5, -0.5, 161 | 0.5, -0.5, 0.5, 162 | 0.5, -0.5, -0.5, 163 | 0.5, 0.5, -0.5, 164 | 0.5, 0.5, 0.5, 165 | 0.5, -0.5, 0.5, 166 | 0.5, 0.5, 0.5, 167 | -0.5, -0.5, 0.5, 168 | 0.5, -0.5, 0.5, 169 | 0.5, 0.5, 0.5, 170 | -0.5, 0.5, 0.5, 171 | -0.5, -0.5, 0.5, 172 | -0.5, -0.5, -0.5, 173 | 0.5, -0.5, 0.5, 174 | -0.5, -0.5, 0.5, 175 | -0.5, -0.5, -0.5, 176 | 0.5, -0.5, -0.5, 177 | 0.5, -0.5, 0.5, 178 | }; 179 | 180 | const float colorsGlass[] = 181 | { 182 | 0.2, 1.0, 0.0, 0.2, /* green */ 183 | 0.2, 1.0, 0.0, 0.2, /* green */ 184 | 1.0, 0.0, 0.0, 0.2, /* green */ 185 | 1.0, 0.0, 0.0, 0.2, /* green */ 186 | }; 187 | 188 | 189 | 190 | #endif /* FETCH_DEPTH_H */ 191 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # How to set-up, compile and run 2 | 3 | 1. Clone the repository 4 | ```bash 5 | git clone https://github.com/Xilinx/SDKOpenGLES/tree/master 6 | ``` 7 |
8 | 9 | 2. Edit the run_export.sh and change appropriate path for cross-compiler & libs.
10 | 3. Keep this flag enabled CXXFLAGS=-DENABLE_FBDEV , If you are compiling for FBDEV & for x11 disable this flag.
11 | 4. Source the modified file run_export.sh 12 | 13 | ```bash 14 | source ./run_export.sh 15 | ``` 16 |
17 | 18 | 5. Build examples 19 | 20 | ```bash 21 | make all 22 | ``` 23 |
24 | 25 | 6. Run. Respective binaries should be compiled for each sample & then you can run them. E.g: 26 | 27 | ```bash 28 | cd MultiCubeSample && ./MultiCubeSample 29 | ``` 30 |
31 | 32 | 33 | # SDKOpenGLES 34 | Open Source Software development Kit for Graphics which can run on GPU for Kria and Zu+ Platforms of AMD-Xilinx. 35 | 36 | 37 | # Cube Sample 38 | Multi Cube rendering Sample GPU 39 | This sample contains simple cube rendering technique on GPU using OpenGL ES 2.0 API’s. 40 | Colors are Interpolated across the vertices and showcase rotation matrix application for creating animation 41 | effects. This is available in both versions X11 and FBDEV. 42 | 43 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/MultiCubeSample/CubesSample.png) 44 | 45 | 46 | # Depth Buffer Sample GPU 47 | This sample is designed to use depth buffer and create an effect on GPU . It draws cube and vertical plane with overlapping depth.Animation is created using matrices which allows the objects to rotate. 48 | This is available in both versions X11 and FBDEV. 49 | 50 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/Alpha_DepthSample/Depth.png) 51 | 52 | 53 | # EGL Image Texture Swapping 54 | This sample is designed to showcase the usage of EGL Image extension. It defines a new EGL resource type that is suitable for 55 | sharing 2D arrays of image data between client APIs, the EGLImage. Although the intended purpose is sharing 2D image data, the 56 | underlying interface makes no assumptions about the format or purpose of the resource being shared, leaving those decisions to 57 | the application and associated client APIs. This is available for FBDEV 58 | 59 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/EGLRenderingSample/EGL1.png) 60 | 61 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/EGLRenderingSample/EGL2.png) 62 | 63 | 64 | # EGL Image Live Video streaming texture update - GPU 65 | This sample is designed to showcase the usage of EGL Image extension in real time which will take live feed from camera mounted on ZCU+ board and streaming the data on /dev/video0 node. The application reads that streaming and use it as a texture in OpenGL ES application and render and update the texture frame-per-frame using EGL Image instead of classic glteximage2D approach and is quite fast compared to classic approach. This is available for FBDEV. 66 | 67 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/EGLTextureVideoSample/EGLVideo1.png) 68 | 69 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/EGLTextureVideoSample/EGLVideo2.png) 70 | 71 | 72 | # Frame Buffer Object (Render to Texture) Sample GPU 73 | This sample contains Render to texture rendering technique sample on GPU using OpenGL ES 2.0 API’s. 74 | FBO is used to create the color cube which is rendered to a texture and is being used in subsequent rendering pass as input texture to be applied across all six faces of bigger cube .Rotating matrix are used here to create animation effects on both cubes separately.This is available in both versions X11 and FBDEV 75 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/FrameBufferObject-FBOSample/FBO.png) 76 | 77 | 78 | # MIPMAP Levels & Compressed Texture Sample 79 | This sample is designed to show the capability of GPU to decompress the compressed texture on the fly with multiple levels of MIPMAPS being used for textures. The rendering shows Texture MipMaps at multiple levels which were stored as ETC compressed. 80 | This is available in both versions X11 and FBDEV. 81 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/TextureMipMapSample/MIPMAP.png) 82 | 83 | 84 | # Multi Particle rendering Sample GPU 85 | This sample is designed to create particle system effect 86 | on GPU . It draws multiple particles on screen which are created using a small texture , each particle has a 87 | lifetime and color which can be controlled by the application. Animation is created using matrices which allows the particles to diverge in multiple locations and sustain based on there lifetime token.This is available in both versions X11 and FBDEV 88 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/ParticleRenderingSample/Particles.png) 89 | 90 | 91 | Simple Triangle rendering Sample GPU 92 | This sample contains simple triangle rendering technique on GPU using OpenGL ES 2.0 API’s.Colors are Interpolated across the vertices and showcase rotation matrix application for creating animation effects.This is available in both versions X11 and FBDEV. 93 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/TriangleSample/Triangle.png) 94 | 95 | # Waveform Pattern Generation using GLSL Fragment Shader on GPU 96 | This sample is designed to show the capability of GPU to Waveform rendering using GLSL Shader code only 97 | Without using lot of vertices. The rendering show multiple waveforms on the screen which are implemented using math functions in Pixel Shader.This is available in both versions X11 and FBDEV 98 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/WaveformSample/Waveform.png) 99 | 100 | 101 | # YUV TO RGB CONVERSION ON GPU Shader core - GLSL 102 | This sample is designed to show the capability of GPU to do fast Color conversion from YUV to RGB 103 | in GLSL Shader code on the Fly. And render the converted Image on the framebuffer continuously frame by frame. 104 | This is available in both versions X11 and FBDEV 105 | ![alt text](https://github.com/Xilinx/SDKOpenGLES/blob/master/YUV2RGBSample/Yuv2rgb.png) 106 | 107 | 108 | 109 | # Test File size was large so download this out.yuv file form link below & place it under "/YUV2RGBonGPUSample/Supportingfiles/" Folder 110 | 111 | https://drive.google.com/open?id=1x-iDJurB3rB9TrF_Wa-4uARr8YtTxfzc 112 | -------------------------------------------------------------------------------- /TextureMipMapSample/MipMapSample.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file TextureMipMap.h 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #ifndef ETCMIPMAP_H 54 | #define ETCMIPMAP_H 55 | 56 | #define GLES_VERSION 2 57 | 58 | #include 59 | #include 60 | 61 | using namespace std; 62 | 63 | 64 | string resourceDirectory = "Supportingfiles/"; 65 | string textureFilename = "xilinx_mip_"; 66 | string imageExtension = ".pkm"; 67 | 68 | string vertexShaderFilename = "textureMipMap.vert"; 69 | string fragmentShaderFilename = "textureMipMap.frag"; 70 | 71 | GLuint textureID = 0; 72 | 73 | GLuint vertexShaderID = 0; 74 | GLuint fragmentShaderID = 0; 75 | GLuint programID = 0; 76 | GLint iLocPosition = -1; 77 | GLint iLocTexCoord = -1; 78 | GLint iLocSampler = -1; 79 | 80 | static const GLubyte indices[] = 81 | { 82 | 0, 1, 2, 3, 83 | 3, 4, 84 | 4, 5, 6, 7, 85 | 7, 8, 86 | 8, 9, 10, 11, 87 | 11, 12, 88 | 12, 13, 14, 15, 89 | 15, 16, 90 | 16, 17, 18, 19, 91 | 19, 20, 92 | 20, 21, 22, 23, 93 | 23, 24, 94 | 24, 25, 26, 27, 95 | 27, 28, 96 | 28, 29, 30, 31, 97 | 31, 32, 98 | 32, 33, 34, 35, 99 | }; 100 | 101 | 102 | static const GLfloat textureCoordinates[] = 103 | { 104 | 0.0f, 0.0f, /* 0 */ 105 | 0.0f, 1.0f, /* 1 */ 106 | 1.0f, 0.0f, /* 2 */ 107 | 1.0f, 1.0f, /* 3 */ 108 | 0.0f, 0.0f, /* 4 */ 109 | 0.0f, 1.0f, /* 5 */ 110 | 1.0f, 0.0f, /* 6 */ 111 | 1.0f, 1.0f, /* 7 */ 112 | 0.0f, 0.0f, /* 8 */ 113 | 0.0f, 1.0f, /* 9 */ 114 | 1.0f, 0.0f, /* 10 */ 115 | 1.0f, 1.0f, /* 11 */ 116 | 0.0f, 0.0f, /* 12 */ 117 | 0.0f, 1.0f, /* 13 */ 118 | 1.0f, 0.0f, /* 14 */ 119 | 1.0f, 1.0f, /* 15 */ 120 | 0.0f, 0.0f, /* 16 */ 121 | 0.0f, 1.0f, /* 17 */ 122 | 1.0f, 0.0f, /* 18 */ 123 | 1.0f, 1.0f, /* 19 */ 124 | 0.0f, 0.0f, /* 20 */ 125 | 0.0f, 1.0f, /* 21 */ 126 | 1.0f, 0.0f, /* 22 */ 127 | 1.0f, 1.0f, /* 23 */ 128 | 0.0f, 0.0f, /* 24 */ 129 | 0.0f, 1.0f, /* 25 */ 130 | 1.0f, 0.0f, /* 26 */ 131 | 1.0f, 1.0f, /* 27 */ 132 | 0.0f, 0.0f, /* 28 */ 133 | 0.0f, 1.0f, /* 29 */ 134 | 1.0f, 0.0f, /* 30 */ 135 | 1.0f, 1.0f, /* 31 */ 136 | 0.0f, 0.0f, /* 32 */ 137 | 0.0f, 1.0f, /* 33 */ 138 | 1.0f, 0.0f, /* 34 */ 139 | 1.0f, 1.0f, /* 35 */ 140 | }; 141 | 142 | 143 | static const GLfloat vertices[] = 144 | { 145 | -1.000000f, 1.0000f, 0.0f, /* 0 */ 146 | -1.000000f, 0.4666f, 0.0f, /* 1 */ 147 | -0.200000f, 1.0000f, 0.0f, /* 2 */ 148 | -0.200000f, 0.4666f, 0.0f, /* 3 */ 149 | -0.200000f, 1.0000f, 0.0f, /* 4 */ 150 | -0.200000f, 0.7333f, 0.0f, /* 5 */ 151 | 0.200000f, 1.0000f, 0.0f, /* 6 */ 152 | 0.200000f, 0.7333f, 0.0f, /* 7 */ 153 | 0.200000f, 1.0000f, 0.0f, /* 8 */ 154 | 0.200000f, 0.8666f, 0.0f, /* 9 */ 155 | 0.400000f, 1.0000f, 0.0f, /* 10 */ 156 | 0.400000f, 0.8666f, 0.0f, /* 11 */ 157 | 0.400000f, 1.0000f, 0.0f, /* 12 */ 158 | 0.400000f, 0.9333f, 0.0f, /* 13 */ 159 | 0.500000f, 1.0000f, 0.0f, /* 14 */ 160 | 0.500000f, 0.9333f, 0.0f, /* 15 */ 161 | 0.500000f, 1.0000f, 0.0f, /* 16 */ 162 | 0.500000f, 0.9666f, 0.0f, /* 17 */ 163 | 0.550000f, 1.0000f, 0.0f, /* 18 */ 164 | 0.550000f, 0.9666f, 0.0f, /* 19 */ 165 | 0.550000f, 1.0000f, 0.0f, /* 20 */ 166 | 0.550000f, 0.9833f, 0.0f, /* 21 */ 167 | 0.575000f, 1.0000f, 0.0f, /* 22 */ 168 | 0.575000f, 0.9833f, 0.0f, /* 23 */ 169 | 0.575000f, 1.0000f, 0.0f, /* 24 */ 170 | 0.575000f, 0.9916f, 0.0f, /* 25 */ 171 | 0.587500f, 1.0000f, 0.0f, /* 26 */ 172 | 0.587500f, 0.9916f, 0.0f, /* 27 */ 173 | 0.587500f, 1.0000f, 0.0f, /* 28 */ 174 | 0.587500f, 0.9958f, 0.0f, /* 29 */ 175 | 0.593750f, 1.0000f, 0.0f, /* 30 */ 176 | 0.593750f, 0.9958f, 0.0f, /* 31 */ 177 | 0.593750f, 1.0000f, 0.0f, /* 32 */ 178 | 0.593750f, 0.9958f, 0.0f, /* 33 */ 179 | 0.596875f, 1.0000f, 0.0f, /* 34 */ 180 | 0.596875f, 0.9958f, 0.0f, /* 35 */ 181 | }; 182 | 183 | #endif /* ETCMIPMAP_H */ 184 | -------------------------------------------------------------------------------- /WaveformSample/WaverenderSample.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file WaverenderSample.cpp 36 | * 37 | * This file implements test application for OpenGL rendering using SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include "XLinuxPodium.h" 60 | #include "WaverenderSample.h" 61 | #include "XGLSLCompile.h" 62 | #include "XEGLIntf.h" 63 | #include "XMatrixAPI.h" 64 | #include 65 | 66 | using namespace std; 67 | 68 | #define SCENE_WIDTH 800 69 | #define SCENE_HEIGHT 600 70 | 71 | string resourceDirectory = "Supportingfiles/"; 72 | string vertexShaderFilename = "WaverenderSample.vert"; 73 | string fragmentShaderFilename = "WaverenderSample.frag"; 74 | 75 | GLuint programID; 76 | GLint iLocPosition = -1; 77 | GLint itimeLocation = -1; 78 | GLint iLocMVP = -1; 79 | 80 | 81 | 82 | void GraphicsUpdate(float time) 83 | { 84 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 85 | 86 | glUseProgram(programID); 87 | glUniform1f (itimeLocation, time); 88 | glVertexAttribPointer(iLocPosition, 3, GL_FLOAT, GL_FALSE, 0, Vertices); 89 | glEnableVertexAttribArray(iLocPosition); 90 | 91 | static float angleX = 0, angleY = 0, angleZ = 0; 92 | XMatrixAPI modelView = XMatrixAPI::createRotationX(angleX); 93 | XMatrixAPI translate1 = XMatrixAPI::createTranslation(0.0,0.0,-1.5); 94 | 95 | modelView = translate1 * modelView; 96 | 97 | XMatrixAPI perspective = XMatrixAPI::XMatrixAPIPerspective(45.0f, 1280/720, 0.01f, 100.0f); 98 | XMatrixAPI modelViewPerspective = perspective * modelView; 99 | 100 | glUniformMatrix4fv(iLocMVP, 1, GL_FALSE, modelViewPerspective.getAsArray()); 101 | 102 | glDrawArrays(GL_TRIANGLES, 0, 36); 103 | 104 | } 105 | 106 | bool prepareGraphics(int width, int height) 107 | { 108 | string vertexShaderPath = resourceDirectory + vertexShaderFilename; 109 | string fragmentShaderPath = resourceDirectory + fragmentShaderFilename; 110 | 111 | GLuint vertexShaderID = 0; 112 | GLuint fragmentShaderID = 0; 113 | 114 | glEnable(GL_DEPTH_TEST); 115 | glDepthFunc(GL_LEQUAL); 116 | 117 | 118 | glEnable(GL_BLEND); 119 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 120 | Shader::processShader(&vertexShaderID, vertexShaderPath.c_str(), GL_VERTEX_SHADER); 121 | printf("vertexShaderID = %d", vertexShaderID); 122 | Shader::processShader(&fragmentShaderID, fragmentShaderPath.c_str(), GL_FRAGMENT_SHADER); 123 | printf("fragmentShaderID = %d", fragmentShaderID); 124 | 125 | programID = glCreateProgram(); 126 | if (programID == 0) 127 | { 128 | printf("Could not create program."); 129 | return false; 130 | } 131 | 132 | glAttachShader(programID, vertexShaderID); 133 | glAttachShader(programID, fragmentShaderID); 134 | glLinkProgram(programID); 135 | glUseProgram(programID); 136 | 137 | iLocPosition = glGetAttribLocation(programID, "a_v4Position"); 138 | itimeLocation = glGetUniformLocation(programID, "iGlobalTime"); 139 | iLocMVP = glGetUniformLocation(programID, "mvp"); 140 | 141 | glViewport(0, 0, width, height); 142 | 143 | glClearColor(0.0f, 0.0f, 0.2f, 1.0f); 144 | glClearDepthf(1.0f); 145 | return true; 146 | } 147 | 148 | static void usage(void) 149 | { 150 | printf("Usage:\n"); 151 | printf(" -Window Set X11 or FBDEV\n"); 152 | printf(" -info display OpenGL renderer info\n"); 153 | } 154 | 155 | 156 | int main(int argc, char* argv[]) 157 | { 158 | 159 | XPodium *podium = XPodium::getHandler(); 160 | podium->prepareWindow(SCENE_WIDTH, SCENE_HEIGHT); 161 | CoreEGL::initializeEGL(CoreEGL::OPENGLES2); 162 | eglMakeCurrent(CoreEGL::display, CoreEGL::surface, CoreEGL::surface, CoreEGL::context); 163 | 164 | prepareGraphics(SCENE_WIDTH, SCENE_HEIGHT); 165 | 166 | bool end = false; 167 | float i = 0.0f; 168 | while(!end) 169 | { 170 | if(podium->checkWindow() != XPodium::WINDOW_IDLE) 171 | { 172 | end = true; 173 | } 174 | 175 | GraphicsUpdate(i); 176 | eglSwapBuffers(CoreEGL::display, CoreEGL::surface); 177 | 178 | if(i<=10000) 179 | i= i + 0.04f; 180 | else 181 | i=0; 182 | 183 | } 184 | 185 | CoreEGL::terminateEGL(); 186 | podium->destroyWindow(); 187 | delete podium; 188 | 189 | return 0; 190 | } 191 | 192 | 193 | -------------------------------------------------------------------------------- /TriangleSample/TriangleSample.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file TriangleSample.cpp 36 | * 37 | * This file implements test application for OpenGL rloopering using SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include "XLinuxPodium.h" 60 | #include "TriangleSample.h" 61 | #include "XGLSLCompile.h" 62 | #include "XEGLIntf.h" 63 | #include "XMatrixAPI.h" 64 | #include 65 | 66 | using namespace std; 67 | 68 | 69 | bool prepareGraphics(int width, int height) 70 | { 71 | printf("prepareGraphics(%d, %d)", width, height); 72 | string vertexShaderPath = resourceDirectory + vertexShaderFilename; 73 | string fragmentShaderPath = resourceDirectory + fragmentShaderFilename; 74 | 75 | GLuint vertexShaderID = 0; 76 | GLuint fragmentShaderID = 0; 77 | 78 | glEnable(GL_DEPTH_TEST); 79 | glDepthFunc(GL_LEQUAL); 80 | 81 | glEnable(GL_BLEND); 82 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 83 | Shader::processShader(&vertexShaderID, vertexShaderPath.c_str(), GL_VERTEX_SHADER); 84 | printf("vertexShaderID = %d", vertexShaderID); 85 | Shader::processShader(&fragmentShaderID, fragmentShaderPath.c_str(), GL_FRAGMENT_SHADER); 86 | printf("fragmentShaderID = %d", fragmentShaderID); 87 | 88 | programID = glCreateProgram(); 89 | if (programID == 0) 90 | { 91 | printf("Could not create program."); 92 | return false; 93 | } 94 | 95 | glAttachShader(programID, vertexShaderID); 96 | glAttachShader(programID, fragmentShaderID); 97 | glLinkProgram(programID); 98 | glUseProgram(programID); 99 | 100 | iLocPosition = glGetAttribLocation(programID, "a_v4Position"); 101 | printf("glGetAttribLocation(\"a_v4Position\") = %d\n", iLocPosition); 102 | 103 | iLocFillColor = glGetAttribLocation(programID, "a_v4FillColor"); 104 | printf("glGetAttribLocation(\"a_v4FillColor\") = %d\n", iLocFillColor); 105 | 106 | iLocMVP = glGetUniformLocation(programID, "mvp"); 107 | 108 | glViewport(0, 0, width, height); 109 | 110 | glClearColor(0.0f, 0.0f, 0.2f, 1.0f); 111 | glClearDepthf(1.0f); 112 | return true; 113 | } 114 | 115 | void GraphicsUpdate(void) 116 | { 117 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 118 | 119 | glUseProgram(programID); 120 | glVertexAttribPointer(iLocPosition, 3, GL_FLOAT, GL_FALSE, 0, triangleVertices); 121 | 122 | glEnableVertexAttribArray(iLocPosition); 123 | 124 | if(iLocFillColor != -1) 125 | { 126 | glVertexAttribPointer(iLocFillColor, 4, GL_FLOAT, GL_FALSE, 0, triangleColors); 127 | glEnableVertexAttribArray(iLocFillColor); 128 | } 129 | 130 | static float rotateangleX = 0, rotateangleY = 0, rotateangleZ = 0; 131 | XMatrixAPI modelView = XMatrixAPI::createRotationX(rotateangleX); 132 | XMatrixAPI rotation = XMatrixAPI::createRotationY(rotateangleY); 133 | 134 | modelView = rotation * modelView; 135 | 136 | rotation = XMatrixAPI::createRotationZ(rotateangleZ); 137 | XMatrixAPI translate1 = XMatrixAPI::createTranslation(0.0,0.0,0.0); 138 | 139 | modelView = translate1 *rotation * modelView; 140 | 141 | modelView[14] -= 2.5; 142 | 143 | XMatrixAPI perspective = XMatrixAPI::XMatrixAPIPerspective(45.0f, 1280/720, 0.01f, 100.0f); 144 | XMatrixAPI modelViewPerspective = perspective * modelView; 145 | 146 | glUniformMatrix4fv(iLocMVP, 1, GL_FALSE, modelViewPerspective.getAsArray()); 147 | rotateangleX += 4; 148 | rotateangleY += 3; 149 | rotateangleZ += 2; 150 | 151 | if(rotateangleX >= 360) rotateangleX -= 360; 152 | if(rotateangleX < 0) rotateangleX += 360; 153 | if(rotateangleY >= 360) rotateangleY -= 360; 154 | if(rotateangleY < 0) rotateangleY += 360; 155 | if(rotateangleZ >= 360) rotateangleZ -= 360; 156 | if(rotateangleZ < 0) rotateangleZ += 360; 157 | glDrawArrays(GL_TRIANGLES, 0, 3); 158 | 159 | } 160 | 161 | 162 | int main(int argc, char* argv[]) 163 | { 164 | 165 | XPodium *podium = XPodium::getHandler(); 166 | podium->prepareWindow(SCENE_WIDTH, SCENE_HEIGHT); 167 | CoreEGL::initializeEGL(CoreEGL::OPENGLES2); 168 | eglMakeCurrent(CoreEGL::display, CoreEGL::surface, CoreEGL::surface, CoreEGL::context); 169 | 170 | prepareGraphics(SCENE_WIDTH, SCENE_HEIGHT); 171 | 172 | bool loop = false; 173 | while(!loop) 174 | { 175 | if(podium->checkWindow() != XPodium::WINDOW_IDLE) 176 | { 177 | loop = true; 178 | } 179 | 180 | GraphicsUpdate(); 181 | 182 | eglSwapBuffers(CoreEGL::display, CoreEGL::surface); 183 | } 184 | 185 | CoreEGL::terminateEGL(); 186 | podium->destroyWindow(); 187 | delete podium; 188 | 189 | return 0; 190 | } 191 | 192 | 193 | -------------------------------------------------------------------------------- /TextureMipMapSample/MipMapSample.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file MipMapSample.cpp 36 | * 37 | * This is an test example for OpenGL rendering using this SDK. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Header Files ********************************/ 51 | 52 | 53 | #define LOAD_MIPMAPS 54 | #undef DISABLE_MIPMAPS 55 | 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include "XLinuxPodium.h" 63 | #include "XGLSLCompile.h" 64 | #include "XEGLIntf.h" 65 | #include "XMatrixAPI.h" 66 | #include "XTexture.h" 67 | #include 68 | 69 | using namespace std; 70 | 71 | #define SCENE_WIDTH 800 72 | #define SCENE_HEIGHT 600 73 | 74 | #include "MipMapSample.h" 75 | 76 | 77 | 78 | bool prepareGraphics(int w, int h) 79 | { 80 | string texturePath = resourceDirectory + textureFilename; 81 | string vertexShaderPath = resourceDirectory + vertexShaderFilename; 82 | string fragmentShaderPath = resourceDirectory + fragmentShaderFilename; 83 | glEnable(GL_CULL_FACE); 84 | glCullFace(GL_BACK); 85 | glEnable(GL_DEPTH_TEST); 86 | glEnable(GL_BLEND); 87 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 88 | if (!XTexture::XisETCSupported(true)) 89 | { 90 | printf("ETC1 not supported"); 91 | return false; 92 | } 93 | 94 | #ifdef LOAD_MIPMAPS 95 | XTexture::XloadCompressedMipmaps(texturePath.c_str(), imageExtension.c_str(), &textureID); 96 | #else /* LOAD_MIPMAPS */ 97 | glGenTextures(1, &textureID); 98 | glBindTexture(GL_TEXTURE_2D, textureID); 99 | string mainTexturePath = texturePath + "0" + imageExtension; 100 | unsigned char *textureData; 101 | Texture::loadData(mainTexturePath.c_str(), &textureData); 102 | ETCHeaderforTexture loadedETCHeaderforTexture = ETCHeaderforTexture(textureData); 103 | glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES, 104 | loadedETCHeaderforTexture.getWidth(), loadedETCHeaderforTexture.getHeight(), 0, 105 | loadedETCHeaderforTexture.getPaddedWidth() * loadedETCHeaderforTexture.getPaddedHeight() >> 1, 106 | textureData + 16); 107 | free(textureData); 108 | 109 | # ifdef DISABLE_MIPMAPS 110 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 111 | # else /* DISABLE_MIPMAPS */ 112 | glGenerateMipmap(GL_TEXTURE_2D); 113 | # endif /* DISABLE_MIPMAPS */ 114 | #endif /* LOAD_MIPMAPS */ 115 | 116 | Shader::processShader(&vertexShaderID, vertexShaderPath.c_str(), GL_VERTEX_SHADER); 117 | printf("vertexShaderID = %d", vertexShaderID); 118 | Shader::processShader(&fragmentShaderID, fragmentShaderPath.c_str(), GL_FRAGMENT_SHADER); 119 | printf("fragmentShaderID = %d", fragmentShaderID); 120 | programID = glCreateProgram(); 121 | if (!programID) 122 | { 123 | printf("Could not create program."); 124 | return false; 125 | } 126 | glAttachShader(programID, vertexShaderID); 127 | glAttachShader(programID, fragmentShaderID); 128 | glLinkProgram(programID); 129 | glUseProgram(programID); 130 | 131 | iLocPosition = glGetAttribLocation(programID, "a_v4Position"); 132 | if(iLocPosition == -1) 133 | { 134 | exit(1); 135 | } 136 | glEnableVertexAttribArray(iLocPosition); 137 | 138 | iLocTexCoord = glGetAttribLocation(programID, "a_v2TexCoord"); 139 | if(iLocTexCoord == -1) 140 | { 141 | printf("Warning: Attribute not found: \"a_v2TexCoord\""); 142 | } 143 | else 144 | { 145 | glEnableVertexAttribArray(iLocTexCoord); 146 | } 147 | 148 | iLocSampler = glGetUniformLocation(programID, "u_s2dTexture"); 149 | if(iLocSampler == -1) 150 | { 151 | printf("Warning: Uniform not found: \"u_s2dTexture\""); 152 | } 153 | else 154 | { 155 | glUniform1i(iLocSampler, 0); 156 | } 157 | 158 | glClearColor(0.0f, 0.0f, 0.2f, 1.0); 159 | 160 | return true; 161 | } 162 | 163 | void GraphicsUpdate(void) 164 | { 165 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 166 | 167 | glUseProgram(programID); 168 | 169 | glEnableVertexAttribArray(iLocPosition); 170 | glVertexAttribPointer(iLocPosition, 3, GL_FLOAT, GL_FALSE, 0, vertices); 171 | 172 | if(iLocTexCoord != -1) 173 | { 174 | glVertexAttribPointer(iLocTexCoord, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates); 175 | glEnableVertexAttribArray(iLocTexCoord); 176 | } 177 | 178 | glActiveTexture(GL_TEXTURE0); 179 | glBindTexture(GL_TEXTURE_2D, textureID); 180 | 181 | glDrawElements(GL_TRIANGLE_STRIP, sizeof(indices) / sizeof(GLubyte), GL_UNSIGNED_BYTE, indices); 182 | 183 | } 184 | 185 | int main(void) 186 | { 187 | 188 | XPodium *podium = XPodium::getHandler(); 189 | podium->prepareWindow(SCENE_WIDTH, SCENE_HEIGHT); 190 | CoreEGL::initializeEGL(CoreEGL::OPENGLES2); 191 | eglMakeCurrent(CoreEGL::display, CoreEGL::surface, CoreEGL::surface, CoreEGL::context); 192 | prepareGraphics(SCENE_WIDTH, SCENE_HEIGHT); 193 | 194 | bool end = false; 195 | while(!end) 196 | { 197 | if(podium->checkWindow() != XPodium::WINDOW_IDLE) 198 | { 199 | end = true; 200 | } 201 | GraphicsUpdate(); 202 | 203 | eglSwapBuffers(CoreEGL::display, CoreEGL::surface); 204 | } 205 | 206 | glDeleteTextures(1, &textureID); 207 | CoreEGL::terminateEGL(); 208 | podium->destroyWindow(); 209 | delete podium; 210 | 211 | return 0; 212 | } 213 | -------------------------------------------------------------------------------- /MultiCubeSample/CubeSample.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file CubeSample.cpp 36 | * 37 | * This file implements test application for OpenGL rendering using SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include "XLinuxPodium.h" 60 | #include "CubeSample.h" 61 | #include "XGLSLCompile.h" 62 | #include "XEGLIntf.h" 63 | #include "XMatrixAPI.h" 64 | #include 65 | 66 | using namespace std; 67 | 68 | #define SCENE_WIDTH 800 69 | #define SCENE_HEIGHT 600 70 | 71 | 72 | /* Asset directories and filenames. */ 73 | string resourceDirectory = "Supportingfiles/"; 74 | string vertexShaderFilename = "CubeSample.vert"; 75 | string fragmentShaderFilename = "CubeSample.frag"; 76 | 77 | /* Shader variables. */ 78 | GLuint programID; 79 | GLint iLocPosition = -1; 80 | GLint iLocFillColor = -1; 81 | GLint iLocMVP = -1; 82 | 83 | bool prepareGraphics(int width, int height) 84 | { 85 | printf("prepareGraphics(%d, %d)", width, height); 86 | 87 | string vertexShaderPath = resourceDirectory + vertexShaderFilename; 88 | string fragmentShaderPath = resourceDirectory + fragmentShaderFilename; 89 | 90 | GLuint vertexShaderID = 0; 91 | GLuint fragmentShaderID = 0; 92 | 93 | glEnable(GL_DEPTH_TEST); 94 | glDepthFunc(GL_LEQUAL); 95 | 96 | glEnable(GL_BLEND); 97 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 98 | 99 | Shader::processShader(&vertexShaderID, vertexShaderPath.c_str(), GL_VERTEX_SHADER); 100 | Shader::processShader(&fragmentShaderID, fragmentShaderPath.c_str(), GL_FRAGMENT_SHADER); 101 | 102 | programID = glCreateProgram(); 103 | if (programID == 0) 104 | { 105 | printf("Could not create program."); 106 | return false; 107 | } 108 | 109 | glAttachShader(programID, vertexShaderID); 110 | glAttachShader(programID, fragmentShaderID); 111 | glLinkProgram(programID); 112 | glUseProgram(programID); 113 | 114 | iLocPosition = glGetAttribLocation(programID, "a_v4Position"); 115 | 116 | iLocFillColor = glGetAttribLocation(programID, "a_v4FillColor"); 117 | 118 | iLocMVP = glGetUniformLocation(programID, "mvp"); 119 | 120 | glViewport(0, 0, width, height); 121 | 122 | glClearColor(0.0f, 0.0f, 0.2f, 1.0f); 123 | glClearDepthf(1.0f); 124 | return true; 125 | } 126 | 127 | void GraphicsUpdate(void) 128 | { 129 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 130 | glUseProgram(programID); 131 | glVertexAttribPointer(iLocPosition, 3, GL_FLOAT, GL_FALSE, 0, cubeVertices); 132 | glEnableVertexAttribArray(iLocPosition); 133 | 134 | if(iLocFillColor != -1) 135 | { 136 | glVertexAttribPointer(iLocFillColor, 3, GL_FLOAT, GL_FALSE, 0, cubeColors); 137 | glEnableVertexAttribArray(iLocFillColor); 138 | } 139 | 140 | static float angleX = 0, angleY = 0, angleZ = 0; 141 | XMatrixAPI modelView = XMatrixAPI::createRotationX(angleX); 142 | XMatrixAPI rotation = XMatrixAPI::createRotationY(angleY); 143 | modelView = rotation * modelView; 144 | rotation = XMatrixAPI::createRotationZ(angleZ); 145 | XMatrixAPI translate1 = XMatrixAPI::createTranslation(-1.0,0.0,0.0); 146 | modelView = translate1 *rotation * modelView; 147 | modelView[14] -= 4.5; 148 | XMatrixAPI perspective = XMatrixAPI::XMatrixAPIPerspective(45.0f, 1280/720, 0.01f, 100.0f); 149 | XMatrixAPI modelViewPerspective = perspective * modelView; 150 | glUniformMatrix4fv(iLocMVP, 1, GL_FALSE, modelViewPerspective.getAsArray()); 151 | angleX += 4; 152 | angleY += 3; 153 | angleZ += 2; 154 | if(angleX >= 360) angleX -= 360; 155 | if(angleX < 0) angleX += 360; 156 | if(angleY >= 360) angleY -= 360; 157 | if(angleY < 0) angleY += 360; 158 | if(angleZ >= 360) angleZ -= 360; 159 | if(angleZ < 0) angleZ += 360; 160 | glDrawArrays(GL_TRIANGLES, 0, 36); 161 | 162 | 163 | static float angle1X = 0, angle1Y = 0, angle1Z = 0; 164 | XMatrixAPI modelView1 = XMatrixAPI::createRotationX(angle1X); 165 | XMatrixAPI rotation1 = XMatrixAPI::createRotationY(angle1Y); 166 | modelView1 = rotation1 * modelView1; 167 | rotation1 = XMatrixAPI::createRotationZ(angle1Z); 168 | XMatrixAPI translate2 = XMatrixAPI::createTranslation(1.0,0.0,0.0); 169 | modelView1 = translate2 *rotation1 * modelView1; 170 | modelView1[14] -= 4.5; 171 | XMatrixAPI perspective1 = XMatrixAPI::XMatrixAPIPerspective(45.0f, 1280/720, 0.01f, 100.0f); 172 | XMatrixAPI modelViewPerspective1 = perspective1 * modelView1; 173 | glUniformMatrix4fv(iLocMVP, 1, GL_FALSE, modelViewPerspective1.getAsArray()); 174 | angle1X += 2; 175 | angle1Y += 3; 176 | angle1Z += 4; 177 | if(angle1X >= 360) angle1X -= 360; 178 | if(angle1X < 0) angle1X += 360; 179 | if(angle1Y >= 360) angle1Y -= 360; 180 | if(angle1Y < 0) angle1Y += 360; 181 | if(angle1Z >= 360) angle1Z -= 360; 182 | if(angle1Z < 0) angle1Z += 360; 183 | glDrawArrays(GL_TRIANGLES, 0, 36); 184 | 185 | } 186 | 187 | 188 | int main(int argc, char* argv[]) 189 | { 190 | 191 | XPodium *podium = XPodium::getHandler(); 192 | podium->prepareWindow(SCENE_WIDTH, SCENE_HEIGHT); 193 | CoreEGL::initializeEGL(CoreEGL::OPENGLES2); 194 | eglMakeCurrent(CoreEGL::display, CoreEGL::surface, CoreEGL::surface, CoreEGL::context); 195 | prepareGraphics(SCENE_WIDTH, SCENE_HEIGHT); 196 | 197 | bool end = false; 198 | while(!end) 199 | { 200 | if(podium->checkWindow() != XPodium::WINDOW_IDLE) 201 | { 202 | end = true; 203 | } 204 | 205 | 206 | GraphicsUpdate(); 207 | eglSwapBuffers(CoreEGL::display, CoreEGL::surface); 208 | } 209 | 210 | CoreEGL::terminateEGL(); 211 | podium->destroyWindow(); 212 | delete podium; 213 | 214 | return 0; 215 | } 216 | 217 | 218 | -------------------------------------------------------------------------------- /YUV2RGBSample/YUV2RGBonGPUSample.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file YUV2RGBonGPUSample.cpp 36 | * 37 | * This file implements test application for OpenGL rendering using SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include "XLinuxPodium.h" 60 | #include "YUV2RGBonGPUSample.h" 61 | #include "XGLSLCompile.h" 62 | #include "XEGLIntf.h" 63 | #include "XMatrixAPI.h" 64 | #include "string" 65 | 66 | 67 | #define SCENE_WIDTH 800 68 | #define SCENE_HEIGHT 600 69 | 70 | using std::string; 71 | 72 | string resourceDirectory = "Supportingfiles/"; 73 | string vertexShaderFilename = "YUV2RGBonGPUSample.vert"; 74 | string fragmentShaderFilename = "YUV2RGBonGPUSample.frag"; 75 | 76 | GLuint programID; 77 | GLint iLocPosition = -1; 78 | GLint itimeLocation = -1; 79 | GLint iLocMVP = -1; 80 | GLint iLocTexture = -1; 81 | 82 | //YUV file 83 | GLuint id_y, id_u, id_v; // Texture id 84 | GLuint textureUniformY, textureUniformU, textureUniformV; 85 | 86 | const int pixel_w = 640, pixel_h = 480; 87 | FILE *infile = NULL; 88 | unsigned char buf[pixel_w*pixel_h * 3 / 2]; 89 | unsigned char *plane[3]; 90 | 91 | 92 | 93 | bool prepareGraphics(int width, int height) 94 | { 95 | printf("setupGraphics(%d, %d)", width, height); 96 | string vertexShaderPath = resourceDirectory + vertexShaderFilename; 97 | string fragmentShaderPath = resourceDirectory + fragmentShaderFilename; 98 | 99 | GLuint vertexShaderID = 0; 100 | GLuint fragmentShaderID = 0; 101 | 102 | glEnable(GL_DEPTH_TEST); 103 | glDepthFunc(GL_LEQUAL); 104 | 105 | glEnable(GL_BLEND); 106 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 107 | 108 | Shader::processShader(&vertexShaderID, vertexShaderPath.c_str(), GL_VERTEX_SHADER); 109 | printf("vertexShaderID = %d", vertexShaderID); 110 | Shader::processShader(&fragmentShaderID, fragmentShaderPath.c_str(), GL_FRAGMENT_SHADER); 111 | printf("fragmentShaderID = %d", fragmentShaderID); 112 | 113 | programID = glCreateProgram(); 114 | if (programID == 0) 115 | { 116 | printf("Could not create program."); 117 | return false; 118 | } 119 | 120 | glAttachShader(programID, vertexShaderID); 121 | glAttachShader(programID, fragmentShaderID); 122 | glLinkProgram(programID); 123 | glUseProgram(programID); 124 | 125 | iLocPosition = glGetAttribLocation(programID, "av4position"); 126 | iLocTexture = glGetAttribLocation(programID, "av3colour"); 127 | iLocMVP = glGetUniformLocation(programID, "mvp"); 128 | textureUniformY = glGetUniformLocation(programID, "tex_y"); 129 | textureUniformU = glGetUniformLocation(programID, "tex_u"); 130 | textureUniformV = glGetUniformLocation(programID, "tex_v"); 131 | 132 | glEnable(GL_CULL_FACE); 133 | glEnable(GL_DEPTH_TEST); 134 | 135 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 136 | 137 | glUseProgram (programID); 138 | glEnableVertexAttribArray(iLocPosition); 139 | glEnableVertexAttribArray(iLocTexture); 140 | glVertexAttribPointer(iLocPosition, 2, GL_FLOAT, GL_FALSE, 0, vertexVertices); 141 | glVertexAttribPointer(iLocTexture, 2, GL_FLOAT, GL_FALSE, 0, textureVertices); 142 | 143 | glGenTextures(1, &id_y); 144 | glBindTexture(GL_TEXTURE_2D, id_y); 145 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 146 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 147 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 148 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 149 | 150 | glGenTextures(1, &id_u); 151 | glBindTexture(GL_TEXTURE_2D, id_u); 152 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 153 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 154 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 155 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 156 | 157 | glGenTextures(1, &id_v); 158 | glBindTexture(GL_TEXTURE_2D, id_v); 159 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 160 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 161 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 162 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 163 | 164 | 165 | return true; 166 | } 167 | 168 | void GraphicsUpdate(float time) 169 | { 170 | 171 | static float angleX = 0, angleY = 0, angleZ = 0; 172 | XMatrixAPI modelView = XMatrixAPI::createRotationX(angleX); 173 | XMatrixAPI rotation = XMatrixAPI::createRotationY(angleY); 174 | modelView = rotation * modelView; 175 | modelView[14] -= 1.5; 176 | 177 | XMatrixAPI perspective = XMatrixAPI::XMatrixAPIPerspective(45.0f, 800/600, 0.01f, 100.0f); 178 | XMatrixAPI modelViewPerspective = perspective * modelView; 179 | 180 | glUniformMatrix4fv(iLocMVP, 1, GL_FALSE, modelViewPerspective.getAsArray()); 181 | 182 | 183 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 184 | 185 | 186 | if (fread(buf, 1, pixel_w*pixel_h * 3 / 2, infile) != pixel_w*pixel_h * 3 / 2) { 187 | fseek(infile, 0, SEEK_SET); 188 | fread(buf, 1, pixel_w*pixel_h * 3 / 2, infile); 189 | } 190 | 191 | glClearColor(0.0, 0.0, 0.0, 0.0); 192 | glClear(GL_COLOR_BUFFER_BIT); 193 | 194 | //Y 195 | glActiveTexture(GL_TEXTURE0); 196 | glBindTexture(GL_TEXTURE_2D, id_y); 197 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pixel_w, pixel_h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, plane[0]); 198 | glUniform1i(textureUniformY, 0); 199 | //U 200 | glActiveTexture(GL_TEXTURE1); 201 | glBindTexture(GL_TEXTURE_2D, id_u); 202 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pixel_w / 2, pixel_h / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, plane[1]); 203 | glUniform1i(textureUniformU, 1); 204 | //V 205 | glActiveTexture(GL_TEXTURE2); 206 | glBindTexture(GL_TEXTURE_2D, id_v); 207 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pixel_w / 2, pixel_h / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, plane[2]); 208 | glUniform1i(textureUniformV, 2); 209 | 210 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 211 | 212 | } 213 | 214 | 215 | int main(int argc, char* argv[]) 216 | { 217 | 218 | XPodium *podium = XPodium::getHandler(); 219 | podium->prepareWindow(SCENE_WIDTH, SCENE_HEIGHT); 220 | CoreEGL::initializeEGL(CoreEGL::OPENGLES2); 221 | eglMakeCurrent(CoreEGL::display, CoreEGL::surface, CoreEGL::surface, CoreEGL::context); 222 | 223 | //Open YUV420P file 224 | string rawyuvfile = resourceDirectory + "out.yuv"; 225 | 226 | if ((infile = fopen(rawyuvfile.c_str(), "rb")) == NULL) { 227 | printf("cannot open out.yuv file\n"); 228 | return -1; 229 | } 230 | 231 | //YUV Data 232 | plane[0] = buf; 233 | plane[1] = plane[0] + pixel_w*pixel_h; 234 | plane[2] = plane[1] + pixel_w*pixel_h / 4; 235 | 236 | prepareGraphics(SCENE_WIDTH, SCENE_HEIGHT); 237 | 238 | bool end = false; 239 | float i = 0.0f; 240 | while(!end) 241 | { 242 | if(podium->checkWindow() != XPodium::WINDOW_IDLE) 243 | { 244 | end = true; 245 | } 246 | GraphicsUpdate(i); 247 | eglSwapBuffers(CoreEGL::display, CoreEGL::surface); 248 | 249 | if(i<=10000) 250 | i= i + 0.04f; 251 | else 252 | i=0; 253 | 254 | } 255 | CoreEGL::terminateEGL(); 256 | podium->destroyWindow(); 257 | delete podium; 258 | return 0; 259 | } 260 | 261 | 262 | -------------------------------------------------------------------------------- /Coreframework/XTexture.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file Texture.cpp 36 | * 37 | * This file implements all the functions related to texture compression techniques. 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | 54 | #include "XTexture.h" 55 | #include "XCompressionTexture.h" 56 | #include "XPodium.h" 57 | 58 | #include 59 | 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | using std::string; 66 | 67 | 68 | 69 | void XTexture::XloadPKMData(const char *filename, ETCHeaderforTexture* etcHeader, unsigned char **textureData) 70 | { 71 | const int sizeOfETCHeaderforTexture = 16; 72 | unsigned char* tempTextureData = NULL; 73 | 74 | XloadData(filename, &tempTextureData); 75 | 76 | if (textureData == NULL) 77 | { 78 | exit(1); 79 | } 80 | if (etcHeader == NULL) 81 | { 82 | exit(1); 83 | } 84 | 85 | if (tempTextureData != NULL) 86 | { 87 | ETCHeaderforTexture tempEtcHeader(tempTextureData); 88 | 89 | *etcHeader = tempEtcHeader; 90 | *textureData = tempTextureData + sizeOfETCHeaderforTexture; 91 | } 92 | else 93 | { 94 | exit(1); 95 | } 96 | } 97 | 98 | void XTexture::XloadCompressedMipmaps(const char *filenameBase, const char *filenameSuffix, GLuint *textureID) 99 | { 100 | glGenTextures(1, textureID); 101 | glBindTexture(GL_TEXTURE_2D, *textureID); 102 | 103 | string filename = filenameBase + string("0") + filenameSuffix; 104 | unsigned char *data = NULL; 105 | XloadData(filename.c_str(), &data); 106 | ETCHeaderforTexture loadedETCHeaderforTexture = ETCHeaderforTexture(data); 107 | 108 | int width = loadedETCHeaderforTexture.getWidth(); 109 | int height = loadedETCHeaderforTexture.getHeight(); 110 | int numberOfMipmaps = 1; 111 | while((width > 1) || (height > 1)) 112 | { 113 | numberOfMipmaps ++; 114 | if(width > 1) width >>= 1; 115 | if(height > 1) height >>= 1; 116 | } 117 | 118 | glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_ETC1_RGB8_OES, loadedETCHeaderforTexture.getWidth(), loadedETCHeaderforTexture.getHeight(), 0, (loadedETCHeaderforTexture.getPaddedWidth() * loadedETCHeaderforTexture.getPaddedHeight()) >> 1, data + 16); 119 | free(data); 120 | data = NULL; 121 | 122 | for(int allMipmaps = 1; allMipmaps < numberOfMipmaps; allMipmaps++) 123 | { 124 | char *level = NULL; 125 | int input = allMipmaps; 126 | int inputLength = 0; 127 | 128 | do 129 | { 130 | input /= 10; 131 | inputLength ++; 132 | } 133 | while(input != 0); 134 | 135 | level = (char *)calloc(inputLength + 1, sizeof(char)); 136 | if(level == NULL) 137 | { 138 | exit(1); 139 | } 140 | sprintf(level, "%i", allMipmaps); 141 | 142 | filename = filenameBase + string(level) + filenameSuffix; 143 | XloadData(filename.c_str(), &data); 144 | free(level); 145 | level = NULL; 146 | loadedETCHeaderforTexture = ETCHeaderforTexture(data); 147 | 148 | glCompressedTexImage2D(GL_TEXTURE_2D, allMipmaps, GL_ETC1_RGB8_OES, loadedETCHeaderforTexture.getWidth(), loadedETCHeaderforTexture.getHeight(), 0, (loadedETCHeaderforTexture.getPaddedWidth() * loadedETCHeaderforTexture.getPaddedHeight()) >> 1, data + 16); 149 | free(data); 150 | data = NULL; 151 | } 152 | } 153 | 154 | void XTexture::XgetCompressedTextureFormats(GLint** textureFormats, int* numberOfTextureFormats) 155 | { 156 | glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, numberOfTextureFormats); 157 | 158 | *textureFormats = (GLint *)calloc(*numberOfTextureFormats, sizeof(GLint)); 159 | if(*textureFormats == NULL) 160 | { 161 | exit(1); 162 | } 163 | 164 | glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, *textureFormats); 165 | } 166 | 167 | bool XTexture::XisETCSupported(bool verbose) 168 | { 169 | bool supportETC = false; 170 | GLint *textureFormat = NULL; 171 | GLint numberOfTextureFormats = 0; 172 | XgetCompressedTextureFormats(&textureFormat, &numberOfTextureFormats); 173 | 174 | if (verbose != 0) 175 | { 176 | for(int allTextureFormats = 0; allTextureFormats < numberOfTextureFormats; allTextureFormats++) 177 | { 178 | switch(textureFormat[allTextureFormats]) 179 | { 180 | case GL_ETC1_RGB8_OES: 181 | break; 182 | default: 183 | break; 184 | } 185 | } 186 | } 187 | 188 | for(int allTextureFormats = 0; allTextureFormats < numberOfTextureFormats; allTextureFormats++) 189 | { 190 | if (textureFormat[allTextureFormats] == GL_ETC1_RGB8_OES) 191 | { 192 | supportETC = true; 193 | } 194 | } 195 | 196 | free(textureFormat); 197 | textureFormat = NULL; 198 | 199 | if(!supportETC) 200 | { 201 | printf("BAD ETC\n"); 202 | } 203 | return supportETC; 204 | } 205 | 206 | void XTexture::XcreateTexture(unsigned int width, unsigned int height, GLvoid **textureData) 207 | { 208 | unsigned char *randomTexture = new unsigned char [width * height * 4]; 209 | if(randomTexture == NULL) 210 | { 211 | exit(1); 212 | } 213 | 214 | for(unsigned int allTexels = 0; allTexels < width * height; allTexels ++) 215 | { 216 | randomTexture[allTexels * 4 + 3] = 255; 217 | for (int allChannels = 0; allChannels < 3; allChannels++) 218 | { 219 | int randomNumber = (int)(255 * (rand() / (float)RAND_MAX)); 220 | randomTexture[allTexels * 4 + allChannels] = randomNumber; 221 | } 222 | } 223 | 224 | *textureData = randomTexture; 225 | } 226 | 227 | void XTexture::XcreateTexture(unsigned int width, unsigned int height, unsigned int red, GLvoid **textureData) 228 | { 229 | unsigned char* newTexture = new unsigned char [width * height]; 230 | 231 | if(newTexture == NULL) 232 | { 233 | exit(1); 234 | } 235 | 236 | for (unsigned int texelIndex = 0; texelIndex < width * height; ++texelIndex) 237 | { 238 | newTexture[texelIndex] = red; 239 | } 240 | *textureData = newTexture; 241 | } 242 | 243 | void XTexture::XcreateTexture(unsigned int width, unsigned int height, short red, short **textureData) 244 | { 245 | *textureData = new short [width * height]; 246 | 247 | if (*textureData == NULL) 248 | { 249 | exit(1); 250 | } 251 | 252 | for (unsigned int texelIndex = 0; texelIndex < width * height; ++texelIndex) 253 | { 254 | (*textureData)[texelIndex] = red; 255 | } 256 | } 257 | 258 | void XTexture::XdeleteTextureData(GLvoid** textureData) 259 | { 260 | delete[] (unsigned char*)*textureData; 261 | } 262 | 263 | void XTexture::XloadData(const char *filename, unsigned char **textureData) 264 | { 265 | 266 | FILE *file = fopen(filename, "rb"); 267 | if(file == NULL) 268 | { 269 | exit(1); 270 | } 271 | fseek(file, 0, SEEK_END); 272 | unsigned int length = ftell(file); 273 | unsigned char *loadedTexture = (unsigned char *)calloc(length, sizeof(unsigned char)); 274 | if(loadedTexture == NULL) 275 | { 276 | exit(1); 277 | } 278 | fseek(file, 0, SEEK_SET); 279 | size_t read = fread(loadedTexture, sizeof(unsigned char), length, file); 280 | if(read != length) 281 | { 282 | exit(1); 283 | } 284 | fclose(file); 285 | 286 | *textureData = loadedTexture; 287 | } 288 | 289 | void XTexture::XreversePixelLine(float* destination, const float* source, int lineWidth) 290 | { 291 | const int rgbComponentsCount = 3; 292 | 293 | for (int pixelIndex = 0; pixelIndex < lineWidth; ++pixelIndex) 294 | { 295 | memcpy(destination + pixelIndex * rgbComponentsCount, 296 | source + (lineWidth - pixelIndex - 1) * rgbComponentsCount, 297 | rgbComponentsCount * sizeof(float)); 298 | } 299 | } 300 | -------------------------------------------------------------------------------- /FrameBufferObject-FBOSample/FBOSample.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * Copyright (C) 2023 Xilinx, Inc. All rights reserved. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to deal 7 | * in the Software without restriction, including without limitation the rights 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * Use of the Software is limited solely to applications: 16 | * (a) running on a Xilinx device, or 17 | * (b) that interact with a Xilinx device through a bus or interconnect. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 24 | * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | * SOFTWARE. 26 | * 27 | * Except as contained in this notice, the name of the Xilinx shall not be used 28 | * in advertising or otherwise to promote the sale, use or other dealings in 29 | * this Software without prior written authorization from Xilinx. 30 | * 31 | *******************************************************************************/ 32 | /******************************************************************************/ 33 | /** 34 | * 35 | * @file FBOSample.cpp 36 | * 37 | * This file implements test application for OpenGL rendering using SDK 38 | * 39 | * @note None. 40 | * 41 | *
 42 |  * MODIFICATION HISTORY:
 43 |  *
 44 |  * Ver   Who            Date            Changes
 45 |  * ----- ----           --------        -----------------------------------------------
 46 |  * 1.0   Alok G         10/06/17        Initial release.
 47 |  * 
48 | * 49 | *******************************************************************************/ 50 | /******************************* Source Files ********************************/ 51 | 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include "XLinuxPodium.h" 60 | #include "FBOSample.h" 61 | #include "XGLSLCompile.h" 62 | #include "XEGLIntf.h" 63 | #include "XMatrixAPI.h" 64 | #include 65 | 66 | using namespace std; 67 | 68 | #define SCENE_WIDTH 800 69 | #define SCENE_HEIGHT 600 70 | 71 | 72 | string resourceDirectory = "Supportingfiles/"; 73 | string vertexShaderFilename = "FrameBufferObject_cube.vert"; 74 | string fragmentShaderFilename = "FrameBufferObject_cube.frag"; 75 | 76 | #define FBO_WIDTH 256 77 | #define FBO_HEIGHT 256 78 | 79 | GLuint vertexShaderID = 0; 80 | GLuint fragmentShaderID = 0; 81 | GLuint programID = 0; 82 | GLint iLocPosition = -1; 83 | GLint iLocTextureMix = -1; 84 | GLint iLocTexture = -1; 85 | GLint iLocFillColor = -1; 86 | GLint iLocTexCoord = -1; 87 | GLint iLocProjection = -1; 88 | GLint iLocModelview = -1; 89 | 90 | static float angleX = 0; 91 | static float angleY = 0; 92 | static float angleZ = 0; 93 | XMatrixAPI rotationX; 94 | XMatrixAPI rotationY; 95 | XMatrixAPI rotationZ; 96 | XMatrixAPI translation; 97 | XMatrixAPI modelView; 98 | XMatrixAPI projection; 99 | XMatrixAPI projectionFBO; 100 | 101 | GLuint iFBO = 0; 102 | 103 | GLuint iFBOTex = 0; 104 | 105 | int windowWidth = -1; 106 | int windowHeight = -1; 107 | 108 | bool prepareGraphics(int width, int height) 109 | { 110 | windowWidth = width; 111 | windowHeight = height; 112 | 113 | string vertexShaderPath = resourceDirectory + vertexShaderFilename; 114 | string fragmentShaderPath = resourceDirectory + fragmentShaderFilename; 115 | 116 | projection = XMatrixAPI::XMatrixAPIPerspective(45.0f, windowWidth/(float)windowHeight, 0.01f, 100.0f); 117 | projectionFBO = XMatrixAPI::XMatrixAPIPerspective(45.0f, (FBO_WIDTH / (float)FBO_HEIGHT), 0.01f, 100.0f); 118 | translation = XMatrixAPI::createTranslation(0.0f, 0.0f, -2.0f); 119 | 120 | glEnable(GL_CULL_FACE); 121 | glCullFace(GL_BACK); 122 | glEnable(GL_DEPTH_TEST); 123 | glEnable(GL_BLEND); 124 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 125 | 126 | glGenTextures(1, &iFBOTex); 127 | glBindTexture(GL_TEXTURE_2D, iFBOTex); 128 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 129 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 130 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FBO_WIDTH, FBO_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 131 | 132 | glGenFramebuffers(1, &iFBO); 133 | 134 | glBindFramebuffer(GL_FRAMEBUFFER, iFBO); 135 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, iFBOTex, 0); 136 | GLenum iResult = glCheckFramebufferStatus(GL_FRAMEBUFFER); 137 | if(iResult != GL_FRAMEBUFFER_COMPLETE) 138 | { 139 | printf("Framebuffer incomplete at %s:%i\n", __FILE__, __LINE__); 140 | return false; 141 | } 142 | 143 | glBindFramebuffer(GL_FRAMEBUFFER, 0); 144 | 145 | Shader::processShader(&vertexShaderID, vertexShaderPath.c_str(), GL_VERTEX_SHADER); 146 | Shader::processShader(&fragmentShaderID, fragmentShaderPath.c_str(), GL_FRAGMENT_SHADER); 147 | 148 | programID = glCreateProgram(); 149 | glAttachShader(programID, vertexShaderID); 150 | glAttachShader(programID, fragmentShaderID); 151 | glLinkProgram(programID); 152 | glUseProgram(programID); 153 | 154 | iLocPosition = glGetAttribLocation(programID, "a_v4Position"); 155 | if(iLocPosition == -1) 156 | { 157 | printf("Attribute not found at %s:%i\n", __FILE__, __LINE__); 158 | return false; 159 | } 160 | glEnableVertexAttribArray(iLocPosition); 161 | 162 | iLocTextureMix = glGetUniformLocation(programID, "u_fTex"); 163 | if(iLocTextureMix == -1) 164 | { 165 | printf("Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__); 166 | } 167 | else 168 | { 169 | glUniform1f(iLocTextureMix, 0.0); 170 | } 171 | 172 | iLocTexture = glGetUniformLocation(programID, "u_s2dTexture"); 173 | if(iLocTexture == -1) 174 | { 175 | printf("Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__); 176 | } 177 | else 178 | { 179 | glUniform1i(iLocTexture, 0); 180 | } 181 | 182 | iLocFillColor = glGetAttribLocation(programID, "a_v4FillColor"); 183 | if(iLocFillColor == -1) 184 | { 185 | printf("Warning: Attribute not found at %s:%i\n", __FILE__, __LINE__); 186 | } 187 | else 188 | { 189 | glEnableVertexAttribArray(iLocFillColor); 190 | } 191 | 192 | iLocTexCoord = glGetAttribLocation(programID, "a_v2TexCoord"); 193 | if(iLocTexCoord == -1) 194 | { 195 | printf("Warning: Attribute not found at %s:%i\n", __FILE__, __LINE__); 196 | } 197 | else 198 | { 199 | glEnableVertexAttribArray(iLocTexCoord); 200 | } 201 | 202 | iLocProjection = glGetUniformLocation(programID, "u_m4Projection"); 203 | if(iLocProjection == -1) 204 | { 205 | printf("Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__); 206 | } 207 | else 208 | { 209 | glUniformMatrix4fv(iLocProjection, 1, GL_FALSE, projection.getAsArray()); 210 | } 211 | 212 | iLocModelview = glGetUniformLocation(programID, "u_m4Modelview"); 213 | if(iLocModelview == -1) 214 | { 215 | printf("Warning: Uniform not found at %s:%i\n", __FILE__, __LINE__); 216 | } 217 | 218 | return true; 219 | } 220 | 221 | void GraphicsUpdate(void) 222 | { 223 | glUseProgram(programID); 224 | glEnableVertexAttribArray(iLocPosition); 225 | glVertexAttribPointer(iLocPosition, 3, GL_FLOAT, GL_FALSE, 0, cubeVertices); 226 | 227 | if(iLocFillColor != -1) 228 | { 229 | glEnableVertexAttribArray(iLocFillColor); 230 | glVertexAttribPointer(iLocFillColor, 4, GL_FLOAT, GL_FALSE, 0, cubeColors); 231 | } 232 | 233 | if(iLocTexCoord != -1) 234 | { 235 | glEnableVertexAttribArray(iLocTexCoord); 236 | glVertexAttribPointer(iLocTexCoord, 2, GL_FLOAT, GL_FALSE, 0, cubeTextureCoordinates); 237 | } 238 | 239 | glBindFramebuffer(GL_FRAMEBUFFER, iFBO); 240 | glViewport(0, 0, FBO_WIDTH, FBO_HEIGHT); 241 | 242 | glClearColor(1.0f, 0.8f, 0.1f, 1.0f); 243 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 244 | 245 | rotationX = XMatrixAPI::createRotationX(-angleZ); 246 | rotationY = XMatrixAPI::createRotationY(-angleY); 247 | rotationZ = XMatrixAPI::createRotationZ(-angleX); 248 | 249 | modelView = translation * rotationX; 250 | modelView = modelView * rotationY; 251 | modelView = modelView * rotationZ; 252 | 253 | glUniformMatrix4fv(iLocModelview, 1, GL_FALSE, modelView.getAsArray()); 254 | glUniformMatrix4fv(iLocProjection, 1, GL_FALSE, projectionFBO.getAsArray()); 255 | 256 | if(iLocTextureMix != -1) 257 | { 258 | glUniform1f(iLocTextureMix, 0.0); 259 | } 260 | 261 | glDrawElements(GL_TRIANGLE_STRIP, sizeof(cubeIndices) / sizeof(GLubyte), GL_UNSIGNED_BYTE, cubeIndices); 262 | 263 | glBindFramebuffer(GL_FRAMEBUFFER,0); 264 | 265 | glViewport(0, 0, windowWidth, windowHeight); 266 | 267 | glClearColor(0.0f, 0.0f, 0.2f, 1.0); 268 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 269 | 270 | rotationX = XMatrixAPI::createRotationX(angleX); 271 | rotationY = XMatrixAPI::createRotationY(angleY); 272 | rotationZ = XMatrixAPI::createRotationZ(angleZ); 273 | 274 | modelView = translation * rotationX; 275 | modelView = modelView * rotationY; 276 | modelView = modelView * rotationZ; 277 | 278 | glUniformMatrix4fv(iLocModelview, 1, GL_FALSE, modelView.getAsArray()); 279 | glUniformMatrix4fv(iLocProjection, 1, GL_FALSE, projection.getAsArray()); 280 | 281 | if(iLocTextureMix != -1) 282 | { 283 | glUniform1f(iLocTextureMix, 1.0); 284 | } 285 | 286 | glActiveTexture(GL_TEXTURE0); 287 | glBindTexture(GL_TEXTURE_2D, iFBOTex); 288 | 289 | glDrawElements(GL_TRIANGLE_STRIP, sizeof(cubeIndices) / sizeof(GLubyte), GL_UNSIGNED_BYTE, cubeIndices); 290 | 291 | angleX += 0.2; 292 | angleY += 0.2; 293 | angleZ += 0; 294 | 295 | if(angleX >= 360) angleX -= 360; 296 | if(angleY >= 360) angleY -= 360; 297 | if(angleZ >= 360) angleZ -= 360; 298 | } 299 | 300 | int main(void) 301 | { 302 | XPodium *podium = XPodium::getHandler(); 303 | podium->prepareWindow(SCENE_WIDTH, SCENE_HEIGHT); 304 | CoreEGL::initializeEGL(CoreEGL::OPENGLES2); 305 | eglMakeCurrent(CoreEGL::display, CoreEGL::surface, CoreEGL::surface, CoreEGL::context); 306 | prepareGraphics(SCENE_WIDTH, SCENE_HEIGHT); 307 | 308 | bool end = false; 309 | while(!end) 310 | { 311 | if(podium->checkWindow() != XPodium::WINDOW_IDLE) 312 | { 313 | end = true; 314 | } 315 | GraphicsUpdate(); 316 | eglSwapBuffers(CoreEGL::display, CoreEGL::surface); 317 | } 318 | 319 | CoreEGL::terminateEGL(); 320 | podium->destroyWindow(); 321 | delete podium; 322 | 323 | return 0; 324 | } 325 | --------------------------------------------------------------------------------