ちょっとレンダリング結果を動画にして確認したい場合に、.txt形式で出力してconvert (ImageMagick)すると便利です。

   1  /*
   2   * Output image
   3   */
   4  std::vector<unsigned char> buf(3*width*height);
   5  glFlush();
   6  glReadBuffer(GL_BACK);       
   7  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   8  glReadPixels(0, 0, width, height,
   9      GL_RGB, GL_UNSIGNED_BYTE, &buf[0]);
  10      
  11  char filename[1024];
  12  sprintf(filename, "%s_%04d.txt", basename, frame);
  13  FILE *fp = fopen(filename, "w");
  14  fprintf(fp,
  15      "# ImageMagick pixel enumeration: %d,%d,%d,rgb\n",
  16      width, height, 255);
  17  for(int y = 0; y < host->height; ++y){
  18      for(int x = 0; x < host->width; ++x){
  19          int idx = (host->height - y - 1)*host->width + x;
  20          fprintf(fp, "%d,%d: (%d,%d,%d)\n",
  21              x, y, 
  22              buf[3*idx + 0],
  23              buf[3*idx + 1],
  24              buf[3*idx + 2]);
  25      } 
  26  }
  27  fclose(fp);

出来上がったら、

   1  % convert basename_*.txt basename.mp4

posted by Png genki on Sat 30 Jan 2010 at 15:13

fltkもGLUTも気がつけばFATになっていっている気がします。

  • FrameBufferにpixelsをput出来る
  • 最低限のマウス、キーボードからの入力をさばける
  • Windowは1個. resizeとかは不要

だいたいこのぐらいで十分なので、

  • 外部ライブラリに依存しない
  • OS/アーキテクチャに依存せず 32bit/64bit で動く
  • 初心を忘れない鉄の意志でメンテナンスされている

GUI toolkitが欲しいです。無かったら作ろうかな。

posted by Png genki on Sat 30 Jan 2010 at 06:17
Contents
テスト用に連番画像を出力して動画を作成したい場合のメモ
ポータブルでシンプルなGUI toolkitが欲しい
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