LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2017, 03:54 AM   #16
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869

Does this have anything to do with you having found a bug in function 'abs'?
 
Old 10-09-2017, 03:58 AM   #17
842Mono
Member
 
Registered: Oct 2016
Distribution: Ubuntu
Posts: 35

Original Poster
Rep: Reputation: Disabled
hmm not really, but I think that it's because my ubuntu falls back to OpenGL version 3.0, and it said in the link that abs() supports double values starting version 4.1. Actually the code fails because it gives abs() double values.

So apparently I will have problems because of my old OpenGL version, so I'm asking about how to install and use version 4.1 directly.

Last edited by 842Mono; 10-09-2017 at 04:00 AM.
 
Old 10-09-2017, 04:03 AM   #18
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
First, will you please create a mvce that proves that function 'abs' is broken?
 
Old 10-09-2017, 04:08 AM   #19
842Mono
Member
 
Registered: Oct 2016
Distribution: Ubuntu
Posts: 35

Original Poster
Rep: Reputation: Disabled
But my stackoverflow account currently reached its question limit. I can't ask.

And I can't ask that on askubuntu can I? It's a programming question.
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2017-10-09 11-05-04.png
Views:	7
Size:	24.5 KB
ID:	26071  
 
Old 10-09-2017, 04:14 AM   #20
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Right here. Paste here that 5-6 lines that shows the problem. No loops are required, just one single printf.
https://stackoverflow.com/help/mcve
 
1 members found this post helpful.
Old 10-09-2017, 04:32 AM   #21
842Mono
Member
 
Registered: Oct 2016
Distribution: Ubuntu
Posts: 35

Original Poster
Rep: Reputation: Disabled
I tried to take out the lines that cause the error but it's not working. The error is not showing. It only shows when I run the batman file

What I tried

Code:
void Display(void)
{
	double x = 5555.12380000;
	double y = -2234234.017234821;
	x = abs(x);
	y = abs(y);

  glPushMatrix();

  glBegin(GL_POINTS);
	glVertex3d(x, y, 0);
  glEnd();

  glPopMatrix();

  glFlush();
}
but this code works fine. I don't know how
 
Old 10-09-2017, 04:41 AM   #22
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
It should be something like this:
Code:
/* abs_test.cc */

#include <cmath>
#include <cstdio>

int main (void)
{
    double x = 5555.12380000;
    double y = -2234234.017234821;

    printf ("abs(%g)=%g\n", x, std::abs (x));
    printf ("abs(%g)=%g\n", y, std::abs (y));

    return 0;
}
result:
Code:
g++ -W -Wall -Werror abs_test.cc -o abs_test && ./abs_test
abs(5555.12)=5555.12
abs(-2.23423e+06)=2.23423e+06
Problem is, this doesn't show the error, it cannot be used in a bug-report
 
Old 10-09-2017, 04:59 AM   #23
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
because probably it is an error in your code. You may try to split long lines into smaller parts (and debugger will still print lines).
Code:
 double ycordNeg = -3 * sqrt((double)(1 - pow((xcord / 7), 2)))*sqrt((double)(abs(abs(xcord) - 4) / (abs(xcord) - 4)));
And you will(may) see which abs caused the problem.
 
1 members found this post helpful.
Old 10-09-2017, 08:33 AM   #24
842Mono
Member
 
Registered: Oct 2016
Distribution: Ubuntu
Posts: 35

Original Poster
Rep: Reputation: Disabled
But the thing is, the batman code runs fine on the windows computers in the lab, but throws an exception on my Ubuntu.

I didn't check what version of OpenGL was there and now I'm at home. I will check. It's either a version issue (I hope so) or a platform issue.

pan64 if we change all abs() to fabs() the code runs fine. But on the windows PCs we didn't need to change anything.
 
Old 10-09-2017, 09:47 AM   #25
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,860
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
C++ is a wonderful thing. A name like "abs" might mean virtually anything, depending on the context. That's why you should step-by-step reduce the problem, until you get a mvce.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Windows 8 Beats Ubuntu Linux For Intel "Haswell" OpenGL LXer Syndicated Linux News 0 07-25-2013 01:12 AM
LXer: Windows 8 Outperforming Ubuntu Linux With Intel OpenGL Graphics LXer Syndicated Linux News 1 03-21-2013 05:46 PM
ubuntu qemu windows xp catia uncertified opengl error ,check installation rag123 Ubuntu 0 10-23-2009 04:28 AM
Bad opengl performance with two or more OpenGL windows on nvidia drivers (GF 7600 GS) psokol Linux - Software 0 02-21-2009 10:40 AM
opengl on fedora how to start coding? ashjas Fedora 1 01-17-2008 06:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration