6 displayDriver = "OpenGL";
7 nativeDecorations = true;
8 text = "GL+Ecere Camera Demo";
13 Camera camera { fixed, position = { 50, -50, -300 }, orientation = Euler { 25, 0, 0 }, fov = 53; };
14 Light light { diffuse = white; specular = white; orientation = Euler { pitch = -45, yaw = 0 }; };
27 static Time lastTime = 0, time;
29 if(!lastTime) lastTime = time;
30 UpdateObjects(time - lastTime);
37 void UpdateObjects(Time diffTime)
39 Quaternion orientation = cube.transform.orientation;
40 orientation.RotateYawPitch((Degrees)diffTime * 0.5, (Degrees)diffTime * 0.5);
41 orientation.RotateRoll((Degrees)diffTime * 0.5);
42 cube.transform.orientation = orientation;
43 cube.UpdateTransform();
48 cube.Create(displaySystem);
49 cube.transform.scaling = { 100, 100, 100 };
50 cube.transform.position = { 0, 0, 0 };
51 cube.transform.orientation = Euler { 50, 50 };
52 cube.UpdateTransform();
56 void OnResize(int w, int h)
58 camera.Setup(w, h, null);
61 void OnRedraw(Surface surface)
63 surface.Clear(depthBuffer);
65 display.SetLight(0, light);
66 display.fogDensity = 0;
67 display.SetCamera(surface, camera);
69 display.DrawObject(cube);
77 glDisable(GL_LIGHTING);
82 glVertex3f(-300, 0, 0);
83 glVertex3f(300, 0, 0);
86 glVertex3f(0, -300, 0);
87 glVertex3f(0, 300, 0);
90 glVertex3f(0, 0, -300);
91 glVertex3f(0, 0, 300);
95 glEnable(GL_LIGHTING);
99 display.SetCamera(surface, null);
102 bool OnMouseMove(int x, int y, Modifiers mods)
106 int dx = (int)(x - lastMouse.x), dy = (int)(lastMouse.y - y);
107 camera.RotateYaw(-dx, 0,0);
108 camera.RotatePitch(dy, 0,0);
116 bool OnLeftButtonDown(int x, int y, Modifiers mods)
123 lastMouse = { x, y };
128 bool OnLeftButtonUp(int x, int y, Modifiers mods)
138 bool OnKeyHit(Key key, unichar ch)
143 camera.Move({ 0,0,100 });
147 camera.Move({ 0,0,-100 });
155 GLDemo glDemo { anchor = { horz = 160, vert = 120 } };