-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTextureCanvas.h
61 lines (50 loc) · 1.32 KB
/
TextureCanvas.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef TXCANVAS
#define TXCANVAS
#include <vector>
#include <iostream>
//#include <GL/glut.h>
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL/QGLWidget>
#include "BasicTypes.h"
using namespace std;
class textureTile{
public:
int width;
int height;
GLuint tex_id;
vector< unsigned char > data;
textureTile(int w, int h) {
width = w;
height = h;
}
};
class TextureCanvas{
public:
TextureCanvas();
TextureCanvas(vector<color>& pixels, int width, bool raggedEdge = false);
~TextureCanvas();
void init(int w = 1, bool raggedEdge = false);
void display();
static int const maxSaneWidth = 4000;
bool ragged;
int getMaxSize();
private:
int max_size;
int checkForDisplayDriver();
void loadPixelsToCard(vector<color>& pixels, int w);
void createEmptyTiles(int canvas_width, int canvas_height, int max_size);
void createDisplayList();
void drawTextureSquare();
point2D grid_position(int i, int width, int height, int max_size );
GLuint loadTexture(textureTile& tile);
point get_position(int index);
void paint_square(point position, color c);
void textureFreeRender();
bool useTextures;
GLuint displayList;
int width;
int height;
vector< vector< textureTile > > canvas;
vector<color> colors;
};
#endif