src/gl/basicshaderprogram.cpp

changeset 118
8e1c9f18ae15
parent 70
f21b800b02a4
child 215
34c6e7bc4ee1
equal deleted inserted replaced
117:121a40d5e34c 118:8e1c9f18ae15
35 this->program.emplace(this); 35 this->program.emplace(this);
36 gl::buildShaders(&*this->program, this->vertexShaderSource(), this->fragmentShaderSource()); 36 gl::buildShaders(&*this->program, this->vertexShaderSource(), this->fragmentShaderSource());
37 this->program->bind(); 37 this->program->bind();
38 this->buffer.create(); 38 this->buffer.create();
39 this->buffer.bind(); 39 this->buffer.bind();
40 this->buffer.setUsagePattern(QOpenGLBuffer::StaticDraw); 40 const QOpenGLBuffer::UsagePattern pattern = this->usagePattern();
41 this->buffer.allocate(this->vertexData(), this->vertexCount() * this->vertexSize()); 41 this->buffer.setUsagePattern(pattern);
42 if (pattern == QOpenGLBuffer::StaticDraw)
43 {
44 this->buffer.allocate(this->vertexData(), this->vertexCount() * this->vertexSize());
45 }
42 this->vertexArrayObject.create(); 46 this->vertexArrayObject.create();
43 this->vertexArrayObject.bind(); 47 this->vertexArrayObject.bind();
44 this->setupVertexArrays(); 48 this->setupVertexArrays();
45 this->vertexArrayObject.release(); 49 this->vertexArrayObject.release();
46 this->buffer.release(); 50 this->buffer.release();

mercurial