MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / Draw

Function Draw

test/browser/test_sdl_gl_read.c:105–126  ·  view source on GitHub ↗

Draw a triangle using the shader pair created in Init()

Source from the content-addressed store, hash-verified

103// Draw a triangle using the shader pair created in Init()
104//
105void Draw ()
106{
107 GLfloat vVertices[] = { 0.0f, 0.5f, 0.0f,
108 -0.5f, -0.5f, 0.0f,
109 0.5f, -0.5f, 0.0f };
110
111 // No clientside arrays, so do this in a webgl-friendly manner
112 GLuint vertexPosObject;
113 glGenBuffers(1, &vertexPosObject);
114 glBindBuffer(GL_ARRAY_BUFFER, vertexPosObject);
115 glBufferData(GL_ARRAY_BUFFER, 9*4, vVertices, GL_STATIC_DRAW);
116
117 glViewport ( 0, 0, width, height );
118 glClear ( GL_COLOR_BUFFER_BIT );
119 glUseProgram ( programObject );
120
121 glBindBuffer(GL_ARRAY_BUFFER, vertexPosObject);
122 glVertexAttribPointer(0 /* ? */, 3, GL_FLOAT, 0, 0, 0);
123 glEnableVertexAttribArray(0);
124
125 glDrawArrays ( GL_TRIANGLES, 0, 3 );
126}
127
128void Verify() {
129 unsigned char *data = malloc(width*height*4 + 16);

Callers 1

mainFunction · 0.70

Calls 1

glBufferDataFunction · 0.85

Tested by

no test coverage detected