diff options
18 files changed, 1 insertions, 2213 deletions
diff --git a/source/blender/freestyle/SConscript b/source/blender/freestyle/SConscript index eefee0cc2c4..4ad790f53e5 100644 --- a/source/blender/freestyle/SConscript +++ b/source/blender/freestyle/SConscript @@ -53,10 +53,6 @@ view_map_sources = env.Glob(prefix + '/*.cpp') prefix = 'intern/stroke' stroke_sources = env.Glob(prefix + '/*.cpp') -# rendering -prefix = 'intern/rendering' -rendering_sources = env.Glob(prefix + '/GL*.cpp') - # application prefix = 'intern/application' application_sources = env.Glob(prefix + '/*.cpp') @@ -73,7 +69,7 @@ python_sources = env.Glob(prefix + '/*.cpp') \ + env.Glob(prefix + '/*/*/*/*.cpp') sources = system_sources + image_sources + geometry_sources + scene_graph_sources \ - + winged_edge_sources + view_map_sources + stroke_sources + rendering_sources \ + + winged_edge_sources + view_map_sources + stroke_sources \ + application_sources + interface_sources + python_sources env.BlenderLib (libname="bf_freestyle", diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp index 3844cf2195a..2895549a79c 100755 --- a/source/blender/freestyle/intern/application/AppCanvas.cpp +++ b/source/blender/freestyle/intern/application/AppCanvas.cpp @@ -20,14 +20,11 @@ /////////////////////////////////////////////////////////////////////////////// #include "Controller.h" -#include "../rendering/GLBlendEquation.h" #include "AppView.h" #include "../image/Image.h" #include "../system/TimeStamp.h" #include "../stroke/StrokeRenderer.h" #include "AppCanvas.h" -#include "../rendering/GLRenderer.h" -#include "../rendering/GLStrokeRenderer.h" #include "AppConfig.h" #include "../system/StringUtils.h" diff --git a/source/blender/freestyle/intern/rendering/GLBBoxRenderer.cpp b/source/blender/freestyle/intern/rendering/GLBBoxRenderer.cpp deleted file mode 100755 index 464779d6a43..00000000000 --- a/source/blender/freestyle/intern/rendering/GLBBoxRenderer.cpp +++ /dev/null @@ -1,108 +0,0 @@ - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "GLBBoxRenderer.h" -#include "../scene_graph/IndexedFaceSet.h" -#include "../scene_graph/NodeDrawingStyle.h" -#include "../scene_graph/NodeShape.h" -#include "../scene_graph/NodeLight.h" -#include "../scene_graph/NodeTransform.h" - -#include "../scene_graph/Rep.h" -#include "../scene_graph/Node.h" - -void GLBBoxRenderer::visitIndexedFaceSet(IndexedFaceSet& iFaceSet) -{ - RenderRep(iFaceSet); -} - -void GLBBoxRenderer::visitNodeGroup(NodeGroup& iGroupNode) -{ - RenderNode(iGroupNode); -} - -void GLBBoxRenderer::visitNodeTransform(NodeTransform& iTransformNode) -{ - RenderNode(iTransformNode); -} - -void GLBBoxRenderer::visitDrawingStyle(DrawingStyle& iDrawingStyle) -{ - if(DrawingStyle::INVISIBLE == iDrawingStyle.style()) - return ; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - glPolygonMode(GL_FRONT, GL_LINE); - glLineWidth(1.f); - - glDisable(GL_LIGHTING); -} - -void GLBBoxRenderer::RenderRep(const Rep& iRep) const -{ - RenderBBox(iRep.bbox()); -} - -void GLBBoxRenderer::RenderNode(const Node& iNode) const -{ - RenderBBox(iNode.bbox()); -} - -void GLBBoxRenderer::RenderBBox(const BBox<Vec3r>& iBox) const -{ - if(iBox.empty()) - return; - - Vec3r m = iBox.getMin(); - Vec3r M = iBox.getMax(); - - glColor3f(0.f, 0.f, 0.f); - glBegin(GL_LINE_LOOP); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], m[1], m[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], m[1], m[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], M[1], m[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], M[1], m[2]); - glEnd(); - - glBegin(GL_LINE_LOOP); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], m[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], m[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], M[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], M[1], M[2]); - glEnd(); - - glBegin(GL_LINE_LOOP); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], m[1], m[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], m[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], M[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(m[0], M[1], m[2]); - glEnd(); - - glBegin(GL_LINE_LOOP); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], m[1], m[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], m[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], M[1], M[2]); - ((GLBBoxRenderer*)(this))->glVertex3r(M[0], M[1], m[2]); - glEnd(); - -} diff --git a/source/blender/freestyle/intern/rendering/GLBBoxRenderer.h b/source/blender/freestyle/intern/rendering/GLBBoxRenderer.h deleted file mode 100755 index 4bb72ba80b0..00000000000 --- a/source/blender/freestyle/intern/rendering/GLBBoxRenderer.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// Filename : GLBBoxRenderer.h -// Author(s) : Stephane Grabli -// Purpose : Class to render BBoxes of a 3D scene thanks to OpenGL -// Date of creation : 07/02/2002 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GLBBOXRENDERER_H -# define GLBBOXRENDERER_H - -# include "../system/FreestyleConfig.h" -# include "GLRenderer.h" -# include "../geometry/BBox.h" - -class Rep; -class Node; - -class LIB_RENDERING_EXPORT GLBBoxRenderer : public GLRenderer -{ -public: - - inline GLBBoxRenderer() : GLRenderer() {} - virtual ~GLBBoxRenderer() {} - - VISIT_DECL(NodeGroup) - VISIT_DECL(NodeTransform) - VISIT_DECL(IndexedFaceSet) - VISIT_DECL(DrawingStyle) - - protected: - - void RenderRep(const Rep& iRep) const ; - void RenderNode(const Node& iNode) const ; - void RenderBBox(const BBox<Vec3r>& iBox) const ; -}; - -#endif // GLBBOXRENDERER_H diff --git a/source/blender/freestyle/intern/rendering/GLBlendEquation.cpp b/source/blender/freestyle/intern/rendering/GLBlendEquation.cpp deleted file mode 100644 index 2cbd003c58e..00000000000 --- a/source/blender/freestyle/intern/rendering/GLBlendEquation.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "GLBlendEquation.h" - -void FRS_glBlendEquation(GLenum mode) { - if( glBlendEquation ) { - glBlendEquation(mode); - } else if ( glBlendEquationEXT ) { - glBlendEquationEXT(mode); - } -} diff --git a/source/blender/freestyle/intern/rendering/GLBlendEquation.h b/source/blender/freestyle/intern/rendering/GLBlendEquation.h deleted file mode 100644 index 89a90837bea..00000000000 --- a/source/blender/freestyle/intern/rendering/GLBlendEquation.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef GLBLENDEQUATION_H -#define GLBLENDEQUATION_H - -#include <GL/glew.h> -#ifdef WIN32 -# include <windows.h> -#endif -#ifdef __MACH__ -# include <OpenGL/gl.h> -#else -# include <GL/gl.h> -#endif - -void FRS_glBlendEquation(GLenum mode); - -#endif // GLBLENDEQUATION_H diff --git a/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp b/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp deleted file mode 100755 index 12428ab633f..00000000000 --- a/source/blender/freestyle/intern/rendering/GLDebugRenderer.cpp +++ /dev/null @@ -1,201 +0,0 @@ - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "GLDebugRenderer.h" - -#include <stdio.h> -#include "../scene_graph/VertexRep.h" -#include "../scene_graph/NodeShape.h" -#include "../scene_graph/IndexedFaceSet.h" -#include "../scene_graph/LineRep.h" -#include "../geometry/Grid.h" - -#ifdef __MACH__ -#include <GLUT/glut.h> -#else -# ifdef WIN32 -# include <GL/glu.h> -# else -# include <GL/glut.h> -# endif -#endif - -void GLDebugRenderer::visitIndexedFaceSet(IndexedFaceSet& iFaceSet) -{ - unsigned int fIndex = 0; - - const real * vertices = iFaceSet.vertices(); - const real * normals = iFaceSet.normals(); - const FrsMaterial *const* frs_materials = (const FrsMaterial**)iFaceSet.frs_materials(); - const unsigned *vindices = iFaceSet.vindices(); - const unsigned *nindices = iFaceSet.nindices(); - const unsigned *mindices = iFaceSet.mindices(); - const unsigned numfaces = iFaceSet.numFaces(); - const unsigned *numVertexPerFace = iFaceSet.numVertexPerFaces(); - const IndexedFaceSet::TRIANGLES_STYLE * faceStyle = iFaceSet.trianglesStyle(); - - const unsigned *pvi = vindices; - const unsigned *pni = nindices; - const unsigned* pmi = mindices; - - for(fIndex=0; fIndex<numfaces; fIndex++) - { - switch(faceStyle[fIndex]) - { - case IndexedFaceSet::TRIANGLE_STRIP: - RenderTriangleStrip(vertices, normals, frs_materials, pvi, pni, pmi, numVertexPerFace[fIndex]); - break; - case IndexedFaceSet::TRIANGLE_FAN: - RenderTriangleFan(vertices, normals, frs_materials, pvi, pni, pmi, numVertexPerFace[fIndex]); - break; - case IndexedFaceSet::TRIANGLES: - RenderTriangles(vertices, normals, frs_materials, pvi, pni, pmi, numVertexPerFace[fIndex]); - break; - } - pvi += numVertexPerFace[fIndex]; - pni += numVertexPerFace[fIndex]; - pmi += numVertexPerFace[fIndex]; - } -} - -void GLDebugRenderer::visitNodeShape(NodeShape& iShapeNode) -{ - // Gets the bbox size: - real minY = iShapeNode.bbox().getMin()[1]; - real maxY = iShapeNode.bbox().getMax()[1]; - - // sets the text size: - _bboxSize = fabs((maxY-minY)); ///1000.f; -} - -void GLDebugRenderer::visitLineRep(LineRep& iLine) -{ - - glColor3f(0,0,0); - - GLRenderer::visitLineRep(iLine); -} - -void GLDebugRenderer::visitOrientedLineRep(OrientedLineRep& iLine) -{ - GLRenderer::visitOrientedLineRep(iLine); -} - -void GLDebugRenderer::visitVertexRep(VertexRep& iVertex) -{ - glPointSize(3.0); - - GLRenderer::visitVertexRep(iVertex); -} - - -void GLDebugRenderer::renderBitmapString(real x, - real y, - real z, - void *font, - char *string, - float size) -{ - char *c; - - glPushMatrix(); - glTranslater(x, y,z); - real textSize = min(_bboxSize/10.0, _minEdgeSize/2.0); - // adjust the text size so as it - // is acceptable giving the bbox size: - while(_bboxSize/textSize>1000) - textSize *= 10.0; - - glScalef(size, size, size); - glScalef(textSize/200.0, textSize/200.0, textSize/200.0); - for (c=string; *c != '\0'; c++) - { - //soc glutStrokeCharacter(font, *c); - } - glPopMatrix(); -} - -void GLDebugRenderer::RenderTriangleStrip(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned iNVertices) -{ - // glBegin(GL_TRIANGLE_STRIP); - // for(unsigned int i=0; i<iNVertices; i++) - // { - // glNormal3r(iNormals[iNIndices[i]], - // iNormals[iNIndices[i]+1], - // iNormals[iNIndices[i]+2]); - // - // glVertex3r( iVertices[iVIndices[i]], - // iVertices[iVIndices[i]+1], - // iVertices[iVIndices[i]+2]); - // } - // glEnd(); -} - -void GLDebugRenderer::RenderTriangleFan(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned iNVertices) -{ - // glBegin(GL_TRIANGLE_FAN); - // for(unsigned int i=0; i<iNVertices; i++) - // { - // glNormal3r(iNormals[iNIndices[i]], - // iNormals[iNIndices[i]+1], - // iNormals[iNIndices[i]+2]); - // - // glVertex3r( iVertices[iVIndices[i]], - // iVertices[iVIndices[i]+1], - // iVertices[iVIndices[i]+2]); - // } - // glEnd(); -} - -void GLDebugRenderer::RenderTriangles(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned iNVertices) -{ - // // Renders the normals: - // glBegin(GL_LINES); - // for(unsigned int i=0; i<iNVertices; i++) - // { - // glVertex3r( iVertices[iVIndices[i]], - // iVertices[iVIndices[i]+1], - // iVertices[iVIndices[i]+2]); - // - // glVertex3r(iVertices[iVIndices[i]] + iNormals[iNIndices[i]]/10.f, - // iVertices[iVIndices[i]+1] + iNormals[iNIndices[i]+1]/10.f, - // iVertices[iVIndices[i]+2] + iNormals[iNIndices[i]+2]/10.f); - // } - // glEnd(); -} diff --git a/source/blender/freestyle/intern/rendering/GLDebugRenderer.h b/source/blender/freestyle/intern/rendering/GLDebugRenderer.h deleted file mode 100755 index 45316b3abc6..00000000000 --- a/source/blender/freestyle/intern/rendering/GLDebugRenderer.h +++ /dev/null @@ -1,182 +0,0 @@ -// -// Filename : GLDebugRenderer.h -// Author(s) : Stephane Grabli -// Purpose : Class to render the debug informations related to -// a scene -// Date of creation : 03/04/2002 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GLDEBUGRENDERER_H -# define GLDEBUGRENDERER_H - -# include "../view_map/Silhouette.h" -# include <float.h> -# include "../system/FreestyleConfig.h" -# include "GLRenderer.h" -# include "../winged_edge/Curvature.h" - -class WSMeshShape; -class WSExactShape; - -class LIB_RENDERING_EXPORT GLDebugRenderer : public GLRenderer -{ -public: - - inline GLDebugRenderer() : GLRenderer() { - _bboxSize = 2.0; - setMaxValue(&_minEdgeSize); - _SelectedFEdge = 0; - } - - inline ~GLDebugRenderer() {} - - VISIT_DECL(NodeShape) - - VISIT_DECL(IndexedFaceSet) - VISIT_DECL(LineRep) - VISIT_DECL(OrientedLineRep) - VISIT_DECL(VertexRep) - - /*! Renders a bitmap string in world coordinates - * x, y, z - * The world coordinates of the sentence's starting point - * font - * The font used to display the text. - * Must be one of : - * - GLUT_STROKE_ROMAN - * - GLUT_STROKE_MONO_ROMAN - * string - * The text to display - * size - * The relative size of the text to display - */ - void renderBitmapString(real x, - real y, - real z, - void *font, - char *string, - float size = 1.f) ; - - /*! Reinitialize the Renderer so as the previous - * text size does not affect the current one. - * iBBoxSize - * The size of the scene bounding box. - */ - inline void ReInit(real iBBoxSize) {_bboxSize = iBBoxSize; setMaxValue(&_minEdgeSize);} - - inline void setSelectedFEdge(FEdge *iFEdge) {_SelectedFEdge = iFEdge;} - inline FEdge * selectedFEdge() {return _SelectedFEdge;} - -protected: - - /*! Renders a face made of a triangles strip - * iVertices - * Array of float containing the face vertices. 3 floats per - * x, y, z vertex coordinates - * iNormals - * Array of float containing the face normals. 3 floats per - * x, y, z vertex normal coordinates - * iVIndices - * Array of the indices (to use with the iVertices array) - * describing the vertices parsing order - * iNIndices - * Array of normals indices (to use with iNormals array) - * describing the normals parsing order - * iNVertices - * The number of vertices in the face - */ - virtual void RenderTriangleStrip(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned iNVertices); - - /*! Renders a face made of a triangles fan - * iVertices - * Array of float containing the face vertices. 3 floats per - * x, y, z vertex coordinates - * iNormals - * Array of float containing the face normals. 3 floats per - * x, y, z vertex normal coordinates - * iVIndices - * Array of the indices (to use with the iVertices array) - * describing the vertices parsing order - * iNIndices - * Array of normals indices (to use with iNormals array) - * describing the normals parsing order - * iNVertices - * The number of vertices in the face - */ - virtual void RenderTriangleFan(const real *iVertices, - const real *iNormals, - const FrsMaterial *const*iMaterials, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned iNVertices); - - /*! Renders a face made of single triangles - * iVertices - * Array of float containing the face vertices. 3 floats per - * x, y, z vertex coordinates - * iNormals - * Array of float containing the face normals. 3 floats per - * x, y, z vertex normal coordinates - * iVIndices - * Array of the indices (to use with the iVertices array) - * describing the vertices parsing order - * iNIndices - * Array of normals indices (to use with iNormals array) - * describing the normals parsing order - * iNVertices - * The number of vertices in the face - */ - virtual void RenderTriangles(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned iNVertices); - - /*! glTranslatef or glTranslated */ - inline void glTranslater(float x, float y, float z) {glTranslatef(x,y,z);} - inline void glTranslater(real x, real y, real z) {glTranslated(x,y,z);} - - -private: - - inline void setMaxValue(float *oValue) {*oValue = FLT_MAX;} - inline void setMaxValue(real *oValue) {*oValue = DBL_MAX;} - - mutable real _bboxSize; - mutable real _minEdgeSize; - - FEdge *_SelectedFEdge; -}; - -#endif // GLDEBUGRENDERER_H diff --git a/source/blender/freestyle/intern/rendering/GLFreeMemoryVisitor.cpp b/source/blender/freestyle/intern/rendering/GLFreeMemoryVisitor.cpp deleted file mode 100644 index b5a835f5104..00000000000 --- a/source/blender/freestyle/intern/rendering/GLFreeMemoryVisitor.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "GLFreeMemoryVisitor.h" -#include "../scene_graph/IndexedFaceSet.h" - -# ifdef WIN32 -# include <windows.h> -# endif -# ifdef __MACH__ -# include <OpenGL/gl.h> -# else -# include <GL/gl.h> -# endif - -GLFreeMemoryVisitor::GLFreeMemoryVisitor() -:SceneVisitor(){ -} - -GLFreeMemoryVisitor::~GLFreeMemoryVisitor(){ -} - -void GLFreeMemoryVisitor::visitIndexedFaceSet(IndexedFaceSet& ifs){ - GLuint dl = ifs.displayList(); - if(dl != 0){ - if(glIsList(dl)){ - glDeleteLists(dl, 1); - } - } -} diff --git a/source/blender/freestyle/intern/rendering/GLFreeMemoryVisitor.h b/source/blender/freestyle/intern/rendering/GLFreeMemoryVisitor.h deleted file mode 100644 index 2b9314f3701..00000000000 --- a/source/blender/freestyle/intern/rendering/GLFreeMemoryVisitor.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef GL_FREE_MEMORY_VISITOR_H_ -#define GL_FREE_MEMORY_VISITOR_H_ - -# include "../system/FreestyleConfig.h" -# include "../scene_graph/SceneVisitor.h" - -/*! Mainly used to delete display lists */ -class LIB_RENDERING_EXPORT GLFreeMemoryVisitor : public SceneVisitor -{ -public: - - GLFreeMemoryVisitor() ; - virtual ~GLFreeMemoryVisitor() ; - - // - // visitClass methods - // - ////////////////////////////////////////////// - - VISIT_DECL(IndexedFaceSet) -}; - -#endif // GL_FREE_MEMORY_H_ diff --git a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp b/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp deleted file mode 100755 index ff893484fb5..00000000000 --- a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "GLMonoColorRenderer.h" - -void GLMonoColorRenderer::visitFrsMaterial(FrsMaterial&) { - glColor3f(_r, _g, _b); -} - -void GLMonoColorRenderer::visitDrawingStyle(DrawingStyle&) { - glDisable(GL_LIGHTING); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - glLineWidth(3.0); - glPolygonMode(GL_BACK, GL_LINE); - //glPolygonMode(GL_BACK, GL_FILL); -} - -void GLMonoColorRenderer::setColor(float r, float g, float b, float alpha) { - _r = r; - _g = g; - _b = b; - _alpha = alpha; -} diff --git a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h b/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h deleted file mode 100755 index 9eb6c8134bb..00000000000 --- a/source/blender/freestyle/intern/rendering/GLMonoColorRenderer.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// Filename : GLMonoColorRenderer.h -// Author(s) : Stephane Grabli -// Purpose : Class to render 3D scene in 2 colors thanks to OpenGL -// Date of creation : 07/02/2002 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GLMONOCOLORRENDERER_H -# define GLMONOCOLORRENDERER_H - -# include "../system/FreestyleConfig.h" -# include "GLRenderer.h" - -class LIB_RENDERING_EXPORT GLMonoColorRenderer : public GLRenderer -{ - public: - - GLMonoColorRenderer() : GLRenderer() { - _r = _g = _b = 0.f; - _alpha = 1.f; - } - - virtual ~GLMonoColorRenderer() {} - - VISIT_DECL(DrawingStyle) - VISIT_DECL(FrsMaterial) - - void setColor(float r, float g, float b, float alpha = 1.f); - -private: - - float _r; - float _g; - float _b; - float _alpha; -}; - -#endif // GLMONOCOLORRENDERER_H diff --git a/source/blender/freestyle/intern/rendering/GLRenderer.cpp b/source/blender/freestyle/intern/rendering/GLRenderer.cpp deleted file mode 100755 index 75901e09c2b..00000000000 --- a/source/blender/freestyle/intern/rendering/GLRenderer.cpp +++ /dev/null @@ -1,467 +0,0 @@ - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "../stroke/Stroke.h" -#include "../scene_graph/IndexedFaceSet.h" -#include "../scene_graph/NodeDrawingStyle.h" -#include "../scene_graph/NodeLight.h" -#include "../scene_graph/NodeCamera.h" -#include "../scene_graph/NodeTransform.h" -#include "../scene_graph/NodeShape.h" -#include "../scene_graph/OrientedLineRep.h" -#include "../scene_graph/VertexRep.h" - -#include "../scene_graph/TriangleRep.h" - -#include "GLRenderer.h" - -static GLenum lights[8] = {GL_LIGHT0, - GL_LIGHT1, - GL_LIGHT2, - GL_LIGHT3, - GL_LIGHT4, - GL_LIGHT5, - GL_LIGHT6, - GL_LIGHT7}; - -void GLRenderer::visitIndexedFaceSet(IndexedFaceSet& ifs) -{ - /*GLuint dl = ifs.displayList(); - if(dl != 0){ - glCallList(dl); - return; - }*/ - unsigned int fIndex = 0; - - const real * vertices = ifs.vertices(); - const real * normals = ifs.normals(); - const real * texCoords = ifs.texCoords(); - const FrsMaterial *const* frs_materials = ifs.frs_materials(); - const unsigned *vindices = ifs.vindices(); - const unsigned *nindices = ifs.nindices(); - const unsigned *mindices = ifs.mindices(); - const unsigned *tindices = ifs.tindices(); - const unsigned numfaces = ifs.numFaces(); - const IndexedFaceSet::TRIANGLES_STYLE * faceStyle = ifs.trianglesStyle(); - const unsigned *numVertexPerFace = ifs.numVertexPerFaces(); - - - const unsigned* pvi = vindices; - const unsigned* pni = nindices; - const unsigned* pmi = mindices; - const unsigned* pti = tindices; - - //dl = glGenLists(1); - //glNewList(dl, GL_COMPILE_AND_EXECUTE); - for(fIndex=0; fIndex<numfaces; fIndex++) - { - switch(faceStyle[fIndex]) - { - case IndexedFaceSet::TRIANGLE_STRIP: - RenderTriangleStrip(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); - break; - case IndexedFaceSet::TRIANGLE_FAN: - RenderTriangleFan(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); - break; - case IndexedFaceSet::TRIANGLES: - RenderTriangles(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); - break; - } - pvi += numVertexPerFace[fIndex]; - pni += numVertexPerFace[fIndex]; - if(pmi) - pmi += numVertexPerFace[fIndex]; - if(pti) - pti += numVertexPerFace[fIndex]; - } - //glEndList(); - //ifs.setDisplayList(dl); -} - -void GLRenderer::visitNodeTransform(NodeTransform& tn) { - if(tn.scaled()) - glEnable(GL_NORMALIZE); -} - -void GLRenderer::visitNodeTransformBefore(NodeTransform& tn) { - glPushMatrix(); - - // Now apply transform - applyTransform(tn.matrix()); -} - -void GLRenderer::visitNodeTransformAfter(NodeTransform& tn) { - glPopMatrix(); -} - -void GLRenderer::visitNodeLight(NodeLight& ln) -{ - if(true != ln.isOn()) - return; - - int number = ln.number(); - - glLightfv(lights[number], GL_AMBIENT, ln.ambient()); - glLightfv(lights[number], GL_DIFFUSE, ln.diffuse()); - glLightfv(lights[number], GL_SPECULAR, ln.specular()); - glLightfv(lights[number], GL_POSITION, ln.position()); - - glEnable(lights[number]); -} - -void GLRenderer::visitNodeCamera(NodeCamera& cn) -{ - const double * mvm = cn.modelViewMatrix(); - const double * pm = cn.projectionMatrix(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMultMatrixd(pm); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMultMatrixd(mvm); - - -} - -void GLRenderer::visitNodeDrawingStyleBefore(NodeDrawingStyle& ds) { - glPushAttrib(GL_ALL_ATTRIB_BITS); -} - -void GLRenderer::visitNodeDrawingStyleAfter(NodeDrawingStyle&) { - glPopAttrib(); -} - -void GLRenderer::RenderTriangleStrip( const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const real *iTexCoords, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned* iTIndices, - const unsigned iNVertices) -{ - unsigned index = -1; - glBegin(GL_TRIANGLE_STRIP); - for(unsigned int i=0; i<iNVertices; i++) - { - if(iMIndices){ - if(iMIndices[i] != index){ - visitFrsMaterial(*(iMaterials[iMIndices[i]])); - index = iMIndices[i]; - } - } - - if(iTIndices){ - glTexCoord2f( iTexCoords[iTIndices[i]], - iTexCoords[iTIndices[i]+1]); - } - - glNormal3r(iNormals[iNIndices[i]], - iNormals[iNIndices[i]+1], - iNormals[iNIndices[i]+2]); - - glVertex3r( iVertices[iVIndices[i]], - iVertices[iVIndices[i]+1], - iVertices[iVIndices[i]+2]); - } - glEnd(); -} - -void GLRenderer::RenderTriangleFan( const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const real *iTexCoords, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned* iTIndices, - const unsigned iNVertices) -{ - unsigned index = -1; - glBegin(GL_TRIANGLE_FAN); - for(unsigned int i=0; i<iNVertices; i++) - { - if(iMIndices){ - if(iMIndices[i] != index){ - visitFrsMaterial(*(iMaterials[iMIndices[i]])); - index = iMIndices[i]; - } - } - if(iTIndices){ - glTexCoord2f( iTexCoords[iTIndices[i]], - iTexCoords[iTIndices[i]+1]); - } - - glNormal3r(iNormals[iNIndices[i]], - iNormals[iNIndices[i]+1], - iNormals[iNIndices[i]+2]); - - glVertex3r( iVertices[iVIndices[i]], - iVertices[iVIndices[i]+1], - iVertices[iVIndices[i]+2]); - } - glEnd(); -} - -void GLRenderer::RenderTriangles( const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const real *iTexCoords, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned* iTIndices, - const unsigned iNVertices) -{ - unsigned index = -1; - glBegin(GL_TRIANGLES); - for(unsigned int i=0; i<iNVertices; i++) - { - if(iMIndices){ - if(iMIndices[i] != index){ - visitFrsMaterial(*(iMaterials[iMIndices[i]])); - index = iMIndices[i]; - } - } - if(iTIndices){ - glTexCoord2f( iTexCoords[iTIndices[i]], - iTexCoords[iTIndices[i]+1]); - } - - glNormal3r(iNormals[iNIndices[i]], - iNormals[iNIndices[i]+1], - iNormals[iNIndices[i]+2]); - - glVertex3r( iVertices[iVIndices[i]], - iVertices[iVIndices[i]+1], - iVertices[iVIndices[i]+2]); - } - glEnd(); -} - -void GLRenderer::visitLineRep( LineRep& iLine) -{ - if(iLine.width() != 0) - glLineWidth(iLine.width()); - - switch(iLine.style()) - { - case LineRep::LINES: - glBegin(GL_LINES); - break; - case LineRep::LINE_STRIP: - glBegin(GL_LINE_STRIP); - break; - case LineRep::LINE_LOOP: - glBegin(GL_LINE_LOOP); - break; - default: - return; - } - - const vector<Vec3r>& vertices = iLine.vertices(); - //soc unused float step=1.f/vertices.size(); - vector<Vec3r>::const_iterator v; - - for(v=vertices.begin(); v!=vertices.end(); v++) - glVertex3r((*v)[0], (*v)[1], (*v)[2]); - - glEnd(); -} - - -void GLRenderer::visitTriangleRep( TriangleRep& iTriangle) -{ - glPushAttrib(GL_ALL_ATTRIB_BITS); - switch(iTriangle.style()) - { - case TriangleRep::FILL: - glPolygonMode(GL_FRONT, GL_FILL); - break; - case TriangleRep::LINES: - glPolygonMode(GL_FRONT, GL_LINES); - break; - default: - return; - } - - glBegin(GL_TRIANGLES); - for(int i=0; i<3; ++i) - { - glColor3f(iTriangle.color(i)[0], iTriangle.color(i)[1], iTriangle.color(i)[2]); - glVertex3r(iTriangle.vertex(i)[0], iTriangle.vertex(i)[1], iTriangle.vertex(i)[2]); - } - - glEnd(); - - - - glPopAttrib(); - -} - -void GLRenderer::visitOrientedLineRep(OrientedLineRep& iLine) -{ - switch(iLine.style()) - { - case LineRep::LINES: - glBegin(GL_LINES); - break; - case LineRep::LINE_STRIP: - glBegin(GL_LINE_STRIP); - break; - case LineRep::LINE_LOOP: - glBegin(GL_LINE_LOOP); - break; - default: - return; - } - - int i=0; - int ncolor = iLine.getId().getFirst()%3; - - const vector<Vec3r>& vertices = iLine.vertices(); - float step=1.f/vertices.size(); - vector<Vec3r>::const_iterator v; - for(v=vertices.begin(); v!=vertices.end(); v++) - { - switch(ncolor) - { - case 0: - glColor3f(i*step,0.f,0.f); - break; - case 1: - glColor3f(0.f, i*step, 0.f); - break; - case 2: - glColor3f(0.f, 0.f, i*step); - break; - default: - glColor3f(i*step, i*step,i*step); - break; - } - i++; - glVertex3r((*v)[0], (*v)[1], (*v)[2]); - } - - glEnd(); -} - -void GLRenderer::visitVertexRep( VertexRep& iVertex) -{ - if(iVertex.pointSize() != 0.f) - glPointSize(iVertex.pointSize()); - - glBegin(GL_POINTS); - glVertex3r(iVertex.x(), iVertex.y(), iVertex.z()); - glEnd(); -} - -void GLRenderer::visitDrawingStyle(DrawingStyle& iDrawingStyle) -{ - - // Drawing Style management - switch(iDrawingStyle.style()) - { - case DrawingStyle::FILLED: - glPolygonMode(GL_FRONT, GL_FILL); - glShadeModel(GL_SMOOTH); - break; - - case DrawingStyle::LINES: - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - glPolygonMode(GL_FRONT, GL_LINE); - glLineWidth(iDrawingStyle.lineWidth()); - break; - - case DrawingStyle::POINTS: - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_POINT_SMOOTH); - glPolygonMode(GL_FRONT, GL_POINT); - glPointSize(iDrawingStyle.pointSize()); - break; - - case DrawingStyle::INVISIBLE: - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glDepthMask(0); - break; - - default: - break; - } - - glLineWidth(iDrawingStyle.lineWidth()); - glPointSize(iDrawingStyle.pointSize()); - - // FIXME - if(true == iDrawingStyle.lightingEnabled()) - glEnable(GL_LIGHTING); - else - glDisable(GL_LIGHTING); -} - -void GLRenderer::visitFrsMaterial(FrsMaterial& m) { - const float* diff = m.diffuse(); - const float* amb = m.ambient(); - const float* spec = m.specular(); - const float* em = m.emission(); - - RenderColor(diff); - glMaterialfv(GL_FRONT, GL_AMBIENT, amb); - glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); - glMaterialfv(GL_FRONT, GL_SPECULAR, spec); - glMaterialfv(GL_FRONT, GL_EMISSION, em); - glMaterialf(GL_FRONT, GL_SHININESS, m.shininess()); -} - -void GLRenderer::visitFrsMaterial(const FrsMaterial& m) { - const float* diff = m.diffuse(); - const float* amb = m.ambient(); - const float* spec = m.specular(); - const float* em = m.emission(); - - RenderColor(diff); - glMaterialfv(GL_FRONT, GL_AMBIENT, amb); - glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); - glMaterialfv(GL_FRONT, GL_SPECULAR, spec); - glMaterialfv(GL_FRONT, GL_EMISSION, em); - glMaterialf(GL_FRONT, GL_SHININESS, m.shininess()); -} -void GLRenderer::applyTransform( const Matrix44r &iMatrix) -{ - real m[16]; - for(int lign=0; lign<4; lign++) - for(int column=0; column<4; column++) - m[column*4+lign] = iMatrix(lign, column); - - glMultMatrixr(m); -} - -void GLRenderer::RenderColor( const float *rgba) -{ - glColor4fv(rgba); -} diff --git a/source/blender/freestyle/intern/rendering/GLRenderer.h b/source/blender/freestyle/intern/rendering/GLRenderer.h deleted file mode 100755 index 3769aefb92b..00000000000 --- a/source/blender/freestyle/intern/rendering/GLRenderer.h +++ /dev/null @@ -1,204 +0,0 @@ -// -// Filename : GLRenderer.h -// Author(s) : Stephane Grabli, Emmanuel Turquin -// Purpose : Class to render a 3D scene thanks to OpenGL -// Date of creation : 07/02/2002 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GLRENDERER_H -# define GLRENDERER_H - -# ifdef WIN32 -# include <windows.h> -# endif -# ifdef __MACH__ -# include <OpenGL/gl.h> -# else -# include <GL/gl.h> -# endif - -# include "../system/FreestyleConfig.h" -# include "../system/Precision.h" -# include "../scene_graph/SceneVisitor.h" -# include "../geometry/Geom.h" -using namespace Geometry; - -class LIB_RENDERING_EXPORT GLRenderer : public SceneVisitor -{ - public: - - inline GLRenderer() : SceneVisitor() {} - virtual ~GLRenderer() {} - - // - // visitClass methods - // - ////////////////////////////////////////////// - - VISIT_DECL(NodeLight) - VISIT_DECL(NodeCamera) - VISIT_DECL(NodeTransform) - - VISIT_DECL(LineRep) - VISIT_DECL(OrientedLineRep) - VISIT_DECL(TriangleRep) - VISIT_DECL(VertexRep) - VISIT_DECL(IndexedFaceSet) - VISIT_DECL(DrawingStyle) - VISIT_DECL(FrsMaterial) - - virtual void visitFrsMaterial(const FrsMaterial&); - virtual void visitNodeTransformBefore(NodeTransform&); - virtual void visitNodeTransformAfter(NodeTransform&); - virtual void visitNodeDrawingStyleBefore(NodeDrawingStyle&); - virtual void visitNodeDrawingStyleAfter(NodeDrawingStyle&); - - protected: - - /*! Renders a face made of a triangles strip - * iVertices - * Array of float containing the face vertices. 3 floats per - * x, y, z vertex coordinates - * iNormals - * Array of float containing the face normals. 3 floats per - * x, y, z vertex normal coordinates - * iTexCoords - * Array of float containing the face uv coords. 2 floats per - * u,v vertex texture coordinates - * iVIndices - * Array of the indices (to use with the iVertices array) - * describing the vertices parsing order - * iNIndices - * Array of normals indices (to use with iNormals array) - * describing the normals parsing order - * iTIndices - * Array of texture coordinates indices (to use with iTexCoords array) - * describing the texture coordinates parsing order - * iNVertices - * The number of vertices in the face - */ - virtual void RenderTriangleStrip(const real *iVertices, - const real *iNormals, - const FrsMaterial *const*iMaterials, - const real *iTexCoords, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned* iTIndices, - const unsigned iNVertices) ; - - /*! Renders a face made of a triangles fan - * iVertices - * Array of float containing the face vertices. 3 floats per - * x, y, z vertex coordinates - * iNormals - * Array of float containing the face normals. 3 floats per - * x, y, z vertex normal coordinates - * iTexCoords - * Array of float containing the face uv coords. 2 floats per - * u,v vertex texture coordinates - * iVIndices - * Array of the indices (to use with the iVertices array) - * describing the vertices parsing order - * iNIndices - * Array of normals indices (to use with iNormals array) - * describing the normals parsing order - * iTIndices - * Array of texture coordinates indices (to use with iTexCoords array) - * describing the texture coordinates parsing order - * iNVertices - * The number of vertices in the face - */ - virtual void RenderTriangleFan(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const real *iTexCoords, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned* iTIndices, - const unsigned iNVertices) ; - - /*! Renders a face made of single triangles - * iVertices - * Array of float containing the face vertices. 3 floats per - * x, y, z vertex coordinates - * iNormals - * Array of float containing the face normals. 3 floats per - * x, y, z vertex normal coordinates - * iTexCoords - * Array of float containing the face uv coords. 2 floats per - * u,v vertex texture coordinates - * iVIndices - * Array of the indices (to use with the iVertices array) - * describing the vertices parsing order - * iNIndices - * Array of normals indices (to use with iNormals array) - * describing the normals parsing order - * iTIndices - * Array of texture coordinates indices (to use with iTexCoords array) - * describing the texture coordinates parsing order - * iNVertices - * The number of vertices in the face - */ - virtual void RenderTriangles(const real *iVertices, - const real *iNormals, - const FrsMaterial *const* iMaterials, - const real *iTexCoords, - const unsigned* iVIndices, - const unsigned* iNIndices, - const unsigned* iMIndices, - const unsigned* iTIndices, - const unsigned iNVertices) ; - - /*! Apply a transform matrix by multiplying - * the current OpenGL ModelView Matrix by - * iMatrix - */ - virtual void applyTransform( const Matrix44r &iMatrix) ; - - /*! Sets the current drawing color. - * Active only when light is disabled - * (simple call to glColor4fv) - * rgba - * array of 4 floats (r, g, b and alpha) - */ - virtual void RenderColor( const float *rgba); - - /*! glVertex3f or glVertex3d */ - inline void glVertex3r(float x, float y, float z) {glVertex3f(x,y,z);} - inline void glVertex3r(real x, real y, real z) {glVertex3d(x,y,z);} - - /*! glVertex3f or glNormal3d */ - inline void glNormal3r(float x, float y, float z) {glNormal3f(x,y,z);} - inline void glNormal3r(real x, real y, real z) {glNormal3d(x,y,z);} - - /*! glMultMatrixf or glMultMatrixd */ - inline void glMultMatrixr(float *m) {glMultMatrixf(m);} - inline void glMultMatrixr(real *m) {glMultMatrixd(m);} - -}; - -#endif // GLRENDERER_H diff --git a/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp b/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp deleted file mode 100755 index ca9199740f8..00000000000 --- a/source/blender/freestyle/intern/rendering/GLSelectRenderer.cpp +++ /dev/null @@ -1,159 +0,0 @@ - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "../scene_graph/IndexedFaceSet.h" -#include "../scene_graph/NodeShape.h" -#include "GLSelectRenderer.h" - -static const float INACTIVE_COLOR_MIN = 0.2; -static const float INACTIVE_COLOR_MAX = 0.8; -static const float INACTIVE_COLOR_OFFSET = 0.2; - -static const float ACTIVE_COLOR[4] = {0.8, - 0.2, - 0.2, - 1}; - -static float selection_color[4] = {INACTIVE_COLOR_MIN, - INACTIVE_COLOR_MIN, - INACTIVE_COLOR_MIN, - 1}; - - -void GLSelectRenderer::resetColor() { - for (unsigned i = 0; i < 3; ++i) - selection_color[i] = INACTIVE_COLOR_MIN; -} - -void GLSelectRenderer::visitNodeShape(NodeShape& sn) { - if (_gl_select_rendering) - return; - for (unsigned i = 0; i < 3; ++i) { - selection_color[i] += INACTIVE_COLOR_OFFSET; - if (selection_color[i] > INACTIVE_COLOR_MAX) - selection_color[i] = INACTIVE_COLOR_MIN; - } - if (sn.shapes()[0]->getId() == _selected_shape) { - _current_shape_active = true; - return; - } - _current_shape_active = false; -} - -void GLSelectRenderer::visitFrsMaterial(FrsMaterial& m) { - if (_gl_select_rendering) - return; - - const float* amb = m.ambient(); - const float* spec = m.specular(); - const float* em = m.emission(); - - if (_current_shape_active) { - RenderColor(ACTIVE_COLOR); - glMaterialfv(GL_FRONT, GL_DIFFUSE, ACTIVE_COLOR); - } else { - RenderColor(selection_color); - glMaterialfv(GL_FRONT, GL_DIFFUSE, selection_color); - } - glMaterialfv(GL_FRONT, GL_AMBIENT, amb); - glMaterialfv(GL_FRONT, GL_SPECULAR, spec); - glMaterialfv(GL_FRONT, GL_EMISSION, em); - glMaterialf(GL_FRONT, GL_SHININESS, m.shininess()); -} - -void GLSelectRenderer::visitFrsMaterial(const FrsMaterial& m) { - if (_gl_select_rendering) - return; - - const float* amb = m.ambient(); - const float* spec = m.specular(); - const float* em = m.emission(); - - if (_current_shape_active) { - RenderColor(ACTIVE_COLOR); - glMaterialfv(GL_FRONT, GL_DIFFUSE, ACTIVE_COLOR); - } else { - RenderColor(selection_color); - glMaterialfv(GL_FRONT, GL_DIFFUSE, selection_color); - } - glMaterialfv(GL_FRONT, GL_AMBIENT, amb); - glMaterialfv(GL_FRONT, GL_SPECULAR, spec); - glMaterialfv(GL_FRONT, GL_EMISSION, em); - glMaterialf(GL_FRONT, GL_SHININESS, m.shininess()); -} - -void GLSelectRenderer::visitIndexedFaceSet(IndexedFaceSet& ifs) -{ - unsigned int fIndex = 0; - - const real * vertices = ifs.vertices(); - const real * normals = ifs.normals(); - const FrsMaterial *const* frs_materials = ifs.frs_materials(); - const real * texCoords= ifs.texCoords(); - const unsigned *vindices = ifs.vindices(); - const unsigned *nindices = ifs.nindices(); - const unsigned *mindices = ifs.mindices(); - const unsigned *tindices = ifs.tindices(); - const unsigned numfaces = ifs.numFaces(); - const IndexedFaceSet::TRIANGLES_STYLE * faceStyle = ifs.trianglesStyle(); - const unsigned *numVertexPerFace = ifs.numVertexPerFaces(); - - - const unsigned* pvi = vindices; - const unsigned* pni = nindices; - const unsigned* pmi = mindices; - const unsigned* pti = tindices; - - for(fIndex=0; fIndex<numfaces; fIndex++) - { - switch(faceStyle[fIndex]) - { - case IndexedFaceSet::TRIANGLE_STRIP: - RenderTriangleStrip(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); - break; - case IndexedFaceSet::TRIANGLE_FAN: - RenderTriangleFan(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); - break; - case IndexedFaceSet::TRIANGLES: - RenderTriangles(vertices, normals, frs_materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]); - break; - } - pvi += numVertexPerFace[fIndex]; - pni += numVertexPerFace[fIndex]; - pmi += numVertexPerFace[fIndex]; - if(pti) - pti += numVertexPerFace[fIndex]; - } -} - -void GLSelectRenderer::visitNodeShapeBefore(NodeShape& sn) { - if (!_gl_select_rendering) - return; - - glPushName(sn.shapes()[0]->getId().getFirst()); -} - -void GLSelectRenderer::visitNodeShapeAfter(NodeShape& sn) { - if (!_gl_select_rendering) - return; - - glPopName(); -} diff --git a/source/blender/freestyle/intern/rendering/GLSelectRenderer.h b/source/blender/freestyle/intern/rendering/GLSelectRenderer.h deleted file mode 100755 index 2ce8c3f62db..00000000000 --- a/source/blender/freestyle/intern/rendering/GLSelectRenderer.h +++ /dev/null @@ -1,85 +0,0 @@ -// -// Filename : GLSelectRenderer.h -// Author(s) : Emmanuel Turquin -// Purpose : Class to highlight selected shapes -// Date of creation : 09/01/2004 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GL_SELECT_RENDERER_H -# define GL_SELECT_RENDERER_H - -# include "GLRenderer.h" - -class LIB_RENDERING_EXPORT GLSelectRenderer : public GLRenderer -{ - public: - - inline GLSelectRenderer() : GLRenderer() { - _selected_shape = -1; // -1 means no selection - _current_shape_active = false; - _gl_select_rendering = false; - } - virtual ~GLSelectRenderer() {} - - // - // visitClass methods - // - ////////////////////////////////////////////// - - VISIT_DECL(NodeShape) - - VISIT_DECL(IndexedFaceSet) - VISIT_DECL(FrsMaterial) - - virtual void visitFrsMaterial(const FrsMaterial&); - virtual void visitNodeShapeBefore(NodeShape&); - virtual void visitNodeShapeAfter(NodeShape&); - - void resetColor(); - - void setSelectedId(const int id) { - _selected_shape = id; - } - - void setSelectRendering(bool b) { - _gl_select_rendering = b; - } - - int getSelectedId() const { - return _selected_shape; - } - - bool getSelectRendering() const { - return _gl_select_rendering; - } - - private: - - int _selected_shape; - bool _current_shape_active; - bool _gl_select_rendering; -}; - -#endif // GL_SELECT_RENDERER_H diff --git a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp deleted file mode 100755 index e29dd5cad8f..00000000000 --- a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp +++ /dev/null @@ -1,474 +0,0 @@ - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#include "GLStrokeRenderer.h" - -//soc -// #include <qimage.h> -// #include <qfileinfo.h> -// #include <qgl.h> -// #include <qfile.h> - -extern "C" { -#include "BLI_blenlib.h" -#include "IMB_imbuf.h" -#include "IMB_imbuf_types.h" -#include "MEM_guardedalloc.h" -} - -#include "../system/StringUtils.h" - -GLStrokeRenderer::GLStrokeRenderer() -:StrokeRenderer() -{ - _textureManager = new GLTextureManager; -} - -GLStrokeRenderer::~GLStrokeRenderer() -{ - if(0 != _textureManager) - { - delete _textureManager; - _textureManager = 0; - } -} - -float initialColor(float x, float avTex=0.5) -{ - float y=(1-x)/avTex; - return (y>1 ? 1 : y); -} -//float complementColor(float x, float avTex=0.5) -//{ -// float y=(1-x)/avTex-1; -// return (y<0 ? 0 : y); -//} - -float complementColor(float x, float avTex=0.5) -{ - float y=(1-x);///avTex-1; - return (y<0 ? 0 : y); -} - -void GLStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const -{ - glPushAttrib(GL_COLOR_BUFFER_BIT); - Stroke::MediumType strokeType = iStrokeRep->getMediumType(); - // int averageTextureAlpha=0.5; //default value - // if (strokeType==OIL_STROKE) - // averageTextureAlpha=0.75; - // if (strokeType>=NO_BLEND_STROKE) - // averageTextureAlpha=1.0; - // if (strokeType<0) - // { - // renderNoTexture(iStrokeRep); - // return; - // } - //soc unused - int i; - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glShadeModel(GL_SMOOTH); - glDisable(GL_DEPTH_TEST); - - glEnable(GL_BLEND); - - if(strokeType==Stroke::DRY_MEDIUM) - { - FRS_glBlendEquation(GL_MAX); - } - else if(strokeType==Stroke::OPAQUE_MEDIUM) - { - FRS_glBlendEquation(GL_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - FRS_glBlendEquation(GL_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - } - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - //first texture, basically the only one for lighter strokes - glBindTexture(GL_TEXTURE_2D, iStrokeRep->getTextureId()); - - vector<Strip*>& strips = iStrokeRep->getStrips(); - for(vector<Strip*>::iterator s=strips.begin(), send=strips.end(); - s!=send; - ++s){ - Strip::vertex_container& vertices = (*s)->vertices(); - glBegin(GL_TRIANGLE_STRIP); - for(Strip::vertex_container::iterator v=vertices.begin(), vend=vertices.end(); - v!=vend; - ++v){ - - StrokeVertexRep * svRep = (*v); - Vec3r color = svRep->color(); - real alpha = svRep->alpha(); - glColor4f(complementColor(color[0]), - complementColor(color[1]), - complementColor(color[2]), alpha); - glTexCoord2f(svRep->texCoord()[0],svRep->texCoord()[1] ); - glVertex2f(svRep->point2d()[0], svRep->point2d()[1]); - } - glEnd(); - } -// if (strokeType>=NO_BLEND_STROKE) return; - // //return; - // - // //second texture, the complement, for stronger strokes - // glBindTexture(GL_TEXTURE_2D, _textureManager.getTextureIndex(2*strokeType+1)); - // glBegin(GL_TRIANGLE_STRIP); - // for(i=0; i<_sizeStrip; i++) - // { - // glColor4f(complementColor(_color[i][0]), - // complementColor(_color[i][1]), - // complementColor(_color[i][2]), _alpha[i]); - // glTexCoord2f(_texCoord[i][0],_texCoord[i][1] ); - // glVertex2f(_vertex[i][0], _vertex[i][1]); - // } - // glEnd(); - - glPopAttrib(); -} - -void GLStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const -{ - glPushAttrib(GL_COLOR_BUFFER_BIT); - //soc unused - Stroke::MediumType strokeType = iStrokeRep->getMediumType(); - //soc unused - int i; - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glShadeModel(GL_SMOOTH); - glDisable(GL_DEPTH_TEST); - - glEnable(GL_BLEND); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - //first texture, basically the only one for lighter strokes - glBindTexture(GL_TEXTURE_2D, iStrokeRep->getTextureId()); - - vector<Strip*>& strips = iStrokeRep->getStrips(); - for(vector<Strip*>::iterator s=strips.begin(), send=strips.end(); - s!=send; - ++s){ - Strip::vertex_container& vertices = (*s)->vertices(); - glBegin(GL_TRIANGLE_STRIP); - for(Strip::vertex_container::iterator v=vertices.begin(), vend=vertices.end(); - v!=vend; - ++v){ - StrokeVertexRep * svRep = (*v); - Vec3r color = svRep->color(); - real alpha = svRep->alpha(); - glColor4f(color[0], - color[1], - color[2], alpha); - glTexCoord2f(svRep->texCoord()[0],svRep->texCoord()[1] ); - glVertex2f(svRep->point2d()[0], svRep->point2d()[1]); - } - glEnd(); - } - glPopAttrib(); -} - -//No Texture -//void GLStrokeRenderer::renderNoTexture(StrokeRep *iStrokeRep) const -//{ -// Stroke::MediumType strokeType = iStrokeRep->getMediumType(); -// int sizeStrip = iStrokeRep->sizeStrip(); -// const Vec3r *color = iStrokeRep->colors(); -// const Vec2r *vertex = iStrokeRep->vertices(); -// const float *alpha = iStrokeRep->alpha(); -// -// glDisable(GL_LIGHTING); -// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -// glShadeModel(GL_SMOOTH); -// glDisable(GL_DEPTH_TEST); -// -// //if (strokeType==NO_TEXTURE_STROKE) -// if(strokeType < 0) -// { -// glDisable(GL_BLEND); -// glDisable(GL_TEXTURE_2D); -// glBegin(GL_TRIANGLE_STRIP); -// for(int i=0; i<sizeStrip; i++) -// { -// glColor4f(complementColor(color[i][0]), -// complementColor(color[i][1]), -// complementColor(color[i][2]), alpha[i]); -// glVertex2f(vertex[i][0], vertex[i][1]); -// } -// glEnd(); -// } -// else -// { -// //#ifdef WIN32 -// //glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); -// glBlendEquation(GL_ADD); -// //#endif -// glEnable(GL_BLEND); -// glBlendFunc(GL_SRC_ALPHA, GL_ONE); -// glDisable(GL_TEXTURE_2D); -// glBegin(GL_TRIANGLE_STRIP); -// for(int i=0; i<sizeStrip; i++) -// { -// glColor4f(complementColor(color[i][0]), -// complementColor(color[i][1]), -// complementColor(color[i][2]), alpha[i]); -// glVertex2f(vertex[i][0], vertex[i][1]); -// } -// glEnd(); -// } -// // cerr<<"color="<<_color[1][0]<<", "<<_color[1][1]<<", "<<_color[1][2]<<") "<<endl; -// -// -//} - - -/**********************************/ -/* */ -/* */ -/* GLTextureManager */ -/* */ -/* */ -/**********************************/ - -//#define TEXTURES_DIR ROOT_DIR "/data/textures" - -GLTextureManager::GLTextureManager () -: TextureManager() -{ - //_brushes_path = Config::getInstance()... -} - -GLTextureManager::~GLTextureManager () -{ -} - -void GLTextureManager::loadStandardBrushes() -{ - // getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::HUMID_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/washbrushAlpha.bmp", Stroke::HUMID_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/oil.bmp", Stroke::HUMID_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/oilnoblend.bmp", Stroke::HUMID_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/charcoalAlpha.bmp", Stroke::DRY_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/washbrushAlpha.bmp", Stroke::DRY_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/opaqueDryBrushAlpha.bmp", Stroke::OPAQUE_MEDIUM); - // getBrushTextureIndex(TEXTURES_DIR "/brushes/opaqueBrushAlpha.bmp", Stroke::OPAQUE_MEDIUM); - _defaultTextureId = getBrushTextureIndex("smoothAlpha.bmp", Stroke::OPAQUE_MEDIUM); -} - - -unsigned -GLTextureManager::loadBrush(string sname, Stroke::MediumType mediumType) -{ - GLuint texId; - glGenTextures(1, &texId); - bool found = false; - vector<string> pathnames; - string path; //soc - StringUtils::getPathName(TextureManager::Options::getBrushesPath(), - sname, - pathnames); - for (vector<string>::const_iterator j = pathnames.begin(); j != pathnames.end(); j++) { - path = j->c_str(); - //soc if(QFile::exists(path)){ - if( BLI_exists( const_cast<char *>(path.c_str()) ) ) { - found = true; - break; - } - } - if(!found) - return 0; - // Brush texture - cout << "Loading brush texture..." << endl; - switch(mediumType){ - case Stroke::DRY_MEDIUM: - //soc prepareTextureLuminance((const char*)path.toAscii(), texId); - prepareTextureLuminance(StringUtils::toAscii(path), texId); - break; - case Stroke::HUMID_MEDIUM: - case Stroke::OPAQUE_MEDIUM: - default: - //soc prepareTextureAlpha((const char*)path.toAscii(), texId); - prepareTextureAlpha(StringUtils::toAscii(path), texId); - break; - } - cout << "Done." << endl << endl; - - return texId; -} - -bool -GLTextureManager::prepareTextureAlpha (string sname, GLuint itexname) -{ - //soc const char * name = sname.c_str(); - char * name = (char *) sname.c_str(); - - //soc - ImBuf *qim = IMB_loadiffname(name, 0); - char filename[FILE_MAXFILE]; - char *p = BLI_strdup(name); - BLI_splitdirstring(p, filename); - MEM_freeN(p); - -//soc if (qim.isNull()) - if (!qim) //soc - { - cerr << " Error: unable to read \"" << filename << "\"" << endl; - IMB_freeImBuf(qim); - return false; - } - - if( qim->depth > 8) //soc - { - cerr<<" Error: \""<< filename <<"\" has "<< qim->depth <<" bits/pixel"<<endl; //soc - return false; - } - // qim=QGLWidget::convertToGLFormat( qimOri ); - - glBindTexture(GL_TEXTURE_2D, itexname); - //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - // GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, qim->x, qim->y, 0, - GL_ALPHA, GL_UNSIGNED_BYTE, qim->rect); //soc - - //soc cout << " \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl; - cout << " \"" << filename << "\" loaded with 32 bits per pixel" << endl; - - return true; - -} - -bool -GLTextureManager::prepareTextureLuminance (string sname, GLuint itexname) -{ - //soc const char * name = sname.c_str(); - char * name = (char *) sname.c_str(); - - //soc - ImBuf *qim = IMB_loadiffname(name, 0); - char filename[FILE_MAXFILE]; - char *p = BLI_strdup(name); - BLI_splitdirstring(p, filename); - MEM_freeN(p); - - if (!qim) //soc - { - cerr << " Error: unable to read \"" << filename << "\"" << endl; - IMB_freeImBuf(qim); - return false; - } - if (qim->depth > 8) //soc - { - cerr<<" Error: \""<<filename<<"\" has "<<qim->depth <<" bits/pixel"<<endl;//soc - return false; - } - - glBindTexture(GL_TEXTURE_2D, itexname); - //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - // GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, qim->x, qim->y, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, qim->rect); //soc - - //soc cout << " \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl; - cout << " \"" << filename << "\" loaded with "<< qim->depth << " bits per pixel" << endl; - - return true; - -} - -bool -GLTextureManager::prepareTextureLuminanceAndAlpha (string sname, GLuint itexname) -{ - //soc const char * name = sname.c_str(); - char * name = (char *) sname.c_str(); - - //soc - ImBuf *qim = IMB_loadiffname(name, 0); - char filename[FILE_MAXFILE]; - char *p = BLI_strdup(name); - BLI_splitdirstring(p, filename); - MEM_freeN(p); - - if (!qim) //soc - { - cerr << " Error: unable to read \"" << filename << "\"" << endl; - IMB_freeImBuf(qim); - return false; - } - - if (qim->depth > 8) //soc - { - cerr<<" Error: \""<<filename<<"\" has "<< qim->depth <<" bits/pixel"<<endl; //soc - return false; - } - - glBindTexture(GL_TEXTURE_2D, itexname); - //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - // GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, qim->x, qim->y, 0, - GL_LUMINANCE, GL_UNSIGNED_BYTE, qim->rect); //soc - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, qim->x, qim->y, 0, - GL_ALPHA, GL_UNSIGNED_BYTE, qim->rect); //soc - - //soc cout << " \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl; - cout << " \"" << filename << "\" loaded with "<< qim->depth << " bits per pixel" << endl; - - return true; - -} - - diff --git a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h deleted file mode 100755 index 70289924002..00000000000 --- a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h +++ /dev/null @@ -1,88 +0,0 @@ -// -// Filename : GLStrokeRenderer.h -// Author(s) : Stephane Grabli -// Purpose : Class to define the GL stroke renderer. -// Date of creation : 05/03/2003 -// -/////////////////////////////////////////////////////////////////////////////// - - -// -// Copyright (C) : Please refer to the COPYRIGHT file distributed -// with this source distribution. -// -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef GLSTROKERENDERER_H -# define GLSTROKERENDERER_H - -# include "../stroke/StrokeRenderer.h" -# include "../stroke/StrokeRep.h" -# include "../system/FreestyleConfig.h" - -#include "GLBlendEquation.h" - -/**********************************/ -/* */ -/* */ -/* GLTextureManager */ -/* */ -/* */ -/**********************************/ - -/*! Class to load textures - */ -class LIB_RENDERING_EXPORT GLTextureManager : public TextureManager -{ - public: - GLTextureManager (); - virtual ~GLTextureManager (); -protected: - virtual unsigned loadBrush(string fileName, Stroke::MediumType = Stroke::OPAQUE_MEDIUM); - - protected: - virtual void loadStandardBrushes(); - bool prepareTextureAlpha (string name, GLuint itexname); - bool prepareTextureLuminance (string name, GLuint itexname); - bool prepareTextureLuminanceAndAlpha (string name, GLuint itexname); -}; - - - -/**********************************/ -/* */ -/* */ -/* GLStrokeRenderer */ -/* */ -/* */ -/**********************************/ - -class LIB_RENDERING_EXPORT GLStrokeRenderer : public StrokeRenderer -{ -public: - GLStrokeRenderer(); - virtual ~GLStrokeRenderer(); - - /*! Renders a stroke rep */ - virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const; - virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const; - -protected: - //void renderNoTexture(StrokeRep *iStrokeRep) const; -}; - -#endif // GLSTROKERENDERER_H |