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
|
/* ----------------------------------------------------------------------------
* simplegame.cpp
*
* Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
* MIT License, see LICENSE file for more details.
* ----------------------------------------------------------------------------
*/
#include <yage.cpp>
#include <iostream>
using std::cout;
using namespace yage;
int main()
{
Window window;
GlslProgram program;
window.create("Simple Game", 800, 640);
SpriteBatch sp;
program.compileShaders(
"/home/yannherklotz/Github/YAGE/resources/defaultshader.vert",
"/home/yannherklotz/Github/YAGE/resources/defaultshader.frag");
program.addAttribute("vertex_position");
program.addAttribute("vertex_colour");
program.addAttribute("vertex_uv");
program.linkShaders();
Texture fountain =
ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/"
"resources/dngn_blood_fountain.png");
cout << "texture: " << fountain.width << ", " << fountain.height << '\n';
Camera2D camera(800, 640);
while (!window.shouldClose()) {
window.clearBuffer();
program.use();
camera.update(program);
glActiveTexture(GL_TEXTURE0);
GLint texture_location = program.getUniformLocation("texture_sampler");
glUniform1i(texture_location, 0);
sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, fountain.id, Colour(), 0);
sp.render();
glBindTexture(GL_TEXTURE_2D, 0);
program.unuse();
window.pollEvents();
window.swapBuffer();
}
}
|