Another tricky thing would be to apply the cube map to a GLModel object, since in principle you can texture a GLModel only with GLTextures. One possible solution (and here I'm just speculating, I never tried this) would be to texture the GLModel with a regular image (containing a base color for example) contained in a GLTexture, and then create a cube map texture "manually" with the above code and binding right before rendering the model, again using direct OpenGL calls. Something like this:
int loc = shader.getUniformLocation("cubemap"); // The argument should be the name of the cubeSampler uniform in the fragment shader.
This is a nasty mixture of GLGraphics and OpenGL calls, which I'm not even sure if it would work. In any case, the GLSL code in this page might become handy (and note that the links for cube and spherical maps are outdated, use these instead: spheremaps, cubemaps).
I tested the shader with OpenGL Shader Builder without setting any of the parameters (or yes maybe default 0) and it looked way better. I still have only red and yellow tones even if the image is pure blue so I thought it has to be a mistake in the pixel/color formats.
Yes, you are right, the problem is that the pixels array from PImage is in the ARGB format used by Processing. But OpenGL stores pixels as RGBA. GLTexture has a getBuffer() method that allows you to get the pixel array directly in OpenGL format:
I've been trying to get this sketch to work in processing 2, but its a drag. i know that the GLGraphics library from andres has been included in processing, thus the same stuff should be possible with processing 2, but i dont know how. did anybody do this before in processing 2 and can give us a raw sketch here please.
Leave a comment on marzzzel's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic