Oval draw problem in Linux oolite 1.62RC3

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Wyrm
Poor
Poor
Posts: 5
Joined: Tue Jan 24, 2006 12:41 pm
Location: ToeKeyOO

Oval draw problem in Linux oolite 1.62RC3

Post by Wyrm »

Not sure if anyone else has this problem (and I apologise if this is known), but ovals drawn on the hud for me (or the starchart galaxy or local for that matter), have an extra straight line in them (looks like a chunk taken out of the circle). Pretty hard to miss, so it's probably a quirk somewhere else?

I'm using Fedora Core 4 / Nvidia geForce4 with Oolite 1.62R3 built from source.
I traced the problem down to the function in HeadUpDisplay.m

Code: Select all

void drawOval( double x, double y, double z, NSSize siz, int step)
changing the

Code: Select all

glBegin(GL_LINE_LOOP);
to

Code: Select all

glBegin(GL_LINE_STRIP);
and uncommenting the

Code: Select all

glVertex3f(x, y + hh, z);
makes it all better.
so the final function looks like:

Code: Select all

void drawOval( double x, double y, double z, NSSize siz, int step)
{
	int i;
	GLfloat ww = 0.5 * siz.width;
	GLfloat hh = 0.5 * siz.height;
	//glBegin(GL_LINE_LOOP);
	glBegin(GL_LINE_STRIP);
	for (i = 0; i < 360; i += step){
		glVertex3f(x + ww * sin_value[i], y + hh * sin_value[(i + 90) % 360], z);
	}
	glVertex3f(x, y + hh, z);
	glEnd();
	return;
}
note: we can get back a few cycles (not that my system is hard pressed or anything by oolite) by calculating the cos tables, so we don't have to do a + and % for every step. That's done in PlanetEntity.h/PlanetEntity.m

-Wyrm
User avatar
TGHC
---- E L I T E ----
---- E L I T E ----
Posts: 2157
Joined: Mon Jan 31, 2005 4:16 pm
Location: Berkshire, UK

Post by TGHC »

Great first post.

Not only finds a bug but comes up with a fix for it as well.

(well he seeems to know what he is talking about, but there again how would I know)

This community is awesome.
The Grey Haired Commander has spoken!
OK so I'm a PC user - "you know whats scary? Out of billions of sperm I was the fastest"
User avatar
aegidian
Master and Commander
Master and Commander
Posts: 1161
Joined: Thu May 20, 2004 10:46 pm
Location: London UK
Contact:

Re: Oval draw problem in Linux oolite 1.62RC3

Post by aegidian »

Wyrm wrote:
Not sure if anyone else has this problem (and I apologise if this is known), but ovals drawn on the hud for me (or the starchart galaxy or local for that matter), have an extra straight line in them (looks like a chunk taken out of the circle). Pretty hard to miss, so it's probably a quirk somewhere else?

I'm using Fedora Core 4 / Nvidia geForce4 with Oolite 1.62R3 built from source.
I traced the problem down to the function in HeadUpDisplay.m
Sounds more like a problem within your particular implementation of OpenGL, although the fix you describe will work, the original code relies on the drawing GL_LINE_LOOP being properly implemented (which is IMO, a fair assumption).

I'd like to ask you to see if there is an update for your OpenGL drivers before I make any changes to Oolite's code to cope with a particular OpenGL driver problem.
"The planet Rear is scourged by well-intentioned OXZs."

Oolite models and gear? click here!
User avatar
winston
Pirate
Pirate
Posts: 731
Joined: Mon Sep 27, 2004 10:21 pm
Location: Port St. Mary, Isle of Man
Contact:

Post by winston »

Can you post a screen shot? Also, what version of the nvidia drivers are you using? (The reference ones from nvidia themselves, or is it from a yum repo such as livna or dag?)
User avatar
Rxke
Retired Assassin
Retired Assassin
Posts: 1760
Joined: Thu Aug 12, 2004 4:54 pm
Location: Belgium

Post by Rxke »

TGHC wrote:
Great first post.

Not only finds a bug but comes up with a fix for it as well.
AND an optimisation suggestion!

This community is uber-awesome!
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Not necessarily a good optimisation, though - it would involve more memory bandwidth. A better way would be to extend the sin table by 90 entries, so you could skip the % 360, and possibly use an offset counter - that’s a 25% increase in memory load rather than 100%. If implementing this, don’t forget to profile it. ;-)
dajt
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 364
Joined: Tue Aug 17, 2004 7:05 am
Location: Orange, NSW, Australia

Post by dajt »

Hi,

I'm glad someone else has seen this now ;) See https://bb.oolite.space/viewtopic.php?t=681 for the original report.

I've been seeing it since doing the original porting work, but no-one else has ever got it.
Regards,
David Taylor.
User avatar
aegidian
Master and Commander
Master and Commander
Posts: 1161
Joined: Thu May 20, 2004 10:46 pm
Location: London UK
Contact:

Post by aegidian »

Okay, I'm convinced it's a problem with more than one OpenGL implementation.

I'm a little shattered to be coding at the moment (hungover from Burns' night - small child with chicken-pox - whisky tasting this weekend). But this fix will go in.
"The planet Rear is scourged by well-intentioned OXZs."

Oolite models and gear? click here!
User avatar
aegidian
Master and Commander
Master and Commander
Posts: 1161
Joined: Thu May 20, 2004 10:46 pm
Location: London UK
Contact:

Post by aegidian »

Okay changes and optimisations committed. That and a tweak to the laser graphics code are the last into v1.62. I'm releasing this weekend. Then I can get on with recoding collision detection (again).
"The planet Rear is scourged by well-intentioned OXZs."

Oolite models and gear? click here!
User avatar
winston
Pirate
Pirate
Posts: 731
Joined: Mon Sep 27, 2004 10:21 pm
Location: Port St. Mary, Isle of Man
Contact:

Post by winston »

Ah. So I should expect a busy weekend of uploading, testing, putting announcements out on Freshmeat and HappyPenguin :-)
User avatar
Wyrm
Poor
Poor
Posts: 5
Joined: Tue Jan 24, 2006 12:41 pm
Location: ToeKeyOO

Post by Wyrm »

Happy to note my problem is gone. Thanks!

I'm using the Nvidia driver: NVIDIA-Linux-x86-1.0-8178
The OpenGL accel is really quite good on this card under Linux, but it's such an obvious wtf that I kinda figured it wasn't oolite. Besides, it works perfectly on my wife's mac.

-Wyrm
Post Reply