Change Color problem

Hi. I have problem. I try code change color by UI slider.
But when i have value of Color. It doesn’t update. I know I forget on some.

My code:

float CRedColor, CGreenColor, CBlueColor, CAlphaColor;

float RedColor()
	if(CRedColor == NULL)
		Log << "CRedColor is NULL" << std::endl;

			Log << "CRedColor is NULL + NoggIt.conf doesn't exists" << std::endl;

			return 1.0f;
			std::stringstream ss(ConfigFile("NoggIt.conf").read<float>("RedColor"));

			Log << "CRedColor isn't NULL" << std::endl;

				Log << "CRedColor isn't NULL, but haven't mention about RedColor" << std::endl;

				return 1.0f;
				Log << "CRedColor isn't NULL and have mention about RedColor" << std::endl;

				return ConfigFile("NoggIt.conf").read<float>("RedColor");
		return CRedColor;

	return 1.0f;

void LoadColor()
	CRedColor = RedColor();
	CGreenColor = GreenColor();
	CBlueColor = BlueColor();
	CAlphaColor = AlphaColor();

void renderDisk(float x1, float y1, float z1, float x2, float y2, float z2, float radius, int subdivisions, GLUquadricObj *quadric)
  float vx = x2 - x1;
  float vy = y2 - y1;
  float vz = z2 - z1;

  //handle the degenerate case of z1 == z2 with an approximation
  if( vz == 0.0f )
    vz = .0001f;

  float v = sqrt( vx*vx + vy*vy + vz*vz );
  float ax = 57.2957795f*acos( vz/v );
  if(vz < 0.0f)
    ax = -ax;

  float rx = -vy * vz;
  float ry = vx * vz;



  //draw the quadric
  glTranslatef(x1, y1, z1);
  glRotatef(ax, rx, ry, 0.0f);
  glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
  glColor4f(CRedColor, CGreenColor, CBlueColor, CAlphaColor);

  gluQuadricOrientation(quadric, GLU_OUTSIDE);
  gluDisk(quadric, radius - 0.25f, radius + 5.0f, subdivisions, 2);

  //glColor4f(0.0f, 0.8f, 0.1f, 0.9f);
  //gluDisk(quadric, (radius * 1.5) - 2, (radius * 1.5) + 2, 0, 1);


void renderDisk_convenient(float x, float y, float z, float radius, int subdivisions)
  GLUquadricObj *quadric = gluNewQuadric();
  gluQuadricDrawStyle(quadric, GLU_LINE);
  gluQuadricNormals(quadric, GLU_SMOOTH);
  renderDisk(x, y, z, x, y, z, radius, subdivisions, quadric);

I don’t give here code of GreenColor(), … it’s same.

How i work?
1)Check if float CRedColor have value, if not check if config exists, if yea load value from config, else return 1.0f, if CRedColor have value return RedColor;
2)float CRedColor = RedColor(); // its for get value from config or …
3)call LoadColor() in renderDisk
4)glColor4f(CRedColor, CGreenColor, CBlueColor, CAlphaColor);
5)I have now first color
6)Now User want change color of Disk so use Slider
7)User change Color, but he doesn’t see change.

Why this CredColor == NULL test ???

You cannot directly modify the values of C[Red,Green,Blue,Alpha]Color with a slider or something like this ???

I can modify value of C[Red,Green,Blue,Alpha].

Why CRedColor == NULL test?
Easy… Because when have NULL value or empty, RedColor load value from config or return 1.0f.

So now have CRedColor value 1.0f if config doesnt exists.

I can modify value of CRedColors, …

But problem is: I havent coded some repainting or some like that.And i don’t know how do it.


Again…I can modify value of CRedColor, CGReenColor, …
But program it dont re-rendering

Are you forcing a repaint when the value changes? in glut, u call glutPostRedisplay() to force a repaint. I dont know which library you are using but i suppose there will be a repaint function you can call.

boosts, glew32, sdl, glu32, opengl32 and advapi32

I don’t using glut. So is any next alternative solution?

SDL has SDL_UpdateRect function to force repaint see the SDL reference for details.

glu.h or gl.h haven’t? I’m not great coder in SDL :stuck_out_tongue: