Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //:AUTHOR: John Mark Isaac Madison ( CODE_TOLD_FAST & CODE_TOLD_SLOW )
- //:THIS_FILE_ON_PASTEBIN: https://pastebin.com/YeY2CHCX
- //:YOUTUBE_VIDEO_ON_THIS: https://www.youtube.com/watch?v=x2dtAg5I6mk
- //|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|//
- //| |//
- //| [ x_0 , y_0 ] |//
- //| \ y_0 |//
- //| +-------------+ +------|------+ |//
- //| | | | | |//
- //| | | | | |//
- //| | | x_0 ___| |___ x_1 |//
- //| | | | | |//
- //| | | | | |//
- //| | | | | |//
- //| +-------------+ +------|------+ |//
- //| \ y_1 |//
- //| [ x_1 , y_1 ] |//
- //| |//
- //|__________________________________________________________|//
- |<---- pix_wid ---->| || |<---- pix_wid ---->|
- +-------------------+ || +-------------------+
- | | || | |
- | | || | | cpu_sub | |
- | | || | +---------+ |
- | cpu_img | || | | 256-x-64| |
- | | || | +---------+ |
- | | || | |
- | | || | |
- +-------------------+ || +-------------------+
- V || V
- gl.texImage2D(...) || gl.texSubImage2D(...)
- V || V
- +-------------------+ || +-------------------+
- | | || | |
- | | || | | gpu_sub | |
- | | || | +---------+ |
- | gpu_img | || | | 256-x-64| |
- | | || | +---------+ |
- | | || | |
- | | || | |
- +-------------------+ || +-------------------+
- G = YOUR_WEBGL_CONTEXT_OBJECT;
- G.activeTexture( G.TEXTURE0 + tex_lot );
- G.bindTexture( G.TEXTURE_2D , tex_han );
- const ALN = 4; //:ALN:"Alignment" GUESS?
- G.pixelStorei(G.UNPACK_ALIGNMENT, ALN);
- //:CALCULATE_STARTING_OFFSET_IN_BYTES:( src_oib)
- var p_x =( _.cpu_sub.x_0 ); //:TOP_LEF:X
- var p_y =( _.cpu_sub.y_0 ); //:TOP_LEF:Y
- var pix_dex = p_x + ( pix_wid * p_y);
- var src_oip = pix_dex * ( 1 );//:PixelOffset
- var src_oib = pix_dex * pix_com;//:ComponentOffset
- G.pixelStorei( G.UNPACK_ROW_LENGTH , pix_wid );
- G.texSubImage2D(
- /* 01 */ G.TEXTURE_2D //:TARGET
- /* 02 */ , 0 //:LEVEL_OF_DETAIL (LOD)
- /* 03 */ , cpu_sub.x_0 //:TOP_LEFT
- /* 04 */ , cpu_sub.y_0 //:TOP_LEFT
- /* -- */ ,
- /* 05 */ ( ( _.cpu_sub.x_1 ) //:WIDTH
- /* 05 */ - ( _.cpu_sub.x_0 ) + 1 ) //:WIDTH
- /* -- */ ,
- /* 06 */ ( ( _.cpu_sub.y_1 ) //:HEIGHT
- /* 06 */ - ( _.cpu_sub.y_0 ) + 1 ) //:HEIGHT
- /* 07 */ , G.RGBA_INTEGER //:SOURCE_FORMAT
- /* 08 */ , G.UNSIGNED_BYTE //:SOURCE_TYPE
- /* 09 */ , pix_arr //:ARRAY_BUFFER_VIEW
- /* 10 */ , src_oib //:SOURCE_OFFSET
- );;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement