soc-2008-mxcurioni: merged changes to revision 14798, compilation works for rendering...
authorMaxime Curioni <maxime.curioni@gmail.com>
Sun, 11 May 2008 20:28:47 +0000 (20:28 +0000)
committerMaxime Curioni <maxime.curioni@gmail.com>
Sun, 11 May 2008 20:28:47 +0000 (20:28 +0000)
16 files changed:
1  2 
release/scripts/bevel_center.py
release/scripts/paths_import.py
release/scripts/rvk1_torvk2.py
source/blender/blenkernel/intern/object.c
source/blender/freestyle/SConscript
source/blender/freestyle/intern/rendering/GLRenderer.cpp
source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp
source/blender/freestyle/intern/rendering/GLUtils.cpp
source/blender/freestyle/intern/rendering/pbuffer.cpp
source/blender/freestyle/intern/rendering/pbuffer.h
source/blender/freestyle/intern/system/StringUtils.cpp
source/blender/freestyle/intern/system/StringUtils.h
source/blender/src/buttons_object.c
source/blender/src/buttons_shading.c
source/blender/src/drawseq.c
source/blender/src/space.c

Simple merge
Simple merge
Simple merge
index 2bc08822a6ed98e8a0ba491e4f929155e214d5cb,0000000000000000000000000000000000000000..b56c0c66c6ea08d55fb3b1409f48296cf542bab6
mode 100644,000000..100644
--- /dev/null
@@@ -1,64 -1,0 +1,70 @@@
 +#!/usr/bin/python
 +import sys
 +Import ('env')
 +
 +sources = []
 +defs = []
 +incs = ''
 +
 +incs += '../blenkernel ../blenlib ../imbuf ../makesdna'
 +# incs += ' #/extern/freestyle/lib3ds #/extern/freestyle/swig'
 +incs += ' ' + env['BF_PYTHON_INC']
 +incs += ' ' + env['BF_LIB3DS_INC']
 +incs += ' ' + env['BF_PNG_INC']
 +
 +########################################################
 +#     folders sources 
 +########################################################
 +
 +#     system
 +prefix = 'intern/system'
 +system_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     image
 +prefix = 'intern/image'
 +image_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     geometry
 +prefix = 'intern/geometry'
 +geometry_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     scene_graph
 +prefix = 'intern/scene_graph'
 +scene_graph_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     winged_edge
 +prefix = 'intern/winged_edge'
 +winged_edge_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     view_map
 +prefix = 'intern/view_map'
 +view_map_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     stroke
 +prefix = 'intern/stroke'
 +stroke_sources = env.Glob(prefix + '/*.cpp')
 +
 +#     rendering
++prefix = 'intern/rendering'
++stroke_sources = env.Glob(prefix + '/GL*.cpp')
++
++if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw'):
++      stroke_sources = env.Glob(prefix + '/extgl.cpp')
++
 +#     app
 +
 +sources =     system_sources + image_sources + geometry_sources + scene_graph_sources + \
 +                      winged_edge_sources + view_map_sources + stroke_sources
 +#print sources
 +
 +env.BlenderLib (libname="bf_freestyle",
 +                              sources=sources,
 +                includes=Split(incs),
 +                defines=defs,
 +                libtype=['blender'],
 +                priority = [15] )
 +
 +########################################################
 +# SWIG
 +########################################################
 +#     swig
index d566060dfc7b7222744798f5ac12f2d5fdfc9a16,0000000000000000000000000000000000000000..016b159da5ca16a970eb12eaee49f44b4c0989c4
mode 100755,000000..100755
--- /dev/null
@@@ -1,467 -1,0 +1,467 @@@
-   float step=1.f/vertices.size();
 +
 +//
 +//  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/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 "../stroke/Stroke.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 Material *const* materials = ifs.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, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]);
 +      break;
 +    case IndexedFaceSet::TRIANGLE_FAN:
 +      RenderTriangleFan(vertices, normals, materials, texCoords, pvi, pni, pmi, pti, numVertexPerFace[fIndex]);
 +      break;
 +    case IndexedFaceSet::TRIANGLES:
 +      RenderTriangles(vertices, normals, 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 Material *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){
 +                              visitMaterial(*(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 Material *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){
 +                              visitMaterial(*(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 Material *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){
 +                              visitMaterial(*(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::visitMaterial(Material& 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::visitMaterial(const Material& 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);
 +} 
index 7525807da474e824d1b9322194a4e91cf0781f79,0000000000000000000000000000000000000000..8177f3b02db34465945a2d1c50d964a6fc965cb2
mode 100755,000000..100755
--- /dev/null
@@@ -1,495 -1,0 +1,534 @@@
- #include <qimage.h>
- #include <qfileinfo.h>
- #include <qgl.h>
- #include <qfile.h>
 +
 +//
 +//  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.
 +//
 +///////////////////////////////////////////////////////////////////////////////
 +
-   int i;
 +#include "GLStrokeRenderer.h"
 +
++//soc
++// #include <qimage.h>
++// #include <qfileinfo.h>
++// #include <qgl.h>
++// #include <qfile.h>
++#include "BLI_blenlib.h"
++#include "IMB_imbuf.h"
++#include "IMB_imbuf_types.h"
++#include "../system/StringUtils.h"
++
 +#ifdef WIN32
 +# include "extgl.h"
 +#endif // WIN32
 +
 +//#define glBlendEquation(x)
 +
 +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;
 +    // }
-   Stroke::MediumType strokeType = iStrokeRep->getMediumType();
-   int i;
++  //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)
 +    {
 +      glBlendEquation(GL_MAX);
 +    }
 +  else if(strokeType==Stroke::OPAQUE_MEDIUM)
 +    {
 +      glBlendEquation(GL_ADD);
 +      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 +    }
 +  else
 +    {
 +      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()); 
 +  //glBindTexture(GL_TEXTURE_2D, _textureManager.getPaperTextureIndex()); 
 +  
 +  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);
-   for(int i=0;i<size;++i){
++  //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()); 
 +  //glBindTexture(GL_TEXTURE_2D, _textureManager.getPaperTextureIndex()); 
 +  
 +  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::loadPapers ()
 +{
 +  unsigned size = _papertextures.size();
 +  _papertexname = new unsigned[size];
 +  GLuint *tmp = new GLuint[size];
 +  glGenTextures(size, tmp);
-   QString path;
++  for(unsigned i=0;i<size;++i){
 +    _papertexname[i] = tmp[i];
 +  }
 +  delete [] tmp;
 +
 +  // Papers textures
 +  cout << "Loading papers textures..." << endl;
 +
 +  for (unsigned i = 0; i < size; i++)
 +    preparePaper(_papertextures[i].c_str(), _papertexname[i]);
 +
 +  cout << "Done." << endl << endl;
 +}
 +
 +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;
-     if(QFile::exists(path)){
++  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();
-     prepareTextureLuminance((const char*)path.toAscii(), texId);
++    //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:
-     prepareTextureAlpha((const char*)path.toAscii(), texId);
++    //soc prepareTextureLuminance((const char*)path.toAscii(), texId);
++      prepareTextureLuminance(StringUtils::toAscii(path), texId);
 +    break;
 +  case Stroke::HUMID_MEDIUM:
 +  case Stroke::OPAQUE_MEDIUM:
 +  default:
-   const char * name = sname.c_str();
-   QImage qim(name);
-   QFileInfo fi(name);
-   QString filename = fi.fileName();
-   if (qim.isNull()) 
++    //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)
 +{
-   if (qim.depth()>8)
++  //soc const char * name = sname.c_str();
++      char * name = (char *) sname.c_str();
++      
++  //soc 
++  // QImage qim(name);
++  // QFileInfo fi(name);
++  // QString filename = fi.fileName();
++      ImBuf *qim = IMB_loadiffname(name, 0);
++      char filename[FILE_MAXFILE];
++      BLI_splitdirstring(name, filename);
++
++//soc  if (qim.isNull()) 
++      if( qim )
 +    {
 +      cerr << "  Error: unable to read \"" << name << "\"" << endl;
 +      return false;
 +    }
-       cerr<<"  Error: \""<< name <<"\" has "<<qim.depth()<<" bits/pixel"<<endl;
++  if( qim->depth > 8) //soc
 +    {
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, qim.width(), qim.height(), 0, 
-              GL_ALPHA, GL_UNSIGNED_BYTE, qim.bits()); 
-   cout << "  \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl;
++      cerr<<"  Error: \""<< name <<"\" 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);     
 +
-   const char * name = sname.c_str();
-   QImage qim(name);
-   QFileInfo fi(name);
-   QString filename = fi.fileName();
-   if (qim.isNull()) 
++  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 << "  \"" << StringUtils::toAscii(filename) << "\" loaded with "<< qim->depth << " bits per pixel" << endl;
++      
 +  return true;
 +
 +}
 +
 +bool 
 +GLTextureManager::prepareTextureLuminance (string sname, GLuint itexname)
 +{
-   if (qim.depth() > 8)
++  //soc const char * name = sname.c_str();
++      char * name = (char *) sname.c_str();
++      
++  //soc
++  // QImage qim(name);
++  // QFileInfo fi(name);
++  // QString filename = fi.fileName();
++      ImBuf *qim = IMB_loadiffname(name, 0);
++      char filename[FILE_MAXFILE];
++      BLI_splitdirstring(name, filename);
++      
++  if (qim) //soc
 +    {
 +      cerr << "  Error: unable to read \"" << name << "\"" << endl;
 +      return false;
 +    }
-       cerr<<"  Error: \""<<name<<"\" has "<<qim.depth()<<" bits/pixel"<<endl;
++  if (qim->depth > 8) //soc
 +    {
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, qim.width(), qim.height(), 0, 
-              GL_LUMINANCE, GL_UNSIGNED_BYTE, qim.bits());     
-   cout << "  \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl;
++      cerr<<"  Error: \""<<name<<"\" 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);     
 +
-   const char * name = sname.c_str();
-   QImage qim(name);
-   QFileInfo fi(name);
-   QString filename = fi.fileName();
-   if (qim.isNull()) 
++  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 << "  \"" << StringUtils::toAscii(filename) << "\" loaded with "<< qim->depth << " bits per pixel" << endl;
++      
 +  return true;
 +
 +}
 +
 +bool 
 +GLTextureManager::prepareTextureLuminanceAndAlpha (string sname, GLuint itexname)
 +{
-   if (qim.depth() > 8)
++  //soc const char * name = sname.c_str();
++      char * name = (char *) sname.c_str();
++      
++  //soc
++  // QImage qim(name);
++  // QFileInfo fi(name);
++  // QString filename = fi.fileName();
++      ImBuf *qim = IMB_loadiffname(name, 0);
++      char filename[FILE_MAXFILE];
++      BLI_splitdirstring(name, filename);
++
++  if (qim) //soc
 +    {
 +      cerr << "  Error: unable to read \"" << name << "\"" << endl;
 +      return false;
 +    }
-       cerr<<"  Error: \""<<name<<"\" has "<<qim.depth()<<" bits/pixel"<<endl;
++  if (qim->depth > 8) //soc
 +    {
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, qim.width(), qim.height(), 0, 
-              GL_LUMINANCE, GL_UNSIGNED_BYTE, qim.bits());     
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, qim.width(), qim.height(), 0, 
-              GL_ALPHA, GL_UNSIGNED_BYTE, qim.bits()); 
++      cerr<<"  Error: \""<<name<<"\" 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);     
 +                                                   
-   cout << "  \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl;                                                   
++  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
 +                                                       
-   QImage qim(name);
-   QFileInfo fi(name);
-   QString filename = fi.fileName();
-   if (qim.isNull()) 
++  //soc cout << "  \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl;                                             
++      cout << "  \"" << StringUtils::toAscii(filename) << "\" loaded with "<< qim->depth << " bits per pixel" << endl;
 +
 +  return true;
 +                                                           
 +}
 +
 +bool 
 +GLTextureManager::preparePaper (const char *name, GLuint itexname)
 +{
-   if (qim.depth()!=32)
++  //soc
++  // QImage qim(name);
++  // QFileInfo fi(name);
++  // QString filename = fi.fileName();
++      ImBuf *qim = IMB_loadiffname(name, 0);
++      char filename[FILE_MAXFILE];
++      BLI_splitdirstring((char *)name, filename);
++
++  if (qim) //soc 
 +    {
 +      cerr << "  Error: unable to read \"" << name << "\"" << endl;
 +      return false;
 +    }
-       cerr<<"  Error: \""<<name<<"\" has "<<qim.depth()<<" bits/pixel"<<endl;
++  if (qim->depth !=32) //soc
 +    {
-   QImage qim2=QGLWidget::convertToGLFormat( qim );
++      cerr<<"  Error: \""<<name<<"\" has "<<qim->depth<<" bits/pixel"<<endl; //soc
 +      return false;
 +    }
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, qim.width(), qim.height(), 0, 
-              GL_RGBA, GL_UNSIGNED_BYTE, qim2.bits()); 
-   cout << "  \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl;
++  //soc QImage qim2=QGLWidget::convertToGLFormat( qim );
 +
 +  glBindTexture(GL_TEXTURE_2D, itexname);
 +      
 +  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_MIN_FILTER,
 +                GL_LINEAR);     
 +
++  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, qim->x, qim->y, 0, 
++             GL_RGBA, GL_UNSIGNED_BYTE, qim->rect);   //soc: here qim->rect, not qim2->rect, used
 +
++  //cout << "  \"" << filename.toAscii().data() << "\" loaded with "<< qim.depth() << " bits per pixel" << endl;
++      cout << "  \"" << StringUtils::toAscii(filename) << "\" loaded with "<< qim->depth << " bits per pixel" << endl;
 +  return true;
 +}
 +
index 5e9ba2a5bf44573dd317b2929c3a284110edbed6,0000000000000000000000000000000000000000..f086f86e2cd04ff64fa226e31bf2e4e5b7ab47ac
mode 100755,000000..100755
--- /dev/null
@@@ -1,68 -1,0 +1,70 @@@
 +
 +//
 +//  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 "GLUtils.h"
 +
 +# ifdef WIN32
 +#  include <windows.h>
 +# endif
 +# ifdef __MACH__
 +#  include <OpenGL/gl.h>
 +# else
 +#  include <GL/gl.h>
 +# endif
 +#include <string.h>
 +
 +int isExtensionSupported(const char *extension)
 +{
 +  const GLubyte *extensions = NULL;
 +  const GLubyte *start;
 +  GLubyte *where, *terminator;
 +
 +  /* Extension names should not have spaces. */
 +  where = (GLubyte *) strchr(extension, ' ');
 +  if (where || *extension == '\0')
 +    return 0;
 +  extensions = glGetString(GL_EXTENSIONS);
 +  /* It takes a bit of care to be fool-proof about parsing the
 +     OpenGL extensions string. Don't be fooled by sub-strings,
 +     etc. */
 +  start = extensions;
 +  for (;;) {
 +    where = (GLubyte *) strstr((const char *) start, extension);
 +    if (!where)
 +      break;
 +    terminator = where + strlen(extension);
 +    if (where == start || *(where - 1) == ' ')
 +      if (*terminator == ' ' || *terminator == '\0')
 +        return 1;
 +    start = terminator;
 +  }
 +  return 0;
 +}
 +
 +void *glutils_extgl_GetProcAddress(const char *name)
 +{
 +#ifdef _WIN32
 +    void *t = wglGetProcAddress(name);
 +    return t;
++#else
++      return NULL;
 +#endif
 +}
 +
index ec73fc52ae46c70df49ada7eec82eb1ffac23293,0000000000000000000000000000000000000000..0cb9013ddcd58c39c0fb9e21d0f9f76b6ff91571
mode 100755,000000..100755
--- /dev/null
@@@ -1,292 -1,0 +1,292 @@@
- #include <pbuffer.h>
++#include "pbuffer.h"
 +
 +#include <memory.h>
 +
 +#define MAX_PFORMATS 256
 +#define MAX_ATTRIBS  32
 +#define PBUFFER_AS_TEXTURE 2048
 +
 +//************************************************************
 +// Implementation of PBuffer
 +//************************************************************
 +/*!
 + * Creates a PBuffer of size \p w by \p h, eith mode \p mode.
 + */
 +PBuffer::PBuffer(const unsigned int w,
 +               const unsigned int h,
 +               const int format) 
 +  : format_(format),
 +    sharedContext_(false),
 +    sharedLists_(false),
 +    display_(NULL),
 +    glxPbuffer_(0),
 +    glxContext_(0), 
 +    width_(w),
 +    height_(h)
 +{
 +}    
 +/*!
 + * Initialize the pbuffer. If \p shareContext is true, then the currently
 + * active context with be shared by the pbuffer, meaning for example that
 + * textures objects or display lists of the currently active GL context will
 + * be available to the pbuffer.  If you want it to be the case just for
 + * display lists, set \p sharedContext to false and \p shareLists to true.
 + * 
 + * This function is outside of the constructor for several reasons. First it
 + * might raise exceptions so it cannot be done in the constructor. Secondly,
 + * it is using the current context for sharing so you might want to create
 + * the pbuffer at a moment where this context is not yet active, and then
 + * initialise it once the context has been created and activated.
 + *
 + * Return false if creation failed.
 + */
 +bool
 +PBuffer::create(const bool shareContext, const bool shareLists)
 +{
 +  // Set display and screen
 +  Display *pDisplay     = glXGetCurrentDisplay();
 +  if (pDisplay == NULL)
 +  {
 +    pDisplay = XOpenDisplay(NULL);
 +  }
 +  int iScreen           = DefaultScreen(pDisplay);
 +  GLXContext glxContext = glXGetCurrentContext();
 +  
 +  GLXFBConfig *glxConfig;
 +  int iConfigCount;   
 +    
 +  sharedContext_ = shareContext;
 +  sharedLists_ = shareLists;
 +
 +  if (sharedContext_)
 +  {
 +    glxConfig = glXGetFBConfigs(pDisplay, iScreen, &iConfigCount);
 +    if (!glxConfig)
 +    {
 +//       "pbuffer creation error:  glXGetFBConfigs() failed"
 +      return false;
 +    }
 +  }  
 +  else
 +  {
 +    int iAttributes[2*MAX_ATTRIBS];
 +    int curAttrib = 0;
 +        
 +    memset(iAttributes, 0, 2*MAX_ATTRIBS*sizeof(int));        
 +            
 +    iAttributes[2*curAttrib  ] = GLX_DRAWABLE_TYPE;
 +    iAttributes[2*curAttrib+1] = GLX_PBUFFER_BIT;
 +    curAttrib++;
 +        
 +    if (format_ & ColorIndex)
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_RENDER_TYPE;
 +      iAttributes[2*curAttrib+1] = GLX_COLOR_INDEX_BIT;
 +      curAttrib++;
 +    }
 +    else
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_RENDER_TYPE;
 +      iAttributes[2*curAttrib+1] = GLX_RGBA_BIT;
 +      iAttributes[2*curAttrib  ] = GLX_ALPHA_SIZE;
 +      iAttributes[2*curAttrib+1] = 8;
 +      curAttrib++;
 +    }
 +        
 +    if (format_ & DoubleBuffer)
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_DOUBLEBUFFER;
 +      iAttributes[2*curAttrib+1] = true;
 +      curAttrib++;
 +    }
 +    else
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_DOUBLEBUFFER;
 +      iAttributes[2*curAttrib+1] = false;
 +      curAttrib++;
 +    }  
 +    if (format_ & DepthBuffer)
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_DEPTH_SIZE;
 +      iAttributes[2*curAttrib+1] = 1;
 +      curAttrib++;
 +    }
 +    else
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_DEPTH_SIZE;
 +      iAttributes[2*curAttrib+1] = 0;
 +      curAttrib++;
 +    }    
 +        
 +    if (format_ & StencilBuffer)
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_STENCIL_SIZE;
 +      iAttributes[2*curAttrib+1] = 1;
 +      curAttrib++;
 +    }
 +    else
 +    {
 +      iAttributes[2*curAttrib  ] = GLX_STENCIL_SIZE;
 +      iAttributes[2*curAttrib+1] = 0;
 +      curAttrib++;
 +    }
 +
 +    iAttributes[2*curAttrib  ] = None;
 +    
 +    glxConfig = glXChooseFBConfigSGIX(pDisplay, iScreen, iAttributes, &iConfigCount);
 +    if (!glxConfig)
 +    {
 +      // "pbuffer creation error:  glXChooseFBConfig() failed"
 +      return false;
 +    }
 +  }
 +   
 +  int attributes[5];
 +  int iCurAttrib = 0;
 +    
 +  memset(attributes, 0, 5*sizeof(int));
 +
 +  attributes[2*iCurAttrib  ] = GLX_LARGEST_PBUFFER;
 +  attributes[2*iCurAttrib+1] = true;
 +  iCurAttrib++;
 +
 +  attributes[2*iCurAttrib  ] = GLX_PRESERVED_CONTENTS;
 +  attributes[2*iCurAttrib+1] = true;
 +  iCurAttrib++;
 +    
 +  attributes[2*iCurAttrib  ] = None;
 +
 +  glxPbuffer_ = glXCreateGLXPbufferSGIX(pDisplay, glxConfig[0],
 +                                      width_, height_, attributes);
 +    
 +  if (!glxPbuffer_)
 +  {
 +    // "pbuffer creation error:  glXCreatePbuffer() failed"
 +    return false;
 +  }
 +    
 +  if (sharedContext_)
 +  {
 +    glxContext_ = glxContext;
 +  }
 +  else
 +  {
 +    if (format_ & ColorIndex)
 +    {
 +      if (sharedLists_)
 +      glxContext_ = glXCreateContextWithConfigSGIX(pDisplay,
 +                                                   glxConfig[0],
 +                                                   GLX_COLOR_INDEX_TYPE,
 +                                                   glxContext, true);
 +      else
 +      glxContext_ = glXCreateContextWithConfigSGIX(pDisplay,
 +                                                   glxConfig[0],
 +                                                   GLX_COLOR_INDEX_TYPE,
 +                                                   NULL, true);
 +    }
 +    else
 +    {
 +      if (sharedLists_)
 +      glxContext_ = glXCreateContextWithConfigSGIX(pDisplay,
 +                                                   glxConfig[0],
 +                                                   GLX_RGBA_TYPE,
 +                                                   glxContext, true);
 +      else
 +      glxContext_ = glXCreateContextWithConfigSGIX(pDisplay,
 +                                                   glxConfig[0],
 +                                                   GLX_RGBA_TYPE,
 +                                                   NULL, true);
 +    }
 +
 +    if (!glxConfig)
 +    {
 +      // "pbuffer creation error:  glXCreateNewContext() failed"
 +      return false;
 +    }
 +  }
 +
 +  display_ = pDisplay;
 +
 +  glXQueryGLXPbufferSGIX(display_, glxPbuffer_, GLX_WIDTH, &width_);
 +  glXQueryGLXPbufferSGIX(display_, glxPbuffer_, GLX_HEIGHT, &height_);
 +
 +  return true;
 +}
 +/*!
 + * Destroy the pbuffer
 + */
 +PBuffer::~PBuffer()
 +{
 +  if (glxPbuffer_)
 +  {
 +    glXDestroyGLXPbufferSGIX(display_, glxPbuffer_);        
 +  }
 +}
 +/*!
 + * Activate the pbuffer as the current GL context. All subsequents GL
 + * commands will now affect the pbuffer. If you want to push/pop the current
 + * OpenGL context use subclass PBufferEx instead.
 + *
 + * Return false if it failed.
 + */
 +bool
 +PBuffer::makeCurrent()
 +{
 +  return glXMakeCurrent(display_, glxPbuffer_, glxContext_);
 +}
 +/*!
 + * Return the width of the pbuffer
 + */
 +unsigned int
 +PBuffer::width() const
 +{
 +  return width_;
 +}
 +/*!
 + * Return the height of the pbuffer
 + */
 +unsigned int
 +PBuffer::height() const
 +{
 +  return height_;
 +}
 +//************************************************************
 +// Implementation of PBufferEx
 +//************************************************************
 +PBufferEx::PBufferEx(const unsigned int width,
 +                   const unsigned int height,
 +                   const int mode)
 +  : PBuffer(width, height, mode),
 +    oldDisplay_(NULL),
 +    glxOldDrawable_(0),
 +    glxOldContext_(0)
 +{
 +}
 +/*!
 + * Activate the pbuffer as the current GL context. All subsequents GL
 + * commands will now affect the pbuffer. Once you are done with you GL
 + * commands, you can call endCurrent() to restore the context that was active
 + * when you call makeCurrent().
 + *
 + * Return false if it failed.
 + */
 +bool
 +PBufferEx::makeCurrent()
 +{
 +  oldDisplay_ = glXGetCurrentDisplay();
 +  glxOldDrawable_ = glXGetCurrentDrawable();
 +  glxOldContext_ = glXGetCurrentContext();
 +  
 +  return PBuffer::makeCurrent();
 +}
 +/*!
 + * Restore the GL context that was active when makeCurrent() was called.
 + *
 + * Return false if it failed.
 + */
 +bool
 +PBufferEx::endCurrent()
 +{
 +  return glXMakeCurrent(oldDisplay_, glxOldDrawable_, glxOldContext_);
 +}
 +
index 7f11f461b1cddf8a56d856152f70fde143a44afd,0000000000000000000000000000000000000000..35fd24484b631663eb372f1b9655707b4a71590b
mode 100755,000000..100755
--- /dev/null
@@@ -1,77 -1,0 +1,75 @@@
- #ifndef WIN32
- #  ifdef __MACH__
 +#ifndef PBUFFERS_H
 +#define PBUFFERS_H
 +
- #  else
++# ifdef __MACH__
 +#    include <OpenGL/gl.h>
- #  endif
++# else
 +#    include <GL/gl.h>
 +#    include <GL/glx.h>
- #endif //WIN32
++# endif
 +
 +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 +// Interface of PBuffer
 +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 +class PBuffer
 +{
 +public:
 +  enum FormatOption
 +  {
 +    DoubleBuffer            = 0x0001,
 +    DepthBuffer             = 0x0002,
 +    Rgba                    = 0x0004,
 +    StencilBuffer           = 0x0020,
 +    SingleBuffer            = DoubleBuffer  << 16,
 +    NoDepthBuffer           = DepthBuffer   << 16,
 +    ColorIndex              = Rgba          << 16,
 +    NoStencilBuffer         = StencilBuffer << 16,
 +  };
 +     
 +  PBuffer(const unsigned int width,
 +        const unsigned int height,
 +        int format);
 +  bool create(const bool shareContext = false,
 +            const bool shareLists = false);
 +  virtual ~PBuffer();
 +  
 +  virtual bool makeCurrent();
 +  unsigned int width() const;
 +  unsigned int height() const;
 +protected:
 +  ///! Flags indicating the type of pbuffer.
 +  int          format_;
 +  ///! Flag indicating if the rendering context is shared with another context.
 +  bool         sharedContext_;
 +  //! Flag indicating if display lists should be shared between rendering
 +  // contexts.(If the rendering context is shared (default), then display
 +  // lists are automatically shared).
 +  bool         sharedLists_; 
 +  Display*     display_;
 +  GLXPbuffer   glxPbuffer_;
 +  GLXContext   glxContext_;    
 +  unsigned int width_;
 +  unsigned int height_;
 +};
 +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 +// Interface of PBufferEx
 +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 +/*!
 + * pbuffer layer to keep previous pbuffer states.
 + */
 +class PBufferEx : public PBuffer
 +{
 +public:
 +  PBufferEx(const unsigned int width,
 +          const unsigned int height,
 +          const int mode );
 +  virtual bool makeCurrent();
 +  bool endCurrent();
 +private:
 +  Display*    oldDisplay_;
 +  GLXDrawable glxOldDrawable_;
 +  GLXContext  glxOldContext_;
 +  int       vp[4];
 +};
 +
 +#endif //PBUFFERS_H
index 1afee94d962c1a4ee893fc53985722a7eb6e72cd,0000000000000000000000000000000000000000..556299e45c5e7ca96a88e5a5b25c275d18b85210
mode 100755,000000..100755
--- /dev/null
@@@ -1,56 -1,0 +1,70 @@@
- //soc
- #include "BKE_utildefines.h"
- #include "BLI_blenlib.h"
 +
 +//
 +//  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.
 +//
 +///////////////////////////////////////////////////////////////////////////////
 +
 +//soc #include <qfileinfo.h>
 +#include "FreestyleConfig.h"
 +#include "StringUtils.h"
 +
-       string res(cleaned);
 +namespace StringUtils {
 +
 +  void getPathName(const string& path, const string& base, vector<string>& pathnames) {
 +    string dir;
 +    unsigned size = path.size();
 +    pathnames.push_back(base);
 +    for (unsigned pos = 0, sep = path.find(Config::PATH_SEP, pos);
 +       pos < size;
 +       pos = sep + 1, sep = path.find(Config::PATH_SEP, pos)) {
 +      if (sep == (unsigned)string::npos)
 +              sep = size;
 +      dir = path.substr(pos, sep - pos);
 +
 +//soc      QFileInfo fi(dir.c_str());
 +//soc      string res = (const char*)fi.absoluteFilePath().toAscii();
 +      char cleaned[FILE_MAX];
 +      BLI_strncpy(cleaned, dir.c_str(), FILE_MAX);
 +      BLI_cleanup_file(NULL, cleaned);
++      string res = toAscii( string(cleaned) );
 +      
 +      if (!base.empty())
 +              res += Config::DIR_SEP + base;
 +      pathnames.push_back(res);
 +    }
 +  }
 +
++      string toAscii( const string &str ){
++              stringstream out("");
++              char s;
++              
++              for(uint i=0; i < str.size() ; i++){
++                      s =  ((char)(str.at(i) & 0x7F));
++                      out << s;
++              }       
++              
++              return out.str();
++      }
++      
++      const char* toAscii( const char *str ){
++              return toAscii(string(str)).c_str();
++      }
++
++  
++
 +} // end of namespace StringUtils
