[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/patrickdown/HelloT5Cube/master/HelloT5Cube.cpp [Back]  [Original]

#include 
#include 
#include 
#include "HelloT5Cube.h"
#include "VertexDefinition.h"


/****************************************************************************
Get static data defined in InlineVertexData and InlineShaderCode
*****************************************************************************/
std::span GetCubeVertices();
const char* GetVertexShaderCode(bool multiview = false);
const char* GetFragmentShaderCode();

/****************************************************************************
Set up for window and OpenGL context creation.
*****************************************************************************/
bool HelloT5Cube::InitializeApplication()
{
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

	std::cout DrawBuffers(0);

		if(!rightLayerFramebuffer->IsReady()) {
			std::cerr ColorAttachment(*leftLayerTexture);
		leftLayerFramebuffer->DrawBuffers(0);

		if(!leftLayerFramebuffer->IsReady()) {
			std::cerr width = width;
	this->height = height;

	// Make a texture to hold the image that will be passed to the glasses
	texture = MakeOwned();
	texture->Create(GL_TEXTURE_2D);
	texture->SetTextureStorage(GL_RGBA8, width, height);
	texture->SetMinFilter(GL_LINEAR);
	texture->SetMagFilter(GL_LINEAR);

	if(hasDepth) {
		// Make a depth buffer
		depth = MakeOwned();
		depth->Create(GL_TEXTURE_2D);
		depth->SetDepthStorage(width, height);
		depth->SetMinFilter(GL_LINEAR);
		depth->SetMagFilter(GL_LINEAR);
	}

	// Attach texture and depth
	framebuffer = MakeOwned();
	framebuffer->Create();
	framebuffer->ColorAttachment(*texture);
	if(hasDepth) {
		framebuffer->DepthAttachment(*depth);
	}
	framebuffer->DrawBuffers(0);

	if (!framebuffer->IsReady())
	{
		std::cerr height = height;
	this->layers = layers;

	// Make a texture to hold the image that will be passed to the glasses
	texture = MakeOwned();
	texture->Create(GL_TEXTURE_2D_ARRAY);
	texture->SetTextureStorage(GL_RGBA8, width, height, layers);
	texture->SetMinFilter(GL_LINEAR);
	texture->SetMagFilter(GL_LINEAR);

	// Make a depth buffer
	depth = MakeOwned();
	depth->Create(GL_TEXTURE_2D_ARRAY);
	depth->SetDepthStorage(width, height, layers);
	depth->SetMinFilter(GL_LINEAR);
	depth->SetMagFilter(GL_LINEAR);

	// Attach texture and depth
	framebuffer = MakeOwned();
	framebuffer->Create();
	framebuffer->Bind(GL_DRAW_FRAMEBUFFER);
	framebuffer->ColorAttachmentMultiview(*texture, 0, layers);
	framebuffer->DepthAttachmentMultiview(*depth, 0, layers);
	framebuffer->DrawBuffers(0);
	framebuffer->Unbind(GL_DRAW_FRAMEBUFFER);

	if(!framebuffer->IsReady()) {
		std::cerr BlitToScreen(0, 0, width, height, 0, 0, dstWidth, dstHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}

void HelloT5Cube::DisplaySurface::BlitToFrameBuffer(GLW::Framebuffer& dstFramebuffer, int dstHeight, int dstWidth) 	{
	framebuffer->BlitToFramebuffer(dstFramebuffer, 0, 0, width, height, 0, 0, dstWidth, dstHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}

void HelloT5Cube::DisplaySurface::BlitFromFrameBuffer(GLW::Framebuffer& dstFramebuffer) {
	dstFramebuffer.BlitToFramebuffer(*framebuffer, 0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}

Owned HelloT5Cube::DisplaySurface::GetTextureLayer(int layer) {
	return texture->CreateView(GL_TEXTURE_2D, GL_RGBA8, 0, 1, layer, 1);
}

/****************************************************************************
'P' key dumps a head pose to standard out
*****************************************************************************/
void HelloT5Cube::OnKey(int key, int scancode, int action, int mods)
{
	Application::OnKey(key, scancode, action, mods);
	if (key == GLFW_KEY_P && action == GLFW_PRESS)
		isOutputingOnePoseFrame = true;
}

/****************************************************************************
Initialize the T5 context, get a list of glasses, connect to the first
one found. 

There might be delays in starting the service and the main gui shouldn't be hung
up waiting. So in a real application parts of this should probably be an done
in a non blocking way as part of the render loop.
*****************************************************************************/
bool HelloT5Cube::InitializeT5()
{
	context = MakeOwned();
	
	auto result = context->Create(windowTitle, "0.0.1");

	if (result != T5_SUCCESS)
	{
		std::cerr 

Web Proxy Viewer  |  New URL  |  Original Page