Marc Garcia <[email protected]> writes:
> I could make the monkey example work, and I've been playing with it
> with excellent results.
>
> What I couldn't make it work, is applying a texture to any PLY file. I
> followed your instructions, tried several models, and textures, and I
> always get the model painted with the solid color defined by
> cogl_material_set_color4ub.
>
> I used the exact code as you posted, using
>
> texture = cogl_texture_new_from_file ("models/models.png",
> COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, &error);
>
> I also checked that the texture is loaded successfully.
The texturing is at least working for me. Could you double check whether
your models include texture coordinates? You should be able to see by
opening the model in a text editor and seeing whether it has the lines
"property float s" and "property float t".
> Any idea on what's wrong? In the COGL reference says that the color
> set in cogl_material_set_color4ub will be used when no lighting is
> enabled. Could be this the reason?
When there is no lighting then yes, the color set in set_color4ub will
be used as the vertex color. However the default layer combine combines
this with the texture color - so both the texture and the material color
influence the final fragment color. You would usually want to set the
color to white when rendering with a texture so that it will end up as
just the texture color.
Also note if your model contains vertex color properties (which would be
in the file as "red", "green" and "blue") then these will replace the
material color.
If you want to ensure that only the texture is used for the fragment
color you could change the material layer combine function like this:
cogl_material_set_layer_combine (material, 0,
"RGB=REPLACE(TEXTURE)",
&error);
Hope that helps
- Neil
--
To unsubscribe send a mail to [email protected]