Esempio n. 1
0
	void nativeRender(int camtex, float *mat) {
		if (!running) return;
		ShaderEngine::Engine->reset();
		ShaderBuffer *oldfbo = ShaderEngine::Engine->setFramebuffer(rdrTgt);
		ShaderEngine::Engine->setViewport(0, 0, tex->width, tex->height);
		Matrix4 projection = ShaderEngine::Engine->setOrthoFrustum(0,
				tex->baseWidth, 0, tex->baseHeight, -1, 1);
		ShaderEngine::Engine->setProjection(projection);
		Matrix4 model;
		ShaderEngine::Engine->setModel(model);

		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_EXTERNAL_OES, camtex);

		shader->setConstant(shader->getConstantByName("tMatrix"),
				ShaderProgram::CMATRIX, 1, mat);
		shader->setData(ShaderProgram::DataVertex, ShaderProgram::DFLOAT, 2,
				&vertices[0], vertices.size(), vertices.modified,
				&vertices.bufferCache);
		shader->setData(ShaderProgram::DataTexture, ShaderProgram::DFLOAT, 2,
				&texcoords[0], texcoords.size(), texcoords.modified,
				&texcoords.bufferCache);
		shader->drawElements(ShaderProgram::TriangleStrip, indices.size(),
				ShaderProgram::DUSHORT, &indices[0], indices.modified,
				&indices.bufferCache);
		vertices.modified = false;
		texcoords.modified = false;
		indices.modified = false;

		ShaderEngine::Engine->setFramebuffer(oldfbo);
	}
Esempio n. 2
0
void VideoFrameSurface::render() {
    if (!g_frame.isValid()) return;
	GLCALL_INIT;
	if(g_frame.map(QAbstractVideoBuffer::ReadOnly))
	{
		GLuint tid=*((GLuint *)camtex->getNative());
		GLCALL glBindTexture(GL_TEXTURE_2D, tid);
		//qDebug() << "Render:" << g_frame.width()<< g_frame.height() << tid;
		GLCALL glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch,0, GL_RGBA, GL_UNSIGNED_BYTE, g_frame.bits());
		ShaderEngine *engine=gtexture_get_engine();
		engine->reset();
		ShaderBuffer *oldfbo = engine->setFramebuffer(rdrTgt);
		engine->setViewport(0, 0, gtex->width, gtex->height);
		Matrix4 projection = engine->setOrthoFrustum(0,
				gtex->baseWidth, 0, gtex->baseHeight, -1, 1);
		engine->setProjection(projection);
		Matrix4 model;
		engine->setModel(model);
		engine->bindTexture(0,camtex);
		shader->setData(ShaderProgram::DataVertex, ShaderProgram::DFLOAT, 2,
				&vertices[0], vertices.size(), vertices.modified,
				&vertices.bufferCache);
		shader->setData(ShaderProgram::DataTexture, ShaderProgram::DFLOAT, 2,
				&texcoords[0], texcoords.size(), texcoords.modified,
				&texcoords.bufferCache);
		shader->drawElements(ShaderProgram::TriangleStrip, indices.size(),
				ShaderProgram::DUSHORT, &indices[0], indices.modified,
				&indices.bufferCache);
		vertices.modified = false;
		texcoords.modified = false;
		indices.modified = false;

		engine->setFramebuffer(oldfbo);
        g_frame.unmap();
	}

}