Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

bug in 2d visualization #46

Closed
CarloLucibello opened this issue Dec 12, 2015 · 23 comments
Closed

bug in 2d visualization #46

CarloLucibello opened this issue Dec 12, 2015 · 23 comments

Comments

@CarloLucibello
Copy link

I obtain a weird result when trying to visualize multiple 2d points, as in

    w, r = glscreen()
    s = Vec2f0(100)
    N = 10
    points = Point2f0[rand(Point2f0, -10f0:eps(Float32):10f0) for x=1:N]
    # points = Point2f0[Point2f0(x,0f0) for x=-10f0:0.1f0:10f0]
    v = visualize(points, scale=s)
    view(v)
    r()

The resulting render is a single point in the bottom left corner of the window:
glvisualize_001

The same happens when running the testsuite, except for two cases,

push!(TEST_DATA2D, visualize(particle_robj[:positions], scale=s, color=particle_color, style=Cint(OUTLINED), shape=Cint(ROUNDED_RECTANGLE)))

and

curve_data(i) = Point2f0[Point2f0(sin(x/i)*250, x) for x=1:1024]
push!(TEST_DATA2D, visualize(const_lift(curve_data, bounce(20f0:0.1f0:1024f0)), :lines))

which are displayed correctly

Cheers,
Carlo

@SimonDanisch
Copy link
Member

Well this is sort of to expected, since the units are in pixels.
Have you tried rand(Point2f0, -500f0:eps(Float32):500f0) ?
It should be okay in the testsuite, though. Can you attach a screenshot?

@CarloLucibello
Copy link
Author

thank you for helping out

Have you tried rand(Point2f0, -500f0:eps(Float32):500f0) ?

the same happens

Here is tests' screenshot, see those empty spaces
glvisualize_002

How do you translate the camera btw? I can only rotate and zoom

@SimonDanisch
Copy link
Member

Oh wait, I think I've seen that bug.
Can you try to replace the call to glscreen with this:

w,r = glscreen(debugging=true)

Also, this might be fixed in the next2 branch.
If you wish, I can look what packages you will need to checkout.
It should be somethin like:

Pkg.checkout("GLVisualize", "next2")
Pkg.checkout("GLAbstraction", "sd/next²")
Pkg.checkout("GeometryTypes", "sd/typealias")
Pkg.checkout("FixedSizeArrays")
Pkg.checkout("GLWindow")

@SimonDanisch
Copy link
Member

The middle mouse button gives you translate... I'll need to rework the camera, since a lot of people don't actually use a mouse with a middle button...

@CarloLucibello
Copy link
Author

I tried the debugging option but it didń't print any additional information

on the branch next2 my script yields this
glvisualize_002
Now I have one single triangle and a change in the camera mode (from orthogonal to perspective I think)

@SimonDanisch
Copy link
Member

Can you try runtest.jl?

@CarloLucibello
Copy link
Author

glvisualize_003

@SimonDanisch
Copy link
Member

Great, this looks like it should be fixed :)
Try

using GLVisualize, GeometryTypes
w, r = glscreen()
s = Vec2f0(100)
N = 10
points = Point2f0[Point2f0(x,0f0) for x=linspace(0, N*s[1], N)]
v = visualize(points, scale=s)
#v = visualize((Circle(Point2f0(0), scale[1]), points))
view(v, method=:orthographic_pixel) #it's actually a bug that you need to define the method.
r()

@CarloLucibello
Copy link
Author

nice, it works!

@SimonDanisch
Copy link
Member

Awesome, thanks for trying this out! I'll leave this open until next2 is merged!

@ashleylid
Copy link

Hi - is this still open? I get an error when running the test:

ERROR: LoadError: ArgumentError: StructsOfArrays not found in path

I am rendering in a loop and would like to clear the screen re-rendering in the same window, is there an easy way to do that? Because with every render the loop slows.

@SimonDanisch
Copy link
Member

So are you on the next branch?
I've updated the README in that branch. It now contains all the packages you need.
Note, that I just pushed some changes to the ArraysOfStructs fork, which are not compatible yet -.-
You need to be on this commit:
JuliaArrays/StructsOfArrays.jl#3
SimonDanisch/StructsOfArrays.jl@333e5f5

@ashleylid
Copy link

I need the sd/screenbuffer so have just been merging with master. When I am on either branch of GLVisualize:

Pkg.test("GLVisualize")
INFO: Computing test dependencies for GLVisualize...
INFO: No packages to install, update or remove
INFO: Testing GLVisualize
surface
Barplot
3d dot particles
some more funcitonality from Meshes
particles
sierpinski
vectorfielddata
volume_data
ERROR: LoadError: LoadError: syntax: "<<" is not a unary operator

I was just running the test file out of interest, to make sure everything was working. But my origional quest was just to find a way to clear the window before rerunning my loop. I found this: empty!(w.renderlist) but it doesnt seem to do anything.. ie the render slows with every iteration. Which hurts after 1000 renders - just crashes.

I dont want to bog you down with stuff thats not that important, although it would be nice to fix what the problem is - what branch should I be on?

