GLUT Question.

Why dose this just turn my cube black, it should be lighting it up with white and grey lights



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 #ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <stdlib.h>

float yup = 0.0f;
float ydown = 0.0f;


 void KeyUp(int key, int x, int y){

ydown = ydown + 0.5f;

    }


void cube(void){
    glRotatef(ydown,0.0f,0.0f,0.0f);
     glColor4f(0.0, 1.0, 0.0, 0.2);
glutSolidCube(1);
 glColor4f(0.0, 1.0, 0.0, 0.5);
}

void init(void){
glClearDepth(1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

}

void display(void){
    glClearColor(1.0f,0.0f,0.0f,1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glLoadIdentity();
cube();
glutSwapBuffers();
}

int main(int argc, char **argv) {

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Dimension");
init();
glutDisplayFunc(display);
glutIdleFunc(display);

glLoadIdentity();

    glutSpecialFunc(KeyUp);

glutMainLoop();

return 0;
}
nvm, it works fine sorry.
Oh, wait again, I was right it dose not work lol.
I don't really have an answer to your question... I just wanted to point out that you are using a very, very old version of OpenGL. Most of the functions you are using have been deprecated and no longer exist in recent versions.
Actualy they all work great, I have a older version of OpenGL I am guessing. The lighting will not work for some reason.. :/
I don't see where you're specifying the position/color/intensity of the lights.
Ah, thats something the tutorial actualy did not mention, ill look that up myself.
Whatever tutorial you're using is teaching you outdated techniques. I recommend you find a better one.
Do you know of any better ones?
Topic archived. No new replies allowed.