That's an interesting clue. Thank you.

But I'm still not understanding something important. For example, this
still renders black:

require 'graphics/gl2 api/gles'
coinsert 'jgl2 jgles'

FORM=: 0 : 0
 pc form closeok;
 minwh 320 240; cc gl opengl flush;
)
fshader=: 0 :0
  #version 110
  void main(void) {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  }
)
form_run=: 3 : 0
  wd FORM
  wd 'pshow'
)
form_gl_initialize=: 3 : 0
  smoutput 'initializing'
  smoutput wglGLSL''
  'err program'=: gl_makeprogram '';fshader
  if.#err do.
    smoutput 'fail'
    smoutput err return. end.
  glUseProgram program
)
form_gl_paint=: 3 : 0
  smoutput 'painting'
)
form_run''

The output I get is:

initializing
450
painting

painting

(I also am wondering where that blank line is coming from...)

Thanks,

-- 
Raul

On Fri, Jun 26, 2015 at 8:44 PM, bill lam <[email protected]> wrote:
> you run opengl functions in form_run but opengl context has not yet
> available at that point. try put them inside the initialize callback. see
> the shader.ijs demo.
>
> you can query the version of shader langauge in the initialize callback and
> determine whether you need the #version header.
> On Jun 27, 2015 8:28 AM, "Raul Miller" <[email protected]> wrote:
>
>> I am trying to implement a minimal example of using a shader within J.
>>
>> This means: no vertex shader. I just want to paint the screen a solid
>> color.
>>
>> This means: no #version header (which I believe is equivalent to #version
>> 110).
>>
>> Unfortunately, while this should work in principle, a number of
>> variations on the implementation have not worked for me.
>>
>> I can show that opengl is working, using the glClear mechanism, but
>> while that accomplishes the "set the screen to a single color"
>> subtask, it does not get me my minimal shader which was the point of
>> the exercise.
>>
>> Here's an example:
>>
>> load 'pacman'
>> 'install' jpkg 'graphics/gl2 api/gles'
>> require 'graphics/gl2 api/gles'
>> coinsert 'jgl2 jgles'
>>
>> FORM=: 0 : 0
>>  pc form closeok;
>>  minwh 320 240; cc gl opengl flush;
>> )
>> fshader=: 0 :0
>>   void main(void) {
>>     gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>>   }
>> )
>> form_run=: 3 : 0
>>   wd FORM
>>   'err program'=: gl_makeprogram '';fshader
>>   if.#err do. smoutput err return. end.
>>   wd 'pshow'
>>   gl_paint ''
>> )
>> form_gl_paint=: 3 : 0
>>   smoutput 'painting'
>>   glClearColor 0 0 1 1
>>   glClear GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
>>   glUseProgram program
>> )
>> form_run''
>>
>> Now...
>>
>> Part of the problem is that I do not know what is happening in libjqt,
>> and those entry points are not documented. But I do not necessarily
>> need that, I hope, not right now anyways.
>>
>> Anyways, if I eliminate the glClearColor and glClear statements, the
>> image is black. But if the shader were to be used, the image would be
>> red.
>>
>> How do I make this work?
>>
>> Thanks,
>>
>> --
>> Raul
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to