Skip to content
Snippets Groups Projects
Commit e4b83f26 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

try to fix some weird race conditions due to WID->check (called inside

Msg) firing a 2nd draw() before the fir(st has finished... This is a
general problem with our "pseudo-threaded" (i.e. putting many
WID->check() calls) approach... I added a new lock in draw() (we
already have one in Generate()), but this is pretty ugly.
parent 78b27dc6
No related branches found
No related tags found
No related merge requests found
// $Id: Message.cpp,v 1.29 2002-06-15 21:25:27 geuzaine Exp $ // $Id: Message.cpp,v 1.30 2002-08-28 07:14:55 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -128,6 +128,9 @@ void Msg(int level, char *fmt, ...){ ...@@ -128,6 +128,9 @@ void Msg(int level, char *fmt, ...){
window = -1; window = -1;
else else
WID->check(); WID->check();
// this is pretty costly, but permits to keep the app
// responsive... the downside is that it can cause race
// conditions
if(CTX.verbosity >= verb){ if(CTX.verbosity >= verb){
va_start (args, fmt); va_start (args, fmt);
......
// $Id: Opengl_Window.cpp,v 1.27 2002-08-26 17:41:32 geuzaine Exp $ // $Id: Opengl_Window.cpp,v 1.28 2002-08-28 07:14:55 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -46,6 +46,12 @@ static int ZOOM = 0 ; ...@@ -46,6 +46,12 @@ static int ZOOM = 0 ;
static double ZOOM_X0, ZOOM_Y0, ZOOM_X1, ZOOM_Y1; static double ZOOM_X0, ZOOM_Y0, ZOOM_X1, ZOOM_Y1;
void Opengl_Window::draw() { void Opengl_Window::draw() {
static int locked=0;
if(locked)
return;
else
locked=1;
Msg(DEBUG, "Opengl_Window->draw()");
if(!valid()){ if(!valid()){
valid(1); valid(1);
CTX.viewport[0] = 0 ; CTX.viewport[1] = 0 ; CTX.viewport[0] = 0 ; CTX.viewport[1] = 0 ;
...@@ -109,6 +115,7 @@ void Opengl_Window::draw() { ...@@ -109,6 +115,7 @@ void Opengl_Window::draw() {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
ZOOM = 0; ZOOM = 0;
} }
locked=0;
} }
void Opengl_Window::draw_overlay() { void Opengl_Window::draw_overlay() {
......
// $Id: Post.cpp,v 1.38 2002-08-28 03:16:09 geuzaine Exp $ // $Id: Post.cpp,v 1.39 2002-08-28 07:14:55 geuzaine Exp $
// //
// Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle
// //
...@@ -138,7 +138,7 @@ void Get_Coords(double Explode, double *Offset, int nbnod, ...@@ -138,7 +138,7 @@ void Get_Coords(double Explode, double *Offset, int nbnod,
} }
} }
static double storedEye[3]={0,0,0}; static double storedEye[3]={0.,0.,0.};
int changedEye(){ int changedEye(){
double zeye=100*CTX.lc, tmp[3]; double zeye=100*CTX.lc, tmp[3];
...@@ -151,6 +151,7 @@ int changedEye(){ ...@@ -151,6 +151,7 @@ int changedEye(){
storedEye[0] = tmp[0]; storedEye[0] = tmp[0];
storedEye[1] = tmp[1]; storedEye[1] = tmp[1];
storedEye[2] = tmp[2]; storedEye[2] = tmp[2];
Msg(DEBUG, "New eye = (%g %g %g)", tmp[0], tmp[1], tmp[2]);
return 1; return 1;
} }
return 0; return 0;
...@@ -227,6 +228,18 @@ void Draw_Post (void) { ...@@ -227,6 +228,18 @@ void Draw_Post (void) {
if(v->Visible && !v->Dirty){ if(v->Visible && !v->Dirty){
// sort the data % eye for transparency
if(CTX.alpha &&
v->NbST && v->DrawTriangles && v->DrawScalars &&
ColorTable_IsAlpha(&v->CT) &&
changedEye()){
Msg(DEBUG, "Sorting triangles in view %d", v->Num);
nb = List_Nbr(v->ST) / v->NbST ;
qsort(v->ST->array,v->NbST,nb*sizeof(double),compareTriangleEye);
v->Changed = 1; // force displaylist regeneration
}
if(CTX.display_lists && !v->Changed && v->DisplayListNum>0){ if(CTX.display_lists && !v->Changed && v->DisplayListNum>0){
Msg(DEBUG, "Call display List %d", v->DisplayListNum); Msg(DEBUG, "Call display List %d", v->DisplayListNum);
...@@ -386,15 +399,6 @@ void Draw_Post (void) { ...@@ -386,15 +399,6 @@ void Draw_Post (void) {
if(v->NbST && v->DrawTriangles && v->DrawScalars){ if(v->NbST && v->DrawTriangles && v->DrawScalars){
nb = List_Nbr(v->ST) / v->NbST ; nb = List_Nbr(v->ST) / v->NbST ;
if(CTX.alpha){ // sort the triangles % eye
if(ColorTable_IsAlpha(&v->CT) && changedEye()){
Msg(INFO, "Resorting triangles (eye=%g %g %g)",
storedEye[0],storedEye[1],storedEye[2]);
qsort(v->ST->array,v->NbST,nb*sizeof(double),compareTriangleEye);
v->Changed = 1;
Msg(INFO, "End sorting triangles");
}
}
if(v->Light && v->SmoothNormals && v->Changed && v->IntervalsType != DRAW_POST_ISO){ if(v->Light && v->SmoothNormals && v->Changed && v->IntervalsType != DRAW_POST_ISO){
Msg(DEBUG, "Preprocessing of triangle normals in view %d", v->Num); Msg(DEBUG, "Preprocessing of triangle normals in view %d", v->Num);
for(i = 0 ; i < List_Nbr(v->ST) ; i+=nb){ for(i = 0 ; i < List_Nbr(v->ST) ; i+=nb){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment