load_cube_data   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/gl/gl-objects2.xtm

Implementation

(bind-func load_cube_data
  (lambda (tex:Texture* flipped:i32 front:String* back:String* top:String* bottom:String* left:String* right:String*)
    ;; seems to need to be set
    (stbi_set_flip_vertically_on_load flipped)
    (let ((width_ptr:i32* (tref-ptr tex 2))
          (height_ptr:i32* (tref-ptr tex 3))
          (comp_ptr:i32* (salloc))
          (i:i32 0)
          (wp:i32* (salloc 6))
          (hp:i32* (salloc 6))
          (cp:i32* (salloc 6))
          (wpt:i32 0)
          (hpt:i32 0)
          (cpt:i32 0)
          (front_data (stbi_load (cstring front) (pref-ptr wp 0) (pref-ptr hp 0) (pref-ptr cp 0) 4))
          (back_data (stbi_load (cstring back) (pref-ptr wp 1) (pref-ptr hp 1) (pref-ptr cp 1) 4))
          (top_data (stbi_load (cstring top) (pref-ptr wp 2) (pref-ptr hp 2) (pref-ptr cp 2) 4))
          (bottom_data (stbi_load (cstring bottom) (pref-ptr wp 3) (pref-ptr hp 3) (pref-ptr cp 3) 4))
          (left_data (stbi_load (cstring left) (pref-ptr wp 4) (pref-ptr hp 4) (pref-ptr cp 4) 4))
          (right_data (stbi_load (cstring right) (pref-ptr wp 5) (pref-ptr hp 5) (pref-ptr cp 5) 4))
          (w:i32 (pref wp 0))
          (h:i32 (pref hp 0))
          (c:i32 (pref cp 0))
          (whc:i64 (convert (* w h 4))) ;; always 4 channels
          (data:i8* (alloc (* whc 6)))) ;; always allocate 4 channels
      ;; (println "CUBE LOAD: width:" w "height:" h "channels:" c)
      (dotimes (i 6)
        (set! wpt (+ wpt (pref wp i)))
        (set! hpt (+ hpt (pref hp i)))
        (set! cpt (+ cpt (pref cp i))))
      (if (<> (/ wpt 6) w)
          (begin (println "Bad cube map!  All 6 images must have the same width!" w)
                 (set! front_data null)))
      (if (<> (/ hpt 6) h)
          (begin (println "Bad cube map!  All 6 images must have the same height!" h)
                 (set! front_data null)))
      (if (<> (/ cpt 6) c)
          (begin (println "Bad cube map!  All 6 images must have the same number of components" c)
                 (set! front_data null)))
      (pset! width_ptr 0 w)
      (pset! height_ptr 0 h)
      (pset! comp_ptr 0 4) ;; we actually forced (stbi_load ... 4) to 4 channels
      (tset! tex 1 GL_RGBA) ;; 4 componenets
      (if (or (null? front_data)
              (null? back_data)
              (null? top_data)
              (null? bottom_data)
              (null? left_data)
              (null? right_data))
          (begin
            (println "failed to load some images" (stbi_failure_reason))
            1)
          (begin
            ;; front
            (memcpy (pref-ptr data (* whc 0)) front_data whc)
            ;; back
            (memcpy (pref-ptr data (* whc 1)) back_data whc)
            ;; top
            (memcpy (pref-ptr data (* whc 2)) top_data whc)
            ;; bottom
            (memcpy (pref-ptr data (* whc 3)) bottom_data whc)
            ;; left
            (memcpy (pref-ptr data (* whc 4)) left_data whc)
            ;; right
            (memcpy (pref-ptr data (* whc 5)) right_data whc)
            ;; back
            (tset! tex 4 data)
            1))
      void)))


Back to Index

