Red15 wrote:
>> Graphics cards don't draw quads, they will be split up into triangles by the
>> driver anyway. You are probably better off pre-triangulating (most exporters
>> and modelling packages have this option), and then rendering everything as
>> triangles.
>>
>
> Done, a bit of a downer to this imo is the disk size but I guess in a
> world where google throws gigabytes at your head you shouldn't bicker
> about 1-2k more or less :)
>
>
>> Pyglet's vertex_list is considerably simpler to use. Beyond that,
>> vertex_list will use VBOs (Vertex Buffer Objects) if available, to ensure
>> your vertex data is actually in video memory.
>>
>
> After implementing it I was still having trouble with the performance
> from as little as 100-200 entities.
> I was playing around a bit and when I disabled the material setting on
> each model suddenly my frames jump into the 1000fps.
>
> What is the way to efficiently switch between materials as this
> apparently is causing major slowdown:
>
Lookup glColorMaterial. It allows you to change one material parameter
per vertex quickly using glColor.
Normally glColor specifies values for use when lighting is *off*,
and glMaterial specifies values for use when lighting is *on*.
However, glClorMaterial is a kind of cross-over between the two.
Specify all your glMaterial parameters as normal.
Choose one parameter for cross-over. Examples:
glColorMaterial(GL_FRONT, GL_DIFFUSE)
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE)
Enable lighting and color material features:
glEnable(GL_LIGHTING)
glEnable(GL_COLOR_MATERIAL)
Then draw your geometry with frequent changes to glColor:
big loop:
glColor3fv(color) # will become the materials diffuse value (for
instance)
glNormalfv(normal)
glVertex3fv(position)
If you are using vertex arrays (and you ought to), throw in a
glColorPointer(...)
along with the other arrays
glTexCoordPointer(...)
glNormalPointer(...)
glVertexPointer(...)
and get the same effect with the colors specified that way.
Enjoy,
Gary Herron
> def compile(self):
> self.gllist = glGenLists(1)
> glNewList(self.gllist,GL_COMPILE)
> for mat, vlist in self.ivlists: # ivlists are dicts where key =
> material name and value = IndexedVertexList
>
> # Disabling next statments gives me frame boost
> glMaterialfv(GL_FRONT, GL_DIFFUSE, materials[mat]['diffuse'])
> # And all other material properties here one by one as well as
> texture binding
>
> vlist.draw(GL_TRIANGLES)
> glEndList()
>
> Do notice this is while compiling the list, apparently the list
> actually also does the glMaterialfv and glBindTexture call each frame
> which (I suspect) is pushing the texture down the pipeline each frame
> (Ouch, poor PCIe bus ;)
>
> I guess I have to use something like glPushAttrib or glPushState but
> what is appropriate for material and texture calls ?
>
> A simple rtfm with a good tutorial anyone found particulary usefull
> would be appreciated.
>
> Regards,
> Niels
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---