Hi,
I'm trying to do a program which includes an opengl widget on the left and a tree on the right. So when the user selects the object from the tree, The object in the left shhould be highlighted or change color or smth else u offer me to do which is easier.
I thought that changing its color would be the easiest one. But I didnot managed to succeed it.
It seems correct. I don't understand where is the mistake.
Here is my code:
Qt Code:
  1. void GLWidget::initializeGL()
  2. {
  3. qglClearColor(trolltechPurple.dark());
  4. object = makeObject();
  5. glShadeModel(GL_FLAT);
  6. glEnable(GL_DEPTH_TEST);
  7. glEnable(GL_CULL_FACE);
  8. }
  9.  
  10. void GLWidget::paintGL()
  11. {
  12. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  13. glLoadIdentity();
  14. glTranslated(0.0, 0.0, -10.0);
  15. glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
  16. glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
  17. glRotated(zRot / 16.0, 0.0, 0.0, 1.0);
  18. glCallList(object);
  19. }
  20.  
  21. void GLWidget::resizeGL(int width, int height)
  22. {
  23. int side = qMin(width, height);
  24. glViewport((width - side) / 2, (height - side) / 2, side, side);
  25.  
  26. glMatrixMode(GL_PROJECTION);
  27. glLoadIdentity();
  28. glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);
  29. glMatrixMode(GL_MODELVIEW);
  30. }
  31. void GLWidget::setHighlighted(){
  32. Purple = QColor::fromCmykF(0.25, 0.25, 0.20, 0.0);
  33. qglColor(Purple);
  34. //paintGL();
  35. //,nitializeGL();
  36. updateGL();
  37.  
  38. }
To copy to clipboard, switch view to plain text mode