Пример #1
0
void Renderer::apply(){
	changeShader(selectedShader);

	assignNamedTextures();

	for (int textureUnit = 0; textureUnit < nSimultaneousTextures; textureUnit++){
		changeTextureUnit(textureUnit);
		changeTexture(selectedTextures[textureUnit]);
		changeTexEnv(selectedColorTexEnvs[textureUnit], selectedAlphaTexEnvs[textureUnit]);
	}

	changeBlending(selectedSrcFactor, selectedDestFactor, selectedBlendMode);
	changeDepthFunc(selectedDepthFunc);
	changeMask(selectedMask);

	reset();
}
Пример #2
0
void Renderer::apply()
{

#ifdef DEBUG
	/*if (!wasReset){
		CHG_WARNING("Warning: reset() not called before apply()");
	}
	wasReset = false;*/
#endif


	if (selectedShader != DONTCARE)
	{
		changeShader(selectedShader);
		applyConstants();
	}

	applyTextures();

    applyImageBuffers();

	applyObjectBuffers();
	
	applyRWStructuredBuffers();

	applySamplerStates();

	changeVertexFormat(selectedVertexFormat);

	changeVertexBuffer(0, numVertexBufferUsed, selectedVertexBuffers, selectedOffsets);

	if (selectedIndexBuffer != DONTCARE) changeIndexBuffer(selectedIndexBuffer);

	if (selectedDepthState != DONTCARE)
	{
		changeDepthState(selectedDepthState, selectedStencilRef);
	}
	if (selectedBlendState != DONTCARE)
	{
		changeBlendState(selectedBlendState, selectedSampleMask);
	}
	if (selectedRasterizerState != DONTCARE) changeRasterizerState(selectedRasterizerState);
}
Пример #3
0
void Renderer::apply(){

#ifdef DEBUG
	if (!wasReset){
		outputDebugString("Warning: reset() not called before apply()");
	}
	wasReset = false;
#endif


	if (selectedShader != DONTCARE){
		changeShader(selectedShader);
		applyConstants();
	}

/*	for (uint i = 0; i < nImageUnits; i++){
		if (selectedTextures[i] != DONTCARE) changeTexture(i, selectedTextures[i]);
	}*/
	applyTextures();

/*	for (uint i = 0; i < MAX_SAMPLERSTATE; i++){
		if (selectedSamplerStates[i] != DONTCARE) changeSamplerState(i, selectedSamplerStates[i]);
	}*/
	applySamplerStates();

	changeVertexFormat(selectedVertexFormat);
	for (uint i = 0; i < MAX_VERTEXSTREAM; i++){
		if (selectedVertexBuffers[i] != DONTCARE){
			changeVertexBuffer(i, selectedVertexBuffers[i], selectedOffsets[i]);
		}
	}
	if (selectedIndexBuffer != DONTCARE) changeIndexBuffer(selectedIndexBuffer);

	if (selectedDepthState != DONTCARE){
		changeDepthState(selectedDepthState, selectedStencilRef);
	}
	if (selectedBlendState != DONTCARE){
		changeBlendState(selectedBlendState, selectedSampleMask);
	}
	if (selectedRasterizerState != DONTCARE) changeRasterizerState(selectedRasterizerState);

//	reset();
}
Пример #4
0
void CaptureWinGLEngine::paintGL()
{
	if (m_frameWidth < 1 || m_frameHeight < 1) {
		return;
	}

	if (m_formatChange)
		changeShader();

	if (m_frameData == NULL) {
		paintFrame();
		return;
	}

	switch (m_frameFormat) {
	case V4L2_PIX_FMT_YUYV:
	case V4L2_PIX_FMT_YVYU:
	case V4L2_PIX_FMT_UYVY:
	case V4L2_PIX_FMT_VYUY:
		render_YUY2();
		break;

	case V4L2_PIX_FMT_YUV420:
	case V4L2_PIX_FMT_YVU420:
		render_YUV(m_frameFormat);
		break;

	case V4L2_PIX_FMT_RGB32:
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
				GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, m_frameData);
		checkError("RGB32 paint");
		break;

	case V4L2_PIX_FMT_BGR32:
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
				GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_frameData);
		checkError("BGR32 paint");
		break;

	case V4L2_PIX_FMT_RGB555:
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
				GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, m_frameData);
		checkError("RGB555 paint");
		break;

	case V4L2_PIX_FMT_RGB565:
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
				GL_RGB, GL_UNSIGNED_SHORT_5_6_5, m_frameData);
		checkError("RGB565 paint");
		break;

	case V4L2_PIX_FMT_BGR24:
		render_BGR();
		break;
	case V4L2_PIX_FMT_RGB24:
	default:
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, m_screenTexture[0]);
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
				GL_RGB, GL_UNSIGNED_BYTE, m_frameData);
		checkError("Default paint");
		break;
	}
	paintFrame();
}