Skip to content

Instantly share code, notes, and snippets.

@kjunichi
Last active August 29, 2015 14:06
Show Gist options
  • Save kjunichi/677c644ef69ea7d86887 to your computer and use it in GitHub Desktop.
Save kjunichi/677c644ef69ea7d86887 to your computer and use it in GitHub Desktop.
Rustでシダを描画するまでのメモ

何は無くともGUI

21世紀になっても、画像をファイルにしか出せない言語はクソ以下

進捗状況

最悪でも配列、2次元配列くらは扱いたい

fn next_two(x: int) -> (int, int) { (x + 1i, x + 2i) }

fn main() {
    let mut state = [[0u8, ..4], ..3];
    state[2][3]=5;
    let (x, y) = next_two(1i);
    println!("x, y = {}, {}", x, y);
        let z = state[x as uint][y as uint];
    println!("Hello, world {} !", z);
}

スタックエリアが足りない!

困った

ヒープ領域に自前で明示的にメモリを確保するとかRustは出来るようだが、そこまでしないと画像が扱えないのかなぁ

画像を扱うライブラリを発見

あと必要な事

  • 画像ライブラリで作成したイメージデータをOpenGLで扱えるように変換する事
  • OpenGL側に渡せる画像サイズの配列をRustでどうやって確保できるのか

boxで配列をヒープ領域に確保できた

let mut state = box [[[0u8, ..3], ...4096], ..32768];

TODO

  • mem::size_of::()
  • mem::transmute

関連記事

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment