Skip to content
Snippets Groups Projects
Commit 0fe7c278 authored by Oliver Bock's avatar Oliver Bock
Browse files

Trying to remove strange artefact on windows

* Should again be related to OpenGL context reset
* Explicitly deleting and regenerating the GL lists might solve it
* Minor reindentation and line break improvements
* Makefile improvement (just clean known object files)
parent cf670156
No related branches found
No related tags found
No related merge requests found
...@@ -78,5 +78,5 @@ callgrind: ...@@ -78,5 +78,5 @@ callgrind:
valgrind --tool=callgrind --track-fds=yes --time-stamp=yes ${PWD}/starsphere valgrind --tool=callgrind --track-fds=yes --time-stamp=yes ${PWD}/starsphere
clean: clean:
rm -f ${RESOURCESPEC}.cpp *.o starsphere rm -f ${RESOURCESPEC}.cpp $(OBJS) starsphere
...@@ -90,9 +90,11 @@ void Starsphere::make_stars() ...@@ -90,9 +90,11 @@ void Starsphere::make_stars()
bool is_dupe; bool is_dupe;
int Ndupes=0; int Ndupes=0;
if (!Stars) // delete existing, create new (required for windoze)
if(Stars) glDeleteLists(Stars, 1);
Stars = glGenLists(1); Stars = glGenLists(1);
glNewList(Stars, GL_COMPILE); glNewList(Stars, GL_COMPILE);
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
/** /**
...@@ -116,6 +118,7 @@ void Starsphere::make_stars() ...@@ -116,6 +118,7 @@ void Starsphere::make_stars()
star_marker(star_info[i][0], star_info[i][1], mag_size); star_marker(star_info[i][0], star_info[i][1], mag_size);
} }
} }
glEndList(); glEndList();
} }
...@@ -127,14 +130,17 @@ void Starsphere::make_pulsars() ...@@ -127,14 +130,17 @@ void Starsphere::make_pulsars()
GLfloat mag_size=3.0; GLfloat mag_size=3.0;
int i; int i;
if (!Pulsars) // delete existing, create new (required for windoze)
if(Pulsars) glDeleteLists(Pulsars, 1);
Pulsars = glGenLists(1); Pulsars = glGenLists(1);
glNewList(Pulsars, GL_COMPILE); glNewList(Pulsars, GL_COMPILE);
glColor3f(0.80, 0.0, 0.85); // _P_ulsars are _P_urple glColor3f(0.80, 0.0, 0.85); // _P_ulsars are _P_urple
for (i=0; i < Npulsars; i++) { for (i=0; i < Npulsars; i++) {
star_marker(pulsar_info[i][0], pulsar_info[i][1], mag_size); star_marker(pulsar_info[i][0], pulsar_info[i][1], mag_size);
} }
glEndList(); glEndList();
} }
...@@ -146,14 +152,17 @@ void Starsphere::make_snrs() ...@@ -146,14 +152,17 @@ void Starsphere::make_snrs()
GLfloat mag_size=3.0; GLfloat mag_size=3.0;
int i; int i;
if (!SNRs) // delete existing, create new (required for windoze)
if(SNRs) glDeleteLists(SNRs, 1);
SNRs = glGenLists(1); SNRs = glGenLists(1);
glNewList(SNRs, GL_COMPILE); glNewList(SNRs, GL_COMPILE);
glColor3f(0.7, 0.176, 0.0); // _S_NRs are _S_ienna glColor3f(0.7, 0.176, 0.0); // _S_NRs are _S_ienna
for (i=0; i < NSNRs; i++) { for (i=0; i < NSNRs; i++) {
star_marker(SNR_info[i][0], SNR_info[i][1], mag_size); star_marker(SNR_info[i][0], SNR_info[i][1], mag_size);
} }
glEndList(); glEndList();
} }
...@@ -165,9 +174,11 @@ void Starsphere::make_constellations() ...@@ -165,9 +174,11 @@ void Starsphere::make_constellations()
{ {
GLint star_num=0; GLint star_num=0;
if (!Constellations) // delete existing, create new (required for windoze)
if(Constellations) glDeleteLists(Constellations, 1);
Constellations = glGenLists(1); Constellations = glGenLists(1);
glNewList(Constellations, GL_COMPILE); glNewList(Constellations, GL_COMPILE);
glLineWidth(1.0); glLineWidth(1.0);
glColor3f(0.7, 0.7, 0.0); // light yellow glColor3f(0.7, 0.7, 0.0); // light yellow
...@@ -178,6 +189,7 @@ void Starsphere::make_constellations() ...@@ -178,6 +189,7 @@ void Starsphere::make_constellations()
sphVertex(star_info[star_num][0], star_info[star_num][1]); sphVertex(star_info[star_num][0], star_info[star_num][1]);
} }
glEnd(); glEnd();
glEndList(); glEndList();
} }
...@@ -252,11 +264,14 @@ void Starsphere::make_obs() ...@@ -252,11 +264,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon); RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat; DEdeg= Lat;
if (!LLOmarker) // delete existing, create new (required for windoze)
if(LLOmarker) glDeleteLists(LLOmarker, 1);
LLOmarker = glGenLists(1); LLOmarker = glGenLists(1);
glNewList(LLOmarker, GL_COMPILE); glNewList(LLOmarker, GL_COMPILE);
glColor3f(0.0, 1.0, 0.0); glColor3f(0.0, 1.0, 0.0);
glLineWidth(lineSize); glLineWidth(lineSize);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
// North/South arm: // North/South arm:
sphVertex3D(RAdeg, DEdeg-arm_len_deg, radius); sphVertex3D(RAdeg, DEdeg-arm_len_deg, radius);
...@@ -264,11 +279,13 @@ void Starsphere::make_obs() ...@@ -264,11 +279,13 @@ void Starsphere::make_obs()
// East/West arm: // East/West arm:
sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius); sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius);
glEnd(); glEnd();
// arm joint H2 // arm joint H2
glPointSize((GLfloat) lineSize); glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS); glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius); sphVertex3D(RAdeg, DEdeg, radius);
glEnd(); glEnd();
glEndList(); glEndList();
/** /**
...@@ -281,11 +298,14 @@ void Starsphere::make_obs() ...@@ -281,11 +298,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon); RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat; DEdeg= Lat;
if (!LHOmarker) // delete existing, create new (required for windoze)
if(LHOmarker) glDeleteLists(LHOmarker, 1);
LHOmarker = glGenLists(1); LHOmarker = glGenLists(1);
glNewList(LHOmarker, GL_COMPILE); glNewList(LHOmarker, GL_COMPILE);
glColor3f(0.0, 0.0, 1.0); glColor3f(0.0, 0.0, 1.0);
glLineWidth(lineSize); glLineWidth(lineSize);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
// North/South arm: // North/South arm:
sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius); sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius);
...@@ -293,6 +313,7 @@ void Starsphere::make_obs() ...@@ -293,6 +313,7 @@ void Starsphere::make_obs()
// East/West arm: // East/West arm:
sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius); sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius);
glEnd(); glEnd();
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
// North/South arm, H2: // North/South arm, H2:
sphVertex3D(RAdeg-h2, DEdeg+arm_len_deg/2.0+h2/2.0, radius); sphVertex3D(RAdeg-h2, DEdeg+arm_len_deg/2.0+h2/2.0, radius);
...@@ -300,16 +321,19 @@ void Starsphere::make_obs() ...@@ -300,16 +321,19 @@ void Starsphere::make_obs()
// East/West arm, H2; // East/West arm, H2;
sphVertex3D(RAdeg-arm_len_deg/2.0-h2, DEdeg+h2/2.0, radius); sphVertex3D(RAdeg-arm_len_deg/2.0-h2, DEdeg+h2/2.0, radius);
glEnd(); glEnd();
// arm joint H1 // arm joint H1
glPointSize((GLfloat) lineSize); glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS); glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius); sphVertex3D(RAdeg, DEdeg, radius);
glEnd(); glEnd();
// arm joint H2 // arm joint H2
glPointSize((GLfloat) lineSize); glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS); glBegin(GL_POINTS);
sphVertex3D(RAdeg-h2, DEdeg+h2/2.0, radius); sphVertex3D(RAdeg-h2, DEdeg+h2/2.0, radius);
glEnd(); glEnd();
glEndList(); glEndList();
/** /**
...@@ -323,11 +347,14 @@ void Starsphere::make_obs() ...@@ -323,11 +347,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon); RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat; DEdeg= Lat;
if (!GEOmarker) // delete existing, create new (required for windoze)
if(GEOmarker) glDeleteLists(GEOmarker, 1);
GEOmarker = glGenLists(1); GEOmarker = glGenLists(1);
glNewList(GEOmarker, GL_COMPILE); glNewList(GEOmarker, GL_COMPILE);
glColor3f(1.0, 0.0, 0.0); glColor3f(1.0, 0.0, 0.0);
glLineWidth(lineSize); glLineWidth(lineSize);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
// North/South arm: // North/South arm:
sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius); sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius);
...@@ -335,11 +362,13 @@ void Starsphere::make_obs() ...@@ -335,11 +362,13 @@ void Starsphere::make_obs()
// West/East arm: // West/East arm:
sphVertex3D(RAdeg+arm_len_deg, DEdeg, radius); sphVertex3D(RAdeg+arm_len_deg, DEdeg, radius);
glEnd(); glEnd();
// arm joint // arm joint
glPointSize((GLfloat) lineSize); glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS); glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius); sphVertex3D(RAdeg, DEdeg, radius);
glEnd(); glEnd();
glEndList(); glEndList();
/** /**
...@@ -353,11 +382,14 @@ void Starsphere::make_obs() ...@@ -353,11 +382,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon); RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat; DEdeg= Lat;
if (!VIRGOmarker) // delete existing, create new (required for windoze)
if(VIRGOmarker) glDeleteLists(VIRGOmarker, 1);
VIRGOmarker = glGenLists(1); VIRGOmarker = glGenLists(1);
glNewList(VIRGOmarker, GL_COMPILE); glNewList(VIRGOmarker, GL_COMPILE);
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
glLineWidth(lineSize); glLineWidth(lineSize);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
// North/South arm: // North/South arm:
sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius); sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius);
...@@ -365,11 +397,13 @@ void Starsphere::make_obs() ...@@ -365,11 +397,13 @@ void Starsphere::make_obs()
// West/East arm: // West/East arm:
sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius); sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius);
glEnd(); glEnd();
// arm joint // arm joint
glPointSize((GLfloat) lineSize); glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS); glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius); sphVertex3D(RAdeg, DEdeg, radius);
glEnd(); glEnd();
glEndList(); glEndList();
return; return;
...@@ -385,11 +419,8 @@ void Starsphere::make_search_marker(GLfloat RAdeg, GLfloat DEdeg, GLfloat size) ...@@ -385,11 +419,8 @@ void Starsphere::make_search_marker(GLfloat RAdeg, GLfloat DEdeg, GLfloat size)
// r1 is inner circle, r2 is outer circle, r3 is crosshairs // r1 is inner circle, r2 is outer circle, r3 is crosshairs
r1 = size, r2=3*size, r3=4*size; r1 = size, r2=3*size, r3=4*size;
// delete existing marker, then create a new one // delete existing, create new (required for windoze)
if (SearchMarker) { if(SearchMarker) glDeleteLists(SearchMarker, 1);
glDeleteLists(SearchMarker, 1);
}
SearchMarker = glGenLists(1); SearchMarker = glGenLists(1);
glNewList(SearchMarker, GL_COMPILE); glNewList(SearchMarker, GL_COMPILE);
...@@ -461,12 +492,14 @@ void Starsphere::make_axes() ...@@ -461,12 +492,14 @@ void Starsphere::make_axes()
{ {
GLfloat axl=10.0; GLfloat axl=10.0;
if (!Axes) // delete existing, create new (required for windoze)
if(Axes) glDeleteLists(Axes, 1);
Axes = glGenLists(1); Axes = glGenLists(1);
glNewList(Axes, GL_COMPILE); glNewList(Axes, GL_COMPILE);
glLineWidth(2.0);
glBegin(GL_LINES); glBegin(GL_LINES);
glLineWidth(2.0);
glColor3f(1.0, 0.0, 0.0); glColor3f(1.0, 0.0, 0.0);
glVertex3f(-axl, 0.0, 0.0); glVertex3f(-axl, 0.0, 0.0);
glVertex3f(axl, 0.0, 0.0); glVertex3f(axl, 0.0, 0.0);
...@@ -479,6 +512,7 @@ void Starsphere::make_axes() ...@@ -479,6 +512,7 @@ void Starsphere::make_axes()
glVertex3f(0.0, 0.0, -axl); glVertex3f(0.0, 0.0, -axl);
glVertex3f(0.0, 0.0, axl); glVertex3f(0.0, 0.0, axl);
glEnd(); glEnd();
glEndList(); glEndList();
} }
...@@ -490,18 +524,21 @@ void Starsphere::make_globe() ...@@ -490,18 +524,21 @@ void Starsphere::make_globe()
int hr, j, i, iMax=100; int hr, j, i, iMax=100;
GLfloat RAdeg, DEdeg; GLfloat RAdeg, DEdeg;
if (!sphGrid) // delete existing, create new (required for windoze)
if(sphGrid) glDeleteLists(sphGrid, 1);
sphGrid = glGenLists(1); sphGrid = glGenLists(1);
glNewList(sphGrid, GL_COMPILE); glNewList(sphGrid, GL_COMPILE);
glLineWidth(1.0); glLineWidth(1.0);
// Lines of constant Right Ascencion (East Longitude) // Lines of constant Right Ascencion (East Longitude)
for (hr=0; hr<24; hr++) { for (hr=0; hr<24; hr++) {
RAdeg=hr*15.0; RAdeg=hr*15.0;
glColor3f(0.25, 0.25, 0.25); glColor3f(0.25, 0.25, 0.25);
if (hr==0)
glColor3f(0.55, 0.55, 0.55); // mark median
if(hr==0) glColor3f(0.55, 0.55, 0.55);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for (i=0; i<=iMax; i++) { for (i=0; i<=iMax; i++) {
DEdeg = i*180.0/iMax - 90.0; DEdeg = i*180.0/iMax - 90.0;
...@@ -511,9 +548,9 @@ void Starsphere::make_globe() ...@@ -511,9 +548,9 @@ void Starsphere::make_globe()
} }
// Lines of constant Declination (Lattitude) // Lines of constant Declination (Lattitude)
for (j=1; j<=12; j++) { for (j=1; j<=12; j++) {
DEdeg = 90.0 - j*15.0; DEdeg = 90.0 - j*15.0;
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for (i=0; i<=iMax; i++) { for (i=0; i<=iMax; i++) {
RAdeg = i*360.0/iMax; RAdeg = i*360.0/iMax;
...@@ -521,6 +558,7 @@ void Starsphere::make_globe() ...@@ -521,6 +558,7 @@ void Starsphere::make_globe()
} }
glEnd(); glEnd();
} }
glEndList(); glEndList();
} }
...@@ -663,7 +701,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f ...@@ -663,7 +701,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f
glEnable(GL_POINT_SMOOTH); glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
// FSAA will only be enabled when needed! // FSAA will be enabled explicitly when needed!
glDisable(GL_MULTISAMPLE_ARB); glDisable(GL_MULTISAMPLE_ARB);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment