servo: Use SDL to display a window

Source-Repo: https://github.com/servo/servo
Source-Revision: 4afdbe89c2bb1820e25b586b52d3f2948f9d1988
This commit is contained in:
Brian Anderson 2012-04-15 21:18:53 -07:00
Родитель d47b650ef1
Коммит a609627053
1 изменённых файлов: 40 добавлений и 0 удалений

Просмотреть файл

@ -1,4 +1,44 @@
import azure::cairo;
fn on_main(f: fn~()) {
let builder = task::builder();
let opts = {
sched: some({
mode: task::osmain,
native_stack_size: none
})
with task::get_opts(builder)
};
task::set_opts(builder, opts);
task::run(builder, f);
}
fn main() {
on_main {||
sdl::init([
sdl::init_video
]);
let screen = sdl::video::set_video_mode(
320, 200, 32,
[sdl::video::swsurface],
[sdl::video::doublebuf]);
assert ptr::is_not_null(screen);
let surface = sdl::video::create_rgb_surface(
[sdl::video::swsurface],
320, 200, 32,
0x00FF0000u32,
0x0000FF00u32,
0x000000FFu32,
0x00000000u32
);
assert ptr::is_not_null(surface);
loop {
sdl::video::blit_surface(surface, ptr::null(),
screen, ptr::null());
sdl::video::flip(screen);
sdl::event::poll_event {|_event|
}
}
sdl::quit();
}
}