OSDN Git Service

[backup]NyARToolkit
[nyartoolkit-and/nyartoolkit-and.git] / trunk / 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.raster.*;\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                 initMember(this.getBufferType());\r
61                 return;\r
62         }\r
63         public GLNyARRaster_RGB(int i_width,int i_height,VideoFormat i_format) throws NyARException\r
64         {\r
65                 super(i_width,i_height,i_format);\r
66                 initMember(this.getBufferType());\r
67                 return;\r
68         }       \r
69         private void initMember(int i_buffer_type) throws NyARException\r
70         {\r
71                 switch(i_buffer_type){\r
72                 case INyARRaster.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
73                         this._gl_flag = GL.GL_BGR;\r
74                         break;\r
75                 case INyARRaster.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
76                         this._gl_flag = GL.GL_RGB;\r
77                         break;\r
78                 default:\r
79                         throw new NyARException();\r
80                 }\r
81                 return;\r
82         }\r
83         /**\r
84          * RGBバイト配列への参照値を返します。\r
85          * バッファの並び順は、getGLPixelFlagが返すデータ順で格納されています。\r
86          * @return\r
87          * RGBバイト配列の参照値です。\r
88          */\r
89         public byte[] getGLRgbArray()\r
90         {\r
91                 return (byte[])this.getBuffer();\r
92         }\r
93 \r
94         /**\r
95          * OpenGLの描画フラグを返します。\r
96          * この値は、RGBバッファのバイト並びタイプです。\r
97          * @return\r
98          * GL.GL_BGR等の、RGBバイト配列の形式を表す値です。\r
99          */\r
100         public int getGLPixelFlag()\r
101         {\r
102                 return this._gl_flag;\r
103         }\r
104 \r
105 }\r