Forums > Jitter

jit.gl.lua support for accum buffer

February 22, 2008 | 5:32 pm

I’m attempting to use the accumulation buffer in jit.gl.lua, but calling
gl.Accum() gives me this error:

ob3d_draw_end popmatrix: GL Error: Invalid operation

Is it not supported or am I just doing something wrong? Has anyone used it
successfully?

Thijs

m.sphere = jit.new("jit.gl.gridshape", this.drawto)
m.sphere.automatic = 0
m.sphere.displaylist = 1

m.move = {}
m.move.x = 0.05
m.move.y = 0.02
m.move.z = 0.02

MOTION_FRAMES = 16

function draw()

gl.Clear("ACCUM_BUFFER_BIT")
gl.Enable("BLEND")
gl.Color(0,1,0,0.5)
gl.PushMatrix()

for i=0, MOTION_FRAMES-1, 1 do
render(m.move.x * i, m.move.y * i, m.move.z * i)
gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
end

gl.Accum("RETURN", 1)
gl.PopMatrix()
end

function render(x, y, z)

gl.PushMatrix()
gl.Translate(x,y,z)
gl.Scale(0.2, 0.2, 0.2)
m.sphere:drawraw()
gl.PopMatrix()

end


February 22, 2008 | 6:15 pm

this works for me.
i took down your m constructor and wraped the draw with

jit.gl.draw_begin(sphere, 0)
sphere:drawraw()
jit.gl.draw_end(sphere, 0)

sphere = jit.new("jit.gl.gridshape", this.drawto)
sphere.automatic = 0
sphere.displaylist = 1

move = {}
move.x = 0.05
move.y = 0.02
move.z = 0.02

MOTION_FRAMES = 16

function draw()

gl.Clear("ACCUM_BUFFER_BIT")
gl.Enable("BLEND")
gl.Color(0,1,0,0.5)
gl.PushMatrix()

for i=0, MOTION_FRAMES-1, 1 do
render(move.x * i, move.y * i, move.z * i)
gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
end

gl.Accum("RETURN", 1)
gl.PopMatrix()
end

function render(x, y, z)

gl.PushMatrix()
gl.Translate(x,y,z)
gl.Scale(0.2, 0.2, 0.2)
jit.gl.draw_begin(sphere, 0)
sphere:drawraw()
jit.gl.draw_end(sphere, 0)
gl.PopMatrix()

end

On Fri, Feb 22, 2008 at 7:32 PM, Thijs Koerselman

wrote:

> I’m attempting to use the accumulation buffer in jit.gl.lua, but calling
> gl.Accum() gives me this error:
>
> ob3d_draw_end popmatrix: GL Error: Invalid operation
>
> Is it not supported or am I just doing something wrong? Has anyone used it
> successfully?
>
> Thijs
>
>
> m.sphere = jit.new("jit.gl.gridshape", this.drawto)
> m.sphere.automatic = 0
> m.sphere.displaylist = 1
>
> m.move = {}
> m.move.x = 0.05
> m.move.y = 0.02
> m.move.z = 0.02
>
> MOTION_FRAMES = 16
>
> function draw()
>
> gl.Clear("ACCUM_BUFFER_BIT")
> gl.Enable("BLEND")
> gl.Color(0,1,0,0.5)
> gl.PushMatrix()
>
> for i=0, MOTION_FRAMES-1, 1 do
> render(m.move.x * i, m.move.y * i, m.move.z * i)
> gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
> end
>
> gl.Accum("RETURN", 1)
> gl.PopMatrix()
> end
>
> function render(x, y, z)
>
> gl.PushMatrix()
> gl.Translate(x,y,z)
> gl.Scale(0.2, 0.2, 0.2)
> m.sphere:drawraw()
> gl.PopMatrix()
>
> end
>
>
>


February 22, 2008 | 7:25 pm

On Fri, Feb 22, 2008 at 6:15 PM, yair reshef wrote:

> this works for me.
> i took down your m constructor and wraped the draw with
>
> jit.gl.draw_begin(sphere, 0)
> sphere:drawraw()
> jit.gl.draw_end(sphere, 0)
>

Hi Yair,

You got me really confused now. I’ve never had to use
jit.gl.draw_begin/endcalls in combination with drawraw(), and I have
no clue what they do. They
are not native jit.gl.lua calls and I can’t find any documentation about it.
Can you explain this a bit?
Second it still doesn’t run on my computer. I’ve got rid of the m. that was
just a global shared table that all my variables have. Are you saying the
script below works for you?

I’m using a MacIntel + jit.gl.lua beta4 + OS10.5.2 + Nvidia 7300

Cheers,
Thijs

sphere = jit.new("jit.gl.gridshape", this.drawto)
sphere.automatic = 0
sphere.displaylist = 1

move = {}
move.x = 0.05
move.y = 0.02
move.z = 0.02

MOTION_FRAMES = 16

function draw()

gl.Clear("ACCUM_BUFFER_BIT")
gl.Color(0,1,0,0.5)
gl.PushMatrix()

for i=0, MOTION_FRAMES-1, 1 do
render(move.x * i, move.y * i, move.z * i)
gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
end

