Talk:OpenGL Programming/Scientific OpenGL Tutorial 02

= Could somebody add more descriptions for the magic numbers / scale factors in the code? =

I had a hard time following all of the scale / offset factors going on in the sample code, I'm going through it and trying to figure out what all these constants do. If anyone knows what these do and why they are needed, could somebody add more information to the article? Thanks!

I did my best below but it's nowhere near comprehensive, I'll edit this if I can figure out more of these,

Point array generation:

Vertex shader code

--Jwaffe (discuss • contribs) 21:08, 10 March 2019 (UTC)

= My comments =


 * Try to find out which texture formats your card supports. -> no idea :)

float y = (texture2D(mytexture, vec2(x / 2.0 + 0.5, 0)).r - 0.5) * 2.0; Similarly, to do a full [-1,+1]->[0,1] conversion, and a smoother gradient, the color could be /2: f_color = vec4(x/2 + 0.5, y/2 + 0.5, 1.0, 1.0);
 * Should we use "x / 2 + 0.5" instead of "x * 2 + 0.5" in the vertex shader?


 * Maybe add a few explanations on the scaling/offset algorithm. Between tut01 and tut02, not only the formula is reversed for x, but also the offset has not the same meaning (scaling-independent in tut01 and scaling-dependent in tut02). I hit my head on the wall a couple times before I understood everything ;)