1 /**
2  * projectM -- Milkdrop-esque visualisation SDK
3  * Copyright (C)2003-2007 projectM Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  * See 'LICENSE.txt' included within this release
19  *
20  */
21 /**
22  * $Id: FBO.hpp,v 1.1.1.1 2005/12/23 18:05:00 psperl Exp $
23  *
24  * Opaque render target
25  *
26  */
27 
28 #ifndef _RENDERTARGET_H
29 #define _RENDERTARGET_H
30 
31 #ifdef USE_FBO
32 #ifdef USE_NATIVE_GLEW
33 #include "glew.h"
34 #else
35 #include <GL/glew.h>
36 #endif
37 #endif
38 
39 #ifdef MACOS
40 #include <OpenGL/gl.h>
41 #include <AGL/agl.h>
42 #endif /** MACOS */
43 
44 #ifdef WIN32
45 #include <windows.h>
46 #endif /** WIN32 */
47 
48 #ifdef LINUX
49 #ifdef USE_GLES1
50 #include <GLES/gl.h>
51 #else
52 #include <GL/gl.h>
53 #include <GL/glx.h>
54 #endif
55 #endif
56 
57 typedef enum { SCALE_NEAREST, SCALE_MAGNIFY, SCALE_MINIFY } TextureScale;
58 
59 class RenderTarget {
60 
61 
62 public:
63     /** Texture size */
64     int texsize;
65 
66   int useFBO;
67   int renderToTexture;
68 
69   ~RenderTarget();
70 
71   RenderTarget( int texsize, int width, int height );
72   void lock();
73   void unlock();
74   GLuint initRenderToTexture();
75   int nearestPower2( int value, TextureScale scaleRule );
76   void fallbackRescale(int width, int height);
77 
78     /** Opaque pbuffer context and pbuffer */
79 /*
80 #ifdef MACOS
81     void *origContext;
82     void *pbufferContext;
83     void *pbuffer;
84 #endif
85 */
86     /** Render target texture ID for non-pbuffer systems */
87     GLuint textureID[3];
88 #ifdef USE_FBO
89     GLuint fbuffer[2];
90     GLuint depthb[2];
91 #endif
92   };
93 
94 
95 
96 #endif /** !_RENDERTARGET_H */
97