gl.Accum("RETURN", 1.0)
gl.PopMatrix()
end

function render(x, y, z)

gl.PushMatrix()
gl.Translate(x,y,z)
gl.Scale(0.2, 0.2, 0.2)

jit.gl.draw_begin(sphere, 0)
sphere:drawraw()
jit.gl.draw_end(sphere, 0)

gl.PopMatrix()

end


February 22, 2008 | 7:46 pm

Hi Thijs,
draw_begin
drawraw
draw_end

is equivalent to

draw

for jitter ob3d objects. This allows you to use Jitter’s internal
OpenGL state management and stick your own calls in between the series
of calls normally taken care of for you by the default draw method.

draw_begin -> set opengl state
drawraw -> draw bare geometry
draw_end -> reset opengl state

wes

On Fri, Feb 22, 2008 at 11:25 AM, Thijs Koerselman

wrote:
>
>
> On Fri, Feb 22, 2008 at 6:15 PM, yair reshef wrote:
> > this works for me.
> > i took down your m constructor and wraped the draw with
> >
> > jit.gl.draw_begin(sphere, 0)
> > sphere:drawraw()
> > jit.gl.draw_end(sphere, 0)
> >
> >
>
>
> Hi Yair,
>
> You got me really confused now. I’ve never had to use jit.gl.draw_begin/end
> calls in combination with drawraw(), and I have no clue what they do. They
> are not native jit.gl.lua calls and I can’t find any documentation about it.
> Can you explain this a bit?
> Second it still doesn’t run on my computer. I’ve got rid of the m. that was
> just a global shared table that all my variables have. Are you saying the
> script below works for you?
>
> I’m using a MacIntel + jit.gl.lua beta4 + OS10.5.2 + Nvidia 7300
>
> Cheers,
> Thijs
>
>
> sphere = jit.new("jit.gl.gridshape", this.drawto)
> sphere.automatic = 0
> sphere.displaylist = 1
>
> move = {}
> move.x = 0.05
> move.y = 0.02
> move.z = 0.02
>
> MOTION_FRAMES = 16
>
> function draw()
>
> gl.Clear("ACCUM_BUFFER_BIT")
> gl.Color(0,1,0,0.5)
> gl.PushMatrix()
>
>
> for i=0, MOTION_FRAMES-1, 1 do
> render(move.x * i, move.y * i, move.z * i)
> gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
> end
>
> gl.Accum("RETURN", 1.0)
>
> gl.PopMatrix()
> end
>
> function render(x, y, z)
>
> gl.PushMatrix()
> gl.Translate(x,y,z)
> gl.Scale(0.2, 0.2, 0.2)
>
> jit.gl.draw_begin(sphere, 0)
> sphere:drawraw()
> jit.gl.draw_end(sphere, 0)
>
> gl.PopMatrix()
>
> end
>
>
>
>
>
>

February 22, 2008 | 7:59 pm

hi Thijis, ye it works on my win+1.6.3+9700nvidia setup.
see it in action @ test.ob3d.lua

On Fri, Feb 22, 2008 at 9:46 PM, Wesley Smith wrote:

> Hi Thijs,
> draw_begin
> drawraw
> draw_end
>
> is equivalent to
>
> draw
>
> for jitter ob3d objects. This allows you to use Jitter’s internal
> OpenGL state management and stick your own calls in between the series
> of calls normally taken care of for you by the default draw method.
>
> draw_begin -> set opengl state
> drawraw -> draw bare geometry
> draw_end -> reset opengl state
>
> wes
>
>
> On Fri, Feb 22, 2008 at 11:25 AM, Thijs Koerselman
>

wrote:
> >
> >
> > On Fri, Feb 22, 2008 at 6:15 PM, yair reshef wrote:
> > > this works for me.
> > > i took down your m constructor and wraped the draw with
> > >
> > > jit.gl.draw_begin(sphere, 0)
> > > sphere:drawraw()
> > > jit.gl.draw_end(sphere, 0)
> > >
> > >
> >
> >
> > Hi Yair,
> >
> > You got me really confused now. I’ve never had to use
> jit.gl.draw_begin/end
> > calls in combination with drawraw(), and I have no clue what they do.
> They
> > are not native jit.gl.lua calls and I can’t find any documentation about
> it.
> > Can you explain this a bit?
> > Second it still doesn’t run on my computer. I’ve got rid of the m. that
> was
> > just a global shared table that all my variables have. Are you saying
> the
> > script below works for you?
> >
> > I’m using a MacIntel + jit.gl.lua beta4 + OS10.5.2 + Nvidia 7300
> >
> > Cheers,
> > Thijs
> >
> >
> > sphere = jit.new("jit.gl.gridshape", this.drawto)
> > sphere.automatic = 0
> > sphere.displaylist = 1
> >
> > move = {}
> > move.x = 0.05
> > move.y = 0.02
> > move.z = 0.02
> >
> > MOTION_FRAMES = 16
> >
> > function draw()
> >
> > gl.Clear("ACCUM_BUFFER_BIT")
> > gl.Color(0,1,0,0.5)
> > gl.PushMatrix()
> >
> >
> > for i=0, MOTION_FRAMES-1, 1 do
> > render(move.x * i, move.y * i, move.z * i)
> > gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
> > end
> >
> > gl.Accum("RETURN", 1.0)
> >
> > gl.PopMatrix()
> > end
> >
> > function render(x, y, z)
> >
> > gl.PushMatrix()
> > gl.Translate(x,y,z)
> > gl.Scale(0.2, 0.2, 0.2)
> >
> > jit.gl.draw_begin(sphere, 0)
> > sphere:drawraw()
> > jit.gl.draw_end(sphere, 0)
> >
> > gl.PopMatrix()
> >
> > end
> >
> >
> >
> >
> >
> >
>


February 23, 2008 | 1:36 am

On Fri, Feb 22, 2008 at 7:59 PM, yair reshef wrote:

> hi Thijis, ye it works on my win+1.6.3+9700nvidia setup.
> see it in action @ test.ob3d.lua
>
>
Thanks Wes and Yair. I see that script for first time now. I’ve always been
using drawraw() without the state set/reset. To be honest I don’t see in
what situation you would use it. Isn’t the whole point of using drawraw that
you manage transformations and state calls manually? The redundent state
calls is what I’m trying to avoid in the first place. What am I missing? In
my script for example it resets the color, which is not what I want at all.

But coming back to my initial problem, this doesn’t really change anything
as far as I understand. The accum stuff still doesn’t work for me. Wes can
you please try to run the script on you mac and see if it works?

Cheers,
Thijs


February 25, 2008 | 2:20 pm

On Sat, Feb 23, 2008 at 1:36 AM, Thijs Koerselman

wrote:

>
>
> But coming back to my initial problem, this doesn’t really change anything
> as far as I understand. The accum stuff still doesn’t work for me. Wes can
> you please try to run the script on you mac and see if it works?
>
>
bump…

Anyone with a few spare minutes + jit.gl.lua + mac? I’d really like to know
if this stuff is supported in or not.

Thijs

sphere = jit.new("jit.gl.gridshape", this.drawto)
sphere.automatic = 0
sphere.displaylist = 1

move = {}
move.x = 0.05
move.y = 0.02
move.z = 0.02

MOTION_FRAMES = 16

function draw()

gl.Clear("ACCUM_BUFFER_BIT")
gl.Color(0,1,0,0.5)
gl.PushMatrix()

for i=0, MOTION_FRAMES-1, 1 do
render(move.x * i, move.y * i, move.z * i)
gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
end

gl.Accum("RETURN", 1.0)
gl.PopMatrix()
end

function render(x, y, z)

gl.PushMatrix()
gl.Translate(x,y,z)
gl.Scale(0.2, 0.2, 0.2)

sphere:drawraw()

gl.PopMatrix()

end


February 25, 2008 | 5:23 pm

Why not use render to texture and an accumulating filter?
wes

On Mon, Feb 25, 2008 at 6:20 AM, Thijs Koerselman

wrote:
> On Sat, Feb 23, 2008 at 1:36 AM, Thijs Koerselman
>
wrote:
>
> >
> >
> >
> >
> > But coming back to my initial problem, this doesn’t really change anything
> as far as I understand. The accum stuff still doesn’t work for me. Wes can
> you please try to run the script on you mac and see if it works?
> >
> >
>
> bump…
>
> Anyone with a few spare minutes + jit.gl.lua + mac? I’d really like to know
> if this stuff is supported in or not.
>
>
> Thijs
>
>
> sphere = jit.new("jit.gl.gridshape", this.drawto)
> sphere.automatic = 0
> sphere.displaylist = 1
>
> move = {}
> move.x = 0.05
> move.y = 0.02
> move.z = 0.02
>
> MOTION_FRAMES = 16
>
> function draw()
>
> gl.Clear("ACCUM_BUFFER_BIT")
> gl.Color(0,1,0,0.5)
> gl.PushMatrix()
>
>
> for i=0, MOTION_FRAMES-1, 1 do
> render(move.x * i, move.y * i, move.z * i)
> gl.Accum("ACCUM", 1.0/MOTION_FRAMES)
> end
>
> gl.Accum("RETURN", 1.0)
> gl.PopMatrix()
> end
>
> function render(x, y, z)
>
> gl.PushMatrix()
> gl.Translate(x,y,z)
> gl.Scale(0.2, 0.2, 0.2)
>
>
> sphere:drawraw()
>
> gl.PopMatrix()
>
> end
>
>
>
>
>
>
>
>
>

February 25, 2008 | 6:14 pm

On Mon, Feb 25, 2008 at 5:23 PM, Wesley Smith wrote:

> Why not use render to texture and an accumulating filter?
>
>
That would be a good workaround. Thanks for the tip.

I’d really like to do it the "right way" though. There must be a good reason
why they implemented the accumulation buffer. Or is it very similar to RTT
under the hood? This thing might be the bottleneck of my rendering so I’d
like to use the most efficient hardware instructions.

I’ll use textures for now.

Cheers,
Thijs


Viewing 9 posts - 1 through 9 (of 9 total)