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() = default;
39  ~GLTexture() { Deinit(); }
40 
41  void Init(const QImage &image);
42  void Deinit(void);
43 
44  void Bind(void);
45  void MakeQuad(float alpha = 1.0F, float scale = 1.0F);
46  void SwapWidthHeight(void)
47  { int tmp = width; width = height; height = tmp; }
48 
49  // Sets
50  void SetItem(ThumbItem*, const QSize &sz);
51  void SetSize(const QSize &sz)
52  { width = sz.width(); height = sz.height(); }
53  void SetScale(float x, float y)
54  { cx = x; cy = y; }
55  void ScaleTo(const QSize &dest, ScaleMax scaleMax);
56  void SetAngle(int newangle) { angle = newangle; }
57 
58  // Gets
59  QSize GetSize(void) const { return QSize(width, height); }
60  uint GetPixelCount(void) const { return width * height; }
61  float GetTextureX(void) const { return cx; }
62  float GetTextureY(void) const { return cy; }
63  int GetAngle(void) const { return angle; }
64  QString GetDescription(const QString &status) const;
65 
66  private:
67  GLuint tex {0};
68  int angle {0};
69  ThumbItem *item {nullptr};
70  int width {512};
71  int height {512};
72  float cx {1.0F};
73  float cy {1.0F};
74 };
75 
76 #endif // USING_OPENGL
77 #endif // _GL_TEXTURE_H_
float GetTextureY(void) const
Definition: gltexture.h:62
void SetAngle(int newangle)
Definition: gltexture.h:56
void SetItem(ThumbItem *, const QSize &sz)
Definition: gltexture.cpp:98
uint GetPixelCount(void) const
Definition: gltexture.h:60
float cx
Definition: gltexture.h:72
unsigned int uint
Definition: compat.h:140
GLuint tex
Definition: gltexture.h:67
int width
Definition: gltexture.h:70
float GetTextureX(void) const
Definition: gltexture.h:61
GLTexture()=default
void Bind(void)
Definition: gltexture.cpp:58
static guint32 * tmp
Definition: goom_core.c:35
void MakeQuad(float alpha=1.0F, float scale=1.0F)
Definition: gltexture.cpp:66
int angle
Definition: gltexture.h:68
int GetAngle(void) const
Definition: gltexture.h:63
int height
Definition: gltexture.h:71
ThumbItem * item
Definition: gltexture.h:69
void SetScale(float x, float y)
Definition: gltexture.h:53
float cy
Definition: gltexture.h:73
ScaleMax
Definition: galleryutil.h:28
void Deinit(void)
Delete the texture.
Definition: gltexture.cpp:52
void SetSize(const QSize &sz)
Definition: gltexture.h:51
QString GetDescription(const QString &status) const
Definition: gltexture.cpp:111
QSize GetSize(void) const
Definition: gltexture.h:59
void ScaleTo(const QSize &dest, ScaleMax scaleMax)
Definition: gltexture.cpp:87
~GLTexture()
Definition: gltexture.h:39
void SwapWidthHeight(void)
Definition: gltexture.h:46
void Init(const QImage &image)
Create the texture initialized with QImage.
Definition: gltexture.cpp:34