From 4e1941908000424b26713c185e2cf907d8428e43 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 22 Oct 2022 21:59:24 +0300 Subject: [WGL/P02] Solved practicum exercises --- .../02-Practice-17.10.2022/Problem 0201.html | 64 +++++++++++++ .../02-Practice-17.10.2022/Problem 0202.html | 69 ++++++++++++++ .../02-Practice-17.10.2022/Problem 0203.html | 69 ++++++++++++++ .../02-Practice-17.10.2022/Problem 0204.html | 82 +++++++++++++++++ .../02-Practice-17.10.2022/Problem 0205.html | 79 ++++++++++++++++ .../02-Practice-17.10.2022/Problem 0206.html | 88 ++++++++++++++++++ .../02-Practice-17.10.2022/Problem 0207.html | 100 ++++++++++++++++++++ .../02-Practice-17.10.2022/Problem 0208.html | 101 +++++++++++++++++++++ .../02-Practice-17.10.2022/Problem 0209.html | 83 +++++++++++++++++ .../02-Practice-17.10.2022/webgl-fmi.js | 78 ++++++++++++++++ 10 files changed, 813 insertions(+) create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0201.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0202.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0203.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0204.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0205.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0206.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0207.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0208.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0209.html create mode 100644 Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/webgl-fmi.js diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0201.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0201.html new file mode 100644 index 0000000..f0f22bf --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0201.html @@ -0,0 +1,64 @@ + + + + + Септагон + + + + + + + + + + + +

Септагон

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0202.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0202.html new file mode 100644 index 0000000..0bd14dd --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0202.html @@ -0,0 +1,69 @@ + + + + + Мрежа + + + + + + + + + + + +

Мрежа

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0203.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0203.html new file mode 100644 index 0000000..827b463 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0203.html @@ -0,0 +1,69 @@ + + + + + Цветни точки + + + + + + + + + + + +

Цветни точки

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0204.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0204.html new file mode 100644 index 0000000..9206a04 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0204.html @@ -0,0 +1,82 @@ + + + + + Космата окръжност + + + + + + + + + + + +

Космата окръжност

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0205.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0205.html new file mode 100644 index 0000000..37c4127 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0205.html @@ -0,0 +1,79 @@ + + + + + GLSL пеперуда + + + + + + + + + + + +

GLSL пеперуда

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0206.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0206.html new file mode 100644 index 0000000..b1dbf82 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0206.html @@ -0,0 +1,88 @@ + + + + + Синус-косинус + + + + + + + + + + + +

Синус-косинус

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0207.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0207.html new file mode 100644 index 0000000..4d17ef7 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0207.html @@ -0,0 +1,100 @@ + + + + + Ямайка + + + + + + + + + + + +

Ямайка

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0208.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0208.html new file mode 100644 index 0000000..6cd2470 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0208.html @@ -0,0 +1,101 @@ + + + + + Триъгълник на Рольо + + + + + + + + + + + +

Триъгълник на Рольо

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0209.html b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0209.html new file mode 100644 index 0000000..51728d9 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/Problem 0209.html @@ -0,0 +1,83 @@ + + + + + Колело на цветовете + + + + + + + + + + + +

Колело на цветовете

+ + + + + Искаме canvas, но няма! + + diff --git a/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/webgl-fmi.js b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/webgl-fmi.js new file mode 100644 index 0000000..62bfda8 --- /dev/null +++ b/Year 2/Computer Graphics with WebGL/02-Practice-17.10.2022/webgl-fmi.js @@ -0,0 +1,78 @@ + +var gl; // глобален WebGL контекст +var glprog; // глобална GLSL програма + +// брой байтове в един WebGL FLOAT (трябва да са 4 байта) +var FLOATS = Float32Array.BYTES_PER_ELEMENT; + +// връща WebGL контекст, свързан с HTML елемент с даден id +function getContext(id) +{ + var canvas = document.getElementById(id); + if (!canvas) + { + alert("Искаме canvas с id=\""+id+"\", а няма!"); + return null; + } + + var context = canvas.getContext("webgl"); + if (!context) + { + context = canvas.getContext("experimental-webgl"); + } + + if (!context) + { + alert("Искаме WebGL контекст, а няма!"); + } + + return context; +} + +// връща компилиран шейдър +function getShader(id,type) +{ + var source = document.getElementById(id).text; + var shader = gl.createShader(type); + + gl.shaderSource(shader,source); + gl.compileShader(shader); + if (!gl.getShaderParameter(shader,gl.COMPILE_STATUS)) + { + alert(gl.getShaderInfoLog(shader)); + return null; + } + + return shader; +} + + +// връща готова програма +function getProgram(idv,idf) +{ + var vShader = getShader(idv,gl.VERTEX_SHADER); + var fShader = getShader(idf,gl.FRAGMENT_SHADER); + + if (!vShader || !fShader) {return null;} + + var shaderProgram = gl.createProgram(); + gl.attachShader(shaderProgram,vShader); + gl.attachShader(shaderProgram,fShader); + gl.linkProgram(shaderProgram); + + if (!gl.getProgramParameter(shaderProgram,gl.LINK_STATUS)) + { + alert(gl.getProgramInfoLog(shaderProgram)); + return null; + } + + gl.useProgram(shaderProgram); + return shaderProgram; +} + + +// случайно дробно число в интервал +function random(a,b) +{ + return a+(b-a)*Math.random(); +} \ No newline at end of file -- cgit v1.3.1-23-gd82d