@ashleylid
Copy link

Which branch should I be on? I am a little further along with the test something about << not being a unary operator - but I put this on another issue..

@SimonDanisch
Copy link
Member

I fixed the StructsOfArray thing, so you should be able to simply be on what the readme in next2 says:
https://github.com/JuliaGL/GLVisualize.jl/tree/next2 (If you don't want to be on the tagged version)...

@SimonDanisch
Copy link
Member

This should also include the screenshot function.. It got moved to GLWindow though: https://github.com/JuliaGL/GLWindow.jl/blob/sd/rebuild/src/screen.jl#L231

@ashleylid
Copy link

Ok..

Following the above, my branches are as expected in the list https://github.com/JuliaGL/GLVisualize.jl/tree/next2. Not too worried about version, just as long as everything works :)

I did however run into a snag with glscreen()

LoadError: ArgumentError: function glscreen does not accept keyword arguments
from:

w, r = glscreen(resolution = (width, height)); 

I see that now you call it using Screen, so I have:

w, r = Screen(resolution = (width, height));

and I get the error

WARNING: program 1 not linked. Error in:
~/.julia/v0.4/GLWindow/src/fxaa.vert or
~/.julia/v0.4/GLWindow/src/fxaa.frag or
~/.julia/v0.4/GLWindow/src/fxaa_combine.frag

LoadError: Named attribute (:texturecoordinates) is not an active attribute in the specified program object or

        the name starts with the reserved prefix gl_

while loading In[15], in expression starting on line 27

in get_attribute_location at /home/ashley/.julia/v0.4/GLAbstraction/src/GLExtendedFunctions.jl:30
in call at ~/.julia/v0.4/GLAbstraction/src/GLTypes.jl:154
in call at ~/.julia/v0.4/GLAbstraction/src/GLTypes.jl:216
in postprocess at ~/.julia/v0.4/GLWindow/src/types.jl:32
in call at ~/.julia/v0.4/GLWindow/src/types.jl:55
in Screen at ~/.julia/v0.4/GLWindow/src/screen.jl:272
in Screen at ~/.julia/v0.4/GLWindow/src/screen.jl:237

Running it again not changing anything I get:

LoadError: MethodError: start has no method matching start(::GLWindow.Screen)
while loading In[2], in expression starting on line 27

So I swapped back to sd/screenbuffer (from next2) and its giving me:

LoadError: UndefVarError: createwindow not defined

So all in all everything seems like its not working.. And I am really sorry to be the bearer or bad news not knowing enough to go and fix it myself..

Am I on the right issue? should we move this somewhere else?

@SimonDanisch
Copy link
Member

You're not on the right issue, if you actually try to get next2 running in order to get the point rendering running.

LoadError: MethodError: start has no method matching start(::GLWindow.Screen)

This is to be expected, if you haven't changed your example code in this way:

# old API
window, renderloop = glscreen()

# new API
window = glscreen()

GLWindow.renderloop(window) # renderloop is also exported by GLVisualize

@ashleylid
Copy link

Hi,

I am still getting errors, most likely to do with my understanding of the syntax. Going back to your examples - how do these change with the new methods:

https://github.com/JuliaGL/GLVisualize.jl/blob/master/examples/camera.jl (I have looked at https://github.com/JuliaGL/GLVisualize.jl/blob/next2/examples/camera/camera2.jl)
https://github.com/JuliaGL/GLVisualize.jl/blob/master/examples/rotate_robj.jl

Like how to I now set my resolution? And the camera set up has also changed, but I am failing at getting it working again. And now I am struggling to revert. So not generating my depth images anymore :(

And my errors are going nuts with types..

@SimonDanisch
Copy link
Member

And my errors are going nuts with types..

What does that even mean?

Well, I'll very soon release a new suite of examples with videos and comments and everything. Right now I'm actually nearly done with the camera rebuild, so the camera example should be outdated on next2. I wouldn't recommend working on the next2 branch right now!

@ashleylid
Copy link

Ok.. I get that updating things while in progress is not a good idea.. hopefully I can get everything to go back to when it was working..

To get to where I am I did this:

Pkg.checkout("GLAbstraction", "sd/next²")
Pkg.checkout("GLVisualize", "next2")
Pkg.checkout("GLWindow", "sd/rebuild")
Pkg.checkout("GeometryTypes", "sd/boundingbox")
Pkg.checkout("FixedSizeArrays", "master")

Now I swapped back to Pkg.checkout("GLVisualize", "sd/screenbuffer")
and I get this error LoadError: UndefVarError: createwindow not defined when running this line w = glscreen() and when I go right back to w,r=glscreen(resolution = (width, height)) I get that glscreen does not take arguments and the same createwindow error..

EDIT: I reverted everything, all tagged versions.. and now its working like before - phew.. It still slows down with every loop even though I do empty!(w.renderlist)

@SimonDanisch
Copy link
Member

Is there a particular reason why you need to be on the next2 set of branches? Does the tagged version not work for you?

@ashleylid
Copy link

Nope - was just being pedantic and trying to get the test working.. but I don't need to have my cake and eat it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants