Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# GraphicsBufferFormat.cpp

Go to the documentation of this file.

    00001 //------------------------------------------------------------------------------
    00002 // Lamp : Open source game middleware
    00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
    00004 //
    00005 // This library is free software; you can redistribute it and/or
    00006 // modify it under the terms of the GNU Lesser General Public
    00007 // License as published by the Free Software Foundation; either
    00008 // version 2.1 of the License, or (at your option) any later version.
    00009 //
    00010 // This library is distributed in the hope that it will be useful,
    00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013 // Lesser General Public License for more details.
    00014 //
    00015 // You should have received a copy of the GNU Lesser General Public
    00016 // License along with this library; if not, write to the Free Software
    00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 //------------------------------------------------------------------------------
    00019
    00020 /** @file
    00021  * グラフィックスバッファフォーマット実装
    00022  * @author Junpee
    00023  */
    00024
    00025 #include "LampBasic.h"
    00026 #include "Graphics/Primitive/GraphicsBufferFormat.h"
    00027
    00028 namespace Lamp{
    00029
    00030 //------------------------------------------------------------------------------
    00031 // フォーマット名の取得
    00032 String GraphicsBufferFormat::getName(){
    00033     switch(format_){
    00034         case D3DFMT_UNKNOWN:        return "D3DFMT_UNKNOWN";
    00035
    00036         case D3DFMT_R8G8B8:         return "D3DFMT_R8G8B8";
    00037         case D3DFMT_A8R8G8B8:       return "D3DFMT_A8R8G8B8";
    00038         case D3DFMT_X8R8G8B8:       return "D3DFMT_X8R8G8B8";
    00039         case D3DFMT_R5G6B5:         return "D3DFMT_R5G6B5";
    00040         case D3DFMT_X1R5G5B5:       return "D3DFMT_X1R5G5B5";
    00041         case D3DFMT_A1R5G5B5:       return "D3DFMT_A1R5G5B5";
    00042         case D3DFMT_A4R4G4B4:       return "D3DFMT_A4R4G4B4";
    00043         case D3DFMT_R3G3B2:         return "D3DFMT_R3G3B2";
    00044         case D3DFMT_A8:             return "D3DFMT_A8";
    00045         case D3DFMT_A8R3G3B2:       return "D3DFMT_A8R3G3B2";
    00046         case D3DFMT_X4R4G4B4:       return "D3DFMT_X4R4G4B4";
    00047         case D3DFMT_A2B10G10R10:    return "D3DFMT_A2B10G10R10";
    00048         case D3DFMT_A8B8G8R8:       return "D3DFMT_A8B8G8R8";
    00049         case D3DFMT_X8B8G8R8:       return "D3DFMT_X8B8G8R8";
    00050         case D3DFMT_G16R16:         return "D3DFMT_G16R16";
    00051         case D3DFMT_A2R10G10B10:    return "D3DFMT_A2R10G10B10";
    00052         case D3DFMT_A16B16G16R16:   return "D3DFMT_A16B16G16R16";
    00053
    00054         case D3DFMT_A8P8:           return "D3DFMT_A8P8";
    00055         case D3DFMT_P8:             return "D3DFMT_P8";
    00056
    00057         case D3DFMT_L8:             return "D3DFMT_L8";
    00058         case D3DFMT_A8L8:           return "D3DFMT_A8L8";
    00059         case D3DFMT_A4L4:           return "D3DFMT_A4L4";
    00060
    00061         case D3DFMT_V8U8:           return "D3DFMT_V8U8";
    00062         case D3DFMT_L6V5U5:         return "D3DFMT_L6V5U5";
    00063         case D3DFMT_X8L8V8U8:       return "D3DFMT_X8L8V8U8";
    00064         case D3DFMT_Q8W8V8U8:       return "D3DFMT_Q8W8V8U8";
    00065         case D3DFMT_V16U16:         return "D3DFMT_V16U16";
    00066         case D3DFMT_A2W10V10U10:    return "D3DFMT_A2W10V10U10";
    00067
    00068         case D3DFMT_UYVY:           return "D3DFMT_UYVY";
    00069         case D3DFMT_R8G8_B8G8:      return "D3DFMT_R8G8_B8G8";
    00070         case D3DFMT_YUY2:           return "D3DFMT_YUY2";
    00071         case D3DFMT_G8R8_G8B8:      return "D3DFMT_G8R8_G8B8";
    00072         case D3DFMT_DXT1:           return "D3DFMT_DXT1";
    00073         case D3DFMT_DXT2:           return "D3DFMT_DXT2";
    00074         case D3DFMT_DXT3:           return "D3DFMT_DXT3";
    00075         case D3DFMT_DXT4:           return "D3DFMT_DXT4";
    00076         case D3DFMT_DXT5:           return "D3DFMT_DXT5";
    00077
    00078         case D3DFMT_D16_LOCKABLE:   return "D3DFMT_D16_LOCKABLE";
    00079         case D3DFMT_D32:            return "D3DFMT_D32";
    00080         case D3DFMT_D15S1:          return "D3DFMT_D15S1";
    00081         case D3DFMT_D24S8:          return "D3DFMT_D24S8";
    00082         case D3DFMT_D24X8:          return "D3DFMT_D24X8";
    00083         case D3DFMT_D24X4S4:        return "D3DFMT_D24X4S4";
    00084         case D3DFMT_D16:            return "D3DFMT_D16";
    00085
    00086         case D3DFMT_D32F_LOCKABLE:  return "D3DFMT_D32F_LOCKABLE";
    00087         case D3DFMT_D24FS8:         return "D3DFMT_D24FS8";
    00088
    00089         case D3DFMT_L16:            return "D3DFMT_L16";
    00090
    00091         case D3DFMT_VERTEXDATA:     return "D3DFMT_VERTEXDATA";
    00092         case D3DFMT_INDEX16:        return "D3DFMT_INDEX16";
    00093         case D3DFMT_INDEX32:        return "D3DFMT_INDEX32";
    00094
    00095         case D3DFMT_Q16W16V16U16:   return "D3DFMT_Q16W16V16U16";
    00096
    00097         case D3DFMT_MULTI2_ARGB8:   return "D3DFMT_MULTI2_ARGB8";
    00098
    00099         case D3DFMT_R16F:           return "D3DFMT_R16F";
    00100         case D3DFMT_G16R16F:        return "D3DFMT_G16R16F";
    00101         case D3DFMT_A16B16G16R16F:  return "D3DFMT_A16B16G16R16F";
    00102
    00103         case D3DFMT_R32F:           return "D3DFMT_R32F";
    00104         case D3DFMT_G32R32F:        return "D3DFMT_G32R32F";
    00105         case D3DFMT_A32B32G32R32F:  return "D3DFMT_A32B32G32R32F";
    00106
    00107         case D3DFMT_CxV8U8:         return "D3DFMT_CxV8U8";
    00108     }
    00109     ErrorOut("GraphicsBufferFormat::getName() Unknown format");
    00110     return "";
    00111 }
    00112 //------------------------------------------------------------------------------
    00113 // カラーチャンネルビット数の取得
    00114 u_int GraphicsBufferFormat::getColorChannelBits(){
    00115     switch(format_){
    00116         case D3DFMT_UNKNOWN:        return 0;
    00117
    00118         case D3DFMT_R8G8B8:         return 8;
    00119         case D3DFMT_A8R8G8B8:       return 8;
    00120         case D3DFMT_X8R8G8B8:       return 8;
    00121         case D3DFMT_R5G6B5:         return 5;
    00122         case D3DFMT_X1R5G5B5:       return 5;
    00123         case D3DFMT_A1R5G5B5:       return 5;
    00124         case D3DFMT_A4R4G4B4:       return 4;
    00125         case D3DFMT_R3G3B2:         return 2;
    00126         case D3DFMT_A8:             return 0;
    00127         case D3DFMT_A8R3G3B2:       return 2;
    00128         case D3DFMT_X4R4G4B4:       return 4;
    00129         case D3DFMT_A2B10G10R10:    return 10;
    00130         case D3DFMT_A8B8G8R8:       return 8;
    00131         case D3DFMT_X8B8G8R8:       return 8;
    00132         case D3DFMT_G16R16:         return 16;
    00133         case D3DFMT_A2R10G10B10:    return 10;
    00134         case D3DFMT_A16B16G16R16:   return 16;
    00135
    00136         case D3DFMT_A8P8:           return 0;
    00137         case D3DFMT_P8:             return 0;
    00138
    00139         case D3DFMT_L8:             return 0;
    00140         case D3DFMT_A8L8:           return 0;
    00141         case D3DFMT_A4L4:           return 0;
    00142
    00143         case D3DFMT_V8U8:           return 0;
    00144         case D3DFMT_L6V5U5:         return 0;
    00145         case D3DFMT_X8L8V8U8:       return 0;
    00146         case D3DFMT_Q8W8V8U8:       return 0;
    00147         case D3DFMT_V16U16:         return 0;
    00148         case D3DFMT_A2W10V10U10:    return 0;
    00149
    00150         case D3DFMT_UYVY:           return 0;
    00151         case D3DFMT_R8G8_B8G8:      return 8;
    00152         case D3DFMT_YUY2:           return 0;
    00153         case D3DFMT_G8R8_G8B8:      return 8;
    00154         case D3DFMT_DXT1:           return 5;
    00155         case D3DFMT_DXT2:           return 5;
    00156         case D3DFMT_DXT3:           return 5;
    00157         case D3DFMT_DXT4:           return 5;
    00158         case D3DFMT_DXT5:           return 5;
    00159
    00160         case D3DFMT_D16_LOCKABLE:   return 0;
    00161         case D3DFMT_D32:            return 0;
    00162         case D3DFMT_D15S1:          return 0;
    00163         case D3DFMT_D24S8:          return 0;
    00164         case D3DFMT_D24X8:          return 0;
    00165         case D3DFMT_D24X4S4:        return 0;
    00166         case D3DFMT_D16:            return 0;
    00167
    00168         case D3DFMT_D32F_LOCKABLE:  return 0;
    00169         case D3DFMT_D24FS8:         return 0;
    00170
    00171         case D3DFMT_L16:            return 0;
    00172
    00173         case D3DFMT_VERTEXDATA:     return 0;
    00174         case D3DFMT_INDEX16:        return 0;
    00175         case D3DFMT_INDEX32:        return 0;
    00176
    00177         case D3DFMT_Q16W16V16U16:   return 0;
    00178
    00179         case D3DFMT_MULTI2_ARGB8:   return 8;
    00180
    00181         case D3DFMT_R16F:           return 16;
    00182         case D3DFMT_G16R16F:        return 16;
    00183         case D3DFMT_A16B16G16R16F:  return 16;
    00184
    00185         case D3DFMT_R32F:           return 32;
    00186         case D3DFMT_G32R32F:        return 32;
    00187         case D3DFMT_A32B32G32R32F:  return 32;
    00188
    00189         case D3DFMT_CxV8U8:         return 0;
    00190     }
    00191     ErrorOut("GraphicsBufferFormat::getColorChannelBits() Unknown format");
    00192     return 0;
    00193 }
    00194 //------------------------------------------------------------------------------
    00195 // アルファチャンネルビット数の取得
    00196 u_int GraphicsBufferFormat::getAlphaChannelBits(){
    00197     switch(format_){
    00198         case D3DFMT_UNKNOWN:        return 0;
    00199
    00200         case D3DFMT_R8G8B8:         return 0;
    00201         case D3DFMT_A8R8G8B8:       return 8;
    00202         case D3DFMT_X8R8G8B8:       return 0;
    00203         case D3DFMT_R5G6B5:         return 0;
    00204         case D3DFMT_X1R5G5B5:       return 0;
    00205         case D3DFMT_A1R5G5B5:       return 1;
    00206         case D3DFMT_A4R4G4B4:       return 4;
    00207         case D3DFMT_R3G3B2:         return 0;
    00208         case D3DFMT_A8:             return 8;
    00209         case D3DFMT_A8R3G3B2:       return 8;
    00210         case D3DFMT_X4R4G4B4:       return 0;
    00211         case D3DFMT_A2B10G10R10:    return 2;
    00212         case D3DFMT_A8B8G8R8:       return 8;
    00213         case D3DFMT_X8B8G8R8:       return 0;
    00214         case D3DFMT_G16R16:         return 0;
    00215         case D3DFMT_A2R10G10B10:    return 2;
    00216         case D3DFMT_A16B16G16R16:   return 16;
    00217
    00218         case D3DFMT_A8P8:           return 8;
    00219         case D3DFMT_P8:             return 0;
    00220
    00221         case D3DFMT_L8:             return 0;
    00222         case D3DFMT_A8L8:           return 8;
    00223         case D3DFMT_A4L4:           return 4;
    00224
    00225         case D3DFMT_V8U8:           return 0;
    00226         case D3DFMT_L6V5U5:         return 0;
    00227         case D3DFMT_X8L8V8U8:       return 0;
    00228         case D3DFMT_Q8W8V8U8:       return 0;
    00229         case D3DFMT_V16U16:         return 0;
    00230         case D3DFMT_A2W10V10U10:    return 2;
    00231
    00232         case D3DFMT_UYVY:           return 0;
    00233         case D3DFMT_R8G8_B8G8:      return 0;
    00234         case D3DFMT_YUY2:           return 0;
    00235         case D3DFMT_G8R8_G8B8:      return 0;
    00236         case D3DFMT_DXT1:           return 1;
    00237         case D3DFMT_DXT2:           return 4;
    00238         case D3DFMT_DXT3:           return 4;
    00239         case D3DFMT_DXT4:           return 8;
    00240         case D3DFMT_DXT5:           return 8;
    00241
    00242         case D3DFMT_D16_LOCKABLE:   return 0;
    00243         case D3DFMT_D32:            return 0;
    00244         case D3DFMT_D15S1:          return 0;
    00245         case D3DFMT_D24S8:          return 0;
    00246         case D3DFMT_D24X8:          return 0;
    00247         case D3DFMT_D24X4S4:        return 0;
    00248         case D3DFMT_D16:            return 0;
    00249
    00250         case D3DFMT_D32F_LOCKABLE:  return 0;
    00251         case D3DFMT_D24FS8:         return 0;
    00252
    00253         case D3DFMT_L16:            return 0;
    00254
    00255         case D3DFMT_VERTEXDATA:     return 0;
    00256         case D3DFMT_INDEX16:        return 0;
    00257         case D3DFMT_INDEX32:        return 0;
    00258
    00259         case D3DFMT_Q16W16V16U16:   return 0;
    00260
    00261         case D3DFMT_MULTI2_ARGB8:   return 8;
    00262
    00263         case D3DFMT_R16F:           return 0;
    00264         case D3DFMT_G16R16F:        return 0;
    00265         case D3DFMT_A16B16G16R16F:  return 16;
    00266
    00267         case D3DFMT_R32F:           return 0;
    00268         case D3DFMT_G32R32F:        return 0;
    00269         case D3DFMT_A32B32G32R32F:  return 32;
    00270
    00271         case D3DFMT_CxV8U8:         return 0;
    00272     }
    00273     ErrorOut("GraphicsBufferFormat::getAlphaChannelBits() Unknown format");
    00274     return 0;
    00275 }
    00276 //------------------------------------------------------------------------------
    00277 // 深度ビット数の取得
    00278 u_int GraphicsBufferFormat::getDepthBits(){
    00279     switch(format_){
    00280         case D3DFMT_UNKNOWN:        return 0;
    00281
    00282         case D3DFMT_R8G8B8:         return 0;
    00283         case D3DFMT_A8R8G8B8:       return 0;
    00284         case D3DFMT_X8R8G8B8:       return 0;
    00285         case D3DFMT_R5G6B5:         return 0;
    00286         case D3DFMT_X1R5G5B5:       return 0;
    00287         case D3DFMT_A1R5G5B5:       return 0;
    00288         case D3DFMT_A4R4G4B4:       return 0;
    00289         case D3DFMT_R3G3B2:         return 0;
    00290         case D3DFMT_A8:             return 0;
    00291         case D3DFMT_A8R3G3B2:       return 0;
    00292         case D3DFMT_X4R4G4B4:       return 0;
    00293         case D3DFMT_A2B10G10R10:    return 0;
    00294         case D3DFMT_A8B8G8R8:       return 0;
    00295         case D3DFMT_X8B8G8R8:       return 0;
    00296         case D3DFMT_G16R16:         return 0;
    00297         case D3DFMT_A2R10G10B10:    return 0;
    00298         case D3DFMT_A16B16G16R16:   return 0;
    00299
    00300         case D3DFMT_A8P8:           return 0;
    00301         case D3DFMT_P8:             return 0;
    00302
    00303         case D3DFMT_L8:             return 0;
    00304         case D3DFMT_A8L8:           return 0;
    00305         case D3DFMT_A4L4:           return 0;
    00306
    00307         case D3DFMT_V8U8:           return 0;
    00308         case D3DFMT_L6V5U5:         return 0;
    00309         case D3DFMT_X8L8V8U8:       return 0;
    00310         case D3DFMT_Q8W8V8U8:       return 0;
    00311         case D3DFMT_V16U16:         return 0;
    00312         case D3DFMT_A2W10V10U10:    return 0;
    00313
    00314         case D3DFMT_UYVY:           return 0;
    00315         case D3DFMT_R8G8_B8G8:      return 0;
    00316         case D3DFMT_YUY2:           return 0;
    00317         case D3DFMT_G8R8_G8B8:      return 0;
    00318         case D3DFMT_DXT1:           return 0;
    00319         case D3DFMT_DXT2:           return 0;
    00320         case D3DFMT_DXT3:           return 0;
    00321         case D3DFMT_DXT4:           return 0;
    00322         case D3DFMT_DXT5:           return 0;
    00323
    00324         case D3DFMT_D16_LOCKABLE:   return 16;
    00325         case D3DFMT_D32:            return 32;
    00326         case D3DFMT_D15S1:          return 15;
    00327         case D3DFMT_D24S8:          return 24;
    00328         case D3DFMT_D24X8:          return 24;
    00329         case D3DFMT_D24X4S4:        return 24;
    00330         case D3DFMT_D16:            return 16;
    00331
    00332         case D3DFMT_D32F_LOCKABLE:  return 0;
    00333         case D3DFMT_D24FS8:         return 0;
    00334
    00335         case D3DFMT_L16:            return 0;
    00336
    00337         case D3DFMT_VERTEXDATA:     return 0;
    00338         case D3DFMT_INDEX16:        return 0;
    00339         case D3DFMT_INDEX32:        return 0;
    00340
    00341         case D3DFMT_Q16W16V16U16:   return 0;
    00342
    00343         case D3DFMT_MULTI2_ARGB8:   return 0;
    00344
    00345         case D3DFMT_R16F:           return 0;
    00346         case D3DFMT_G16R16F:        return 0;
    00347         case D3DFMT_A16B16G16R16F:  return 0;
    00348
    00349         case D3DFMT_R32F:           return 0;
    00350         case D3DFMT_G32R32F:        return 0;
    00351         case D3DFMT_A32B32G32R32F:  return 0;
    00352
    00353         case D3DFMT_CxV8U8:         return 0;
    00354     }
    00355     ErrorOut("GraphicsBufferFormat::getDepthBits() Unknown format");
    00356     return 0;
    00357 }
    00358 //------------------------------------------------------------------------------
    00359 // ステンシルビット数の取得
    00360 u_int GraphicsBufferFormat::getStencilBits(){
    00361     switch(format_){
    00362         case D3DFMT_UNKNOWN:        return 0;
    00363
    00364         case D3DFMT_R8G8B8:         return 0;
    00365         case D3DFMT_A8R8G8B8:       return 0;
    00366         case D3DFMT_X8R8G8B8:       return 0;
    00367         case D3DFMT_R5G6B5:         return 0;
    00368         case D3DFMT_X1R5G5B5:       return 0;
    00369         case D3DFMT_A1R5G5B5:       return 0;
    00370         case D3DFMT_A4R4G4B4:       return 0;
    00371         case D3DFMT_R3G3B2:         return 0;
    00372         case D3DFMT_A8:             return 0;
    00373         case D3DFMT_A8R3G3B2:       return 0;
    00374         case D3DFMT_X4R4G4B4:       return 0;
    00375         case D3DFMT_A2B10G10R10:    return 0;
    00376         case D3DFMT_A8B8G8R8:       return 0;
    00377         case D3DFMT_X8B8G8R8:       return 0;
    00378         case D3DFMT_G16R16:         return 0;
    00379         case D3DFMT_A2R10G10B10:    return 0;
    00380         case D3DFMT_A16B16G16R16:   return 0;
    00381
    00382         case D3DFMT_A8P8:           return 0;
    00383         case D3DFMT_P8:             return 0;
    00384
    00385         case D3DFMT_L8:             return 0;
    00386         case D3DFMT_A8L8:           return 0;
    00387         case D3DFMT_A4L4:           return 0;
    00388
    00389         case D3DFMT_V8U8:           return 0;
    00390         case D3DFMT_L6V5U5:         return 0;
    00391         case D3DFMT_X8L8V8U8:       return 0;
    00392         case D3DFMT_Q8W8V8U8:       return 0;
    00393         case D3DFMT_V16U16:         return 0;
    00394         case D3DFMT_A2W10V10U10:    return 0;
    00395
    00396         case D3DFMT_UYVY:           return 0;
    00397         case D3DFMT_R8G8_B8G8:      return 0;
    00398         case D3DFMT_YUY2:           return 0;
    00399         case D3DFMT_G8R8_G8B8:      return 0;
    00400         case D3DFMT_DXT1:           return 0;
    00401         case D3DFMT_DXT2:           return 0;
    00402         case D3DFMT_DXT3:           return 0;
    00403         case D3DFMT_DXT4:           return 0;
    00404         case D3DFMT_DXT5:           return 0;
    00405
    00406         case D3DFMT_D16_LOCKABLE:   return 0;
    00407         case D3DFMT_D32:            return 0;
    00408         case D3DFMT_D15S1:          return 1;
    00409         case D3DFMT_D24S8:          return 8;
    00410         case D3DFMT_D24X8:          return 0;
    00411         case D3DFMT_D24X4S4:        return 4;
    00412         case D3DFMT_D16:            return 0;
    00413
    00414         case D3DFMT_D32F_LOCKABLE:  return 0;
    00415         case D3DFMT_D24FS8:         return 0;
    00416
    00417         case D3DFMT_L16:            return 0;
    00418
    00419         case D3DFMT_VERTEXDATA:     return 0;
    00420         case D3DFMT_INDEX16:        return 0;
    00421         case D3DFMT_INDEX32:        return 0;
    00422
    00423         case D3DFMT_Q16W16V16U16:   return 0;
    00424
    00425         case D3DFMT_MULTI2_ARGB8:   return 0;
    00426
    00427         case D3DFMT_R16F:           return 0;
    00428         case D3DFMT_G16R16F:        return 0;
    00429         case D3DFMT_A16B16G16R16F:  return 0;
    00430
    00431         case D3DFMT_R32F:           return 0;
    00432         case D3DFMT_G32R32F:        return 0;
    00433         case D3DFMT_A32B32G32R32F:  return 0;
    00434
    00435         case D3DFMT_CxV8U8:         return 0;
    00436     }
    00437     ErrorOut("GraphicsBufferFormat::getStencilBits() Unknown format");
    00438     return 0;
    00439 }
    00440 //------------------------------------------------------------------------------
    00441 } // End of namespace Lamp
    00442 //------------------------------------------------------------------------------