Skip to content

Falta el 9 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions basic_concepts/clear-canvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</head>

<body onload="init()">
<canvas id="myCanvas" width="640" height="480"></canvas>
<canvas id="myCanvas" width="1000" height="500"></canvas>
</body>

<script>
Expand All @@ -22,11 +22,11 @@
}

// Set clear color
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clearColor(1.0, 1.0, 0.0, 1.0);

// Clear canvas
gl.clear(gl.COLOR_BUFFER_BIT);
}
</script>

</html>
</html>
77 changes: 7 additions & 70 deletions basic_concepts/draw-a-point.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,13 @@
<canvas id="myCanvas" width="640" height="480"></canvas>
</body>

<script id="shaderVs" type="x-shader/x-vertex">
void main() {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
gl_PointSize = 10.0;
}
</script>
<script
src = "prueba1.vert"></script>

<script id="shaderFs" type="x-shader/x-fragment">
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
<script
src = "prueba2.frag"></script>

<script>
function init() {
// Get canvas object from the DOM
var canvas = document.getElementById("myCanvas");
<script
src = "prueba.js"> </script>

// Init WebGL context
var gl = canvas.getContext("webgl");
if (!gl) {
console.log("Failed to get the rendering context for WebGL");
return;
}

// Clear canvas
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);

// Init shaders
var vs = document.getElementById('shaderVs').innerHTML;
var fs = document.getElementById('shaderFs').innerHTML;
initShaders(gl, vs, fs);

// Draw a point
gl.drawArrays(gl.POINTS, 0, 1);
}


function initShaders(gl, vs_source, fs_source) {
// Compile shaders
var vertexShader = makeShader(gl, vs_source, gl.VERTEX_SHADER);
var fragmentShader = makeShader(gl, fs_source, gl.FRAGMENT_SHADER);

// Create program
var glProgram = gl.createProgram();

// Attach and link shaders to the program
gl.attachShader(glProgram, vertexShader);
gl.attachShader(glProgram, fragmentShader);
gl.linkProgram(glProgram);
if (!gl.getProgramParameter(glProgram, gl.LINK_STATUS)) {
alert("Unable to initialize the shader program");
return;
}

// Use program
gl.useProgram(glProgram);
}

function makeShader(gl, src, type) {
var shader = gl.createShader(type);
gl.shaderSource(shader, src);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert("Error compiling shader: " + gl.getShaderInfoLog(shader));
return;
}
return shader;
}
</script>

</html>
</html>
57 changes: 57 additions & 0 deletions basic_concepts/prueba.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

function init() {
// Get canvas object from the DOM
var canvas = document.getElementById("myCanvas");

// Init WebGL context
var gl = canvas.getContext("webgl");
if (!gl) {
console.log("Failed to get the rendering context for WebGL");
return;
}

// Clear canvas
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);

// Init shaders
var vs = document.getElementById('shaderVs').innerHTML;
var fs = document.getElementById('shaderFs').innerHTML;
initShaders(gl, vs, fs);

// Draw a point
gl.drawArrays(gl.POINTS, 0, 1);
}


function initShaders(gl, vs_source, fs_source) {
// Compile shaders
var vertexShader = makeShader(gl, vs_source, gl.VERTEX_SHADER);
var fragmentShader = makeShader(gl, fs_source, gl.FRAGMENT_SHADER);

// Create program
var glProgram = gl.createProgram();

// Attach and link shaders to the program
gl.attachShader(glProgram, vertexShader);
gl.attachShader(glProgram, fragmentShader);
gl.linkProgram(glProgram);
if (!gl.getProgramParameter(glProgram, gl.LINK_STATUS)) {
alert("Unable to initialize the shader program");
return;
}

// Use program
gl.useProgram(glProgram);
}

function makeShader(gl, src, type) {
var shader = gl.createShader(type);
gl.shaderSource(shader, src);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert("Error compiling shader: " + gl.getShaderInfoLog(shader));
return;
}
return shader;
}
4 changes: 4 additions & 0 deletions basic_concepts/prueba1.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void main() {
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
gl_PointSize = 10.0;
}
3 changes: 3 additions & 0 deletions basic_concepts/prueba2.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void main() {
gl_FragColor = vec4(1.0, 1.0, 0.5, 1.0);
}