本文整理汇总了C++中QOpenGLFunctions::glDisable方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions::glDisable方法的具体用法?C++ QOpenGLFunctions::glDisable怎么用?C++ QOpenGLFunctions::glDisable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions
的用法示例。
在下文中一共展示了QOpenGLFunctions::glDisable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void Renderer::render()
{
QMutexLocker locker(&m_windowLock);
if (m_windows.isEmpty())
return;
HelloWindow *surface = m_windows.at(m_currentWindow);
QColor color = surface->color();
m_currentWindow = (m_currentWindow + 1) % m_windows.size();
if (!m_context->makeCurrent(surface))
return;
QSize viewSize = surface->size();
locker.unlock();
if (!m_initialized) {
initialize();
m_initialized = true;
}
QOpenGLFunctions *f = m_context->functions();
f->glViewport(0, 0, viewSize.width() * surface->devicePixelRatio(), viewSize.height() * surface->devicePixelRatio());
f->glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
f->glFrontFace(GL_CW);
f->glCullFace(GL_FRONT);
f->glEnable(GL_CULL_FACE);
f->glEnable(GL_DEPTH_TEST);
QMatrix4x4 modelview;
modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f);
modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f);
modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f);
modelview.translate(0.0f, -0.2f, 0.0f);
m_program->bind();
m_program->setUniformValue(matrixUniform, modelview);
m_program->setUniformValue(colorUniform, color);
paintQtLogo();
m_program->release();
f->glDisable(GL_DEPTH_TEST);
f->glDisable(GL_CULL_FACE);
m_context->swapBuffers(surface);
m_fAngle += 1.0f;
QTimer::singleShot(0, this, SLOT(render()));
}
示例2: render
void GLTerrainRect::render()
{
if(!initalised())
initGL();
QOpenGLFunctions * f = QOpenGLContext::currentContext()->functions();
f->glEnable(GL_BLEND);CE();
f->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);CE();
m_vao_constraints.bind();CE();
f->glDrawElements(GL_TRIANGLE_STRIP, m_indicies.size(), GL_UNSIGNED_INT, (void*)(0)); CE();CE();
m_vao_constraints.release();CE();
f->glDisable(GL_BLEND);CE();
}
示例3: render
void QtViewRenderer::render()
{
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
OpenGLStateSaver state(f);
f->glEnable(GL_BLEND);
f->glBlendEquation(GL_FUNC_ADD);
f->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
f->glDisable(GL_CULL_FACE);
f->glDisable(GL_DEPTH_TEST);
f->glActiveTexture(GL_TEXTURE0);
glClearColor(m_clearColor[0], m_clearColor[1], m_clearColor[2], 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, m_width, m_height);
QMatrix4x4 ortho;
ortho.ortho(m_viewBounds[0], m_viewBounds[2], m_viewBounds[3], m_viewBounds[1], -1, 1);
m_shader->bind();
m_shader->setUniformValue(m_locationTex, 0);
m_shader->setUniformValue(m_locationProjMtx, ortho);
m_VAO->bind();
int vboSize = 0, eboSize = 0;
for (const auto cmd_list : m_drawLists)
{
if (cmd_list->vtxBuffer().empty() || cmd_list->idxBuffer().empty())
continue;
const DrawList::DrawIdx* idx_buffer_offset = nullptr;
m_VBO->bind();
int vtxSize = cmd_list->vtxBuffer().size() * sizeof(DrawList::DrawVert);
if (vtxSize > vboSize)
{
m_VBO->allocate(vtxSize);
vboSize = vtxSize;
}
m_VBO->write(0, &cmd_list->vtxBuffer().front(), vtxSize);
m_EBO->bind();
int idxSize = cmd_list->idxBuffer().size() * sizeof(DrawList::DrawIdx);
if (idxSize > eboSize)
{
m_EBO->allocate(idxSize);
eboSize = idxSize;
}
m_EBO->write(0, &cmd_list->idxBuffer().front(), idxSize);
for (const auto& pcmd : cmd_list->cmdBuffer())
{
glBindTexture(GL_TEXTURE_2D, pcmd.textureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(pcmd.elemCount), GL_UNSIGNED_INT, idx_buffer_offset);
idx_buffer_offset += pcmd.elemCount;
}
}
m_shader->release();
m_VAO->release();
}
示例4: saveTexture
void QSGDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, int height) const
{
QOpenGLFunctions *functions = QOpenGLContext::currentContext()->functions();
GLuint fboId;
functions->glGenFramebuffers(1, &fboId);
GLuint tmpTexture = 0;
functions->glGenTextures(1, &tmpTexture);
functions->glBindTexture(GL_TEXTURE_2D, tmpTexture);
functions->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
functions->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
functions->glBindTexture(GL_TEXTURE_2D, 0);
functions->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId);
functions->glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
tmpTexture, 0);
functions->glActiveTexture(GL_TEXTURE0);
functions->glBindTexture(GL_TEXTURE_2D, textureId);
functions->glDisable(GL_STENCIL_TEST);
functions->glDisable(GL_DEPTH_TEST);
functions->glDisable(GL_SCISSOR_TEST);
functions->glDisable(GL_BLEND);
GLfloat textureCoordinateArray[8];
textureCoordinateArray[0] = 0.0f;
textureCoordinateArray[1] = 0.0f;
textureCoordinateArray[2] = 1.0f;
textureCoordinateArray[3] = 0.0f;
textureCoordinateArray[4] = 1.0f;
textureCoordinateArray[5] = 1.0f;
textureCoordinateArray[6] = 0.0f;
textureCoordinateArray[7] = 1.0f;
GLfloat vertexCoordinateArray[8];
vertexCoordinateArray[0] = -1.0f;
vertexCoordinateArray[1] = -1.0f;
vertexCoordinateArray[2] = 1.0f;
vertexCoordinateArray[3] = -1.0f;
vertexCoordinateArray[4] = 1.0f;
vertexCoordinateArray[5] = 1.0f;
vertexCoordinateArray[6] = -1.0f;
vertexCoordinateArray[7] = 1.0f;
functions->glViewport(0, 0, width, height);
functions->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray);
functions->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray);
{
static const char *vertexShaderSource =
"attribute vec4 vertexCoordsArray; \n"
"attribute vec2 textureCoordArray; \n"
"varying vec2 textureCoords; \n"
"void main(void) \n"
"{ \n"
" gl_Position = vertexCoordsArray; \n"
" textureCoords = textureCoordArray; \n"
"} \n";
static const char *fragmentShaderSource =
"varying vec2 textureCoords; \n"
"uniform sampler2D texture; \n"
"void main() \n"
"{ \n"
" gl_FragColor = texture2D(texture, textureCoords); \n"
"} \n";
GLuint vertexShader = functions->glCreateShader(GL_VERTEX_SHADER);
GLuint fragmentShader = functions->glCreateShader(GL_FRAGMENT_SHADER);
if (vertexShader == 0 || fragmentShader == 0) {
GLenum error = functions->glGetError();
qWarning("QSGDistanceFieldGlyphCache::saveTexture: Failed to create shaders. (GL error: %x)",
error);
return;
}
functions->glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
functions->glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
functions->glCompileShader(vertexShader);
GLint len = 1;
functions->glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &len);
char infoLog[2048];
functions->glGetShaderInfoLog(vertexShader, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0)
qWarning("Problems compiling vertex shader:\n %s", infoLog);
functions->glCompileShader(fragmentShader);
functions->glGetShaderInfoLog(fragmentShader, 2048, NULL, infoLog);
if (qstrlen(infoLog) > 0)
qWarning("Problems compiling fragment shader:\n %s", infoLog);
GLuint shaderProgram = functions->glCreateProgram();
//.........这里部分代码省略.........