Skip to main content
New Participant
August 31, 2022
Solved

Editing Cubes in hello_xr Android Studio

How can I change the color of the cubes in hello_xr from Android Studio?

I have very little experience with Android Studio, but I can run hello_xr on on my Quest 2 and I understand OpenGL C++. I tried looking at some of the .c and .cpp files, but Android Studio tells me "This file does not belong to any project target; code insight features might not work properly." 

New Participant
September 26, 2022

Yes, in the hello_xr demo app, there only one OpenGL resource (vertices and colors) for all the cubes (defines in InitializeResources), so you must refines the source code to create diffrerents resources and manage differents cubes.

 

The hands cubes are created on the fly in the "openxp_program.cpp" file at the "RenderLayer" function; search for the line with "for (auto hand : {Side::LEFT, Side::RIGHT})".

 

Cheers

3 replies

New Participant
September 25, 2022

Hi,

 

The cube vertices array contains also the face colors, and is defined in the file geometry.h in the c_cubeVertices array.

 

Je cube's color is send to the OpenGLES shader in the "graphicsplugin_opengles.cpp" file at the end of the "InitializeResources" function.
 
Regards

AugmaDevAuthor
New Participant
September 26, 2022

Great thanks!

This works, but it ends up changing the color of every cube in the scene. It looks like c_cubeVertices is used several times to create several instances of the cube. Do you happen to know which file has the OpenGL code for creating the cube on the right controller?

New Participant
September 26, 2022

Yes, in the hello_xr demo app, there only one OpenGL resource (vertices and colors) for all the cubes (defines in InitializeResources), so you must refines the source code to create diffrerents resources and manage differents cubes.

 

The hands cubes are created on the fly in the "openxp_program.cpp" file at the "RenderLayer" function; search for the line with "for (auto hand : {Side::LEFT, Side::RIGHT})".

 

Cheers