void renderScene ( glm::vec4 const & ClearColor, glm::mat4 const & MVP, GLuint Texture2DName ) { GLint const Border = 16; glEnablei(GL_SCISSOR_TEST, 0); glScissor(Border, Border, Window.Size.x - Border * 2, Window.Size.y - Border * 2); glClearBufferfv(GL_COLOR, 0, &ClearColor[0]); // Bind the program for use glUseProgram(ProgramName); glUniform1i(UniformDiffuse, 0); glUniformMatrix4fv(UniformMVP, 1, GL_FALSE, &MVP[0][0]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, Texture2DName); glBindSampler(0, SamplerName); glBindVertexArray(VertexArrayName); glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1); glDisablei(GL_SCISSOR_TEST, 0); glf::checkError("renderScene"); }
void ReplayRenderWidget::paintGL() { // Set up some needed GL state glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDisablei(GL_BLEND, 0); glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); glDisable(GL_SCISSOR_TEST); glDisable(GL_CULL_FACE); // Clear screen glClearColor(0.6f, 0.2f, 0.2f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Draw displays // Setup screen draw shader glBindVertexArray(mVertArray); glBindVertexBuffer(0, mVertBuffer, 0, 4 * sizeof(GLfloat)); glBindProgramPipeline(mPipeline); // Draw screen quad glBindSampler(0, mSampler); glBindTextureUnit(0, mTvBuffer); glDrawArrays(GL_TRIANGLES, 0, 6); }
void raytracer_app::recurse(int depth) { glBindFramebuffer(GL_FRAMEBUFFER, ray_fbo[depth + 1]); static const GLenum draw_buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3, GL_COLOR_ATTACHMENT4, GL_COLOR_ATTACHMENT5 }; glDrawBuffers(6, draw_buffers); glEnablei(GL_BLEND, 0); glBlendFunci(0, GL_ONE, GL_ONE); // static const float zeros[] = { 0.0f, 0.0f, 0.0f, 0.0f }; // glClearBufferfv(GL_COLOR, 0, zeros); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tex_position[depth]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, tex_reflected[depth]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, tex_reflection_intensity[depth]); // Render glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (depth != (max_depth - 1)) { recurse(depth + 1); } //*/ /* if (depth != 0) { glBindTexture(GL_TEXTURE_2D, tex_refracted[depth]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, tex_refraction_intensity[depth]); // Render glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (depth != (max_depth - 1)) { recurse(depth + 1); } } //**/ glDisablei(GL_BLEND, 0); }
void StateSystem::ScissorEnableState::applyGL() const { if (separateEnable){ for (GLuint i = 0; i < MAX_VIEWPORTS; i++){ if (isBitSet(separateEnable,i)) glEnablei (GL_SCISSOR_TEST,i); else glDisablei(GL_SCISSOR_TEST,i); } } }
CRenderingContext::~CRenderingContext() { TAssert(s_aContexts.size()); s_aContexts.pop_back(); if (s_aContexts.size()) { CRenderContext& oContext = GetContext(); UseMaterial(oContext.m_hMaterial); UseFrameBuffer(oContext.m_pFrameBuffer); UseProgram(oContext.m_pShader); if (*oContext.m_szProgram) { oContext.m_bProjectionUpdated = false; oContext.m_bViewUpdated = false; oContext.m_bTransformUpdated = false; } SetViewport(oContext.m_rViewport); SetBlend(oContext.m_eBlend); SetAlpha(oContext.m_flAlpha); SetDepthMask(oContext.m_bDepthMask); SetDepthTest(oContext.m_bDepthTest); SetDepthFunction(oContext.m_eDepthFunction); SetBackCulling(oContext.m_bCull); SetWinding(oContext.m_bWinding); } else { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0); if (m_pRenderer) glViewport(0, 0, (GLsizei)m_pRenderer->m_iWidth, (GLsizei)m_pRenderer->m_iHeight); else glViewport(0, 0, (GLsizei)Application()->GetWindowWidth(), (GLsizei)Application()->GetWindowHeight()); glUseProgram(0); glDisablei(GL_BLEND, 0); glDepthMask(true); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glDepthFunc(GL_LESS); glFrontFace(GL_CCW); } }
u32 GLGSRender::enable(u32 condition, u32 cap, u32 index) { if (condition) { glEnablei(cap, index); } else { glDisablei(cap, index); } return condition; }
PIGLIT_GL_TEST_CONFIG_END /** * Test that ScissorArrayv, ScissorIndexed(v), GetIntegeri_v give the * "expected_error" gl error. Given the values for "first" and "count" * or "index" in range [first, first+count). */ static bool check_sc_index(GLuint first, GLsizei count, GLenum expected_error) { static const GLint sv[] = {0, 10, 20, 35}; GLint *mv, svGet[4]; unsigned int i; bool pass = true; const unsigned int numIterate = (expected_error == GL_NO_ERROR) ? count : 1; mv = malloc(sizeof(GLint) * 4 * count); if (mv == NULL) return false; for (i = 0; i < count; i++) { mv[i * 4] = sv[0]; mv[i * 4 + 1] = sv[1]; mv[i * 4 + 2] = sv[2]; mv[i * 4 + 3] = sv[3]; } glScissorArrayv(first, count, mv); free(mv); pass = piglit_check_gl_error(expected_error) && pass; /* only iterate multiple indices for no error case */ for (i = count; i > count - numIterate; i--) { glScissorIndexed(first + i - 1, sv[0], sv[1], sv[2], sv[3]); pass = piglit_check_gl_error(expected_error) && pass; glGetIntegeri_v(GL_SCISSOR_BOX, first + i - 1, svGet); pass = piglit_check_gl_error(expected_error) && pass; glEnablei(GL_SCISSOR_TEST, first + i - 1); pass = piglit_check_gl_error(expected_error) && pass; glDisablei(GL_SCISSOR_TEST, first + i - 1); pass = piglit_check_gl_error(expected_error) && pass; glIsEnabledi(GL_SCISSOR_TEST, first + i - 1); pass = piglit_check_gl_error(expected_error) && pass; } return pass; }
/** * Draws a single quad full window size, with different scissor rectangles * and different scissor test enables for each viewport index. * Scissor rectangles or viewport restrict drawing to sub-area of full * window surface. Geometry shader is responsible for exapnding primitves * to cover all divX * divY viewport/scissor indices. The function reads * back the expected color to test if the scissored drawing was correct. */ static bool draw_multi_viewport_scissor(void) { bool pass = true, scEnabled; int i, j; GLfloat w = (GLfloat) piglit_width / (GLfloat) divX; GLfloat h = (GLfloat) piglit_height / (GLfloat) divY; /* Setup scissor/viewport rectangles and enables for indices. * Every other index has SCISSOR_TEST enabled with a scissor * rectangle that restricts rendering to the sub-region (wxh). * The other indices restrict rendering by making the viewport * restricted to the sub-region (wxh sized). For the indices with * viewport restricted rendering, the SCISSOR_TEST is alternatively * enabled/disabled. */ glScissor(0, 0, piglit_width, piglit_height); glViewport(0, 0, piglit_width, piglit_height); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_SCISSOR_TEST); scEnabled = false; for (i = 0; i < divX; i++) { for (j = 0; j < divY; j++) { GLuint idx = j + i*divY; if (scEnabled) { /* use viewport to restrict rendering */ if (i & 1) glDisablei(GL_SCISSOR_TEST, idx); glViewportIndexedf(idx, i * w, j * h, w, h); scEnabled = false; } else { /* use scissor to restrict rendering */ glScissorIndexed(idx, i * w, j * h, w, h); scEnabled = true; } } } /* draw restricted size quads with scissoring enabled/disabled */ pass = piglit_check_gl_error(GL_NO_ERROR) && pass; pass = draw_check_pixels() & pass; glDisable(GL_SCISSOR_TEST); return pass; }
void CRenderingContext::SetBlend(blendtype_t eBlend) { if (eBlend) { glEnablei(GL_BLEND, 0); if (eBlend == BLEND_ALPHA) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else if (eBlend == BLEND_ADDITIVE) glBlendFunc(GL_SRC_ALPHA, GL_ONE); else if (eBlend == BLEND_BOTH) glBlendFunc(GL_ONE, GL_ONE); else TUnimplemented(); } else glDisablei(GL_BLEND, 0); GetContext().m_eBlend = eBlend; }
void StateSystem::BlendState::applyGL() const { if (separateEnable){ for (GLuint i = 0; i < MAX_DRAWBUFFERS; i++){ if (isBitSet(separateEnable,i)) glEnablei(GL_BLEND,i); else glDisablei(GL_BLEND,i); } } if (useSeparate){ for (GLuint i = 0; i < MAX_DRAWBUFFERS; i++){ glBlendFuncSeparatei(i,blends[i].rgb.srcw,blends[i].rgb.dstw,blends[i].alpha.srcw,blends[i].alpha.dstw); glBlendEquationSeparatei(i,blends[i].rgb.equ,blends[i].alpha.equ); } } else{ glBlendFuncSeparate(blends[0].rgb.srcw,blends[0].rgb.dstw,blends[0].alpha.srcw,blends[0].alpha.dstw); glBlendEquationSeparate(blends[0].rgb.equ,blends[0].alpha.equ); } //glBlendColor(color[0],color[1],color[2],color[3]); }
void raytracer_app::recurse(int depth) { printf("recuse\n"); glBindFramebuffer(GL_FRAMEBUFFER, ray_fbo[depth + 1]); if(pnt) printf("draw buffers\n"); glDrawBuffers(6, draw_buffers); if(pnt) printf("blend\n"); glEnablei(GL_BLEND, 0); //glEnablei(GL_BLEND, draw_buffers[0]); if(pnt) printf("blend\n"); glBlendFunc(GL_ONE, GL_ONE); //glBlendFunci(0, GL_ONE, GL_ONE); //glBlendFunci(draw_buffers[0], GL_ONE, GL_ONE); // static const float zeros[] = { 0.0f, 0.0f, 0.0f, 0.0f }; // glClearBufferfv(GL_COLOR, 0, zeros); if(pnt) printf("tex_position\n"); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tex_position[depth]); if(pnt) printf("tex_reflected\n"); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, tex_reflected[depth]); if(pnt) printf("tex_reflection_intensity\n"); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, tex_reflection_intensity[depth]); // Render if(pnt) printf("render\n"); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (depth != (max_depth - 1)) { recurse(depth + 1); } /* if (depth != 0) { glBindTexture(GL_TEXTURE_2D, tex_refracted[depth]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, tex_refraction_intensity[depth]); // Render glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (depth != (max_depth - 1)) { recurse(depth + 1); } } */ glDisablei(GL_BLEND, 0); //glDisablei(GL_BLEND, draw_buffers[0]); }
void GLWrapper::Disablei(GLenum cap, GLuint index) { GLLOG(glDisablei(cap,index));ERROR_CHECK; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLES32_glDisablei(JNIEnv *__env, jclass clazz, jint target, jint index) { glDisableiPROC glDisablei = (glDisableiPROC)tlsGetFunction(328); UNUSED_PARAM(clazz) glDisablei(target, index); }
void disable(const GLenum capability, const int index) { glDisablei(capability, index); }
inline void _glDsProxi(GLuint i) { glDisablei(GL_BLEND, i); }