[ / / / / / / / / / / / / / ] [ dir / random / 93 / biohzrd / hkacade / hkpnd / tct / utd / uy / yebalnia ]

/agdg/ - Amateur Game Development General

AGDG - The Board
Name
Email
Subject
REC
STOP
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
Archive
* = required field[▶Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options
dicesidesmodifier

Allowed file types:jpg, jpeg, gif, png, webp,webm, mp4, mov, swf, pdf
Max filesize is16 MB.
Max image dimensions are15000 x15000.
You may upload5 per post.


Welcome to AGDG, keep working on your game anon!
See also: /ideaguy/ | /vm/

File: 3657744cbccffd8⋯.jpg (140.74 KB,1010x568,505:284,41.jpg)

21bbde No.29248

General

/Also requesting some minimalist starter code

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

21bbde No.29249

>>29248

ah nvm, got a response from canvas



<!DOCTYPE html>

<html>

<body>
<canvas id="glCanvas" width="640" height="480">
Your browser doesn't appear to support the
<code>&lt;canvas&gt;</code> element.
</canvas>


<script id="shader-fs" type="x-shader/x-fragment">

void main(void) {
gl_FragColor = vec4(0, 1, 0, 1);
}

</script>

<script id="shader-vs" type="x-shader/x-vertex">

attribute vec4 aVertexPosition;

void main(void) {
gl_Position = vec4(aVertexPosition.xyz, 1);
}

</script>



<script>

var canvas;

var gl = null;

canvas = document.getElementById('glCanvas');

gl = canvas.getContext('webgl2');

if(gl) alert(gl.getParameter(gl.VERSION));

if(gl) doGL();

alert("Fin");


function doGL(){

gl.clearColor(0.0, 0.0, 0.0, 0.5);
// Enable depth testing
gl.enable(gl.DEPTH_TEST);
// Near things obscure far things
gl.depthFunc(gl.LEQUAL);
// Clear the color as well as the depth buffer.
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

alert("A");

initShaders();

alert("B");

initBuffers();

alert("C");

drawScene();

alert("D");

}


function initShaders() {
var fragmentShader = getShader(gl, 'shader-fs');
var vertexShader = getShader(gl, 'shader-vs');

// Create the shader program

shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
gl.linkProgram(shaderProgram);

// If creating the shader program failed, alert

if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
console.log('Unable to initialize the shader program: ' + gl.getProgramInfoLog(shaderProgram));
}

gl.useProgram(shaderProgram);

vertexPositionAttribute = gl.getAttribLocation(shaderProgram, 'aVertexPosition');
gl.enableVertexAttribArray(vertexPositionAttribute);
}

function getShader(gl, id, type) {
var shaderScript, theSource, currentChild, shader;

shaderScript = document.getElementById(id);

if (!shaderScript) {
return null;
}

theSource = shaderScript.text;

if (!type) {
if (shaderScript.type == 'x-shader/x-fragment') {
type = gl.FRAGMENT_SHADER;
} else if (shaderScript.type == 'x-shader/x-vertex') {
type = gl.VERTEX_SHADER;
} else {
// Unknown shader type
return null;
}
}
shader = gl.createShader(type);

gl.shaderSource(shader, theSource);

// Compile the shader program
gl.compileShader(shader);

// See if it compiled successfully
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.log('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(shader));
gl.deleteShader(shader);
return null;
}

return shader;
}


var horizAspect = 480.0/640.0;

function initBuffers() {
squareVerticesBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesBuffer);

var vertices = [
0.2, 1.0, -2.0,
-1.0, 1.0, 2.0,
0.4, -1.0, 2.0,
-1.0, -1.0, -3.0
];

gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
}



function drawScene() {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

//perspectiveMatrix = makePerspective(45, 640.0/480.0, 0.1, 100.0);

//loadIdentity();

// mvTranslate([-0.0, 0.0, -6.0]);

gl.bindBuffer(gl.ARRAY_BUFFER, squareVerticesBuffer);
gl.vertexAttribPointer(vertexPositionAttribute, 3, gl.FLOAT, false, 0, 0);
// setMatrixUniforms();
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
}


</script>


</body>
</html>

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

528cc1 No.29256

File: 9cf1ca70a9bff5e⋯.png (55.82 KB,662x492,331:246,canvas.png)

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

528cc1 No.29257

I don't think w is supposed to be used this way somehow..



<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;

varying lowp vec4 vColor;

// attribute vec4 aVertexPosition;

void main(void) {

gl_Position = vec4(aVertexPosition.xyz, 1).rgab; //, 1, aVertexPosition.z);

vColor = aVertexColor;
}

</script>

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

7e6568 No.29258

File: 09dd66ce85df685⋯.png (153.63 KB,632x462,316:231,canv2.png)

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

40ac1a No.29274

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

194698 No.29282

File: ad2830fc68dda62⋯.png (194.04 KB,672x496,42:31,surf.png)

>>29274

cleardepth 0 // depth order greater / gequals // z = 1/w

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

194698 No.29283

What does agdg think of using a sqrt(x^2 + y^2 +z^2) scaling factor?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



[Return][Go to top][Catalog][Nerve Center][Random][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / random / 93 / biohzrd / hkacade / hkpnd / tct / utd / uy / yebalnia ]