2006-11-08 19:10:07 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2007-02-05 19:57:05 +00:00
|
|
|
Copyright (C) 2006-2007 Rivo Laks <rivolaks@hot.ee>
|
2006-11-08 19:10:07 +00:00
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_GLUTILS_H
|
|
|
|
#define KWIN_GLUTILS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
2007-02-13 23:28:36 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2006-11-08 19:10:07 +00:00
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glx.h>
|
2007-02-13 23:28:36 +00:00
|
|
|
#endif
|
2007-02-05 19:57:05 +00:00
|
|
|
|
|
|
|
#include "glutils_funcs.h"
|
|
|
|
|
2006-11-08 19:10:07 +00:00
|
|
|
|
2007-02-05 18:11:15 +00:00
|
|
|
template< class K, class V > class QHash;
|
|
|
|
|
2006-11-08 19:10:07 +00:00
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// Initializes GLX function pointers
|
|
|
|
void initGLX();
|
|
|
|
// Initializes OpenGL stuff. This includes resolving function pointers as
|
|
|
|
// well as checking for GL version and extensions
|
|
|
|
// Note that GL context has to be created by the time this function is called
|
|
|
|
void initGL();
|
|
|
|
|
|
|
|
|
|
|
|
// Number of supported texture units
|
|
|
|
extern int glTextureUnitsCount;
|
|
|
|
|
|
|
|
|
|
|
|
bool hasGLVersion(int major, int minor, int release = 0);
|
2006-11-14 11:41:52 +00:00
|
|
|
bool hasGLXVersion(int major, int minor, int release = 0);
|
2006-11-14 11:52:20 +00:00
|
|
|
// use for both OpenGL and GLX extensions
|
2006-11-08 19:10:07 +00:00
|
|
|
bool hasGLExtension(const QString& extension);
|
|
|
|
|
2007-01-24 21:35:58 +00:00
|
|
|
inline bool isPowerOfTwo( int x ) { return (( x & ( x - 1 )) == 0 ); }
|
2006-11-08 19:10:07 +00:00
|
|
|
|
2007-02-13 23:28:36 +00:00
|
|
|
#ifdef HAVE_OPENGL
|
2007-02-05 18:11:15 +00:00
|
|
|
|
|
|
|
class GLShader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLShader(const QString& vertexfile, const QString& fragmentfile);
|
|
|
|
|
|
|
|
bool isValid() const { return mValid; }
|
|
|
|
void bind();
|
|
|
|
void unbind();
|
|
|
|
|
|
|
|
int uniformLocation(const QString& name);
|
|
|
|
bool setUniform(const QString& name, float value);
|
|
|
|
bool setUniform(const QString& name, int value);
|
|
|
|
int attributeLocation(const QString& name);
|
|
|
|
bool setAttribute(const QString& name, float value);
|
|
|
|
|
|
|
|
|
2007-03-21 16:17:19 +00:00
|
|
|
static void initStatic();
|
|
|
|
static bool fragmentShaderSupported() { return mFragmentShaderSupported; }
|
|
|
|
static bool vertexShaderSupported() { return mVertexShaderSupported; }
|
|
|
|
|
|
|
|
|
2007-02-05 18:11:15 +00:00
|
|
|
protected:
|
|
|
|
bool loadFromFiles(const QString& vertexfile, const QString& fragmentfile);
|
|
|
|
bool load(const QString& vertexsource, const QString& fragmentsource);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned int mProgram;
|
|
|
|
bool mValid;
|
|
|
|
QHash< QString, int >* mVariableLocations;
|
2007-03-21 16:17:19 +00:00
|
|
|
static bool mFragmentShaderSupported;
|
|
|
|
static bool mVertexShaderSupported;
|
2007-02-05 18:11:15 +00:00
|
|
|
};
|
|
|
|
|
2007-02-13 23:28:36 +00:00
|
|
|
#endif
|
|
|
|
|
2006-11-08 19:10:07 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|