Commit 56e9bb5a authored by vigmond's avatar vigmond

Eliminate needless buffer update when resizing vertices

parent e202a78d
......@@ -574,9 +574,19 @@ void TBmeshWin::draw_vertices(RRegion* reg, bool last )
if ( renderMode==GL_RENDER ) {
dataOpac &dop = dataopac->dop[Vertex];
bool update = _rd_pt.setup_render_data(context()) ||
REDRAW(VBO_Pt_Color|VBO_Position|VBO_Visible) ||
REDRAW(VBO_Colour) && datadst&Vertex_flg ||
REDRAW(VBO_Pt)&&threeD(Vertex) ;
if( last ) {
if( !first && _rd_pt.num() ) _rd_pt.update_nodalbuff();
_rd_pt.opaque( _rd_pt.num()-numTrans );
if( !first && _rd_pt.num() && update ){
_rd_pt.update_nodalbuff();
_rd_pt.opaque( _rd_pt.num()-numTrans );
}
_rd_pt.radius(pt.size());
_rd_pt.threeD(threeD(Vertex));
_rd_pt.mesh_render();
first = true;
return;
......@@ -584,11 +594,7 @@ void TBmeshWin::draw_vertices(RRegion* reg, bool last )
pt.threeD( reg->threeD(Vertex) );
pt.size( reg->size(Vertex) );
dataOpac &dop = dataopac->dop[Vertex];
bool translucent = translucency( Vertex, reg->get_color(Vertex) );
bool update =_rd_pt.setup_render_data(context());
update |= REDRAW(VBO_Pt_Color|VBO_Pt|VBO_Position) || (REDRAW(VBO_Colour) && datadst&Vertex_flg) ||
(REDRAW(VBO_Visible)) ;
if( update || _rd_pt.dirty() ) {
if( !_draw_all_vert ) trim_vertices( draw_vert, reg->show(Cnnx) );
if( first ) {
......@@ -599,9 +605,10 @@ void TBmeshWin::draw_vertices(RRegion* reg, bool last )
if( !reg->show(Vertex) || !reg->visible()) return;
_rd_pt.radius(pt.size());
_rd_pt.threeD( reg->threeD(Vertex) );
int nvis = pt.buffer( _rd_pt, 0, pt.num()-1, reg->get_color(Vertex), cs, datadst&Vertex_flg?data:NULL, 1, &dop );
bool translucent = translucency( Vertex, reg->get_color(Vertex) );
int nvis = pt.buffer( _rd_pt, 0, pt.num()-1, reg->get_color(Vertex), cs,
datadst&Vertex_flg?data:NULL, 1, &dop );
if( translucent ) {
numTrans += nvis;
} else if( numTrans ) {
......
......@@ -136,9 +136,9 @@ class TBmeshWin:public Fl_Gl_Tb_Window
void cutplane_color( GLfloat *cpc ){memcpy(_cutplane_col,cpc,4*sizeof(GLfloat) );redraw(VBO_Clip_Color);}
void threeD( Object_t o, int r, bool b ){model->threeD(o,r,b);
if(o==Cnnx)redraw(VBO_Cnnx_Color|VBO_Hilight);else if(o==Vertex)redraw(VBO_Pt_Color|VBO_Hilight);else redraw();}
bool threeD( Object_t o, int r ){ return model->threeD(o,r); }
bool threeD( Object_t o, int r=0 ){ return model->threeD(o,r); }
void size( Object_t o, int r, float b ){model->size(o,r,b);
if(o==Cnnx)redraw(VBO_Cnnx_Color|VBO_Hilight);else if(o==Vertex)redraw(VBO_Pt_Color|VBO_Hilight);else redraw();}
if(o==Cnnx)redraw(VBO_Cnnx_Color|VBO_Hilight);else if(o==Vertex)redraw(VBO_Pt|VBO_Hilight);else redraw();}
float size( Object_t o, int r ){ return model->size(o,r); }
IsosurfControl *isosurfwin;
int readAuxGrid( void *, const char* agfile );
......
......@@ -135,9 +135,6 @@ inline int get_wireframe_shader()
" gl_ClipDistance[i] = dot(vec4(aPos,1), clipEqn[i]);\n"
"}\n";
//"#extension GL_OES_standard_derivatives : enable\n"
//"#extension GL_EXT_clip_cull_distance : enable\n"
const char *fragmentShaderSource =
GLSL_VERSION
GLSL_PREC
......@@ -201,7 +198,10 @@ inline int get_lit_point_shader()
"{\n"
" Color = aColor;\n"
" Opaque = aOpaque;\n"
" LightDir = vec3( view * model * vec4(lightDir, 0.0) );\n"
"\n"
" // transform light direction to screen coordinates\n"
" LightDir = normalize(vec3( view * model * vec4(lightDir, 0.0)));\n"
"\n"
" matProps = materialProps[int(matNo)];\n"
"\n"
" FragPos = vec3(model * vec4(aPos, 1.0));\n"
......@@ -225,18 +225,17 @@ inline int get_lit_point_shader()
"void main()\n"
"{\n"
"\n"
" // diffuse\n"
" // compute normal of fragment as if on sphere\n"
" vec2 coord = 2*(gl_PointCoord - vec2(0.5,0.5));\n"
" coord.x *= -1.;\n"
" float l = length(coord);\n"
" coord.x *= -1.;\n"
" float l = length(coord);\n"
" if (l >1)\n"
" discard;\n"
" vec3 norm = vec3( coord, sqrt(1.-l*l) );\n"
" vec3 norm = vec3( coord, sqrt(1.-l*l) );\n"
"\n"
" vec3 nlightDir = normalize(LightDir);\n"
" float ldot = dot(norm, nlightDir);\n"
" float ldot = dot(norm, LightDir);\n"
"\n"
" float ambient = ambientStrength;\n"
" float ambient = ambientStrength;\n"
" if( ldot > 0 ) {\n"
" float spec = matProps[0] * specularStrength * pow(ldot, matProps[2]);\n"
" float diffuse = matProps[1] * diffuseStrength * ldot;\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment