Sehr geehrtes Forum,
ich benutze OpenGL mit der SFML auf Code Blocks, und habe folgenden Code geschrieben :
|
C-/C++-Quelltext
|
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
void Displayer::run()
{
while(running)
{
checkEvents();
drawGL();
}
}
void Displayer::checkEvents()
{
sf::Event Event;
while (window->GetEvent(Event))
{
/// Escape Key : EXIT
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
running = false;
}
/// LEFT Key
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Left))
{
camera.x -= 1.0f;
cout << camera.x << endl;
}
/// Right Key
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Right))
{
camera.x += 1.0f;
cout << camera.x << endl;
}
}
}
void Displayer::drawGL()
{
/// Lösche Hintergrund
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gluLookAt (0.0f, 5.0f, 1.0f,
camera.x, 5.0f, camera.z,
0.0f, 1.0f, 0.0f);
/// Einige Transformierungen Bestätigen
glMatrixMode(GL_MODELVIEW);
/// Zeichne Objekte...
drawFloor();
drawObjects();
/// Ende der Zeichnung
/// Aktualisiere Bild
window->Display();
}
void Displayer::drawFloor()
{
glColor3f(0.05f,0.91f,0.18f);
for(float x = -100;x<+100;x+=10)
{
glBegin(GL_LINES);
glVertex3f(x,-10.0f,-100.0f);
glVertex3f(x,-10.0f,+100.0f);
glEnd();
}
for(float z = -100;z<+100;z+=10)
{
glBegin(GL_LINES);
glVertex3f(-100.0f,-10.0f,z);
glVertex3f(+100.0f,-10.0f,z);
glEnd();
}
}
void Displayer::drawObjects()
{
}
|
Wenn ich den Code starte, dann fliegt die Ganze Welt nachunten, und verschwindet, obwohl ich gar nichts mache, und das ist es ja :
ich rufe
glLoadIdentity(); nicht auf, aber wenn ichs mache, am Anfang oder am Ende von
drawFloor(); dann bewegt sich gar nichts, warum?
camera ist ein Point3f des folgenden Structs :
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
|
struct Point3f
{
/// Attribute
float x;
float y;
float z;
};
|
Danke für eure Antwort,
m.f.G. Developer_X