#ifndef PBUFFERS_H
#define PBUFFERS_H

#define MAX_PFORMATS 256
#define MAX_ATTRIBS  32

#ifdef _WIN32
#  include <windows.h>
#else
#  include <GL/glx.h>
#endif

#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>

#ifdef _WIN32
#  include <GL/wglext.h>
#else
#  include <GL/glxext.h>
#endif

class PBuffer
{
private:
    unsigned int mode;      // Flags indicating the type of pbuffer.
    bool         sharedctx; // Flag indicating if the rendering context is shared with another context.
    bool         sharedlists; // Flag indicating if display lists should be shared between rendering contexts.
                              // (If the rendering context is shared (default), then display lists are automatically shared).
#ifdef _WIN32
    HDC          myDC;      // Handle to a device context.
    HGLRC        myGLctx;   // Handle to a GL context.
    HPBUFFERARB  buffer;    // Handle to a pbuffer.
#else
    Display *m_pDisplay;
    GLXPbuffer m_glxPbuffer;
    GLXContext m_glxContext;
#endif
    
    int          width;
    int          height;
public:
    PBuffer( int width, int height, unsigned int mode );
    ~PBuffer();
    void HandleModeSwitch();
    void MakeCurrent();
    void Initialize(bool sharecontexts = true, bool sharelists = false);

	int GetWidth()
	{ return width; }

	int GetHeight()
	{ return height; }
};

/*#else

class PBuffer
{
    private:
        bool m_bSharedContext;
        bool m_bSharedLists;

        unsigned int m_uiWidth;
        unsigned int m_uiHeight;
        unsigned int m_uiMode;
    public:
        PBuffer(int iWidth, int iHeight, unsigned int uiMode);
        ~PBuffer();
	
        void HandleModeSwitch();
        void MakeCurrent();
        void Initialize(bool bShareContexts = true, bool bShareLists = false);
	
        int GetWidth()
        { return m_uiWidth; }

        int GetHeight()
        { return m_uiHeight; }
};

#endif*/

#endif
