MythTV  master
gltexture.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /* ============================================================
3  * File : gltexture.h
4  * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
5  * Date : 2006-07-24
6  * Description :
7  *
8  * Copyright 2004-2006 Renchi Raju, Daniel Kristjansson
9  *
10  * This program is free software; you can redistribute it
11  * and/or modify it under the terms of the GNU General
12  * Public License as published bythe Free Software Foundation;
13  * either version 2, or (at your option)
14  * any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #ifndef _GL_TEXTURE_H_
24 #define _GL_TEXTURE_H_
25 #ifdef USING_OPENGL
26 
27 #include <QtOpenGL>
28 #include <QSize>
29 
30 // MythGallery headers
31 #include "galleryutil.h"
32 
33 class ThumbItem;
34 
35 class GLTexture
36 {
37  public:
38  GLTexture() : tex(0), angle(0), item(nullptr),
39  width(512), height(512), cx(1.0f), cy(1.0f) {}
40  ~GLTexture() { Deinit(); }
41 
42  void Init(const QImage &image);
43  void Deinit(void);
44 
45  void Bind(void);
46  void MakeQuad(float alpha = 1.0f, float scale = 1.0f);
47  void SwapWidthHeight(void)
48  { int tmp = width; width = height; height = tmp; }
49 
50  // Sets
51  void SetItem(ThumbItem*, const QSize &sz);
52  void SetSize(const QSize &sz)
53  { width = sz.width(); height = sz.height(); }
54  void SetScale(float x, float y)
55  { cx = x; cy = y; }
56  void ScaleTo(const QSize &dest, ScaleMax scaleMax);
57  void SetAngle(int newangle) { angle = newangle; }
58 
59  // Gets
60  QSize GetSize(void) const { return QSize(width, height); }
61  uint GetPixelCount(void) const { return width * height; }
62  float GetTextureX(void) const { return cx; }
63  float GetTextureY(void) const { return cy; }
64  int GetAngle(void) const { return angle; }
65  QString GetDescription(const QString &status) const;
66 
67  private:
68  GLuint tex;
69  int angle;
71  int width;
72  int height;
73  float cx;
74  float cy;
75 };
76 
77 #endif // USING_OPENGL
78 #endif // _GL_TEXTURE_H_
float GetTextureY(void) const
Definition: gltexture.h:63
void SetAngle(int newangle)
Definition: gltexture.h:57
void SetItem(ThumbItem *, const QSize &sz)
Definition: gltexture.cpp:98
uint GetPixelCount(void) const
Definition: gltexture.h:61
float cx
Definition: gltexture.h:73
unsigned int uint
Definition: compat.h:140
GLuint tex
Definition: gltexture.h:68
int width
Definition: gltexture.h:71
float GetTextureX(void) const
Definition: gltexture.h:62
void Bind(void)
Definition: gltexture.cpp:58
static guint32 * tmp
Definition: goom_core.c:35
int angle
Definition: gltexture.h:69
int GetAngle(void) const
Definition: gltexture.h:64
void MakeQuad(float alpha=1.0f, float scale=1.0f)
Definition: gltexture.cpp:66
int height
Definition: gltexture.h:72
ThumbItem * item
Definition: gltexture.h:70
void SetScale(float x, float y)
Definition: gltexture.h:54
float cy
Definition: gltexture.h:74
ScaleMax
Definition: galleryutil.h:28
GLTexture()
Definition: gltexture.h:38
void Deinit(void)
Delete the texture.
Definition: gltexture.cpp:52
void SetSize(const QSize &sz)
Definition: gltexture.h:52
QString GetDescription(const QString &status) const
Definition: gltexture.cpp:111
QSize GetSize(void) const
Definition: gltexture.h:60
void ScaleTo(const QSize &dest, ScaleMax scaleMax)
Definition: gltexture.cpp:87
~GLTexture()
Definition: gltexture.h:40
void SwapWidthHeight(void)
Definition: gltexture.h:47
void Init(const QImage &image)
Create the texture initialized with QImage.
Definition: gltexture.cpp:34