Small patch for pgui/pgFrameStyle.cxx

I’ve made a small patch to allow the combination of a groove geometry and a texture (as suggested by drwr):

$ cvs diff panda/src/pgui/pgFrameStyle.cxx 
Index: panda/src/pgui/pgFrameStyle.cxx
===================================================================
RCS file: /cvsroot/panda3d/panda/src/pgui/pgFrameStyle.cxx,v
retrieving revision 1.27
diff -r1.27 pgFrameStyle.cxx
724a725,727
>   if (has_texture()) {
>     state = state->set_attrib(TextureAttrib::make(get_texture()));
>   }
727,729d729
<   // For now, beveled and grooved geoms don't support textures.  Easy
<   // to add if anyone really wants this.
<   

Please merge it in the official panda source code.

Please also update the explanation for the frameTexture keyword in the DirectGUI documentation:

Hmm, is that really all that’s necessary? I don’t see that generate_groove_geom() creates any texture coordinates. Without texture coordinates, you can apply the texture but you’ll only get a flat color. Are you seeing something different?

David

You’re right, I only saw the flat color, but I didn’t notice because the frame is rather small, and the texture doesn’t have much contrast.

Here’s the corrected patch:

$ cvs diff panda/src/pgui/pgFrameStyle.cxx
Index: panda/src/pgui/pgFrameStyle.cxx
===================================================================
RCS file: /cvsroot/panda3d/panda/src/pgui/pgFrameStyle.cxx,v
retrieving revision 1.27
diff -r1.27 pgFrameStyle.cxx
647c647,652
<   CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3cp();
---
>   CPT(GeomVertexFormat) format;
>   if (has_texture()) {
>     format = GeomVertexFormat::get_v3cpt2();
>   } else {
>     format = GeomVertexFormat::get_v3cp();
>   }
719c724,773
<   
---
> 
>   if (has_texture()) {
>     // Generate UV's.
>     float left = uv_range[0];
>     float right = uv_range[1];
>     float bottom = uv_range[2];
>     float top = uv_range[3];
> 
>     float cx = (left + right) * 0.5;
>     float cy = (top + bottom) * 0.5;
> 
>     float mid_left = min(left + 0.5f * _width[0], cx);
>     float mid_right = max(right - 0.5f * _width[0], cx);
>     float mid_bottom = min(bottom + 0.5f * _width[1], cy);
>     float mid_top = max(top - 0.5f * _width[1], cy);
> 
>     float inner_left = min(left + _width[0], cx);
>     float inner_right = max(right - _width[0], cx);
>     float inner_bottom = min(bottom + _width[1], cy);
>     float inner_top = max(top - _width[1], cy);
> 
>     GeomVertexWriter texcoord(vdata, InternalName::get_texcoord());
>     texcoord.add_data2f(right, bottom);
>     texcoord.add_data2f(mid_right, mid_bottom);
>     texcoord.add_data2f(left, bottom);
>     texcoord.add_data2f(mid_left, mid_bottom);
>     texcoord.add_data2f(left, top);
>     texcoord.add_data2f(mid_left, mid_top);
>     texcoord.add_data2f(right, top);
>     texcoord.add_data2f(mid_right, mid_top);
> 
>     texcoord.add_data2f(mid_right, mid_bottom);
>     texcoord.add_data2f(inner_right, inner_bottom);
>     texcoord.add_data2f(mid_left, mid_bottom);
>     texcoord.add_data2f(inner_left, inner_bottom);
>     texcoord.add_data2f(mid_left, mid_top);
>     texcoord.add_data2f(inner_left, inner_top);
>     texcoord.add_data2f(mid_right, mid_top);
>     texcoord.add_data2f(inner_right, inner_top);
> 
>     texcoord.add_data2f(right, bottom);
>     texcoord.add_data2f(right, top);
>     texcoord.add_data2f(mid_right, mid_bottom);
>     texcoord.add_data2f(mid_right, mid_top);
>     texcoord.add_data2f(inner_right, inner_bottom);
>     texcoord.add_data2f(inner_right, inner_top);
>     texcoord.add_data2f(inner_left, inner_bottom);
>     texcoord.add_data2f(inner_left, inner_top);
>   }
> 
724a779,781
>   if (has_texture()) {
>     state = state->set_attrib(TextureAttrib::make(get_texture()));
>   }
726,729c783
<   
<   // For now, beveled and grooved geoms don't support textures.  Easy
<   // to add if anyone really wants this.
<   
---
> 

Is there a specific reason that this patch isn’t added to trunk (yet)?

This patch would allow me to make a new build with one bug less:

Committed, thanks! Sorry for the delay.

You can make changes directly to the manual yourself by logging in here: panda3d.org/wikiedit . Ignore the error message after log in, and just go back into the manual; you’ll have edit links available at the bottom of the page.

David

Done and thanks!