(perspective-texture-meta-3d-example target-width target-height game)

Example

(let [camera (-> (play-cljc.gl.entities-3d/->camera) (play-cljc.transforms/translate 0 0 2) (play-cljc.transforms/look-at [0 0 0] [0 1 0]))] (-> entity (play-cljc.transforms/project (play-cljc.math/deg->rad 60) aspect 1 2000) (play-cljc.transforms/invert camera) (play-cljc.transforms/rotate rx :x) (play-cljc.transforms/rotate ry :y)))

Source

(defn perspective-texture-meta-3d-example [target-width target-height game] (gl game enable (gl game CULL_FACE)) (gl game enable (gl game DEPTH_TEST)) (let [entity (->> {:vertex data/texture-vertex-shader, :fragment data/texture-fragment-shader, :attributes {'a_position {:data data/cube, :type (gl game FLOAT), :size 3}, 'a_texcoord {:data data/cube-texcoords, :type (gl game FLOAT), :size 2, :normalize true}}, :uniforms {'u_texture {:data nil, :opts {:mip-level 0, :internal-fmt (gl game RGBA), :width target-width, :height target-height, :border 0, :src-fmt (gl game RGBA), :src-type (gl game UNSIGNED_BYTE)}, :params {(gl game TEXTURE_WRAP_S) (gl game CLAMP_TO_EDGE), (gl game TEXTURE_WRAP_T) (gl game CLAMP_TO_EDGE), (gl game TEXTURE_MIN_FILTER) (gl game LINEAR)}}}, :clear {:color [1 1 1 1], :depth 1}} e/map->ThreeDEntity (c/compile game)) inner-entity (->> {:vertex data/texture-vertex-shader, :fragment data/texture-fragment-shader, :attributes {'a_position {:data data/cube, :type (gl game FLOAT), :size 3}, 'a_texcoord {:data data/cube-texcoords, :type (gl game FLOAT), :size 2, :normalize true}}, :uniforms {'u_texture {:data [128 64 128 0 192 0], :opts {:mip-level 0, :internal-fmt (gl game R8), :width 3, :height 2, :border 0, :src-fmt (gl game RED), :src-type (gl game UNSIGNED_BYTE)}, :alignment 1, :params {(gl game TEXTURE_WRAP_S) (gl game CLAMP_TO_EDGE), (gl game TEXTURE_WRAP_T) (gl game CLAMP_TO_EDGE), (gl game TEXTURE_MIN_FILTER) (gl game NEAREST), (gl game TEXTURE_MAG_FILTER) (gl game NEAREST)}}}, :clear {:color [0 0 1 1], :depth 1}} e/map->ThreeDEntity (c/compile game)) state {:rx (m/deg->rad 190), :ry (m/deg->rad 40)}] (assoc game :entity entity :inner-entity inner-entity :state state)))