index 44adfc2b044a670fff2c08fabb478de2327f3114,0000000000000000000000000000000000000000..efc16953e48e63e383ee67a274dfaacaddc587e0
mode 100755,000000..100755
--- /dev/null
@@@ -1,51 -1,0 +1,58 @@@
 +//
 +//  Filename         : StringUtils.h
 +//  Author(s)        : Emmanuel Turquin
 +//  Purpose          : String utilities
 +//  Date of creation : 20/05/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  STRING_UTILS_H
 +# define STRING_UTILS_H
 +
 +# include <vector>
 +# include <string>
++# include <sstream>
 +# include "FreestyleConfig.h"
 +
++//soc
++#include "BKE_utildefines.h"
++#include "BLI_blenlib.h"
++
 +using namespace std;
 +
 +namespace StringUtils {
 +
 +  LIB_SYSTEM_EXPORT 
 +  void getPathName(const string& path, const string& base, vector<string>& pathnames);
++  string toAscii( const string &str );
++  const char* toAscii( const char *str );
 +
 +  // STL related
 +  struct ltstr{
 +  bool operator()(const char* s1, const char* s2) const{
 +    return strcmp(s1, s2) < 0;
 +  }
 +};
 +
 +} // end of namespace StringUtils
 +
 +#endif // STRING_UTILS_H
Simple merge
Simple merge
Simple merge
Simple merge