Results 1 to 3 of 3

Thread: strange color problem with GLwidget

  1. #1
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Question strange color problem with GLwidget

    Hello world,

    i have a very strange problem:

    i have done a vector like this: QVector< QVector<int> >colorArray3D;
    and in my constructor i fill it like this:

    Qt Code:
    1. QVector<int> blue;
    2. blue.push_back(0);
    3. blue.push_back(0);
    4. blue.push_back(255);
    5. colorArray3D.push_back(blue);
    6. QVector<int> green;
    7. blue.push_back(0);
    8. blue.push_back(255);
    9. blue.push_back(0);
    10. colorArray3D.push_back(green);
    11. QVector<int> magenta;
    12. blue.push_back(233);
    13. blue.push_back(73);
    14. blue.push_back(214);
    15. colorArray3D.push_back(magenta);
    16. QVector<int> gray;
    17. blue.push_back(161);
    18. blue.push_back(156);
    19. blue.push_back(161);
    20. colorArray3D.push_back(gray);
    21. QVector<int> darkBlue;
    22. blue.push_back(43);
    23. blue.push_back(5);
    24. blue.push_back(203);
    25. colorArray3D.push_back(darkBlue);
    26. QVector<int> darkGreen;
    27. blue.push_back(43);
    28. blue.push_back(203);
    29. blue.push_back(0);
    30. colorArray3D.push_back(darkGreen);
    31. QVector<int> darkMagenta;
    32. blue.push_back(136);
    33. blue.push_back(32);
    34. blue.push_back(101);
    35. colorArray3D.push_back(darkMagenta);
    36. QVector<int> darkGray;
    37. blue.push_back(94);
    38. blue.push_back(94);
    39. blue.push_back(94);
    40. colorArray3D.push_back(darkGray);
    To copy to clipboard, switch view to plain text mode 

    Now i want to chose color in iterations but it show strange color
    Qt Code:
    1. for ( int k = 0 ; k < 2 ; ++k )
    2. {
    3. for ( int i = 0 ; i < 200 ; ++i )
    4. {
    5. //i do something
    6.  
    7. glColor3ub(colorArray3D[k][0],colorArray3D[k][1],colorArray3D[k][2]);
    8. gluSphere(params,radius,10,10);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    normaly my first sphere should be blue and the second green; but it's blue and second like dark magenta



    if i comment this lines, it's works:

    Qt Code:
    1. QVector<int> magenta;
    2. blue.push_back(233);
    3. blue.push_back(73);
    4. blue.push_back(214);
    5. colorArray3D.push_back(magenta);
    6. QVector<int> gray;
    7. blue.push_back(161);
    8. blue.push_back(156);
    9. blue.push_back(161);
    10. colorArray3D.push_back(gray);
    11. QVector<int> darkBlue;
    12. blue.push_back(43);
    13. blue.push_back(5);
    14. blue.push_back(203);
    15. colorArray3D.push_back(darkBlue);
    16. QVector<int> darkGreen;
    17. blue.push_back(43);
    18. blue.push_back(203);
    19. blue.push_back(0);
    20. colorArray3D.push_back(darkGreen);
    21. QVector<int> darkMagenta;
    22. blue.push_back(136);
    23. blue.push_back(32);
    24. blue.push_back(101);
    25. colorArray3D.push_back(darkMagenta);
    26. QVector<int> darkGray;
    27. blue.push_back(94);
    28. blue.push_back(94);
    29. blue.push_back(94);
    30. colorArray3D.push_back(darkGray);
    To copy to clipboard, switch view to plain text mode 


  2. #2
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: strange color problem with GLwidget

    according to your code you only push values in the 'blue' QVector variable... and let other 'color vectors' uninitialized

  3. The following user says thank you to totem for this useful post:

    21did21 (6th July 2011)

  4. #3
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: strange color problem with GLwidget

    oh yes !!!

    i have seen this

    thanks a lot

Similar Threads

  1. problem with glwidget and VBO.
    By Rufjan in forum Qt Programming
    Replies: 2
    Last Post: 25th June 2013, 06:16
  2. Replies: 0
    Last Post: 30th September 2010, 13:22
  3. Replies: 5
    Last Post: 12th August 2010, 22:51
  4. Background color of GLWidget
    By mullwaden in forum Qt Programming
    Replies: 3
    Last Post: 21st August 2008, 17:24
  5. GLWidget
    By dragon in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2007, 15:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.