Advertisement
CODE_TOLD_FAST

WGL_REF/TexSubImage2D

May 23rd, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //:AUTHOR: John Mark Isaac Madison ( CODE_TOLD_FAST & CODE_TOLD_SLOW )
  2. //:THIS_FILE_ON_PASTEBIN: https://pastebin.com/YeY2CHCX
  3. //:YOUTUBE_VIDEO_ON_THIS: https://www.youtube.com/watch?v=x2dtAg5I6mk
  4.  
  5. //|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|//
  6. //|                                                          |//
  7. //| [ x_0 , y_0 ]                                            |//
  8. //|        \                                y_0              |//
  9. //|         +-------------+           +------|------+        |//
  10. //|         |             |           |             |        |//
  11. //|         |             |           |             |        |//
  12. //|         |             |    x_0 ___|             |___ x_1 |//
  13. //|         |             |           |             |        |//
  14. //|         |             |           |             |        |//
  15. //|         |             |           |             |        |//
  16. //|         +-------------+           +------|------+        |//
  17. //|                        \                y_1              |//
  18. //|                   [ x_1 , y_1 ]                          |//
  19. //|                                                          |//
  20. //|__________________________________________________________|//
  21.  
  22.  
  23.     |<---- pix_wid ---->|   ||   |<---- pix_wid ---->|
  24.     +-------------------+   ||   +-------------------+
  25.     |                   |   ||   |                   |
  26.     |                   |   ||   |    | cpu_sub |    |
  27.     |                   |   ||   |    +---------+    |
  28.     |      cpu_img      |   ||   |    | 256-x-64|    |
  29.     |                   |   ||   |    +---------+    |
  30.     |                   |   ||   |                   |
  31.     |                   |   ||   |                   |
  32.     +-------------------+   ||   +-------------------+
  33.              V              ||            V                    
  34.       gl.texImage2D(...)    ||     gl.texSubImage2D(...)  
  35.              V              ||            V                    
  36.     +-------------------+   ||   +-------------------+
  37.     |                   |   ||   |                   |
  38.     |                   |   ||   |    | gpu_sub |    |
  39.     |                   |   ||   |    +---------+    |
  40.     |      gpu_img      |   ||   |    | 256-x-64|    |
  41.     |                   |   ||   |    +---------+    |
  42.     |                   |   ||   |                   |
  43.     |                   |   ||   |                   |
  44.     +-------------------+   ||   +-------------------+
  45.  
  46.         G = YOUR_WEBGL_CONTEXT_OBJECT;
  47.         G.activeTexture( G.TEXTURE0   +  tex_lot );
  48.         G.bindTexture(   G.TEXTURE_2D ,  tex_han );
  49.         const ALN = 4; //:ALN:"Alignment" GUESS?
  50.         G.pixelStorei(G.UNPACK_ALIGNMENT, ALN);
  51.  
  52.  
  53.         //:CALCULATE_STARTING_OFFSET_IN_BYTES:( src_oib)
  54.         var p_x =( _.cpu_sub.x_0 ); //:TOP_LEF:X
  55.         var p_y =( _.cpu_sub.y_0 ); //:TOP_LEF:Y
  56.         var pix_dex = p_x + ( pix_wid * p_y);
  57.         var src_oip = pix_dex * (  1  );//:PixelOffset
  58.         var src_oib = pix_dex * pix_com;//:ComponentOffset
  59.  
  60.         G.pixelStorei( G.UNPACK_ROW_LENGTH , pix_wid );
  61.         G.texSubImage2D(
  62.         /*  01  */    G.TEXTURE_2D //:TARGET                                                                
  63.         /*  02  */  , 0            //:LEVEL_OF_DETAIL (LOD)                                                  
  64.         /*  03  */  , cpu_sub.x_0  //:TOP_LEFT                                                            
  65.         /*  04  */  , cpu_sub.y_0  //:TOP_LEFT                    
  66.         /*  --  */    ,                                          
  67.         /*  05  */    (   ( _.cpu_sub.x_1 )        //:WIDTH      
  68.         /*  05  */      - ( _.cpu_sub.x_0 ) + 1 )  //:WIDTH      
  69.         /*  --  */    ,                                          
  70.         /*  06  */    (   ( _.cpu_sub.y_1 )        //:HEIGHT      
  71.         /*  06  */      - ( _.cpu_sub.y_0 ) + 1 )  //:HEIGHT                                                    
  72.         /*  07  */    ,   G.RGBA_INTEGER   //:SOURCE_FORMAT      
  73.         /*  08  */    ,   G.UNSIGNED_BYTE  //:SOURCE_TYPE                                                  
  74.         /*  09  */    ,   pix_arr          //:ARRAY_BUFFER_VIEW  
  75.         /*  10  */    ,   src_oib          //:SOURCE_OFFSET                                                      
  76.         );;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement