Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Material Problem

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    2

    Material Problem

    My problem is that i cannot set up my material using my structure because the "data member initializer is not allowed". This is deffo a simple mistake but its kinda annyoying. Here is the code.

    struct material {
    float ambient[4];
    float diffuse[4];
    float specular[4];
    float shininess;
    };

    material redShinyMaterial = {
    {0.80,0.05,0.05, 1.0},
    {0.80,0.05,0.05, 1.0},
    {1.0,1.0,1.0, 1.0},
    100.0
    };
    greatful for any help thanks before hand.

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352

    Re: Material Problem

    This is a C question, not openGL. :P
    However, I compiled your code with
    Visual studio 2010
    GCC -> gcc test.cpp -std=gnu++98 -Wall -pedantic
    and it work fine even if I would complain about the double to float cast.
    Are you sure that you don't have some define the change the meaning of material.
    Why don't you use a constructor?
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •