Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are WebGL's draw primitives?

I've been doing some graphics programming using webgl to draw OBJMesh's, but it hasn't gone too well as it is not drawing it correctly. I think thats because of the drawing primitives that I'm using e.g : gl.drawArrays(gl.TRIANGLE_STRIP, 0, vertexBuffer.numItems);

So can I ask what primitives do webGL allow? is it the same as openGL? I've been trying to use gl.QUADS as I thought it would allow it as openGL does, so I'm not too sure anymore.

like image 576
Danny Avatar asked Jan 24 '13 14:01

Danny


People also ask

What are the drawing modes supported by WebGL?

The mode Parameter void drawElements(enum mode, long count, enum type, long offset); void drawArrays(enum mode, int first, long count);

What are GL primitives?

In OpenGL, an object is made up of geometric primitives such as triangle, quad, line segment and point. A primitive is made up of one or more vertices. OpenGL supports the following primitives: A geometric primitive is defined by specifying its vertices via glVertex function, enclosed within a pair glBegin and glEnd .

Does WebGL use shaders?

As mentioned in how it works WebGL requires 2 shaders every time you draw something. A vertex shader and a fragment shader. Each shader is a function.


1 Answers

From https://www.khronos.org/registry/webgl/specs/1.0/:

const GLenum POINTS                         = 0x0000;
const GLenum LINES                          = 0x0001;
const GLenum LINE_LOOP                      = 0x0002;
const GLenum LINE_STRIP                     = 0x0003;
const GLenum TRIANGLES                      = 0x0004;
const GLenum TRIANGLE_STRIP                 = 0x0005;
const GLenum TRIANGLE_FAN                   = 0x0006;
like image 93
Nathan Monteleone Avatar answered Sep 27 '22 18:09

Nathan Monteleone