-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTexture.h
executable file
·61 lines (52 loc) · 1.52 KB
/
Texture.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
61
//
// Texture.h
// RealtimeRending
//
// Created by Philipp Lensing on 24.10.14.
// Copyright (c) 2014 Philipp Lensing. All rights reserved.
//
#ifndef __RealtimeRending__Texture__
#define __RealtimeRending__Texture__
#include <iostream>
#include <map>
#ifdef WIN32
#include <GL/glew.h>
#include <glfw/glfw3.h>
#else
#define GLFW_INCLUDE_GLCOREARB
#define GLFW_INCLUDE_GLEXT
#include <glfw/glfw3.h>
#endif
class RGBImage;
class Texture
{
public:
Texture();
Texture(unsigned int width, unsigned int height, unsigned char* data);
Texture(const char* Filename );
~Texture();
bool load(const char* Filename);
bool create(unsigned int width, unsigned int height, unsigned char* data);
void activate(int slot=0) const;
void deactivate() const;
bool isValid() const;
const RGBImage* getRGBImage() const;
static Texture* defaultTex();
static const Texture* LoadShared(const char* Filename);
static void ReleaseShared( const Texture* pTex );
protected:
unsigned char* LoadBMP( const char* Filename, unsigned int& width, unsigned int& height );
RGBImage* createImage( unsigned char* Data, unsigned int width, unsigned int height );
GLuint m_TextureID;
RGBImage* m_pImage;
mutable int CurrentTextureUnit;
static Texture* pDefaultTex;
struct TexEntry
{
int RefCount;
const Texture* pTex;
};
typedef std::map<std::string, TexEntry> SharedTexMap;
static SharedTexMap SharedTextures;
};
#endif /* defined(__RealtimeRending__Texture__) */