Log in or register to post comments

QCAR + Adreno SDK

November 21, 2010 - 3:15am #1

I'm trying to use the Framework of Adreno SDK to render my scene in QCAR.
If i do my rendering without using QCAR projection Matrix and modelView Matrix it's working fine, but I can't get any single mesh rendered when using QCAR matrixes.

here is my rendering code... if someone has an idea, I'll greatly appreciate.

    QCAR::Matrix44F projectionMatrix =
        QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f, 2000.0f);
	        QCAR::Matrix44F modelViewMatrix =

			MATRIX4X4 *mvMatrix = (MATRIX4X4 *) modelViewMatrix.data;
			MATRIX4X4 *projMatrix = (MATRIX4X4 *) projectionMatrix.data;
		    m_matModelViewProj = MatrixMultiply( *mvMatrix, *projMatrix );
		    m_matNormal        = MatrixNormal( *mvMatrix );
			glUseProgram( m_hPerPixelLightingShader );
			glUniform4f( m_hMaterialAmbientLoc, 0.8f, 0.2f, 0.2f, 1.0f );
			glUniform4f( m_hMaterialDiffuseLoc, 0.3f, 0.3f, 0.8f, 1.0f );
			glUniform4f( m_hMaterialSpecularLoc, 0.65f, 0.6f, 1.0f, 10.0f );
//			glUniformMatrix4fv( m_hModelViewMatrixLoc, 1, FALSE, (FLOAT32*)&m_matModelView );

			glUniformMatrix4fv( m_hModelViewMatrixLoc, 1, FALSE, (FLOAT32*)mvMatrix );
			checkGlError("glUniformMatrix4fv( m_hModelViewMatrixLoc, 1, FALSE, (FLOAT32*)*mvMatrix->m )");
			glUniformMatrix4fv( m_hModelViewProjMatrixLoc, 1, FALSE, (FLOAT32*)&m_matModelViewProj );
			checkGlError("glUniformMatrix4fv( m_hModelViewProjMatrixLoc, 1, FALSE, (FLOAT32*)&m_matModelViewProj )");
			glUniformMatrix3fv( m_hNormalMatrixLoc, 1, FALSE, (FLOAT32*)&m_matNormal );
			checkGlError("glUniformMatrix3fv( m_hNormalMatrixLoc, 1, FALSE, (FLOAT32*)&m_matNormal )");
			glUniform3f( m_hLightPositionLoc, 2.0f, 1.0f, 1.0f );

		    glBindFramebuffer( GL_FRAMEBUFFER, 0 );
			glEnable( GL_DEPTH_TEST );


			glDisable( GL_DEPTH_TEST );

Re: QCAR + Adreno SDK

November 24, 2010 - 5:54am #9

double checked, it would seems my models is smaller than the unity cube.
I played with a scale matrix, and it's working fine.

Thanks for your help, very much appreciate.

Re: QCAR + Adreno SDK

November 23, 2010 - 5:50am #8

Sorry, the image isn't showing up here. Could you please send it to

instead? I can't tell from your message if there is a bug or if you just need to play around with the scale parameters.

- Kim

Re: QCAR + Adreno SDK

November 22, 2010 - 12:30pm #7

I did set the target size to 1.0 x 0.7 and now i can see my model, but it doesnt fill the image space

here is how it looks like

Re: QCAR + Adreno SDK

November 22, 2010 - 8:36am #6

Well, if the target is 247x173 units, and your models are on the scale of a single unit, I would try scaling them by a factor of 100 at first. It isn't really a matter of minimal size, it's a matter of how large you want your models compared to the rectangle defined by the target. Right now they're very tiny compared to the target space, just try scaling things up until you reach a comfortable size.

On the flip side, you could choose to scale down the target, perhaps making it a single unit across. In the config.xml file you would set the size to 1.0x0.7 to maintain the aspect ratio. Now your unit-scale models will fill the target space. You will want to set the near parameter of the projection matrix to something like 0.1 instead of 2.0, because at 2.0 you would have to hold the camera at least two target-widths away to see anything, which is a bit far.

Play around with all these numbers and I think things will become clear. Let me know if your models still aren't showing up!

- Kim

Re: QCAR + Adreno SDK

November 22, 2010 - 8:19am #5

Ok will scale up my models.
Next question: how to know what's the minimal size for a model to be displayed (for a given target size and near/far parameters)?

Re: QCAR + Adreno SDK

November 22, 2010 - 5:23am #4

You know, you're completely right. The near/far isn't the culprit here, it's most likely the size of the target in the config file. If you are using the default ImageTargets sample project, the target plane is defined to be 247x173 units. Your model is simply too small to be viewed on that scale. You can either scale up your models or change the size parameters in the config.xml (located in the assets folder). Be careful to maintain the aspect ratio when changing values in the config file!

If you decide to scale down the target, then you will need to scale down the near/far values as well.

- Kim

Re: QCAR + Adreno SDK

November 22, 2010 - 1:44am #3

Mmmh, yes my model vertices are included in the unity cube.
What's the best way to fix this?
change the call to getProjectionGL with a near parameter of 0.1f or prescale the modelview matrix?

BTW: I though the near/far parameter defines the the "range" for the depth that the camera sees, not the minimal size of objects that can be seen.

Thanks for your help

Re: QCAR + Adreno SDK

November 21, 2010 - 7:22pm #2

It could be something as simple as the near/far parameters set in the getProjectionGL method call. If your models are close to unit size the 2.0 near parameter might be preventing you from seeing anything.

If that isn't it, you should double check that the QCAR matrices are in the format that the Adreno shaders expect (column vs. row major).

- Kim

Log in or register to post comments