OSDN Git Service

[Backup]NyARToolkit for Java
[nyartoolkit-and/nyartoolkit-and.git] / src.utils / jogl / jp / nyatla / nyartoolkit / jogl / utils / GLNyARRaster_RGB.java
1 /* \r
2  * PROJECT: NyARToolkit JOGL utilities.\r
3  * --------------------------------------------------------------------------------\r
4  * This work is based on the original ARToolKit developed by\r
5  *   Hirokazu Kato\r
6  *   Mark Billinghurst\r
7  *   HITLab, University of Washington, Seattle\r
8  * http://www.hitl.washington.edu/artoolkit/\r
9  *\r
10  * The NyARToolkit is Java edition ARToolKit class library.\r
11  * Copyright (C)2008-2009 Ryo Iizuka\r
12  *\r
13  * This program is free software: you can redistribute it and/or modify\r
14  * it under the terms of the GNU General Public License as published by\r
15  * the Free Software Foundation, either version 3 of the License, or\r
16  * (at your option) any later version.\r
17  * \r
18  * This program is distributed in the hope that it will be useful,\r
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21  * GNU General Public License for more details.\r
22  *\r
23  * You should have received a copy of the GNU General Public License\r
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
25  * \r
26  * For further information please contact.\r
27  *      http://nyatla.jp/nyatoolkit/\r
28  *      <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
29  * \r
30  */\r
31 package jp.nyatla.nyartoolkit.jogl.utils;\r
32 \r
33 \r
34 import javax.media.opengl.GL;\r
35 \r
36 import jp.nyatla.nyartoolkit.NyARException;\r
37 import jp.nyatla.nyartoolkit.jmf.utils.*;\r
38 import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
39 import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
40 import javax.media.format.*;\r
41 \r
42 /**\r
43  * NyARRaster_RGBにOpenGL用のデータ変換機能を追加したものです。\r
44  */\r
45 public class GLNyARRaster_RGB extends JmfNyARRaster_RGB\r
46 {\r
47         private int _gl_flag;\r
48         /**\r
49          * コンストラクタです。i_formatを取り込めるi_paramのサイズパラメタを持つ\r
50          * ラスタオブジェクトを作成します。\r
51          * @param i_param\r
52          * カメラパラメタを指定します。コンストラクタは、画面サイズ以外のパラメタを見ていません。\r
53          * @param i_format\r
54          * キャプチャ画像のピクセルフォーマットを指定します。\r
55          * @throws NyARException\r
56          */\r
57         public GLNyARRaster_RGB(NyARParam i_param,VideoFormat i_format) throws NyARException\r
58         {\r
59                 super(i_param.getScreenSize(),i_format);\r
60                 switch(this._reader.getBufferType()){\r
61                 case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
62                         this._gl_flag = GL.GL_BGR;\r
63                         break;\r
64                 case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
65                         this._gl_flag = GL.GL_RGB;\r
66                         break;\r
67                 default:\r
68                         throw new NyARException();\r
69                 }\r
70                 return;\r
71         }\r
72         /**\r
73          * RGBバイト配列への参照値を返します。\r
74          * バッファの並び順は、getGLPixelFlagが返すデータ順で格納されています。\r
75          * @return\r
76          * RGBバイト配列の参照値です。\r
77          */\r
78         public byte[] getGLRgbArray()\r
79         {\r
80                 return (byte[])this._reader.getBuffer();\r
81         }\r
82 \r
83         /**\r
84          * OpenGLの描画フラグを返します。\r
85          * この値は、RGBバッファのバイト並びタイプです。\r
86          * @return\r
87          * GL.GL_BGR等の、RGBバイト配列の形式を表す値です。\r
88          */\r
89         public int getGLPixelFlag()\r
90         {\r
91                 return this._gl_flag;\r
92         }\r
93 }\r