Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TOFFLINEGL_INCLUDED
Toshihiro Shimizu 890ddd
#define TOFFLINEGL_INCLUDED
Toshihiro Shimizu 890ddd
Shinya Kitaoka 262a92
#include <memory></memory>
Shinya Kitaoka 262a92
Toshihiro Shimizu 890ddd
#include "tgl.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TVRENDER_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TVectorRenderData;
Toshihiro Shimizu 890ddd
class TVectorImageP;
Toshihiro Shimizu 890ddd
class TRasterImageP;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TGLContextManager {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  virtual void store()   = 0;
Shinya Kitaoka 120a6e
  virtual void restore() = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TOfflineGL {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  class Imp {
Shinya Kitaoka 120a6e
  protected:
Shinya Kitaoka 120a6e
    int m_lx, m_ly;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    Imp(int lx, int ly) : m_lx(lx), m_ly(ly) {}
Shinya Kitaoka 120a6e
    virtual ~Imp(){};
Shinya Kitaoka 120a6e
    virtual void makeCurrent() = 0;
Shinya Kitaoka 120a6e
    virtual void doneCurrent() = 0;  // Da implementare in Imp
Shinya Kitaoka 120a6e
    virtual void createContext(TDimension rasterSize,
Shinya Kitaoka 120a6e
                               std::shared_ptr<imp> shared) = 0;</imp>
Shinya Kitaoka 120a6e
    virtual void getRaster(TRaster32P)                      = 0;
Shinya Kitaoka 120a6e
    virtual int getLx() const { return m_lx; }
Shinya Kitaoka 120a6e
    virtual int getLy() const { return m_ly; }
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
  typedef std::shared_ptr<imp> ImpGenerator(const TDimension &dim,</imp>
Shinya Kitaoka 120a6e
                                            std::shared_ptr<imp> shared);</imp>
Shinya Kitaoka 120a6e
  static ImpGenerator *defineImpGenerator(ImpGenerator *impGenerator);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TOfflineGL(TDimension dim, const TOfflineGL *shared = 0);
Shinya Kitaoka 120a6e
  TOfflineGL(const TRaster32P &raster, const TOfflineGL *shared = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ~TOfflineGL();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void makeCurrent();
Shinya Kitaoka 120a6e
  void doneCurrent();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static void setContextManager(TGLContextManager *contextManager);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void initMatrix();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void clear(TPixel32 color);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void draw(TVectorImageP image, const TVectorRenderData &rd,
Shinya Kitaoka 120a6e
            bool doInitMatrix = false);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void draw(TRasterImageP image, const TAffine &aff, bool doInitMatrix = false);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void flush();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRaster32P getRaster();  // Ritorna il raster copiandolo dal buffer offline
Shinya Kitaoka 120a6e
  void getRaster(TRaster32P raster);
Shinya Kitaoka 120a6e
  void getRaster(TRasterP raster);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getLx() const;
Shinya Kitaoka 120a6e
  int getLy() const;
Shinya Kitaoka 120a6e
  TDimension getSize() const { return TDimension(getLx(), getLy()); };
Shinya Kitaoka 120a6e
  TRect getBounds() const { return TRect(0, 0, getLx() - 1, getLy() - 1); };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static TOfflineGL *getStock(TDimension dim);
Shinya Kitaoka 120a6e
  // si usa cosi': TOfflineGL *ogl = TOfflineGL::getStock(d);
Shinya Kitaoka 120a6e
  // non bisogna liberare ogl
Shinya Kitaoka 120a6e
  std::shared_ptr<imp> m_imp;</imp>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TOfflineGL(const TOfflineGL &);
Shinya Kitaoka 120a6e
  TOfflineGL &operator=(const TOfflineGL &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif