colored cubes with ofBox

hi, in a mew example i write only:

  
void testApp::draw(){  
  
    ofSetColor(1,0,0);  
    ofFill();  
    ofBox(110);  
  
}  
  

and i see a black square. what to do for get a red one?

I believe ofSetColor(); goes from 0 - 255, not 0 - 1. Therefore, 1 for Red channel would still almost be black. Try ofSetColor(255,0,0);

Seth is correct, you can also use ofSetHexColor( 0xff0000 );

sorry i reopened this topic because i’m getting black box again with lights:

  
tatic float amb[] =  {0.4, 0.4, 0.4, 0.0};  
static float dif[] =  {1.0, 1.0, 1.0, 0.0};  
  
float light_diffuse[] = {1.0, 0.0, 0.0, 1.0};   
float light_position[] = {1.0, 1.0, 1.0, 0.0};  
  
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);  
glLightfv(GL_LIGHT0, GL_POSITION, light_position);  
glEnable(GL_LIGHT0);  
glEnable(GL_LIGHT1);  
glEnable(GL_LIGHTING);  

in this way i get black box. if i add

  
glEnable(GL_DEPTH_TEST);  
  
glMaterialfv(GL_FRONT, GL_AMBIENT, amb);  
glMaterialfv(GL_FRONT, GL_DIFFUSE, dif);  

i see no boxes.
some advice? or some nice light tutorial with openframeworks?

Could you post more code? Running the following I see the light diffuse color ok:

  
	float light_diffuse[] = {1.0, 1.0, 0.0, 1.0};     
	float light_position[] = {1.0, 1.0, 1.0, 0.0};    
	  
	glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);    
	glLightfv(GL_LIGHT0, GL_POSITION, light_position);    
	glEnable(GL_LIGHT0);    
	glEnable(GL_LIGHT1);    
	glEnable(GL_LIGHTING);   
	  
	glEnable(GL_DEPTH_TEST);    
	  
	glMaterialfv(GL_FRONT, GL_AMBIENT, amb);    
	glMaterialfv(GL_FRONT, GL_DIFFUSE, dif);  
	  
	glTranslatef(100.f, 100.f, -100.f);  
	drawCube();  
	glTranslatef(100.f, 100.f, 100.f);  
	drawCube();  
	glTranslatef(200.f, 100.f, -300.f);  
	drawCube();  
  
	  
	glDisable(GL_LIGHT0);    
	glDisable(GL_LIGHT1);    
	glDisable(GL_LIGHTING);   

There might be something else going wrong in your code.

sorry if i reopen this old post

emptyExample with this code:

  
void testApp::draw(){  
  
    static float amb[] =  {0.4, 0.4, 0.4, 0.0};  
    static float dif[] =  {1.0, 1.0, 1.0, 0.0};  
      
    float light_diffuse[] = {1.0, 0.0, 1.0, 1.0};   
    float light_position[] = {-1.0, 1.0, 1.0, 0.0}; // i tried a lot of positions here!  
      
    // set camera  
    glMatrixMode(GL_MODELVIEW);  
    glLoadIdentity();  
    gluLookAt(0, 200, 1200, 0,0,0, 0,1,0);  
  
    // set lights  
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);  
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);  
    glEnable(GL_LIGHT0);  
    glEnable(GL_LIGHT1);  
    glEnable(GL_LIGHTING);  
    glMaterialfv(GL_FRONT, GL_AMBIENT, amb);  
    glMaterialfv(GL_FRONT, GL_DIFFUSE, dif);  
  
    // draw scene  
    ofScale(50, 50, 50);  
    glPushMatrix();  
  
    glutSolidCube(2);  
  
    // close everything  
    glPopMatrix();  
    glDisable(GL_LIGHT0);  
    glDisable(GL_LIGHT1);  
    glDisable(GL_LIGHTING);  
  
  
}  

doesn’t work and i don’t understand why…

ok it was a stupid error, i was not considering the scale factor!