Attached is a version that I have tweaked
unmercifully to avoid repainting (also I have assumed there
is not a resizing of the graphics window). The major
tweaking of gldemo verbs is done at the bottom of the
script. Be aware that the gschar version used in this script
is gscharJAVA, not gscharWDW. And gscharJAVA has been
tweaked to remove glclear'' because when it is not removed,
every movement key whites out the opengl window.

        The result is that if I load the file and then press
a movement key, no change appears in the opengl window. But
if I reload the script without first closing the previous
opengl window, a new window is created and the Lorenz has
been moved by the previous movement key.

        Can anyone suggest a correction for this script?

On Sun, 30 Apr 2006, Oleg Kobchenko wrote:

+ This is great news. I would think of the following:
+
+ User code:
+  - setup -- for a new scene
+    - update -- for new size (optional)
+      - paint -- for every frame
+
+ - "setup" (init) verb will do initial
+   calculation and create lists
+ - the paint verb will only call lists
+
+ OpenGL API:
+  - alloc: new OpenGL context -- on create
+  - reset (or release/alloc) -- on scene change \__ may be the same
+    - update: coordinate change -- on resize    /
+      - beforePaint -- before user paint
+      - afterPaint -- after user paint
+  - release
+
+ - "reset" function to initialize the OpenGL
+   context. (such as when switching to a new sceen
+   with different light, etc, settings). This can
+   easily be done by releasing and allocating new
+   OpenGL context.
+ - otherwise a lot of state can be shared beween
+   frames, such as light, etc. (most of the gsinit)
+ - beforePaint will only update position/rotation
+
+
+ Also there need to be examples how to
+ share lists within lists. Like the balls demos:
+ spheres are lists. But we need to include
+ them in the overall scene list.
+
+
+ > scene, and don't alloc for the next frame. You need to create the lists
+ > again when the control is resized.
+
+ I am not sure, that it's a fact. Unless, dictated by
+ the context/bitmap creation. I would look into how
+ to preserve OpenGL context when switching to a new
+ or updated DC.
+
+
+ --- Chris Burke <[EMAIL PROTECTED]> wrote:
+
+ > Oleg Kobchenko wrote:
+ > > That's a great idea to share lists between frames,
+ > > if only j601 allowed it.
+ >
+ > You can share lists between frames. Use draw_keep__ogl to draw the
+ > scene, and don't alloc for the next frame. You need to create the lists
+ > again when the control is resized.
+ >
+ > This takes a little housekeeping, and examples will be in the next beta.
+
+
+ __________________________________________________
+ Do You Yahoo!?
+ Tired of spam?  Yahoo! Mail has the best spam protection around
+ http://mail.yahoo.com
+ ----------------------------------------------------------------------
+ For information about J forums see http://www.jsoftware.com/forums.htm
+

(B=) <----------my "sig"

Brian Schott
Atlanta, GA, USA
schott DOT bee are eye eh en AT gee em ae eye el DOT com
http://schott.selfip.net/~brian/
NB. Standalone version of the opengl demo.

require 'opengl'
cocurrent 'gldemo'
coinsert 'jzopenglutil'

OPENGL=: 0 : 0
pc opengl closeok;
xywh 0 0 200 150;cc g isigraph rightmove bottommove;
pas 0 0;
rem form end;
)

opengl_run=: 3 : 0
wd OPENGL
ogl=: ''conew'jzopengl'
  gsinit GS_LIGHT
  quad=: {.>gluNewQuadric''

  gsnewlist SPHERE
  gluSphere quad,SPHERESIZE,10 10
  gsendlist''

  gsnewlist LORENZ
  gscolor GRAY
  glPushMatrix ''
  glTranslate T
  SPHERE list_at L
  glPopMatrix ''
  gsendlist''
  glCallList LORENZ

  draw_keep__ogl''
  NB. gsfini''
NB. opengl_g_paint''
wd'pshow;'
)

opengl_close=: 3 : 0
  gluDeleteQuadric quad
destroy__ogl''
wd 'pclose'
)

opengl_cancel=: opengl_close

NB. =========================================================
NB. =========================================================
NB. Lorenz Attractor - for OpenGL demo, j601
NB. 04/29/06 by Oleg Kobchenko
NB. http://www.jsoftware.com/jwiki/Essays/Lorenz_Attractor

'`X Y Z'=: (0&{)`(1&{)`(2&{)
' s r b'=: 10 , 28 , 8%3

dx=: s*(Y - X)
dy=: (X * r - Z) - Y
dz=: (X*Y) - b*Z

dt=: 0.01
I=: + dt * dx,dy,dz

NB. =========================================================
COUNT=: 4000
L=: 0.07*I^:(<COUNT) 0 1 0
T=: -([:-:>./+<./)"1|:L

NB. =========================================================
SPHERESIZE=: 0.03
SPHERE=: 2041
LORENZ =:2042 
GS_ROTXYZ=: 355.519 359.069 321.959
GS_TRNXYZ=: 0.025 0.325 0

NB. =========================================================
paint=: 3 : 0
  NB. gsinit GS_LIGHT
  glCallList LORENZ
  NB. gsfini''
)

NB. =========================================================
list_at=: 4 : 0 "1
glPushMatrix ''
glTranslate y
glCallList x
glPopMatrix ''
)

NB. =========================================================
gscharJAVA=: 3 : 0
  key=. Jout {~ Jin i. {. sysdata
  ('1' = {.sysmodifiers) gskey key
 paint''
 glpaint '' 
)

erase <'gschar_jzopenglutil_'
opengl_g_paint=: paint
opengl_g_char=: gschar
  opengl_g_char=: gscharJAVA f.
opengl_default=: gsdefault

NB. =========================================================
opengl_run''
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to