-/*\r
-BobToolz plugin for GtkRadiant\r
-Copyright (C) 2001 Gordon Biggans\r
-\r
-This library is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU Lesser General Public\r
-License as published by the Free Software Foundation; either\r
-version 2.1 of the License, or (at your option) any later version.\r
-\r
-This library is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
-Lesser General Public License for more details.\r
-\r
-You should have received a copy of the GNU Lesser General Public\r
-License along with this library; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
-*/\r
-\r
-// BobView.cpp: implementation of the DVisDrawer class.\r
-//\r
-//////////////////////////////////////////////////////////////////////\r
-\r
-#include "StdAfx.h"\r
-#include "DPoint.h"\r
-#include "DVisDrawer.h"\r
-#include "misc.h"\r
-#include "funchandlers.h"\r
-\r
-//////////////////////////////////////////////////////////////////////\r
-// Construction/Destruction\r
-//////////////////////////////////////////////////////////////////////\r
-\r
-DVisDrawer::DVisDrawer()\r
-{\r
- refCount = 1;\r
- m_bHooked = FALSE;\r
- m_list = NULL;\r
-}\r
-\r
-DVisDrawer::~DVisDrawer()\r
-{\r
- if(m_bHooked)\r
- UnRegister();\r
-\r
- g_VisView = NULL;\r
-}\r
-\r
-//////////////////////////////////////////////////////////////////////\r
-// Implementation\r
-//////////////////////////////////////////////////////////////////////\r
-\r
-void DVisDrawer::Draw2D(VIEWTYPE vt)\r
-{\r
- if(!m_list)\r
- return;\r
-\r
- g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);\r
-\r
- g_QglTable.m_pfn_qglDisable(GL_BLEND);\r
- g_QglTable.m_pfn_qglDisable(GL_LINE_SMOOTH);\r
-\r
- g_QglTable.m_pfn_qglPushMatrix();\r
- \r
- switch(vt)\r
- {\r
- case XY:\r
- break;\r
- case XZ:\r
- g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);\r
- break;\r
- case YZ:\r
- g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);\r
- g_QglTable.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);\r
- break;\r
- }\r
-\r
- g_QglTable.m_pfn_qglLineWidth(1.0f);\r
- g_QglTable.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 0.5f);\r
-\r
- g_QglTable.m_pfn_qglEnable(GL_BLEND);\r
- g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r
- g_QglTable.m_pfn_qglDisable(GL_POLYGON_SMOOTH);\r
-\r
- g_QglTable.m_pfn_qglDepthFunc(GL_ALWAYS);\r
-\r
- //bleh\r
- list<DWinding *>::const_iterator l=m_list->begin();\r
-\r
- for(; l != m_list->end(); l++)\r
- {\r
- DWinding* w = *l;\r
-\r
- g_QglTable.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);\r
-\r
- g_QglTable.m_pfn_qglBegin(GL_POLYGON);\r
- for(int i = 0; i < w->numpoints; i++) {\r
- g_QglTable.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);\r
- }\r
- g_QglTable.m_pfn_qglEnd();\r
- }\r
-\r
- \r
- g_QglTable.m_pfn_qglPopMatrix();\r
-\r
- g_QglTable.m_pfn_qglPopAttrib();\r
-}\r
-\r
-void DVisDrawer::Draw3D()\r
-{\r
- if(!m_list)\r
- return;\r
-\r
- g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);\r
-\r
- g_QglTable.m_pfn_qglColor4f(1.0, 0.0, 0.0, 0.5f);\r
-\r
-// g_QglTable.m_pfn_qglHint(GL_FOG_HINT, GL_NICEST);\r
- \r
-// g_QglTable.m_pfn_qglDisable(GL_CULL_FACE);\r
- g_QglTable.m_pfn_qglDisable(GL_LINE_SMOOTH);\r
-\r
-// g_QglTable.m_pfn_qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);\r
-// g_QglTable.m_pfn_qglShadeModel(GL_SMOOTH);\r
-\r
- g_QglTable.m_pfn_qglEnable(GL_BLEND);\r
- g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r
- g_QglTable.m_pfn_qglDisable(GL_POLYGON_SMOOTH);\r
-\r
- g_QglTable.m_pfn_qglDepthFunc(GL_ALWAYS);\r
-\r
- //bleh\r
- list<DWinding *>::const_iterator l=m_list->begin();\r
-\r
- for(; l != m_list->end(); l++)\r
- {\r
- DWinding* w = *l;\r
-\r
- g_QglTable.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);\r
-\r
- g_QglTable.m_pfn_qglBegin(GL_POLYGON);\r
- for(int i = 0; i < w->numpoints; i++) {\r
- g_QglTable.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);\r
- }\r
- g_QglTable.m_pfn_qglEnd();\r
- }\r
-\r
- g_QglTable.m_pfn_qglPopAttrib();\r
-}\r
-\r
-void DVisDrawer::Register()\r
-{\r
- g_QglTable.m_pfnHookGL2DWindow( this );\r
- g_QglTable.m_pfnHookGL3DWindow( this );\r
- m_bHooked = TRUE;\r
-}\r
-\r
-void DVisDrawer::UnRegister()\r
-{\r
- g_QglTable.m_pfnUnHookGL2DWindow( this );\r
- g_QglTable.m_pfnUnHookGL3DWindow( this );\r
- m_bHooked = FALSE;\r
-}\r
-\r
-void DVisDrawer::SetList(std::list<DWinding*> *pointList)\r
-{\r
- if(m_list)\r
- ClearPoints();\r
-\r
- m_list = pointList;\r
-}\r
-\r
-void DVisDrawer::ClearPoints()\r
-{\r
- list<DWinding *>::const_iterator deadPoint=m_list->begin();\r
- for(; deadPoint!=m_list->end(); deadPoint++)\r
- delete *deadPoint;\r
- m_list->clear();\r
-}\r
+/*
+BobToolz plugin for GtkRadiant
+Copyright (C) 2001 Gordon Biggans
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+// BobView.cpp: implementation of the DVisDrawer class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "StdAfx.h"
+#include "DPoint.h"
+#include "DVisDrawer.h"
+#include "misc.h"
+#include "funchandlers.h"
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+DVisDrawer::DVisDrawer()
+{
+ refCount = 1;
+ m_bHooked = FALSE;
+ m_list = NULL;
+}
+
+DVisDrawer::~DVisDrawer()
+{
+ if(m_bHooked)
+ UnRegister();
+
+ g_VisView = NULL;
+}
+
+//////////////////////////////////////////////////////////////////////
+// Implementation
+//////////////////////////////////////////////////////////////////////
+
+void DVisDrawer::Draw2D(VIEWTYPE vt)
+{
+ if(!m_list)
+ return;
+
+ g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
+
+ g_QglTable.m_pfn_qglDisable(GL_BLEND);
+ g_QglTable.m_pfn_qglDisable(GL_LINE_SMOOTH);
+
+ g_QglTable.m_pfn_qglPushMatrix();
+
+ switch(vt)
+ {
+ case XY:
+ break;
+ case XZ:
+ g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
+ break;
+ case YZ:
+ g_QglTable.m_pfn_qglRotatef(270.0f, 1.0f, 0.0f, 0.0f);
+ g_QglTable.m_pfn_qglRotatef(270.0f, 0.0f, 0.0f, 1.0f);
+ break;
+ }
+
+ g_QglTable.m_pfn_qglLineWidth(1.0f);
+ g_QglTable.m_pfn_qglColor4f(1.0f, 0.0f, 0.0f, 0.5f);
+
+ g_QglTable.m_pfn_qglEnable(GL_BLEND);
+ g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ g_QglTable.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
+
+ g_QglTable.m_pfn_qglDepthFunc(GL_ALWAYS);
+
+ //bleh
+ list<DWinding *>::const_iterator l=m_list->begin();
+
+ for(; l != m_list->end(); l++)
+ {
+ DWinding* w = *l;
+
+ g_QglTable.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
+
+ g_QglTable.m_pfn_qglBegin(GL_POLYGON);
+ for(int i = 0; i < w->numpoints; i++) {
+ g_QglTable.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
+ }
+ g_QglTable.m_pfn_qglEnd();
+ }
+
+
+ g_QglTable.m_pfn_qglPopMatrix();
+
+ g_QglTable.m_pfn_qglPopAttrib();
+}
+
+void DVisDrawer::Draw3D()
+{
+ if(!m_list)
+ return;
+
+ g_QglTable.m_pfn_qglPushAttrib(GL_ALL_ATTRIB_BITS);
+
+ g_QglTable.m_pfn_qglColor4f(1.0, 0.0, 0.0, 0.5f);
+
+// g_QglTable.m_pfn_qglHint(GL_FOG_HINT, GL_NICEST);
+
+// g_QglTable.m_pfn_qglDisable(GL_CULL_FACE);
+ g_QglTable.m_pfn_qglDisable(GL_LINE_SMOOTH);
+
+// g_QglTable.m_pfn_qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+// g_QglTable.m_pfn_qglShadeModel(GL_SMOOTH);
+
+ g_QglTable.m_pfn_qglEnable(GL_BLEND);
+ g_QglTable.m_pfn_qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ g_QglTable.m_pfn_qglDisable(GL_POLYGON_SMOOTH);
+
+ g_QglTable.m_pfn_qglDepthFunc(GL_ALWAYS);
+
+ //bleh
+ list<DWinding *>::const_iterator l=m_list->begin();
+
+ for(; l != m_list->end(); l++)
+ {
+ DWinding* w = *l;
+
+ g_QglTable.m_pfn_qglColor4f(w->clr[0], w->clr[1], w->clr[2], 0.5f);
+
+ g_QglTable.m_pfn_qglBegin(GL_POLYGON);
+ for(int i = 0; i < w->numpoints; i++) {
+ g_QglTable.m_pfn_qglVertex3f((w->p[i])[0], (w->p[i])[1], (w->p[i])[2]);
+ }
+ g_QglTable.m_pfn_qglEnd();
+ }
+
+ g_QglTable.m_pfn_qglPopAttrib();
+}
+
+void DVisDrawer::Register()
+{
+ g_QglTable.m_pfnHookGL2DWindow( this );
+ g_QglTable.m_pfnHookGL3DWindow( this );
+ m_bHooked = TRUE;
+}
+
+void DVisDrawer::UnRegister()
+{
+ g_QglTable.m_pfnUnHookGL2DWindow( this );
+ g_QglTable.m_pfnUnHookGL3DWindow( this );
+ m_bHooked = FALSE;
+}
+
+void DVisDrawer::SetList(std::list<DWinding*> *pointList)
+{
+ if(m_list)
+ ClearPoints();
+
+ m_list = pointList;
+}
+
+void DVisDrawer::ClearPoints()
+{
+ list<DWinding *>::const_iterator deadPoint=m_list->begin();
+ for(; deadPoint!=m_list->end(); deadPoint++)
+ delete *deadPoint;
+ m_list->clear();
+}