diff options
Diffstat (limited to 'src/components.cpp')
-rw-r--r-- | src/components.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/components.cpp b/src/components.cpp index e85883e..f95f46f 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -59,11 +59,11 @@ void PhysicsSystem::update(entityx::EntityManager &en, entityx::EventManager &ev }); } -GLuint RenderSystem::loadTexture(const std::string& file) +Texture RenderSystem::loadTexture(const std::string& file) { loadTexString = file; - loadTexResult = 0xFFFF; - while (loadTexResult == 0xFFFF) + loadTexResult = Texture(); + while (loadTexResult.isEmpty()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); return loadTexResult; } @@ -73,7 +73,7 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, (void)ev; if (!loadTexString.empty()) { - loadTexResult = Texture::loadTexture(loadTexString); + loadTexResult = Texture(loadTexString); loadTexString.clear(); } @@ -99,17 +99,16 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, 1.0, 0.0}; for (auto &S : sprite.sprite) { - float width = HLINES(S.first.size.x); - float height = HLINES(S.first.size.y); + const auto& size = S.first.tex.getDim() * game::HLINE; vec2 loc = vec2(pos.x + S.first.offset.x, pos.y + S.first.offset.y); GLfloat coords[] = {loc.x, loc.y, visible.z, - loc.x + width, loc.y, visible.z, - loc.x + width, loc.y + height, visible.z, + loc.x + size.x, loc.y, visible.z, + loc.x + size.x, loc.y + size.y, visible.z, - loc.x + width, loc.y + height, visible.z, - loc.x, loc.y + height, visible.z, + loc.x + size.x, loc.y + size.y, visible.z, + loc.x, loc.y + size.y, visible.z, loc.x, loc.y, visible.z}; @@ -120,7 +119,7 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, glUniform4f(Render::worldShader.uniform[WU_tex_color], 1.0, flashAmt, flashAmt, 1.0); }*/ - glBindTexture(GL_TEXTURE_2D, S.first.pic); + S.first.tex.use(); glUniform1i(Render::worldShader.uniform[WU_texture], 0); Render::worldShader.enable(); @@ -275,9 +274,8 @@ std::vector<Frame> developFrame(XMLElement* xml) auto sxml = framexml->FirstChildElement(); while (sxml) { std::string sname = sxml->Name(); - if (sname == "src") { + if (sname == "src") tmpf.push_back(std::make_pair(SpriteData(sxml->GetText(), vec2(0,0)), vec2(0,0))); - } sxml = sxml->NextSiblingElement(); } tmp.push_back(tmpf); |