-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexture.cpp
More file actions
40 lines (37 loc) · 1.04 KB
/
texture.cpp
File metadata and controls
40 lines (37 loc) · 1.04 KB
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
/*
* texture.cpp
* Main texture file
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <clement@decoodt.eu> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Clement Decoodt
* ----------------------------------------------------------------------------
*/
#include <GL/gl.h>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include "texture.hpp"
namespace texture {
void Texture::open() {
std::ifstream file;
file.open(filename.c_str());
file >> magicNum;
std::string dummy;
std::getline(file,dummy);
std::getline(file,dummy);
file >> width >> height;
std::getline(file,dummy);
std::getline(file,dummy);
size_t size = width * height * 3;
image = new unsigned char[size];
int tempInt;
for(size_t i = 0; i < size; i++) {
file >> tempInt;
image[i] = tempInt;
}
file.close();
}
}