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

Function Draw

test/browser/test_sdl2_gl_read.c:104–125  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 1

glBufferDataFunction · 0.85

Tested by

no test coverage detected