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

MayaErrorOutput.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  * Mayaエラー出力実装
00022  * @author Junpee
00023  */
00024 
00025 #include "System/stdafx.h"
00026 #include "System/MayaErrorOutput.h"
00027 #include "Core/System/StringMethod.h"
00028 
00029 namespace LampForMaya{
00030 
00031 //------------------------------------------------------------------------------
00032 // 初期化
00033 void MayaErrorOutput::initialize(){
00034     // エラーハンドラ変更
00035     ErrorOutput::setErrorHandler(MayaErrorOutput::errorHandler);
00036 }
00037 //------------------------------------------------------------------------------
00038 // メッセージ出力
00039 void MayaErrorOutput::mayaMessageOutput(const char* message){
00040     MString messageString(message);
00041     MGlobal::displayInfo(messageString);
00042     StdOutputDebugString(messageString.asChar());
00043 }
00044 //------------------------------------------------------------------------------
00045 // メッセージ出力
00046 void MayaErrorOutput::mayaMessageOutput(const String& message){
00047     MString messageString(message.getBytes());
00048     MGlobal::displayInfo(messageString);
00049     StdOutputDebugString(messageString.asChar());
00050 }
00051 //------------------------------------------------------------------------------
00052 // メッセージ出力
00053 void MayaErrorOutput::mayaMessageOutput(const MString& message){
00054     MGlobal::displayInfo(message);
00055     StdOutputDebugString(message.asChar());
00056 }
00057 //------------------------------------------------------------------------------
00058 // エラー出力
00059 void MayaErrorOutput::mayaErrorOutput(
00060     const char* message, const char* fileName, int lineNumber){
00061     String errorString;
00062     errorString.format("%s\n%s %d\n", message, fileName, lineNumber);
00063     ErrorOut(errorString);
00064 }
00065 //------------------------------------------------------------------------------
00066 // エラー出力
00067 void MayaErrorOutput::mayaErrorOutput(
00068     const String& message, const char* fileName, int lineNumber){
00069     String errorString;
00070     errorString.format("%s\n%s %d\n",
00071         message.getBytes(), fileName, lineNumber);
00072     ErrorOut(errorString);
00073 }
00074 //------------------------------------------------------------------------------
00075 // エラー出力
00076 void MayaErrorOutput::mayaErrorOutput(
00077     const MString& message, const char* fileName, int lineNumber){
00078     String errorString;
00079     errorString.format("%s\n%s %d\n",
00080         message.asChar(), fileName, lineNumber);
00081     ErrorOut(errorString);
00082 }
00083 //------------------------------------------------------------------------------
00084 // エラーチェック
00085 bool MayaErrorOutput::mayaErrorCheck(
00086     const MStatus& status, const char* fileName, int lineNumber){
00087     if(!status){
00088         String errorString;
00089         errorString.format("%s\n%s %d\n",
00090             status.errorString().asChar(), fileName, lineNumber);
00091         ErrorOut(errorString);
00092         return false;
00093     }
00094     return true;
00095 }
00096 //------------------------------------------------------------------------------
00097 // OpenGLエラーチェック
00098 bool MayaErrorOutput::mayaOpenGLErrorCheck(
00099     const char* fileName, int lineNumber){
00100     GLenum mayaOpenGLErrorCode = glGetError();
00101     if(mayaOpenGLErrorCode != GL_NO_ERROR){
00102         String errorString;
00103         errorString.format("%s\n%s %d\n",
00104             (const char*)gluErrorString(mayaOpenGLErrorCode),
00105             fileName, lineNumber);
00106         ErrorOut(errorString);
00107         return false;
00108     }
00109     return true;
00110 }
00111 //------------------------------------------------------------------------------
00112 // Maya用エラーハンドラ
00113 void MayaErrorOutput::errorHandler(const char* message){
00114     MString errorString(message);
00115     MGlobal::displayError(errorString);
00116     StdOutputDebugString(errorString.asChar());
00117 #ifdef _DEBUG
00118     // Maya単体で起動している場合にブレークすると、Mayaが強制終了します。
00119     _asm{ int 3 }
00120 #endif
00121 }
00122 //------------------------------------------------------------------------------
00123 } // End of namespace LampForMaya
00124 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:55 2005 for LampForMaya by doxygen 1.3.2