class MY_SURFACE inherit EM_SURFACE GL_FUNCTIONS_EXTERNAL export {NONE} all end GLU_FUNCTIONS_EXTERNAL export {NONE} all end feature gl_enter_2d is -- Enter 2d mode using opengl. do if not gl_2d_mode then gl_push_attrib_external ( em_gl_enable_bit | em_gl_color_buffer_bit ) gl_disable_external ( em_gl_depth_test ) gl_disable_external ( em_gl_cull_face ) gl_enable_external ( em_gl_texture_2d ) gl_clear_color_external ( 0, 0, 0, 1 ) -- This allows alpha blending of 2D textures with the scene gl_enable_external (em_gl_blend) gl_blend_func_external (em_gl_src_alpha, em_gl_one_minus_src_alpha) gl_viewport_external ( 0, 0, width, height ) -- Set perspective gl_matrix_mode_external ( em_gl_projection ) gl_push_matrix_external gl_load_identity_external gl_ortho_external ( 0, width, height, 0, 0, 1 ) gl_matrix_mode_external ( em_gl_modelview ) gl_push_matrix_external gl_load_identity_external gl_tex_envf_external (em_gl_texture_env, em_gl_texture_env_mode, em_gl_replace) gl_2d_mode := true end ensure in_mode: gl_2d_mode end gl_leave_2d is -- Leave 2d mode using opengl do if gl_2d_mode then gl_matrix_mode_external ( em_gl_projection ) gl_pop_matrix_external gl_matrix_mode_external ( em_gl_modelview ) gl_pop_matrix_external gl_pop_attrib_external gl_2d_mode := false end ensure not_in_mode: not gl_2d_mode end feature -- access gl_2d_mode: BOOLEAN end