private void init_video () {
uint32 video_flags = SurfaceFlag.SWSURFACE | SurfaceFlag.OPENGL;
screen = Screen.set_video_mode (SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, video_flags);
if (screen == null) stderr.printf ("Could not set video mode.\n");
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glFrustum (-2.0f, 2.0f, -2.0f, 2.0f, 1.0f, 300.0f);
glMatrixMode (GL_MODELVIEW);
glEnable (GL_DEPTH_TEST);
glEnable (GL_TEXTURE_2D);
SDL.WindowManager.set_caption ("Title", "Title");
}
それは、私が取り組んでいるゲームのカメラをセットアップする機能です。私は立方体を描くためにこの機能を持っています:
public void draw () {
glLoadIdentity ();
glTranslatef (x, y, z);
glScalef (size, size, size);
glRotatef (x_angle, 1.0f, 0.0f, 0.0f);
glRotatef (y_angle, 0.0f, 1.0f, 0.0f);
glRotatef (z_angle, 0.0f, 0.0f, 1.0f);
glBegin (GL_QUADS);
/* Front face */
glColor3f (1.0f, 0.0f, 0.0f);
glVertex3f (0.5f, 0.5f, 0.5f);
glVertex3f (-0.5f, 0.5f, 0.5f);
glVertex3f (-0.5f, -0.5f, 0.5f);
glVertex3f (0.5f, -0.5f, 0.5f);
/* Left face */
glColor3f (0.0f, 1.0f, 0.0f);
glVertex3f (-0.5f, 0.5f, 0.5f);
glVertex3f (-0.5f, -0.5f, 0.5f);
glVertex3f (-0.5f, -0.5f, -0.5f);
glVertex3f (-0.5f, 0.5f, -0.5f);
/* Back face */
glColor3f (0.0f, 0.0f, 1.0f);
glVertex3f (0.5f, 0.5f, -0.5f);
glVertex3f (-0.5f, 0.5f, -0.5f);
glVertex3f (-0.5f, -0.5f, -0.5f);
glVertex3f (0.5f, -0.5f, -0.5f);
/* Right face */
glColor3f (1.0f, 1.0f, 0.0f);
glVertex3f (0.5f, 0.5f, 0.5f);
glVertex3f (0.5f, -0.5f, 0.5f);
glVertex3f (0.5f, -0.5f, -0.5f);
glVertex3f (0.5f, 0.5f, -0.5f);
/* Top face */
glColor3f (0.0f, 1.0f, 1.0f);
glVertex3f (0.5f, 0.5f, 0.5f);
glVertex3f (-0.5f, 0.5f, 0.5f);
glVertex3f (-0.5f, 0.5f, -0.5f);
glVertex3f (0.5f, 0.5f, -0.5f);
/* Bottom face */
glColor3f (1.0f, 0.0f, 1.0f);
glVertex3f (0.5f, -0.5f, 0.5f);
glVertex3f (-0.5f, -0.5f, 0.5f);
glVertex3f (-0.5f, -0.5f, -0.5f);
glVertex3f (0.5f, -0.5f, -0.5f);
glEnd ();
}
2D コンテキストであるかのようにポイントを描画するにはどうすればよいですか? 何か案は?