سؤال

I am coding a wavefront (.obj) loader with VBO's.

When "usemtl" is called, I am thinking about sending textureID together with vertex, texCoord and normal data.

With that texture ID can I bind the texture inside vertex/fragment shader without calling glBindTexture?

هل كانت مفيدة؟

المحلول

With that texture ID can I bind the texture inside vertex/fragment shader without calling glBindTexture?

No. Textures are not bound to shaders; they're bound to the context.

If you want to get technical, NV_bindless_texture allows such functionality, but that's NVIDIA-specific.

نصائح أخرى

that is problem with materials in general, they need to be switched before rendering geometry.

simplest way is:

foreach object in renderQueue
    set_material()
    draw_geometry()

and of course we get into some troubles when one objects has to be rendered with two different materials. Another problem is with performance, you usually would sort objects by materials and save the switching (of textures, shaders and other data)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top