Example #1
0
void GLPresenter::reshape(int w, int h)
{
	wSizeW = w; wSizeH = h;
	Console::get().setSize(w, h);
	NONRELEASE( RT_GL_ASSERT("Error before resizing viewport.") );
	if(oneToNScaleFactor > 0.0) {
		int x = 0, y = 0, targetW = (int)(reqW*oneToNScaleFactor), targetH = (int)(reqH*oneToNScaleFactor);
		Console::get().setSize(targetW, targetH);
		int dw = targetW-w;
		x = -dw/2; w += dw;
		int dh = targetH-h;
		y = -dh/2; h += dh;
		glViewport(x, y, w, h);
	}
	else {
		const static double epsilon = 0.00001;
		if(fabs((w/(double)h) - aspect) < epsilon) {
			glViewport(0, 0, w, h);
		} else if(h*aspect>w) { // need letterboxing
			GLsizei newh = (GLsizei)(w/aspect);
			GLint box = (h-newh)/2;
			glViewport(0, box, w, newh);
			h = newh;
		} else { // need pillarboxing
			GLsizei neww = (GLsizei)(h*aspect);
			GLint box = (w-neww)/2;
			glViewport(box, 0, neww, h);
			w = neww;
		}
	}
	NONRELEASE( RT_GL_ASSERT("Error resizing viewport.") );
}
Example #2
0
bool GLPresenter::run()
{
	if(!running) {
		return false;
	}
	if(frameIndex > drawnFrameIndex) {
		glBindTexture(GL_TEXTURE_2D, texId);
		drawnFrameIndex = frameIndex;
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, reqW/2, reqH, GL_ABGR_EXT, GL_UNSIGNED_BYTE, dataPointers[drawnFrameIndex%2]);
		NONRELEASE( RT_GL_ASSERT("Error uploading frame data.") );

		// convert UYVY
		buffer->makeCurrent();
		convertUYVY->use();
		glutil::drawQuad();
		convertUYVY->stopUsing();
		buffer->releaseCurrent();
		// apply AA
		aaManager->applyAA(buffer, buffer2);
		// apply IP
		ipManager->applyIP(buffer2, buffer);	
		display();
	}
	glfwPollEvents();
	if(clock()>cursorTimeout) {
		if(GetFocus() == hwnd) glfwDisable(GLFW_MOUSE_CURSOR);
	} else {
		glfwEnable(GLFW_MOUSE_CURSOR);
	}
	return true;
}
Example #3
0
bool GLPresenter::run()
{
	if(!running) {
		return false;
	}
	if(frameIndex > drawnFrameIndex) {
		Timer t;
		glBindTexture(GL_TEXTURE_2D, texId);
		drawnFrameIndex = frameIndex;
		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, captureBufferW, reqH, GL_ABGR_EXT, GL_UNSIGNED_BYTE, dataPointers[drawnFrameIndex % 2]);
		NONRELEASE( RT_GL_ASSERT("Error uploading frame data.") );

		// convert UYVY
		buffer->makeCurrent();
		initialConvert->use();
		glutil::drawQuad();
		initialConvert->stopUsing();
		buffer->releaseCurrent();
		// apply AA
		aaManager->applyAA(buffer, buffer2);
		// apply IP
		ipManager->applyIP(buffer2, buffer);	
		display();

		// statistics
		frameProcTimes.add(t.elapsed()/1000.0);
		graphicsReportText->text = format("Frame processing time (CPU): \n% 6.2lf ms avg, % 6.2lf ms max", frameProcTimes.get(), frameProcTimes.getMax());
	}
	glfwPollEvents();

	if(GetFocus() == hwnd) {
		if(clock()>cursorTimeout) {
			glfwDisable(GLFW_MOUSE_CURSOR);
		} else {
			glfwEnable(GLFW_MOUSE_CURSOR);
		}
	}
	return true;
}