Similar Entries

  • AudioBuffer_data_b64    xtlang
  • AudioBuffer_data_b64_cstring    xtlang
  • AudioBuffer_set_data_b64    xtlang
  • AudioBuffer_shared_data    xtlang
  • Pm_Event_Data1    xtlang
  • Pm_Event_Data2    xtlang
  • Pm_Message_Data1    xtlang
  • Pm_Message_Data2    xtlang
  • QRcode_data    xtlang
  • Texture_bind_data    xtlang
  • Texture_bind_data    xtlang
  • VBO_data    xtlang
  • VBO_update_data    xtlang
  • aiProcess_FindInvalidData    scheme
  • aiProcess_ValidateDataStructure    scheme
  • ai_load_ogl_texture    xtlang
  • ai_load_ogl_texture_from_buffer    xtlang
  • analogue-load-preset    scheme
  • analogue-load-state    scheme
  • assimp_load_model    xtlang
  • assimp_load_model    xtlang
  • assimp_load_model    scheme
  • bind-data    macro
  • bind-data-constructors    scheme
  • bind-data-deconstructors    scheme
  • bind-data-deconstructors-macros    scheme
  • bind-data-getters    scheme
  • bind-data-type    scheme
  • bind-data-type-constructor    scheme
  • bind-data-types    scheme
  • bind_cube    xtlang
  • cerberus-load-preset    scheme
  • cerberus-load-state    scheme
  • clean-cube    xtlang
  • clear_sample_data_    xtlang
  • create_data    xtlang
  • cube_whole    xtlang
  • data    xtlang
  • data    xtlang
  • db_load    xtlang
  • dsp_load    xtlang
  • fits-image-data-R32    xtlang
  • fits-image-data-R32    xtlang
  • fits-image-data-RGBA32    xtlang
  • fits-image-data-RGBA32    xtlang
  • fits-image-data-RGBA32-false    xtlang
  • fits-image-data-RGBA32-false    xtlang
  • fluid-cube-add-density    xtlang
  • fluid-cube-add-density    xtlang
  • fluid-cube-add-velocity    xtlang
  • fluid-cube-add-velocity    xtlang
  • fluid-cube-create    xtlang
  • fluid-cube-create    xtlang
  • fluid-cube-get-column    xtlang
  • fluid-cube-get-first-column    xtlang
  • fluid-cube-get-first-row    xtlang
  • fluid-cube-get-last-column    xtlang
  • fluid-cube-get-last-row    xtlang
  • fluid-cube-get-row    xtlang
  • fluid-cube-set-column    xtlang
  • fluid-cube-set-first-column    xtlang
  • fluid-cube-set-first-row    xtlang
  • fluid-cube-set-last-column    xtlang
  • fluid-cube-set-last-row    xtlang
  • fluid-cube-set-row    xtlang
  • fluid-step-cube    xtlang
  • fluid-step-cube    xtlang
  • fluid_cube_add_density    xtlang
  • fluid_cube_add_velocity    xtlang
  • fluid_cube_create    xtlang
  • fluid_step_cube    xtlang
  • get-fluid-cube    xtlang
  • get-fluid-cube-1    xtlang
  • get-fluid-cube-2    xtlang
  • get_download_handler    xtlang
  • get_fluid_cube    xtlang
  • get_hand_data    xtlang
  • get_load_handler    xtlang
  • glCube    xtlang
  • gl_load_image    xtlang
  • gl_load_image_rect    xtlang
  • gl_load_movie_textures    xtlang
  • gl_load_movie_textures    xtlang
  • gl_load_tex    xtlang
  • gl_load_tex_bgr    xtlang
  • gl_load_tex_ext    xtlang
  • gl_load_tex_ext_bgr    xtlang
  • gl_load_tex_rect    xtlang
  • impc:aot:insert-load-dylib-details    scheme
  • impc:compiler:print-dylib-loading-details-to-log    scheme
  • impc:ti:compile-type-dataconstructors    scheme
  • init_sample_data    xtlang
  • init_sample_data    xtlang
  • ipc:load    scheme
  • is_loading    xtlang
  • lilv_load_plugin    xtlang
  • load-sample    scheme
  • load-sampler    scheme
  • load-tex    xtlang
  • load-tex    xtlang
  • load_assim_material_texture    xtlang
  • load_blep_tables_from_blob    unknown
  • load_data    xtlang
  • load_vg_fonts    xtlang
  • nvg_load_opensans_fonts    xtlang
  • ocv_dataPtr    xtlang
  • ocv_dataPtr    xtlang
  • print-load    scheme
  • reload    xtlang
  • reload_ignore_cache    xtlang
  • set-data-arrays-lines    xtlang
  • set-data-arrays-points    xtlang
  • set-data-particles    xtlang
  • set_sample_data_    xtlang
  • stop_load    xtlang
  • sys:load    scheme
  • sys:load-escape    scheme
  • sys:load-preload-check    scheme
  • sys:load-then-quit    scheme
  • sys_file_datasync    xtlang
  • sys_file_datasync    xtlang
  • unbind_cube    xtlang
  • unbind_cube    xtlang
  • update_cube    xtlang
  • update_data_points    xtlang
  • world_data    xtlang
  • world_data_index    xtlang
  • world_data_size    xtlang
  • xobj_database    xtlang
  • xtm_frame_data_to_tex    xtlang
  • xtm_load_vgimage    xtlang
  • xtm_projection_texture_load    xtlang
  • xtm_set_vgimage_subdata    xtlang