bool initBlend()
{
	glEnable(GL_SAMPLE_MASK);
	glSampleMaski(0, 0xFF);

	glEnablei(GL_BLEND, 0);
	glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
	glBlendEquationSeparatei(0, GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_ADD);
	glBlendFuncSeparatei(0, GL_SRC_COLOR, GL_ONE, GL_ZERO, GL_ZERO);

	glEnablei(GL_BLEND, 1);
	glColorMaski(1, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
	glBlendEquationSeparatei(1, GL_FACTOR_MIN_AMD, GL_FUNC_ADD);
	glBlendFuncSeparatei(1, GL_SRC_COLOR, GL_SRC_COLOR, GL_ZERO, GL_ZERO);

	glEnablei(GL_BLEND, 2);
	glColorMaski(2, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
	glBlendEquationSeparatei(2, GL_FACTOR_MAX_AMD, GL_FUNC_ADD);
	glBlendFuncSeparatei(2, GL_SRC_COLOR, GL_SRC_COLOR, GL_ZERO, GL_ZERO);

	glEnablei(GL_BLEND, 3);
	glColorMaski(3, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);
	glBlendEquationSeparatei(3, GL_FUNC_ADD, GL_FUNC_ADD);
	glBlendFuncSeparatei(3, GL_SRC_COLOR, GL_SRC_COLOR, GL_ZERO, GL_ZERO);

	return glf::checkError("initBlend");
}
Esempio n. 2
0
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");
}
Esempio n. 3
0
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);
}
Esempio n. 4
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);
    }
  }

}
Esempio n. 5
0
u32 GLGSRender::enable(u32 condition, u32 cap, u32 index)
{
	if (condition)
	{
		glEnablei(cap, index);
	}
	else
	{
		glDisablei(cap, index);
	}

	return condition;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
enum piglit_result
piglit_display(void)
{
	static const float expected[] = {
		0.0f, 1.0f, 0.0f, 1.0f
	};

	const int slice_height = (piglit_height + num_viewports - 2)
		/ (num_viewports - 1);

	bool pass = false;
	int i;

	glDisable(GL_SCISSOR_TEST);
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);

	glScissorIndexed(0, 0, 0, piglit_width, piglit_height);
	glEnablei(GL_SCISSOR_TEST, 0);

	for (i = 1; i < num_viewports; i++) {
		glEnablei(GL_SCISSOR_TEST, i);
		glScissorIndexed(i,
				 0, i * slice_height,
				 piglit_width, slice_height);
	}

	glClearColor(0.0, 1.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
				      expected);

	piglit_present_results();
	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Esempio n. 8
0
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;
}
Esempio n. 9
0
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]);
}
Esempio n. 10
0
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]);

}
Esempio n. 11
0
void GLWrapper::Enablei(GLenum cap, GLuint index)
{
	GLLOG(glEnablei(cap,index));ERROR_CHECK;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_GLES32_glEnablei(JNIEnv *__env, jclass clazz, jint target, jint index) {
    glEnableiPROC glEnablei = (glEnableiPROC)tlsGetFunction(327);
    UNUSED_PARAM(clazz)
    glEnablei(target, index);
}
Esempio n. 13
0
void enable(const GLenum capability, const int index)
{
    glEnablei(capability, index);
}
 inline void _glEnProxi(GLuint i)
    {
    glEnablei(GL_BLEND, i);
    }