-
Notifications
You must be signed in to change notification settings - Fork 5
/
texture.cpp
executable file
·56 lines (47 loc) · 1.1 KB
/
texture.cpp
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
/******************************************************
g-Matrix3D Neo Engine
Copyright (c)2003 Kim Seong Wan (kaswan, Â𻧱ͽÅ)
E-mail: [email protected]
http://www.g-matrix.pe.kr
*******************************************************/
#include "texture.h"
#include "bmp.h"
int CTexture::Load(char * name)
{
this->pTex = LoadBMP(name, &TextureWidth, &TextureHeight);
return 0;
}
int CTexture::Create(int width, int height)
{
this->pTex = new BYTE[width * height * 4];
TextureWidth = width;
TextureHeight = height;
int WidthBytes = width * 4;
BYTE *pOffset = pTex;
BYTE color;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
//0x001F blue
//0x03E0 green
//0x7C00 red
if ((i % 64) < 32)
{
if ((j % 64) < 32) color = 255;
else color = 100;
}
else
{
if ((j % 64) < 32) color = 100;
else color = 255;
}
*(pOffset + j*4 + 0) = color;
*(pOffset + j*4 + 1) = color;
*(pOffset + j*4 + 2) = color;
*(pOffset + j*4 + 3) = 255;
}
pOffset += WidthBytes;
}
return 0;
}