Skip to content Skip to sidebar Skip to footer

Rendering An Image Texture Into A Cubemap In Opengl Android

I have a bitmap on my device(which is a 6x1 cubemap), which I want to render on all the faces of the cube InputStream is = getContext().getResources().openRawResource(R.raw.photo)

Solution 1:

A cubemap texture is a texture who's images represent the faces of a cube. The "texture coordinate" for a cubemap texture is the vector direction from the center of the cube which points to the color you want to use.

You are trying to use a regular old 2D texture coordinate, with a third component probably added to silence the compiler. You must provide directions, not 2D coordinates. You can generate them in the vertex shader from your position. But that requires knowing what space aPosition is, and you didn't tell me. So I can't show you how to do that.

Regardless, the vertex shader needs to be providing a 3D direction for the texture coordinate. It should either be generated or passed from a VS input.

Note that your program may have other problems. But this is the problem that can be deduced from your code.

Post a Comment for "Rendering An Image Texture Into A Cubemap In Opengl Android"