Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble getting API to display my scene - from GilesGoat on the forum (https://forum.lookingglassfactory.com/t/opengl-bugs-and-issues/1225/4) #1

Open
alxdncn opened this issue Feb 26, 2019 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@alxdncn
Copy link
Contributor

alxdncn commented Feb 26, 2019

Hi,
Ok … ‘what am I doing wtong ?’
So … my code goes along those lines , first -

wp.w = 512;
wp.h = 256;

	window = Util_InitWindowAndGraphics(wp,
		FullScreen, 4, UseAppWindowFrame, &l_pDevice, NULL, NULL, NULL, &error_code); //UseAppWindowFrame, &pDevice);

*the_Neon_Device = l_pDevice;
g_Neon_Device = l_pDevice;

#ifdef USING_HOLOPLAY
PRINTF(“Initializing Looking Glass\n”);
hp_initialize();
#endif

Then in my ‘begin view’ …

if (nviews == 32)
{
	// ok we ARE in openGL !!

	// simple case, simple screen
	g_Neon_Device->SetCurrentRT(-1);

	float fov = 0.244; // 14° in radians
	float viewCone = 0.698; // 40° in radians
	float cameraSize = 5; // for example
	float aspectRatio = 1.6; // derived from calibration's screenW / screenH
	//totalViews = 45 // derived from the quilt settings
	Vector3 focalPosition;// = (0, 0, 0); // the center of the focal pane
	focalPosition.zero();

	float cameraDistance = -cameraSize / tan(fov / 2);
	Vector3 cameraPosition = focalPosition + Vector3(0, 0, cameraDistance);

	proj = glm::perspectiveRH(
		SCE_MATH_PI / 4.0f,
		(float)w*0.5f / (float)h,
		//1.0f,
		0.1f, // z near
		20.0f); // z far

	g_Neon_Device->camera(0, 0, 3,
		0, 0, 0,
		0, 1, 0,
		&view, true);

	// now let's do what they do

	//PRINTF("View Index %d\n", view_index);

	// start at -viewCone * 0.5 and go up to viewCone * 0.5
	float offsetAngle = ((float)view_index / (float)(nviews - 1) - 0.5) * viewCone;

	// calculate the offset
	float offset = cameraDistance * tan(offsetAngle);

	// modify the view matrix (position)
	view[0, 3] += offset;

	// modify the projection matrix, relative to the camera size and aspect ratio
	proj[0, 2] += offset / (cameraSize * aspectRatio);

	g_Neon_Device->setProjection(&proj);
	g_Neon_Device->setCamera(&view);

}

Then it draw some cubes

the_Neon_Device->setWorld();
the_Neon_Device->scale(0.3, 0.3, 0.3);
the_Neon_Device->translate(0, 0.5, 0);

the_Neon_Device->UpdateWvpMatrix(NULL);

the_cube->draw(0);

Then my 'end-view' calls -

void LS_Display_Compositor::EndView(int view_index, void *graphic_context)
{
#ifdef USING_HOLOPLAY
hp_copyViewToQuilt(view_index);
#endif

return;
}

This is done 32 time with that view_index going from 0 to 31 …

Finally …

void LS_Display_Compositor::EndFrame(int frameindex)
{
if (g_Neon_Device) g_Neon_Device->EndFrame(0);

#ifdef USING_HOLOPLAY
hp_drawLightfield();
#endif

return;
}

I tried to move the Present(1); before to call the hp_drawLightfield(); ( tried also with present(0), no vsynch ) …

Fundamentally … nothing happens … the display just displays the desktop background, it’s like it does not get addressed at all …

What am I missing here ?

I linked with the HoloPlayApi.lib, put the DLL in the correct path … all ‘seems ok’ except the display seems not to give any sign of life.

Suggestions ?

Also I found out that despite the #pragma once and such it appears holoplay.h can be included only one in one source, otherwise it complains all time of ‘duplicated/already defined things’.

Anyway any suggestions to debug what’s going on ??

Cheers.

@alxdncn
Copy link
Contributor Author

alxdncn commented Feb 26, 2019

Ok more, I found out that ‘ok first of all need to find that monitor’, so nothing works unless I do this -

int count;
	GLFWmonitor** monitors = glfwGetMonitors(&count);
	if (count > 1)
	{
		PRINTF("Monitor name : %s\n", glfwGetMonitorName(monitors[1]));
	}

// Open a window and create its OpenGL context
	window = glfwCreateWindow(vp.w / sizeDivisor, vp.h / sizeDivisor, "CubeWorld GL", monitors[1], NULL);
	if (window == NULL) {
		fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
		getchar();
		glfwTerminate();
		return NULL;
	}

On the top of that if I don’t set precisely the resoultion of -

wp.w = 2560; wp.h = 1600;

The monitor refuses to work.

Finally when I run the code, I get a thing like two views of some cubes translated ( I will upload the pic later ) .

I got like the feeling that hp_copyViewToQuilt(view_index); and hp_drawLightfield(); are doing nothing …

Suggestions ?

@alxdncn
Copy link
Contributor Author

alxdncn commented Feb 26, 2019

Some printf show me this -

PRINTF("Values : hp_quiltTexture %d, hp_VAO %d, hp_VBO %d\n", hp_quiltTexture, hp_VAO, hp_FBO);

PRINTF("Values : qs_viewWidth %d, qs_viewHeight %d\n", qs_viewWidth, qs_viewHeight);

Values : hp_quiltTexture 0, hp_VAO 0, hp_VBO 0
Values : qs_viewWidth 0, qs_viewHeight 0

Something is not quite going right here, it’s like the stuff never been correctly initialised ??

@alxdncn alxdncn changed the title Trouble getting API to display my scene Trouble getting API to display my scene - from GilesGoat on the forum (https://forum.lookingglassfactory.com/t/opengl-bugs-and-issues/1225/4) Feb 26, 2019
@alxdncn alxdncn added the help wanted Extra attention is needed label Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant