View Full Version : TBGL_BindMaterial?
ReneMiner
11-03-2013, 15:19
Can't give up on creating some Mesh-Editor, so right now I'm looking for some possibility to do the same with Materials as TBGL_BindTexture() can do to Entity or Displaylist with textures - so if I render a bunch of Entities they are not just supposed to have their own textures but also to have some different materials.
So before I make a new feature-request I want to know if that would be already possible somehow.("thinbasic_gl.inc" I have already included)
It would be great if that could also BindMaterial to m15-layers...
Petr Schreiber
11-03-2013, 16:29
Hi Rene,
you can use these functions to manage materials:
TBGL_NewMaterial / TBGL_DeleteMaterial
TBGL_SetMaterialAmbient
TBGL_SetMaterialDiffuse
TBGL_SetMaterialSpecular
TBGL_SetMaterialSpecularExponent
TBGL_SetMaterialTexture
TBGL_PushMaterial / TBGL_PopMaterial
They should cover what you need, just render the model per-partes.
Petr
ReneMiner
11-03-2013, 16:55
but how shall I do this when I'm using Entity? They get all placed in scene. Do I have to use Material within TBGL_BeginPoly-EndPoly just as I would use color?
So would mean to re-read an Entity in if material gets changed by the user? I would more like to use it as I can do with TBGL_EntitySetColor() to change Entities appearance
Another question: Is there a Vertex-Limit to m15? Currently we experience that a mesh with approx 2.5 Mio Vertices (224MB) is not displayed completely
Petr Schreiber
11-03-2013, 21:06
Do I have to use Material within TBGL_BeginPoly-EndPoly just as I would use color?
You can do it that way:
TBGL_PushMaterial(myMaterial)
TBGL_BeginPoly ...
...
TBGL_EndPoly
TBGL_PopMaterial
So would mean to re-read an Entity in if material gets changed by the user?
If you just change the material using TBGL_SetMaterial..., it should update automagically (but not in display list of course).
Another question: Is there a Vertex-Limit to m15? Currently we experience that a mesh with approx 2.5 Mio Vertices (224MB) is not displayed completely
Strange, check for possible reason with TBGL_GetLastGLError please. Isn't it just a visibility issue (TBGL_SetDrawDistance).
Petr
ReneMiner
25-03-2013, 13:09
I did as you advised, now I experience the following problem:
As soon as I use a material, the vertex-colors don't get applied/ are not visible.
Is there a way to have both?
I would like to use the effects of material as glow, shine, reflect etc. but also enable vertex-colors to shade and colorize certain spots.
Petr Schreiber
25-03-2013, 13:51
Hi Rene,
yes, it is quite confusing, but this is the way OpenGL works internally as well. There is a way to affect this behavior - you can control which properties are controlled by tbgl_Color and which by materials using OpenGL glColorMaterial.
#INCLUDE "thinbasic_gl.inc"
...
TBGL_PushMaterial(mMaterial)
glColorMaterial ( %GL_FRONT_AND_BACK, %GL_AMBIENT_AND_DIFFUSE )
glEnable(%GL_COLOR_MATERIAL)
' -- Draw geometry here
TBGL_PopMaterial
More information from OpenGL point of view here: http://sjbaker.org/steve/omniv/opengl_lighting.html
Petr
ReneMiner
25-03-2013, 13:55
I have included thinBasicGL.inc anyway :)
just about the switch: %GL_FRONT_AND_BACK -
I already enabled glCullFace(%GL_BACK) - so would I have to replace %GL_FRONT_AND_BACK with %GL_FRONT now?
EDIT: Yes I did, and it works :D:D