mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-25 10:25:23 +00:00
Compare commits
3 Commits
cd75b68359
...
b8aada0385
Author | SHA1 | Date | |
---|---|---|---|
|
b8aada0385 | ||
|
90d544271e | ||
|
fa0e3c632f |
@ -256,7 +256,7 @@ We now state Collatz conjecture. The proof is left as an exercise to the reader.
|
|||||||
def collatz_next (n : Nat) : Nat :=
|
def collatz_next (n : Nat) : Nat :=
|
||||||
if n % 2 = 0 then n / 2 else 3 * n + 1
|
if n % 2 = 0 then n / 2 else 3 * n + 1
|
||||||
|
|
||||||
def iter (k : Nat) (f: Nat → Nat) :=
|
def iter (k : Nat) (f : Nat → Nat) :=
|
||||||
match k with
|
match k with
|
||||||
| Nat.zero => fun x => x
|
| Nat.zero => fun x => x
|
||||||
| Nat.succ k' => fun x => f (iter k' f x)
|
| Nat.succ k' => fun x => f (iter k' f x)
|
||||||
|
@ -161,7 +161,7 @@ sf::Event event{ };
|
|||||||
// ...
|
// ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Ofcourse we have to create the vertex and fragment shader before we can load them,
|
Of course we have to create the vertex and fragment shader before we can load them,
|
||||||
so lets create two basic shaders.
|
so lets create two basic shaders.
|
||||||
|
|
||||||
**Vertex Shader**
|
**Vertex Shader**
|
||||||
@ -342,7 +342,7 @@ void main() {
|
|||||||
We define a new input variable ```color``` which represents our color data, this data
|
We define a new input variable ```color``` which represents our color data, this data
|
||||||
is passed on to ```fColor```, which is an output variable of our vertex shader and
|
is passed on to ```fColor```, which is an output variable of our vertex shader and
|
||||||
becomes an input variable for our fragment shader.
|
becomes an input variable for our fragment shader.
|
||||||
It is imporatant that variables passed between shaders have the exact same name
|
It is important that variables passed between shaders have the exact same name
|
||||||
and type.
|
and type.
|
||||||
|
|
||||||
## Handling VBO's
|
## Handling VBO's
|
||||||
@ -501,7 +501,7 @@ glBindTexture(GL_TEXTURE_2D, 0);
|
|||||||
glDeleteTextures(1, &texture);
|
glDeleteTextures(1, &texture);
|
||||||
```
|
```
|
||||||
|
|
||||||
Ofcourse there are more texture formats than only 2D textures,
|
Of course there are more texture formats than only 2D textures,
|
||||||
You can find further information on parameters here:
|
You can find further information on parameters here:
|
||||||
[glBindTexture - OpenGL Refpage](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindTexture.xhtml)<br>
|
[glBindTexture - OpenGL Refpage](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindTexture.xhtml)<br>
|
||||||
[glTexImage2D - OpenGL Refpage](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml)<br>
|
[glTexImage2D - OpenGL Refpage](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml)<br>
|
||||||
@ -574,7 +574,7 @@ in vec2 fTexCoords;
|
|||||||
out vec4 outColor;
|
out vec4 outColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// texture() loads the current texure data at the specified texture coords,
|
// texture() loads the current texture data at the specified texture coords,
|
||||||
// then we can simply multiply them by our color.
|
// then we can simply multiply them by our color.
|
||||||
outColor = texture(tex, fTexCoords) * vec4(fColor, 1.0);
|
outColor = texture(tex, fTexCoords) * vec4(fColor, 1.0);
|
||||||
}
|
}
|
||||||
@ -685,7 +685,7 @@ Geometry shaders are inbetween the vertex and the fragment shader.
|
|||||||
|
|
||||||
layout(location = 0) in vec3 position;
|
layout(location = 0) in vec3 position;
|
||||||
layout(location = 1) in vec3 color;
|
layout(location = 1) in vec3 color;
|
||||||
// Create an output interface block passed to the next shadaer stage.
|
// Create an output interface block passed to the next shader stage.
|
||||||
// Interface blocks can be used to structure data passed between shaders.
|
// Interface blocks can be used to structure data passed between shaders.
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
vec3 color;
|
vec3 color;
|
||||||
|
Loading…
Reference in New Issue
Block a user