diff options
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/.cvsignore | 3 | ||||
-rw-r--r-- | opengl/GNUmakefile | 13 | ||||
-rw-r--r-- | opengl/config.cpp | 94 | ||||
-rw-r--r-- | opengl/config.h | 63 | ||||
-rw-r--r-- | opengl/dialog.h | 1 | ||||
-rw-r--r-- | opengl/dialog.rc | 2 | ||||
-rw-r--r-- | opengl/generate.cpp | 380 | ||||
-rw-r--r-- | opengl/generate.h | 12 | ||||
-rw-r--r-- | opengl/gldialog.cpp | 41 | ||||
-rw-r--r-- | opengl/gldialog.h | 3 | ||||
-rw-r--r-- | opengl/main.cpp | 8 |
11 files changed, 527 insertions, 93 deletions
diff --git a/opengl/.cvsignore b/opengl/.cvsignore index 1efcba0..1f10a8d 100644 --- a/opengl/.cvsignore +++ b/opengl/.cvsignore @@ -1,2 +1,3 @@ msGLExport.dll
-dialog.RES
\ No newline at end of file +dialog.RES
+depend.mak
\ No newline at end of file diff --git a/opengl/GNUmakefile b/opengl/GNUmakefile index 0259322..bedb0b9 100644 --- a/opengl/GNUmakefile +++ b/opengl/GNUmakefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: GNUmakefile,v 1.1 2005-04-15 00:53:56 ianc Exp $ +# $Id: GNUmakefile,v 1.2 2005-04-17 01:53:15 ianc Exp $ # include ../make.conf @@ -28,11 +28,13 @@ RES = dialog SOURCES = main.cpp \ gldialog.cpp \ - generate.cpp + generate.cpp \ + config.cpp HEADERS = $(RES).h \ gldialog.h \ - generate.h + generate.h \ + config.h OBJECTS = $(SOURCES:.cpp=.o) $(RES).o @@ -45,7 +47,8 @@ WRAPPER = ../wrapper DLLLIBS = $(WRAPPER)/mingwms.lib $(MILKSHAPE)/lib/msModelLib.lib \ `w32dlib-config --libs` -FLAGS = -I$(WRAPPER) -I$(MILKSHAPE) -Wall `w32dlib-config --cflags` +FLAGS = -I$(WRAPPER) -I$(MILKSHAPE) -Wall `w32dlib-config --cflags` \ + -DREGISTRY_USAGE=$(REGISTRY_USAGE) $(OUTDLL): $(OBJECTS) @@ -67,7 +70,7 @@ $(RES).res: $(RES).rc $(RES).h -include depend.mak clean: - -rm -f $(OUTDLL) $(OUTLIB) $(OBJECTS) $(RES).res depend.mak + -rm -f $(OUTDLL) $(OUTLIB) $(OBJECTS) $(RES).res depend: @echo Dependencies updated.... diff --git a/opengl/config.cpp b/opengl/config.cpp new file mode 100644 index 0000000..0cbb488 --- /dev/null +++ b/opengl/config.cpp @@ -0,0 +1,94 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// $Id$ +// +#include "config.h" +#include <w32dlib/w32dlib.h> + +#define KEY "Software\\Noddybox\\MSPluginState\\SimpleOpenGL" + +bool Config::m_init=false; +std::string Config::m_path; +bool Config::m_useTexture=false; +bool Config::m_useInfo=false; +bool Config::m_forceCOG=false; +bool Config::m_blitzMax=false; + +void Config::Load() +{ + if (!m_init) + { + m_init=true; + + char path[1024]; + + GetCurrentDirectory(sizeof path,path); + + m_path=path; + m_useTexture=false; + m_useInfo=false; + m_forceCOG=false; + m_blitzMax=false; + +#if REGISTRY_USAGE!=0 + + W32DLib::Registry r(HKEY_CURRENT_USER,KEY); + + r.Read("path",m_path); + r.Read("texture",m_useTexture); + r.Read("info",m_useInfo); + r.Read("cog",m_forceCOG); + r.Read("bmx",m_blitzMax); + +#endif + + } +} + +void Config::Save() +{ +#if REGISTRY_USAGE!=0 + + W32DLib::Registry r(HKEY_CURRENT_USER,KEY,REGISTRY_USAGE==2); + + r.Write("path",m_path); + r.Write("texture",m_useTexture); + r.Write("info",m_useInfo); + r.Write("cog",m_forceCOG); + r.Write("bmx",m_blitzMax); + +#endif +} + +std::string Config::Path() {return m_path;} +void Config::Path(const std::string &val) {m_path=val;} + +bool Config::UseTexture() {return m_useTexture;} +void Config::UseTexture(bool flag) {m_useTexture=flag;} + +bool Config::UseInfo() {return m_useInfo;} +void Config::UseInfo(bool flag) {m_useInfo=flag;} + +bool Config::ForceCOG() {return m_forceCOG;} +void Config::ForceCOG(bool flag) {m_forceCOG=flag;} + +bool Config::BlitzMax() {return m_blitzMax;} +void Config::BlitzMax(bool flag) {m_blitzMax=flag;} diff --git a/opengl/config.h b/opengl/config.h new file mode 100644 index 0000000..812b79a --- /dev/null +++ b/opengl/config.h @@ -0,0 +1,63 @@ +// msGLExport - OpenGL exporter for Milkshape +// +// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// $Id$ +// +#ifndef CONFIG_H +#define CONFIG_H + +#include <string> + +class Config +{ +public: + + static void Load(); + + static void Save(); + + static std::string Path(); + static void Path(const std::string &val); + + static bool UseTexture(); + static void UseTexture(bool flag); + + static bool UseInfo(); + static void UseInfo(bool flag); + + static bool ForceCOG(); + static void ForceCOG(bool flag); + + static bool BlitzMax(); + static void BlitzMax(bool flag); + +private: + Config(); + + static bool m_init; + + static std::string m_path; + static bool m_useTexture; + static bool m_useInfo; + static bool m_forceCOG; + static bool m_blitzMax; +}; + +#endif // CONFIG_H diff --git a/opengl/dialog.h b/opengl/dialog.h index 4955fd6..964de0b 100644 --- a/opengl/dialog.h +++ b/opengl/dialog.h @@ -33,3 +33,4 @@ #define IDC_TXT_DIR 3003 #define IDC_CHK_FORCECOG 3011 #define IDC_CHK_BLITZMAX 3012 +#define IDC_LBL_FUNCNAME 3013 diff --git a/opengl/dialog.rc b/opengl/dialog.rc index 68f85e5..9399f20 100644 --- a/opengl/dialog.rc +++ b/opengl/dialog.rc @@ -16,7 +16,7 @@ FONT 8, "MS Sans Serif" CONTROL "", IDC_TXT_INFO, EDIT, ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL, 5, 15, 325, 70 CONTROL "", IDC_TXT_DIR, EDIT, ES_LEFT | ES_AUTOHSCROLL | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER, 65, 90, 170, 12 CONTROL "Directory", -1, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 90, 30, 10 - CONTROL "Function/object", -1, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 110, 55, 10 + CONTROL "FUNC", IDC_LBL_FUNCNAME, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 110, 55, 10 CONTROL "Force COG to 0,0,0", IDC_CHK_FORCECOG, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 165, 135, 75, 10 CONTROL "Generate for Blitz MAX", IDC_CHK_BLITZMAX, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 248, 135, 85, 10 CONTROL "Info:", -1, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 5, 15, 10 diff --git a/opengl/generate.cpp b/opengl/generate.cpp index cdce010..94403c8 100644 --- a/opengl/generate.cpp +++ b/opengl/generate.cpp @@ -36,7 +36,9 @@ Generate::Generate(msModel *model) : m_model(model), m_max_y(FLT_MIN), m_min_y(FLT_MAX), m_max_z(FLT_MIN), - m_min_z(FLT_MAX) + m_min_z(FLT_MAX), + + m_blitzMax(false) { CalcModelBounds(); } @@ -53,10 +55,19 @@ std::string Generate::Info() { std::ostringstream str; - str << "Create files : " << EOL - << "\t" << m_dir << "\\" << m_funcName << ".c" << EOL - << "\t" << m_dir << "\\" << m_funcName << ".h" << EOL << EOL - << "Centre of gravity : " + str << "Create files : " << EOL; + + if (m_blitzMax) + { + str << "\t" << m_dir << "\\" << m_funcName << ".bmx" << EOL << EOL; + } + else + { + str << "\t" << m_dir << "\\" << m_funcName << ".c" << EOL + << "\t" << m_dir << "\\" << m_funcName << ".h" << EOL << EOL; + } + + str << "Centre of gravity : " << (m_cogx-m_appcogx) << "," << (m_cogy-m_appcogy) << "," << (m_cogz-m_appcogz) << EOL @@ -72,6 +83,136 @@ std::string Generate::Info() void Generate::MakeFiles() { + if (m_blitzMax) + { + GenerateBlitzMax(); + } + else + { + GenerateC(); + } +} + + +void Generate::Setup(const std::string& dir, + const std::string& funcname, + bool texture, + bool info, + bool forceCOG, + bool blitzMax) +{ + m_dir=dir; + m_funcName=funcname; + m_useTexture=texture; + m_useInfo=info; + m_forceCOG=forceCOG; + m_blitzMax=blitzMax; + + if (m_forceCOG) + { + m_appcogx=m_cogx; + m_appcogy=m_cogy; + m_appcogz=m_cogz; + } + else + { + m_appcogx=0; + m_appcogy=0; + m_appcogz=0; + } +} + + +std::string Generate::GenerateFuncname() +{ + std::string fn; + char *name; + + msMesh *mesh=msModel_GetMeshAt(m_model,0); + + name=mesh->szName; + + for(int f=0;name[f];f++) + { + if (std::isalpha(name[f]) || (f && name[f]=='_')) + { + fn+=name[f]; + } + } + + if (fn=="") + { + fn="object"; + } + + return fn; +} + + +////////////////////////////////////////////////////////////////////// +// Private members +////////////////////////////////////////////////////////////////////// + +const char *Generate::Space(int len) +{ + static int cyc=0; + static char buff[10][128]; + int f; + + cyc=(cyc+1)%10; + + for(f=0;f<len && f < 126;f++) + { + buff[cyc][f]=' '; + } + + buff[cyc][f]=0; + + return &buff[cyc][0]; +} + + +void Generate::CalcModelBounds() +{ + for(int m=0;m<m_model->nNumMeshes;m++) + { + msMesh *mesh; + + mesh=m_model->pMeshes+m; + + for(int t=0;t<mesh->nNumTriangles;t++) + { + msTriangle *tri; + + tri=mesh->pTriangles+t; + + if (!(tri->nFlags&eHidden)) + { + for(int i=0;i<3;i++) + { + msVertex *v=mesh->pVertices+tri->nVertexIndices[i]; + + m_min_x=std::min(m_min_x,v->Vertex[0]); + m_max_x=std::max(m_max_x,v->Vertex[0]); + + m_min_y=std::min(m_min_y,v->Vertex[1]); + m_max_y=std::max(m_max_y,v->Vertex[1]); + + m_min_z=std::min(m_min_z,v->Vertex[2]); + m_max_z=std::max(m_max_z,v->Vertex[2]); + } + } + } + } + + m_cogx=m_min_x+(m_max_x-m_min_x)/2; + m_cogy=m_min_y+(m_max_y-m_min_y)/2; + m_cogz=m_min_z+(m_max_z-m_min_z)/2; +} + + +void Generate::GenerateC() +{ std::FILE *fp; int len; std::string fname_c; @@ -95,7 +236,7 @@ void Generate::MakeFiles() // if (!(fp=fopen(fname_h.c_str(),"w"))) { - W32DLib::Common::Error(0,"Couldn't create header file"); + W32DLib::Common::Error(0,0,"Couldn't create header file"); return; } @@ -160,7 +301,7 @@ void Generate::MakeFiles() // if (!(fp=fopen(fname_c.c_str(),"w"))) { - W32DLib::Common::Error(0,"Couldn't create source file"); + W32DLib::Common::Error(0,0,"Couldn't create source file"); return; } @@ -272,94 +413,166 @@ void Generate::MakeFiles() missing="The following meshes had no material:\n\n"+missing; missing+="\n\nThey were given the colour white."; - W32DLib::Common::Message(0,missing); + W32DLib::Common::Message(0,0,missing); } } -void Generate::Setup(const std::string& dir, - const std::string& funcname, - bool texture, - bool info, - bool forceCOG) +void Generate::GenerateBlitzMax() { - m_dir=dir; - m_funcName=funcname; - m_useTexture=texture; - m_useInfo=info; - m_forceCOG=forceCOG; + std::FILE *fp; + int len; + std::string fname_c; + std::string fname_h; + std::string def; + std::string missing; - if (m_forceCOG) + len=m_funcName.length()+6; + + fname_c=m_dir+"\\"+m_funcName; + fname_h=fname_c+".h"; + fname_c+=".c"; + + for(std::string::const_iterator i=m_funcName.begin(); + i!=m_funcName.end();++i) { - m_appcogx=m_cogx; - m_appcogy=m_cogy; - m_appcogz=m_cogz; + def+=std::toupper(*i); } - else + + // Generate header + // + if (!(fp=fopen(fname_h.c_str(),"w"))) { - m_appcogx=0; - m_appcogy=0; - m_appcogz=0; + W32DLib::Common::Error(0,0,"Couldn't create header file"); + return; } -} + std::fprintf(fp,"%s","/* Code generated with Milkshape " + "Export OpenGL plugin\n*/\n"); + std::fprintf(fp,"\n"); -std::string Generate::GenerateFuncname() -{ - std::string fn; - char *name; + std::fprintf(fp,"#ifndef %s_H\n#define %s_H\n\n", + def.c_str(),def.c_str()); - msMesh *mesh=msModel_GetMeshAt(m_model,0); + std::fprintf(fp,"%s","#ifdef _cplusplus\nextern \"C\" {\n#endif\n\n"); - name=mesh->szName; - for(int f=0;name[f];f++) + std::fprintf(fp,"void %s(GLfloat x, GLfloat y, GLfloat z,\n", + m_funcName.c_str()); + std::fprintf(fp,"%sGLfloat rot_x, GLfloat rot_y, GLfloat rot_z", + Space(len)); + + if (m_useTexture) { - if (std::isalpha(name[f]) || (f && name[f]=='_')) - { - fn+=name[f]; - } + std::fprintf(fp,",\n%sGLint tid);\n\n", Space(len)); + } + else + { + std::fprintf(fp,");\n\n"); } - if (fn=="") + if (m_useInfo) { - fn="object"; + std::fprintf(fp,"#define %s_COG_X %f\n",def.c_str(),m_cogx-m_appcogx); + std::fprintf(fp,"#define %s_COG_Y %f\n",def.c_str(),m_cogy-m_appcogy); + std::fprintf(fp,"#define %s_COG_Z %f\n\n",def.c_str(),m_cogz-m_appcogz); + + std::fprintf(fp,"#define %s_MIN_X %f\n",def.c_str(),m_min_x-m_appcogx); + std::fprintf(fp,"#define %s_MAX_X %f\n",def.c_str(),m_max_x-m_appcogx); + std::fprintf(fp,"#define %s_MIN_Y %f\n",def.c_str(),m_min_y-m_appcogy); + std::fprintf(fp,"#define %s_MAX_Y %f\n",def.c_str(),m_max_y-m_appcogy); + std::fprintf(fp,"#define %s_MIN_Z %f\n",def.c_str(),m_min_z-m_appcogz); + std::fprintf(fp,"#define %s_MAX_Z %f\n\n",def.c_str(), + m_max_z-m_appcogz); + + float sx=m_max_x-m_min_x; + float sy=m_max_y-m_min_y; + float sz=m_max_z-m_min_z; + + std::fprintf(fp,"#define %s_SIZE_X %f\n",def.c_str(),sx); + std::fprintf(fp,"#define %s_SIZE_Y %f\n",def.c_str(),sy); + std::fprintf(fp,"#define %s_SIZE_Z %f\n\n",def.c_str(),sz); } - return fn; -} + std::fprintf(fp,"#define %s_TEXTURED %d\n\n",def.c_str(),m_useTexture?1:0); + std::fprintf(fp,"%s","#ifdef _cplusplus\n}\n#endif\n\n"); -////////////////////////////////////////////////////////////////////// -// Private members -////////////////////////////////////////////////////////////////////// + std::fprintf(fp,"#endif /* %s_H */\n\n",def.c_str()); -const char *Generate::Space(int len) -{ - static int cyc=0; - static char buff[10][128]; - int f; + std::fprintf(fp,"%s","/* END OF FILE */\n"); - cyc=(cyc+1)%10; + std::fclose(fp); - for(f=0;f<len && f < 126;f++) + // Generate C source + // + if (!(fp=fopen(fname_c.c_str(),"w"))) { - buff[cyc][f]=' '; + W32DLib::Common::Error(0,0,"Couldn't create source file"); + return; } - buff[cyc][f]=0; + std::fprintf(fp,"%s","/* Code generated with Milkshape " + "Export OpenGL plugin\n*/\n"); - return &buff[cyc][0]; -} + std::fprintf(fp,"%s","#include <GL/gl.h>\n\n"); + std::fprintf(fp,"void %s(GLfloat x, GLfloat y, GLfloat z,\n", + m_funcName.c_str()); + std::fprintf(fp,"%sGLfloat rot_x, GLfloat rot_y, GLfloat rot_z", + Space(len)); + + if (m_useTexture) + { + std::fprintf(fp,",\n%sGLint tid)\n", Space(len)); + } + else + { + std::fprintf(fp,")\n"); + } + + std::fprintf(fp,"{\n"); + + std::fprintf(fp,INDENT "glPushMatrix();\n"); + std::fprintf(fp,INDENT "glLoadIdentity();\n"); + std::fprintf(fp,INDENT "glTranslatef(x,y,z);\n"); + std::fprintf(fp,INDENT "glRotatef(rot_x,1.0f,0.0f,0.0f);\n"), + std::fprintf(fp,INDENT "glRotatef(rot_y,0.0f,1.0f,0.0f);\n"), + std::fprintf(fp,INDENT "glRotatef(rot_z,0.0f,0.0f,1.0f);\n"), + std::fprintf(fp,"\n"); + + std::fprintf(fp,INDENT "glBegin(GL_TRIANGLES);\n"); + + if (m_useTexture) + { + std::fprintf(fp,INDENT "glBindTexture(GL_TEXTURE_2D,tid);\n"); + } + + std::fprintf(fp,"\n"); -void Generate::CalcModelBounds() -{ for(int m=0;m<m_model->nNumMeshes;m++) { - msMesh *mesh; + msMesh *mesh=m_model->pMeshes+m; - mesh=m_model->pMeshes+m; + std::fprintf(fp,INDENT "/* Mesh %d - %s\n",m+1,mesh->szName); + std::fprintf(fp,INDENT "*/\n"); + + if (mesh->nMaterialIndex<0) + { + missing+=mesh->szName; + missing+="\n"; + + std::fprintf(fp,INDENT "glColor3f(1.0f,1.0f,1.0f);\n"); + } + else + { + msMaterial *mat=m_model->pMaterials+mesh->nMaterialIndex; + + std::fprintf(fp,INDENT "glColor3f(%f,%f,%f);\n", + mat->Diffuse[0], + mat->Diffuse[1], + mat->Diffuse[2]); + } for(int t=0;t<mesh->nNumTriangles;t++) { @@ -369,24 +582,47 @@ void Generate::CalcModelBounds() if (!(tri->nFlags&eHidden)) { + // To allow vertex order to be tweaked... + // + static int order[3]={0,1,2}; + for(int i=0;i<3;i++) { - msVertex *v=mesh->pVertices+tri->nVertexIndices[i]; - - m_min_x=std::min(m_min_x,v->Vertex[0]); - m_max_x=std::max(m_max_x,v->Vertex[0]); + msVertex *v=mesh->pVertices+tri->nVertexIndices[order[i]]; - m_min_y=std::min(m_min_y,v->Vertex[1]); - m_max_y=std::max(m_max_y,v->Vertex[1]); + std::fprintf(fp,INDENT "glVertex3f(%f,%f,%f);\n", + v->Vertex[0]-m_appcogx, + v->Vertex[1]-m_appcogy, + v->Vertex[2]-m_appcogz); - m_min_z=std::min(m_min_z,v->Vertex[2]); - m_max_z=std::max(m_max_z,v->Vertex[2]); + if (m_useTexture) + { + std::fprintf(fp,INDENT "glTexCoord2f(%f,%f);\n", + v->u, + v->v); + } } } } - } - m_cogx=m_min_x+(m_max_x-m_min_x)/2; - m_cogy=m_min_y+(m_max_y-m_min_y)/2; - m_cogz=m_min_z+(m_max_z-m_min_z)/2; + std::fprintf(fp,"\n"); + } + + std::fprintf(fp,INDENT "glEnd();\n"); + std::fprintf(fp,INDENT "glPopMatrix();\n"); + + std::fprintf(fp,"}\n"); + + std::fclose(fp); + + if (missing.length()>0) + { + missing="The following meshes had no material:\n\n"+missing; + missing+="\n\nThey were given the colour white."; + + W32DLib::Common::Message(0,0,missing); + } } + + +// END OF FILE diff --git a/opengl/generate.h b/opengl/generate.h index 2aa1ec1..f7f07df 100644 --- a/opengl/generate.h +++ b/opengl/generate.h @@ -30,15 +30,20 @@ class Generate { public: Generate(msModel *model); + virtual ~Generate(); std::string GenerateFuncname(); + void Setup(const std::string& dir, const std::string& funcname, bool texture, bool info, - bool forceCOG); + bool forceCOG, + bool blitzMax); + void MakeFiles(); + std::string Info(); private: @@ -64,9 +69,14 @@ private: float m_max_z; float m_min_z; + bool m_blitzMax; + const char *Space(int len); void CalcModelBounds(); + + void GenerateC(); + void GenerateBlitzMax(); }; #endif // GENERATE_H diff --git a/opengl/gldialog.cpp b/opengl/gldialog.cpp index c279944..ae3ef45 100644 --- a/opengl/gldialog.cpp +++ b/opengl/gldialog.cpp @@ -22,6 +22,7 @@ static const char rcs_id[]="$Id$"; #include "gldialog.h" #include "dialog.h" +#include "config.h" ///////////////////////////////////////////////////////////////////////////// @@ -40,12 +41,11 @@ GLDialog::GLDialog(Generate& gen) , m_dir(this,IDC_TXT_DIR,0) , m_forceCOG(this,IDC_CHK_FORCECOG,0) , m_blitzMax(this,IDC_CHK_BLITZMAX,0) + , m_funcLabel(this,IDC_LBL_FUNCNAME,0) { - char path[1024]; + Config::Load(); - GetCurrentDirectory(sizeof path,path); - - m_fname=path; + m_path=Config::Path(); m_dirButton.OnPress (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnSelect)); @@ -84,9 +84,15 @@ int GLDialog::ResourceID() void GLDialog::OnInit() { - m_dir.SetText(m_fname); + m_dir.SetText(m_path); m_funcName.SetText(m_gen.GenerateFuncname()); m_genButton.Enable(true); + + m_useInfo.SetState(Config::UseInfo()); + m_useTexture.SetState(Config::UseTexture()); + m_forceCOG.SetState(Config::ForceCOG()); + m_blitzMax.SetState(Config::BlitzMax()); + Preview(); } @@ -97,6 +103,13 @@ void GLDialog::OnInit() BOOL GLDialog::OnGenerate(UINT msg, WPARAM wp, LPARAM lp) { + Config::Path(m_path); + Config::UseInfo(m_useInfo.GetState()); + Config::UseTexture(m_useTexture.GetState()); + Config::ForceCOG(m_forceCOG.GetState()); + Config::BlitzMax(m_blitzMax.GetState()); + Config::Save(); + Close(IDOK); return TRUE; } @@ -104,7 +117,7 @@ BOOL GLDialog::OnGenerate(UINT msg, WPARAM wp, LPARAM lp) BOOL GLDialog::OnSelect(UINT msg, WPARAM wp, LPARAM lp) { - if (W32DLib::Common::SelectDir(m_wnd,"Select Directory",m_fname)) + if (W32DLib::Common::SelectDir(m_wnd,"Select Directory",m_path)) { OnChange(msg,wp,lp); } @@ -132,11 +145,23 @@ BOOL GLDialog::OnChange(UINT msg, WPARAM wp, LPARAM lp) void GLDialog::Preview() { - m_gen.Setup(m_fname, + m_dir.SetText(m_path); + + m_gen.Setup(m_path, m_funcName.GetText(), m_useTexture.GetState(), m_useInfo.GetState(), - m_forceCOG.GetState()); + m_forceCOG.GetState(), + m_blitzMax.GetState()); + + if (m_blitzMax.GetState()) + { + m_funcLabel.SetText("Class name:"); + } + else + { + m_funcLabel.SetText("Function name:"); + } m_info.SetText(m_gen.Info()); } diff --git a/opengl/gldialog.h b/opengl/gldialog.h index 675454d..aa5d6e7 100644 --- a/opengl/gldialog.h +++ b/opengl/gldialog.h @@ -49,8 +49,9 @@ private: W32DLib::Text m_dir; W32DLib::AutoCheck m_forceCOG; W32DLib::AutoCheck m_blitzMax; + W32DLib::StaticText m_funcLabel; - std::string m_fname; + std::string m_path; BOOL OnGenerate(UINT msg, WPARAM wp, LPARAM lp); BOOL OnSelect(UINT msg, WPARAM wp, LPARAM lp); diff --git a/opengl/main.cpp b/opengl/main.cpp index 19ca5a9..82bf991 100644 --- a/opengl/main.cpp +++ b/opengl/main.cpp @@ -28,7 +28,6 @@ static const char rcs_id[]="$Id$"; #include "gldialog.h" - // ---------------------------------------------------------------------- // MINGW WRAPPER FUNCTIONS // @@ -39,6 +38,9 @@ static const char* GetTitle() static int Execute(msModel* model) { + W32DLib::Common::Initialise(); + W32DLib::Common::MessageTitle("Simple OpenGL"); + if (!model) { return -1; @@ -46,12 +48,10 @@ static int Execute(msModel* model) if (msModel_GetMeshCount(model)<1) { - W32DLib::Common::Error(NULL,"No meshes in the model!"); + W32DLib::Common::Error(NULL,NULL,"No meshes in the model!"); return 0; } - W32DLib::Common::Initialise(); - Generate gen(model); GLDialog dlg(gen); |