attempt to load texture using sfml-graphics; not building on linux
This commit is contained in:
parent
8d2a03c4c1
commit
d4d2793ecf
BIN
assets/fs/textures/lava.jpg
Normal file
BIN
assets/fs/textures/lava.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
@ -30,6 +30,16 @@ static const float overlay_hex_attributes[][3] = {
|
|||||||
static const GLushort overlay_hex_indices[] = {
|
static const GLushort overlay_hex_indices[] = {
|
||||||
0, 1, 2, 3, 4, 5, 6, 1
|
0, 1, 2, 3, 4, 5, 6, 1
|
||||||
};
|
};
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
float pos[3];
|
||||||
|
float tex_coord[2];
|
||||||
|
} tex_quad_attributes[] = {
|
||||||
|
{{0.5, 0.5, 0.0}, {1.0, 1.0}},
|
||||||
|
{{-0.5, 0.5, 0.0}, {0.0, 1.0}},
|
||||||
|
{{-0.5, -0.5, 0.0}, {0.0, 0.0}},
|
||||||
|
{{0.5, -0.5, 0.0}, {1.0, 0.0}}
|
||||||
|
};
|
||||||
|
|
||||||
static bool load_file(const char *fname, WFObj::Buffer & buff)
|
static bool load_file(const char *fname, WFObj::Buffer & buff)
|
||||||
{
|
{
|
||||||
@ -155,6 +165,12 @@ bool Client::initgl()
|
|||||||
cerr << "Error creating overlay hex indices buffer" << endl;
|
cerr << "Error creating overlay hex indices buffer" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!m_tex_quad_attributes.create(GL_ARRAY_BUFFER, GL_STATIC_DRAW,
|
||||||
|
tex_quad_attributes, sizeof(tex_quad_attributes)))
|
||||||
|
{
|
||||||
|
cerr << "Error creating tex quad attribute buffer" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const double sky_dist = 4500;
|
const double sky_dist = 4500;
|
||||||
vector<GLfloat> sky_attributes((NUM_SKY_STEPS + 1) * 2 * (3 * 3));
|
vector<GLfloat> sky_attributes((NUM_SKY_STEPS + 1) * 2 * (3 * 3));
|
||||||
for (int i = 0, idx = 0; i <= NUM_SKY_STEPS; i++)
|
for (int i = 0, idx = 0; i <= NUM_SKY_STEPS; i++)
|
||||||
@ -182,6 +198,19 @@ bool Client::initgl()
|
|||||||
cerr << "Error creating sky attribute buffer" << endl;
|
cerr << "Error creating sky attribute buffer" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
unsigned int lava_texture_length;
|
||||||
|
const uint8_t *lava_texture = CFS.get_file("assets/textures/lava.jpg",
|
||||||
|
&lava_texture_length);
|
||||||
|
if (lava_texture == NULL)
|
||||||
|
{
|
||||||
|
cerr << "Error loading lava texture" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!m_lava_texture.loadFromMemory(lava_texture, lava_texture_length))
|
||||||
|
{
|
||||||
|
cerr << "Error creating lava texture" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
m_obj_program.use();
|
m_obj_program.use();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#define CLIENT_H
|
#define CLIENT_H
|
||||||
|
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
|
#include <SFML/Graphics/Texture.hpp>
|
||||||
#include "refptr.h"
|
#include "refptr.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
@ -45,8 +46,10 @@ class Client
|
|||||||
GLBuffer m_overlay_hex_attributes;
|
GLBuffer m_overlay_hex_attributes;
|
||||||
GLBuffer m_overlay_hex_indices;
|
GLBuffer m_overlay_hex_indices;
|
||||||
GLBuffer m_sky_attributes;
|
GLBuffer m_sky_attributes;
|
||||||
|
GLBuffer m_tex_quad_attributes;
|
||||||
refptr<Network> m_net_client;
|
refptr<Network> m_net_client;
|
||||||
bool client_has_focus;
|
bool client_has_focus;
|
||||||
|
sf::Texture m_lava_texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user