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:
valgrind --tool=callgrind --track-fds=yes --time-stamp=yes ${PWD}/starsphere
clean:
rm -f ${RESOURCESPEC}.cpp *.o starsphere
rm -f ${RESOURCESPEC}.cpp $(OBJS) starsphere
......@@ -90,9 +90,11 @@ void Starsphere::make_stars()
bool is_dupe;
int Ndupes=0;
if (!Stars)
// delete existing, create new (required for windoze)
if(Stars) glDeleteLists(Stars, 1);
Stars = glGenLists(1);
glNewList(Stars, GL_COMPILE);
glColor3f(1.0, 1.0, 1.0);
/**
......@@ -116,6 +118,7 @@ void Starsphere::make_stars()
star_marker(star_info[i][0], star_info[i][1], mag_size);
}
}
glEndList();
}
......@@ -127,14 +130,17 @@ void Starsphere::make_pulsars()
GLfloat mag_size=3.0;
int i;
if (!Pulsars)
// delete existing, create new (required for windoze)
if(Pulsars) glDeleteLists(Pulsars, 1);
Pulsars = glGenLists(1);
glNewList(Pulsars, GL_COMPILE);
glColor3f(0.80, 0.0, 0.85); // _P_ulsars are _P_urple
for (i=0; i < Npulsars; i++) {
star_marker(pulsar_info[i][0], pulsar_info[i][1], mag_size);
}
glEndList();
}
......@@ -146,14 +152,17 @@ void Starsphere::make_snrs()
GLfloat mag_size=3.0;
int i;
if (!SNRs)
// delete existing, create new (required for windoze)
if(SNRs) glDeleteLists(SNRs, 1);
SNRs = glGenLists(1);
glNewList(SNRs, GL_COMPILE);
glColor3f(0.7, 0.176, 0.0); // _S_NRs are _S_ienna
for (i=0; i < NSNRs; i++) {
star_marker(SNR_info[i][0], SNR_info[i][1], mag_size);
}
glEndList();
}
......@@ -165,9 +174,11 @@ void Starsphere::make_constellations()
{
GLint star_num=0;
if (!Constellations)
// delete existing, create new (required for windoze)
if(Constellations) glDeleteLists(Constellations, 1);
Constellations = glGenLists(1);
glNewList(Constellations, GL_COMPILE);
glLineWidth(1.0);
glColor3f(0.7, 0.7, 0.0); // light yellow
......@@ -178,6 +189,7 @@ void Starsphere::make_constellations()
sphVertex(star_info[star_num][0], star_info[star_num][1]);
}
glEnd();
glEndList();
}
......@@ -252,11 +264,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat;
if (!LLOmarker)
// delete existing, create new (required for windoze)
if(LLOmarker) glDeleteLists(LLOmarker, 1);
LLOmarker = glGenLists(1);
glNewList(LLOmarker, GL_COMPILE);
glColor3f(0.0, 1.0, 0.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
// North/South arm:
sphVertex3D(RAdeg, DEdeg-arm_len_deg, radius);
......@@ -264,11 +279,13 @@ void Starsphere::make_obs()
// East/West arm:
sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius);
glEnd();
// arm joint H2
glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius);
glEnd();
glEndList();
/**
......@@ -281,11 +298,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat;
if (!LHOmarker)
// delete existing, create new (required for windoze)
if(LHOmarker) glDeleteLists(LHOmarker, 1);
LHOmarker = glGenLists(1);
glNewList(LHOmarker, GL_COMPILE);
glColor3f(0.0, 0.0, 1.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
// North/South arm:
sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius);
......@@ -293,6 +313,7 @@ void Starsphere::make_obs()
// East/West arm:
sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius);
glEnd();
glBegin(GL_LINE_STRIP);
// North/South arm, H2:
sphVertex3D(RAdeg-h2, DEdeg+arm_len_deg/2.0+h2/2.0, radius);
......@@ -300,16 +321,19 @@ void Starsphere::make_obs()
// East/West arm, H2;
sphVertex3D(RAdeg-arm_len_deg/2.0-h2, DEdeg+h2/2.0, radius);
glEnd();
// arm joint H1
glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius);
glEnd();
// arm joint H2
glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS);
sphVertex3D(RAdeg-h2, DEdeg+h2/2.0, radius);
glEnd();
glEndList();
/**
......@@ -323,11 +347,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat;
if (!GEOmarker)
// delete existing, create new (required for windoze)
if(GEOmarker) glDeleteLists(GEOmarker, 1);
GEOmarker = glGenLists(1);
glNewList(GEOmarker, GL_COMPILE);
glColor3f(1.0, 0.0, 0.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
// North/South arm:
sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius);
......@@ -335,11 +362,13 @@ void Starsphere::make_obs()
// West/East arm:
sphVertex3D(RAdeg+arm_len_deg, DEdeg, radius);
glEnd();
// arm joint
glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius);
glEnd();
glEndList();
/**
......@@ -353,11 +382,14 @@ void Starsphere::make_obs()
RAdeg= RAofZenith(observatoryDrawTimeGMT, Lon);
DEdeg= Lat;
if (!VIRGOmarker)
// delete existing, create new (required for windoze)
if(VIRGOmarker) glDeleteLists(VIRGOmarker, 1);
VIRGOmarker = glGenLists(1);
glNewList(VIRGOmarker, GL_COMPILE);
glColor3f(1.0, 1.0, 1.0);
glLineWidth(lineSize);
glBegin(GL_LINE_STRIP);
// North/South arm:
sphVertex3D(RAdeg, DEdeg+arm_len_deg, radius);
......@@ -365,11 +397,13 @@ void Starsphere::make_obs()
// West/East arm:
sphVertex3D(RAdeg-arm_len_deg, DEdeg, radius);
glEnd();
// arm joint
glPointSize((GLfloat) lineSize);
glBegin(GL_POINTS);
sphVertex3D(RAdeg, DEdeg, radius);
glEnd();
glEndList();
return;
......@@ -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 = size, r2=3*size, r3=4*size;
// delete existing marker, then create a new one
if (SearchMarker) {
glDeleteLists(SearchMarker, 1);
}
// delete existing, create new (required for windoze)
if(SearchMarker) glDeleteLists(SearchMarker, 1);
SearchMarker = glGenLists(1);
glNewList(SearchMarker, GL_COMPILE);
......@@ -461,12 +492,14 @@ void Starsphere::make_axes()
{
GLfloat axl=10.0;
if (!Axes)
// delete existing, create new (required for windoze)
if(Axes) glDeleteLists(Axes, 1);
Axes = glGenLists(1);
glNewList(Axes, GL_COMPILE);
glLineWidth(2.0);
glBegin(GL_LINES);
glLineWidth(2.0);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-axl, 0.0, 0.0);
glVertex3f(axl, 0.0, 0.0);
......@@ -479,6 +512,7 @@ void Starsphere::make_axes()
glVertex3f(0.0, 0.0, -axl);
glVertex3f(0.0, 0.0, axl);
glEnd();
glEndList();
}
......@@ -490,18 +524,21 @@ void Starsphere::make_globe()
int hr, j, i, iMax=100;
GLfloat RAdeg, DEdeg;
if (!sphGrid)
// delete existing, create new (required for windoze)
if(sphGrid) glDeleteLists(sphGrid, 1);
sphGrid = glGenLists(1);
glNewList(sphGrid, GL_COMPILE);
glLineWidth(1.0);
// Lines of constant Right Ascencion (East Longitude)
for (hr=0; hr<24; hr++) {
RAdeg=hr*15.0;
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);
for (i=0; i<=iMax; i++) {
DEdeg = i*180.0/iMax - 90.0;
......@@ -511,9 +548,9 @@ void Starsphere::make_globe()
}
// Lines of constant Declination (Lattitude)
for (j=1; j<=12; j++) {
DEdeg = 90.0 - j*15.0;
glBegin(GL_LINE_STRIP);
for (i=0; i<=iMax; i++) {
RAdeg = i*360.0/iMax;
......@@ -521,6 +558,7 @@ void Starsphere::make_globe()
}
glEnd();
}
glEndList();
}
......@@ -663,7 +701,7 @@ void Starsphere::initialize(const int width, const int height, const Resource *f
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
// FSAA will only be enabled when needed!
// FSAA will be enabled explicitly when needed!
glDisable(GL_MULTISAMPLE_ARB);
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