nevermind, figured it out colrs=obj.uniforms[:color] # Like this you get a reference to the gpu memory object (a texture in this case) color = map(x->Vec4(.1,.1,abs(x)/.05,1),vals) update!(colrs,color)
On 2 Sep 2014, at 11:33 am, Sheehan Olver <dlfivefi...@gmail.com> wrote: > How do I update the colors too? > > > On 2 Sep 2014, at 9:09 am, Sheehan Olver <dlfivefi...@gmail.com> wrote: > >> Thanks, much much faster! To get it to work you have to do >> >> Pkg.add(“ApproxFun”);Pkg.checkout(“ApproxFun”); >> >> Below is the version that works for me. Is there support for non-evenly >> spaced grids? I also want to do functions on a disk. (And cylinders and >> spheres…not sure how to plot those though.) >> >> >> >> >> >> >> using GLPlot, GLAbstraction, ModernGL, ApproxFun >> window = createdisplay(w=1000,h=1000,eyeposition=Vec3(1,1,1), lookat=Vec3(0)) >> >> function zcolor(i, j, t) >> x = float32(i - 0.5) >> z = float32(j - 0.5) >> radius = sqrt((x * x) + (z * z)) >> >> r = sin(10.0f0 * radius + t) >> g = cos(10.0f0 * radius + t) >> b = radius >> return Vec4(r,g,b, 1) >> end >> >> yy = xx =-1.:.05:1. >> N = length(xx) >> color = [zcolor(i/N, j/N, 15) for i=1:N, j=1:N]; >> >> >> h = 0.01 >> u0 = TensorFun((x,y)->exp(-10x.^2-20(y-.1).^2)) >> d = Interval()⊗Interval() >> L = I-h^2*lap(d) >> B = dirichlet(d) >> S = schurfact([B,L],80) >> >> u = Array(TensorFun,10000) >> u[1] = u0 >> u[2] = u0 >> n = 2 >> >> >> m = 500 >> vals = Float64[u[1][x,y] for x in xx,y in yy] >> texdata=map(Vec1,vals) >> obj = glplot(texdata, primitive=SURFACE(), color=color) >> # this is probably a little opaque, but texdata ends up in :z, as :z is the >> default attribute for the data you upload >> zvalues = obj.uniforms[:z] >> # Like this you get a reference to the gpu memory object (a texture in this >> case) >> >> glClearColor(1,1,1,0) >> for k=n+1:n+m >> u[k] = (S\[zeros(4),2u[k-1]-u[k-2]]) >> vals = Float64[u[k][x,y] for x in xx,y in yy] >> update!(zvalues, map(Vec1,vals)) # now you can simply update the gpu >> object, which should be very efficient >> glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) >> render(obj) >> yield() >> GLFW.SwapBuffers(window.glfwWindow) >> end >> n+=m >> >> >> >> >> >> On 2 Sep 2014, at 6:48 am, Simon Danisch <sdani...@gmail.com> wrote: >> >>> Hi, >>> glad to hear that you like my package! >>> I'm surprised that your code works without being very slow, as you use my >>> (a little confusing) API wrong ;) >>> Here is a better version: >>> https://gist.github.com/SimonDanisch/794c274fbf3090f00359 >>> I couldn't test the code, as some functions where missing! >>> >>> Best, >>> Simon >>> >>> >>> Am Dienstag, 19. August 2014 07:46:22 UTC+2 schrieb Sheehan Olver: >>> Hi, >>> >>> Is there a way to force plotting in PyPlot.jl, to simulate animation? >>> Right now if I do a for loop over a sequence of plots, it only outputs the >>> last plot. >>> >>> This is in IJulia running on OS X with matplotlib version 1.3.1 installed, >>> and pygui(true) >>> >>> Sheehan >> >