attempt to load texture using sfml-graphics; not building on linux

This commit is contained in:
Josh Holtrop 2012-09-20 00:49:17 -04:00
parent 8d2a03c4c1
commit d4d2793ecf
3 changed files with 32 additions and 0 deletions

BIN
assets/fs/textures/lava.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -30,6 +30,16 @@ static const float overlay_hex_attributes[][3] = {
static const GLushort overlay_hex_indices[] = {
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)
{
@ -155,6 +165,12 @@ bool Client::initgl()
cerr << "Error creating overlay hex indices buffer" << endl;
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;
vector<GLfloat> sky_attributes((NUM_SKY_STEPS + 1) * 2 * (3 * 3));
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;
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();
return true;
}

View File

@ -3,6 +3,7 @@
#define CLIENT_H
#include <SFML/Window.hpp>
#include <SFML/Graphics/Texture.hpp>
#include "refptr.h"
#include "Map.h"
#include "Player.h"
@ -45,8 +46,10 @@ class Client
GLBuffer m_overlay_hex_attributes;
GLBuffer m_overlay_hex_indices;
GLBuffer m_sky_attributes;
GLBuffer m_tex_quad_attributes;
refptr<Network> m_net_client;
bool client_has_focus;
sf::Texture m_lava_texture;
};
#endif