HI,
So im sure this is an easy question to answer and that it has been asked before, but not knowing what i am doing at all here goes:
How can i switch from wire frame to flat shading mode while the object is already being displayed. I have already figured out that i need to set
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); for wire frame and
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); for shaded mode. But i need to be able to toggle between the two modes while the object is being displayed on the screen. How do i do that. I have a keyboard function set up that recognizes keystrokes, namely “esc” to exit, but if i add other keys for the system to recognize, as my toggle button, how do i use that to manipulate the polygon mode.
And second, I need to create instances of colors so i can display the color value at different positions. I have found a section of code in Java that pretty much does exactly what I want to do, but i need it in C++, and i know that the opengl function calls are not the same, but have no idea what they are.
JAVE CODE:
private RGB blue = new RGB (0.0, 0.0, 1.0);
private RGB green = new RGB (0.0, 1.0, 0.0);
private RGB white = new RGB (1.0, 1.0, 1.0);
public RGB getColor (double i, double j) {
double a = getAltitude (i, j);
if (a < .5)
return blue.add (green.subtract (blue).scale ((a - 0.0) / 0.5));
else
return green.add (white.subtract (green).scale ((a - 0.5) / 0.5));
}
How can i create those instances in C++ and does c++ have functional calls, like the ones used in the java script, i.e. “blue.add”, “green.subtract”.
Thank you very much for your help.