Fork me on GitHub
#off-topic
<
2018-04-13
>
jjttjj17:04:44

I need to parse a sequence of strings, where one of the values may represent a number n that determines how many subsequent values to group together. For example

;input
["john" "doe" 2 "USD" 200 "CAD" 130]
=>
;output
{:fname "john"
 :lname "doe" 
 :money {"USD" 200 
         "CAD" 130}}
so the 2 in the input dictates that it will be followed by 2 pairs representing currency/value. Is there some sort of terminology (from parsing/compiler design or anything else) to describe what's going on here?

jjttjj17:04:26

basically i sort of need binding in the middle of parsing a sequence of inputs

qqq19:04:10

Anyone here familiar with debugging WebGL?

qqq19:04:33

I have the classical problem of: I'm running my app, there are no runtime errors in the console, and my screen shows the color of glClearColor, but not the triangle I am trying to draw.

qqq19:04:07

The custom shader also compiled fine. The binding vertec/element-array buffers also works. Somehow, the drawElement is not showing anything.

milomord19:04:12

Debugging OpenGL at the shader level is a bit of a nightmare honestly

qqq19:04:25

I believe I have the projection-matrix + model-view-matrix setup correctly too.

qqq19:04:36

It's not the shader which is at the fault -- the shader literally just outputs a single color.

tbaldridge19:04:57

disable stuff until it works = my OpenGL debugging method

tbaldridge19:04:10

disable the shaders, disable the transforms

tbaldridge19:04:14

disable the projections, lol

milomord19:04:16

The best solution I've found in these scenarios is to pare it back exactly

qqq19:04:33

afaik, WebGL only does shaders, there's no 'fixed pipeline'

milomord19:04:36

Start super simple with one vertex array and a basic shader

qqq19:04:53

I'm literally trying to draw two triangles with a shader that just outputs the attrib values.

qqq19:04:09

Is there no debugging tool that shows my camera + locatin of objects ?

tbaldridge19:04:17

Right so in that case, switch to a single triangle with no view transformation and the screen transform matching the screen co-ordinates

qqq19:04:25

I suspect the camera is pointed at one place, and the objects are drawn elsewhere.

tbaldridge19:04:26

No, since those really don't exist

milomord19:04:53

The thing is those sorts of abstractions have to be built with shaders etc and you'd then work in a higher level engine

tbaldridge19:04:08

The "camera" is purely a construct programmers use to talk about the projection vs object transforms

milomord19:04:18

WebGL is a pretty low level API

tbaldridge19:04:24

Another option is to switch to using a scene graph

milomord19:04:29

It might help to see some code?

milomord19:04:01

I would try to draw a single triangle first with a vertex/fragment shader and some hard coded matrices

milomord19:04:59

Or depending on what you want to achieve maybe use a higher level library like Three?

jgh20:04:34

@qqq a helpful exercise is to write a simple rasterizer, you will understand why there is no spoon 😉

jgh20:04:27

although for this particular thing, step 1 is to just use the vertices in your vbo as is (e.g. make a triangle with the coords (-1,-1), (1, 1), (1, -1)) and paint it a different color than your clear color in your shader

qqq21:04:08

step 1 is the problem

qqq21:04:22

I've even sprinkled (. js/cnosole log (.getError gl)) evberywhere, and they are all returning 0

qqq21:04:58

n/m; woot, got triangle to appear!

🍕 12
tbaldridge21:04:32

white triangle on a black screen, the hello world of OpenGL.

tbaldridge21:04:38

Made 50x harder in WebGL.

tbaldridge21:04:11

"Back when I was a kid we didn't have VBOs and shaders, we called glVertex3f in a loop like god intended!"

qqq22:04:15

funnyily enough, it wasn't a webgl issue, it was a clojure issue

qqq22:04:40

I was using ::width ::height on a "window object", but was in the wrong namespace, so I got nil, which (/ nil 2) ==> gave me 0, which screwed up all the projection matrices ...

andy.fingerhut22:04:28

Huh, never knew that (/ nil 2) was 0 in ClojureScript. It raises an exception in Clojure/JVM

qqq22:04:24

@andy.fingerhut: that threw me off too

andy.fingerhut22:04:25

Reminds me of this 4-minute talk by Gary Bernhardt, which entertainly pokes fun at weirdness in some dark corners of Ruby and JavaScript: https://www.destroyallsoftware.com/talks/wat

👍 12
👌 4
😂 4