Kernel means the program running inside GPU, which is
the c source stored inside nouns vsrc and fsrc. 

Fri, 28 Feb 2020, Thomas McGuire написал(а):
> Not sure I know what you mean but I’m using 807 on a MacBook Pro with just 
> the full Jqt install.
> 
> > On Feb 27, 2020, at 9:28 PM, bill lam <bbill....@gmail.com> wrote:
> > 
> > Did kernels need any modification?
> > 
> > Thu, 27 Feb 2020, Thomas McGuire написал(а):
> >> It took me a while to understand this a little bit. But the shader can 
> >> render any number of objects you just need to set up the data and tell the 
> >> shader to paint the object. To create 2 cubes I had to modify the 
> >> a_g_initialize function and the a_g_paint function. I have placed comments 
> >> in the code trying to show with my limited understanding of OpenGL what is 
> >> being done. To just create 2 duplicate cubes this code could be 
> >> simplified.  But if 2 different  types of objects needed to be rendered 
> >> everything would likely stay the same with a second set of vertex and 
> >> color data being added for the new object (right now I reuse vertexData 
> >> and colorData).
> >> 
> >> 
> >> a_g_initialize=: 3 : 0
> >> if. p=. >@{. glGetString GL_VERSION do. smoutput 'GL_VERSION: ', memr 0 _1 
> >> 2,~ p end.
> >> if. 0=p do. smoutput 'cannot retrieve GL_VERSION' return. end.
> >> if. p=. >@{. glGetString GL_VENDOR do. smoutput 'GL_VENDOR: ', memr 0 _1 
> >> 2,~ p end.
> >> if. p=. >@{. glGetString GL_RENDERER do. smoutput 'GL_RENDERER: ', memr 0 
> >> _1 2,~ p end.
> >> if. p=. >@{. glGetString GL_SHADING_LANGUAGE_VERSION do. smoutput 
> >> 'GL_SHADING_LANGUAGE_VERSION: ', memr 0 _1 2,~ p end.
> >> GLSL=: wglGLSL''
> >> 
> >> wglPROC''
> >> sprog=: 0
> >> if. GLSL>120 do.
> >> vsrc=. vsrc2
> >> fsrc=. fsrc2
> >> else.
> >> vsrc=. vsrc1
> >> fsrc=. fsrc1
> >> if. 0=GLES_VERSION_jgles_ do.
> >> vsrc=. vsrc,~ '#define lowp', LF, '#define mediump', LF, '#define highp', 
> >> LF
> >> fsrc=. fsrc,~ '#define lowp', LF, '#define mediump', LF, '#define highp', 
> >> LF
> >> end.
> >> end.
> >> vsrc=. '#version ',(":GLSL),((GLSL>:300)#(*GLES_VERSION){::' core';' 
> >> es'),LF,vsrc
> >> fsrc=. '#version ',(":GLSL),((GLSL>:300)#(*GLES_VERSION){::' core';' 
> >> es'),LF,fsrc
> >> if.(GLSL>:300)*.0~:GLES_VERSION_jgles_ do.
> >> fsrc=. ('void main';'out vec4 gl_FragColor;',LF,'void main') stringreplace 
> >> fsrc
> >> end.
> >> smoutput vsrc
> >> smoutput fsrc
> >> 'err program'=. gl_makeprogram vsrc;fsrc
> >> if. #err do. smoutput err return. end.
> >> 
> >> NB. original cube data and the model-view-projection matrix
> >> vertexAttr=: >@{. glGetAttribLocation program;'vertex'
> >> assert. _1~: vertexAttr
> >> colorAttr=: >@{. glGetAttribLocation program;'color'
> >> assert. _1~: colorAttr
> >> mvpUni=: >@{. glGetUniformLocation program;'mvp'
> >> assert. _1~: mvpUni
> >> 
> >> NB. Second duplicate object as above
> >> vertexAttr1=: >@{. glGetAttribLocation program;'vertex'
> >> assert. _1~: vertexAttr1
> >> colorAttr1=: >@{. glGetAttribLocation program;'color'
> >> assert. _1~: colorAttr1
> >> 
> >> NB. Here is where my shape is defined. this provides the hooks
> >> NB. between J data and openGL
> >> NB. Here I increase the buffer vbo to 4 locations and reuse the
> >> NB. object vertexData and colorData that make the colorful cube
> >> glGenBuffers 2;vbo=: 4#_1
> >> glBindBuffer GL_ARRAY_BUFFER; 0{vbo
> >> glBufferData GL_ARRAY_BUFFER; (#vertexData); (symdat <'vertexData'); 
> >> GL_STATIC_DRAW
> >> glBindBuffer GL_ARRAY_BUFFER; 1{vbo
> >> glBufferData GL_ARRAY_BUFFER; (#colorData); (symdat <'colorData'); 
> >> GL_STATIC_DRAW
> >> glBindBuffer GL_ARRAY_BUFFER; 2{vbo
> >> glBufferData GL_ARRAY_BUFFER; (#vertexData); (symdat <'vertexData'); 
> >> GL_STATIC_DRAW
> >> glBindBuffer GL_ARRAY_BUFFER; 3{vbo
> >> glBufferData GL_ARRAY_BUFFER; (#colorData); (symdat <'colorData'); 
> >> GL_STATIC_DRAW
> >> glBindBuffer GL_ARRAY_BUFFER; 0
> >> 
> >> sprog=: program
> >> 
> >> glClearColor 0; 0; 1; 0
> >> )
> >> 
> >> 
> >> a_g_paint=: 3 : 0
> >> if. 0=sprog do. return. end.
> >> 
> >> wh=. gl_qwh''
> >> glClearColor 0 0 0 0
> >> glClear GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
> >> 
> >> glUseProgram sprog
> >> glEnable GL_DEPTH_TEST
> >> glEnable GL_CULL_FACE
> >> 
> >> NB. matrix convention: current matrix on the left
> >> NB. note pre-multiplication
> >> 
> >> NB. model-view
> >> NB. I created a new model: mvp1 so it will translate the cube
> >> NB. so there will be 2 cubes side by side
> >> mvp=: (gl_Rotate (0{R), 1 0 0 ) mp (gl_Rotate (1{R), 0 1 0) mp (gl_Rotate 
> >> (2{R), 0 0 1) mp (gl_Scale STEPS%100) mp (gl_Translate 0.6 0 _8) mp 
> >> glu_LookAt EYE,LR,UD,IO,UP
> >> mvp1=: (gl_Rotate (0{R), 1 0 0 ) mp (gl_Rotate (1{R), 0 1 0) mp (gl_Rotate 
> >> (2{R), 0 0 1) mp (gl_Scale STEPS%100) mp (gl_Translate _1.2 0 _8) mp 
> >> glu_LookAt EYE,LR,UD,IO,UP
> >> 
> >> NB. projection
> >> mvp=: mvp mp gl_Perspective 30, (%/wh),1 10
> >> mvp1=: mvp1 mp gl_Perspective 30, (%/wh),1 10
> >> 
> >> NB. note GL_FALSE, no transpose
> >> NB. Draw Object 1
> >> glUniformMatrix4fv mvpUni; 1; GL_FALSE; mvp
> >> 
> >> glBindBuffer GL_ARRAY_BUFFER; 0{vbo
> >> glEnableVertexAttribArray vertexAttr
> >> glVertexAttribPointer vertexAttr; 3; GL_FLOAT; 0; 0; 0
> >> 
> >> glBindBuffer GL_ARRAY_BUFFER; 1{vbo
> >> glEnableVertexAttribArray colorAttr
> >> glVertexAttribPointer colorAttr; 3; GL_FLOAT; 0; 0; 0
> >> 
> >> glDrawArrays GL_TRIANGLES; 0; 36
> >> 
> >> NB. Draw object 2
> >> glUniformMatrix4fv mvpUni; 1; GL_FALSE; mvp1
> >> 
> >> glBindBuffer GL_ARRAY_BUFFER; 2{vbo
> >> glEnableVertexAttribArray vertexAttr1
> >> glVertexAttribPointer vertexAttr1; 3; GL_FLOAT; 0; 0; 0
> >> 
> >> glBindBuffer GL_ARRAY_BUFFER; 3{vbo
> >> glEnableVertexAttribArray colorAttr1
> >> glVertexAttribPointer colorAttr1; 3; GL_FLOAT; 0; 0; 0
> >> 
> >> glDrawArrays GL_TRIANGLES; 0; 36
> >> 
> >> NB. Objects drawn perform glDisableVertexAttribArray
> >> NB. what ever that is for
> >> glBindBuffer GL_ARRAY_BUFFER; 0
> >> glDisableVertexAttribArray colorAttr
> >> glDisableVertexAttribArray vertexAttr
> >> glDisableVertexAttribArray colorAttr1
> >> glDisableVertexAttribArray vertexAttr1
> >> 
> >> glDisable GL_DEPTH_TEST
> >> glDisable GL_CULL_FACE
> >> 
> >> glUseProgram 0
> >> 
> >> gl_clear ''
> >> gl_rgb 0 255 0
> >> gl_textcolor ''
> >> gl_textxy 10 30
> >> gl_text 'keys: x y z a s l r F10'
> >> gl_textxy 10 50
> >> gl_text 'scale: ',":STEPS%100
> >> gl_textxy 10 70
> >> gl_text 'angle: ',":R
> >> gl_textxy 10 90
> >> if. 0=sprog do. return. end.
> >> gl_text 'matrix:'
> >> for_i. i.4 do.
> >> gl_textxy 10, 105+i*15
> >> gl_text 6j2": i{mvp
> >> end.
> >> )
> >> 
> >> 
> >>> On Feb 14, 2020, at 4:14 PM, Brian Schott <schott.br...@gmail.com> wrote:
> >>> 
> >>> Bill,
> >>> 
> >>> Thank you very much.
> >>> 
> >>> Mostly I want to get n turtles, not cubes, that are not rotating to time
> >>> but behave like "Logo" turtles and react to commands in the Terminal 
> >>> window
> >>> like Forward 3 and Right 90. So I want to start with 2 separate turtles 
> >>> and
> >>> I guess I am all wrong in my idea that the long mvp commands are moving 
> >>> the
> >>> eye, but moving the cube/turtle. So my next experiment will be to copy and
> >>> edit the code beginning at the following line of code.
> >>> 
> >>> glGenBuffers 2;vbo=: 2#_1
> >>> 
> >>> So for example to make another cube/turtle I'm thinking that that line
> >>> could be changed so that _2 replaces the _1. Does that make any sense?
> >>> 
> >>> *****************below I react to your code 
> >>> revisions***********************
> >>> I had to change your f8 and f9 to f6 and f7 because on my Mac f8 is
> >>> clipboard and f9 is run project.
> >>> Now, at least when I put an smoutput into a_f6_fkey and a_f7_fkey I see
> >>> they are being executed, but I do not see the cube, (and this happens
> >>> without changing the focus to the Terminal window, which is needed below).
> >>> After intially loading and running the shader.ijs script in the project
> >>> window, I get a blank "a" window and each time I press F10 I get a new
> >>> fresh, blank "a" window. But if I click on the Terminal window and then
> >>> click on the "a" window and THEN press F10, I get the moving cube.
> >>> Subsequent F6 and F7 presses produce the smoutput results in the Terminal
> >>> window but BLANK the active "a" window.
> >>> *****************above I react to your code 
> >>> revisions***********************
> >>> 
> >>> But the previous paragraph is mostly a distraction except that you code
> >>> revision shows me a little about how the "handle" is important for finding
> >>> the parent from the child and vice versa. And about repainting.
> >>> 
> >>> I am mostly interested in how commands in the Terminal window can be sent
> >>> to the Cube in the "a" window. Any pointers?
> >>> 
> >>> 
> >>> On Fri, Feb 14, 2020 at 1:58 AM bill lam <bbill....@gmail.com> wrote:
> >>> 
> >>>> I tried to incoporate your change into shader.ijs
> >>>> with f8/f9 to change value for gl_translate.
> >>>> The changes lines are marked by NB. <<<<<
> >>>> pressing f8/f9 can trigger repaint and the matrix
> >>>> display also updated, but I can't see the cube at all.
> >>>> Pressing F10 to start original code, the cube came back.
> >>>> I did not pursue further but hope this is enough to
> >>>> answer your question about how to repaint.
> >>>> 
> >>>> 
> >>> ----------------------------------------------------------------------
> >>> For information about J forums see http://www.jsoftware.com/forums.htm
> >> 
> >> ----------------------------------------------------------------------
> >> For information about J forums see http://www.jsoftware.com/forums.htm
> > 
> > -- 
> > regards,
> > ====================================================
> > GPG key 1024D/4434BAB3 2008-08-24
> > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to