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
|
#include "../core/je_configuration.h"
#if defined(jin_graphics)
#include <stdlib.h>
#include "../math/je_matrix.h"
#include "shader/je_shader.h"
#include "je_graphic.h"
namespace JinEngine
{
namespace Graphics
{
Graphic::Graphic(int w, int h)
: mTexture(0)
, mSize(w, h)
{
mTexture = gl.genTexture();
}
Graphic::Graphic(const Bitmap* bitmap)
: mTexture(0)
{
mSize.w = bitmap->getWidth();
mSize.h = bitmap->getHeight();
const Color* pixels = bitmap->getPixels();
mTexture = gl.genTexture();
gl.bindTexture(mTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl.texImage(GL_RGBA8, mSize.w, mSize.h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
gl.bindTexture(0);
}
Graphic::~Graphic()
{
glDeleteTextures(1, &mTexture);
}
//void Graphic::setFilter(GLint min, GLint max)
//{
// glTexParameteri(GL_)
//}
} // namespace Graphics
} // namespace JinEngine
#endif // defined(jin_graphics)
|