Oddly, that no longer works. And I have made no changes. (Not strictly true - I did make changes, and then it stopped working, so I recovered an unmodified version of the code, and in a fresh instance of jqt it fails.)
The error I get is from wdhandler "error in: form_g_initialize" domain error: glCreateProgram program=: glCreateProgram'' -------------------------------------------------------------------------------------------------- Seems like a pointless error. (As in: how would I obtain information about what causes this problem?) It's followed by a cascade of errors from the paint event which require I shut down jqt to stop the errors from happening. -------------------------------------------------------------------------------------------------- So, basically, I guess I am surfacing some bad design which has been lurking within the system. Gotta cope with it somehow. But which way is forwards? Thanks, -- Raul On Fri, Jun 26, 2015 at 10:47 PM, Raul Miller <[email protected]> wrote: > That works. > > It's about three times as complicated as I was hoping for, so I'll > want to study the mechanisms, but you've given me what looks like a > good starting point. > > Thanks, > > -- > Raul > > > On Fri, Jun 26, 2015 at 10:11 PM, bill lam <[email protected]> wrote: >> Here is a simple example from opengl superbible >> >>> https://github.com/openglsuperbible/sb6code/blob/master/src/singlepoint/singlepoint.cpp >> >> A direct translation without gles utility verbs is (beware >> line wrapping) >> >> require 'gles' >> >> coclass 'singlepoint' >> coinsert 'jgles' >> >> fix_version=: 3 : 0 >> GLSL=. wglGLSL'' >> ('#version 430 core';'#version ',(":GLSL),((GLSL>:300)#(*GLES_VERSION){::' >> core';' es')) stringreplace y >> ) >> >> create=: init >> destroy=: codestroy >> >> form_close=: 3 : 0 >> shutdown'' >> wd 'pclose' >> destroy'' >> ) >> >> form_g_initialize=: startup >> form_g_paint=: render >> >> FORM=: 0 : 0 >> pc form; >> minwh 300 300;cc g opengl flush; >> ) >> >> forminit=: 3 : 0 >> wd FORM >> wd 'pn ', title >> wd 'pshow' >> ) >> >> NB. ========================================================= >> >> program=: 0 >> vao=: ,0 >> >> init=: 3 : 0 >> title=: 'OpenGL SuperBible - Single Point' >> forminit'' >> ) >> >> vs_source=: 0 : 0 >> #version 430 core >> >> void main(void) >> { >> gl_Position = vec4(0.0, 0.0, 0.0, 1.0); >> } >> ) >> >> fs_source=: 0 : 0 >> #version 430 core >> >> out vec4 color; >> >> void main(void) >> { >> color = vec4(0.0, 0.8, 1.0, 1.0); >> } >> ) >> >> startup=: 3 : 0 >> vs_source=: fix_version vs_source >> fs_source=: fix_version fs_source >> >> program=: glCreateProgram'' >> fs=. glCreateShader GL_FRAGMENT_SHADER >> glShaderSource fs; 1; (,symdat <'fs_source'); <<0 >> glCompileShader fs >> >> vs=. glCreateShader GL_VERTEX_SHADER >> glShaderSource vs; 1; (,symdat <'vs_source'); <<0 >> glCompileShader vs >> >> glAttachShader program; vs >> glAttachShader program; fs >> >> glLinkProgram program >> >> glGenVertexArrays 1; vao >> glBindVertexArray {.vao >> ) >> >> render=: 3 : 0 >> red=. 1.0 0.0 0.0 1.0 >> glClearBufferfv GL_COLOR; 0; red >> >> glUseProgram program >> >> glPointSize 40.0 >> >> glDrawArrays GL_POINTS; 0; 1 >> ) >> >> shutdown=: 3 : 0 >> glDeleteVertexArrays 1; vao >> glDeleteProgram program >> ) >> >> ''conew'singlepoint' >> >> Пт, 26 июн 2015, Raul Miller написал(а): >>> https://www.opengl.org/discussion_boards/showthread.php/164054-Frag-shader-without-vertex-shader >>> seems to confirm that vertex shaders are supposed to be optional. >>> >>> But I have added a vertex shader, and that did not help. >>> >>> Also, I moved glUseProgram into the paint event - and that made no >>> difference. (It should not make a difference, though, as the >>> underlying system is basically a state machine - once something gets >>> set to a value it should retain that value until something else >>> changes it. Still, when trying to isolate a problem, every assumption >>> remains suspect.) >>> >>> require 'graphics/gl2 api/gles' >>> coinsert 'jgl2 jgles' >>> >>> FORM=: 0 : 0 >>> pc form closeok; >>> minwh 320 240; cc gl opengl flush; >>> ) >>> vshader=: 0 :0 >>> #version 120 >>> void main(void) { >>> gl_Position=ftransform(); >>> } >>> ) >>> fshader=: 0 :0 >>> #version 120 >>> 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 vshader;fshader >>> if.#err do. >>> smoutput 'fail' >>> smoutput err return. end. >>> ) >>> form_gl_paint=: 3 : 0 >>> smoutput 'painting' >>> glUseProgram program >>> ) >>> form_run'' >>> >>> Session still gets: >>> initializing >>> 450 >>> painting >>> >>> painting >>> >>> And, the rendered image is still black. >>> >>> Thanks, >>> >>> -- >>> Raul >>> >>> On Fri, Jun 26, 2015 at 9:54 PM, bill lam <[email protected]> wrote: >>> > Also can you confirm vertex (rather than fragment) shader is optional? >>> > On Jun 27, 2015 8:56 AM, "Raul Miller" <[email protected]> wrote: >>> > >>> >> 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 >>> >> >>> > ---------------------------------------------------------------------- >>> > 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 --recv-keys 4434BAB3 >> 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
