Results 1 to 4 of 4

Thread: Having trouble compiling a program

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2000
    Posts
    2

    Having trouble compiling a program

    Hi, I'm new to this forum and also opengl. I'm just learning the basics. I've tried copying and pasting some of the projects in the open.org website... and whenever i compile in visual c++ it gives me these complaints... why???

    A:\Project1.cpp(320) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(320) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(320) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(330) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(330) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(330) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(384) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(385) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(386) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    A:\Project1.cpp(387) : warning C4305: 'argument' : truncation from 'const double' to 'float'
    Error executing cl.exe.

    Project1.obj - 4 error(s), 11 warning(s)

    I figured that since i pretty much cut and paste to see what the project does, it should be able to compile!!!

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: Having trouble compiling a program

    without the error messages, we cannot help you!

    The warning you have is only when there is a a value declared as a double wich is passed in a function that that takes a float. This is not a problem.

    The errors are. Please write then down, and we'll be able to help you.



    [This message has been edited by Gorg (edited 03-11-2000).]

  3. #3
    Member Contributor
    Join Date
    Mar 2000
    Location
    PA, USA
    Posts
    70

    Re: Having trouble compiling a program

    The problem is probably that you're program has hard-coded values for colors, vertices, etc. On many compilers, a literals like: 1.0, 2.5, etc. are of type double, not float. Your program probably makes calls like: glColor3f(1.0, 1.0, 0.0) and glVertex3f(0.0, 1.0, 1.0). The 3f in the name of the functions indicates that the arguments should be 3 floats, not doubles. There are two ways to fix this... one is to change your function calls to be the double versions (for example glVertex3d, glColor3d). The other way is to change your constants to floats explicitly like this:
    glVertex3f(1.0f, 2.0f, 3.0f)

    Hope this helps.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2000
    Posts
    2

    Re: Having trouble compiling a program

    Thanks a lot! I finally fixed the problem. anyway, I was just testing the code that was in opengl.org...

Similar Threads

  1. Trouble compiling code
    By Tom2002 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-13-2013, 05:27 PM
  2. trouble compiling glut
    By mstr108 in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 07-14-2008, 11:49 PM
  3. Trouble compiling ColladaMaya for Mac OS X
    By badcheese in forum COLLADA
    Replies: 0
    Last Post: 08-09-2006, 12:32 PM
  4. trouble compiling
    By rolandoo in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 11-20-2004, 11:16 PM
  5. Trouble with glut's compiling
    By DarkWizard in forum OpenGL: Linux
    Replies: 4
    Last Post: 10-28-2004, 05:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean