im hearing jewish voices and i like it

This commit is contained in:
malloc 2018-09-04 16:31:11 -05:00
parent 34539fff01
commit 5d6370eafb
5 changed files with 49 additions and 6 deletions

View file

@ -51,7 +51,7 @@ TODO: populate
To keep track of the status of multiple servers from a centralized point that the client may query, each server must be able to communicate with a "master" server that will record and dispense information regarding all servers to clients. All servers that report to the master server will hereby be refered to as "slave" servers. To keep track of the status of multiple servers from a centralized point that the client may query, each server must be able to communicate with a "master" server that will record and dispense information regarding all servers to clients. All servers that report to the master server will hereby be refered to as "slave" servers.
Communication between master and slave servers will be done over a UDP connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the [_Packet IDs_](#TODO) are defined differently. Communication between master and slave servers will be done over a TCP connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the [_Packet IDs_](#TODO) are defined differently.
Communication between the master server and clients will be done over a WebSocket connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the [_Packet IDs_](#TODO) are defined differently. Communication between the master server and clients will be done over a WebSocket connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the [_Packet IDs_](#TODO) are defined differently.

View file

@ -194,7 +194,6 @@ void sosc::ui::Font::UnbindBitmap() const {
void sosc::ui::Font::Unload() { void sosc::ui::Font::Unload() {
glDeleteTextures(1, &this->texture); glDeleteTextures(1, &this->texture);
this->loaded = false; this->loaded = false;
} }
@ -274,6 +273,29 @@ void sosc::ui::Text::SetWrapWidth(uint32_t w) {
this->Redraw(); this->Redraw();
} }
uint32_t sosc::ui::Text::GetHeight() const {
return this->GetLineCount() * this->font_size;
}
uint32_t sosc::ui::Text::GetLineCount() const {
if(this->wrap_width == 0)
return 1;
else {
uint32_t count = 1, topleft_x = 0;
for(const auto c : this->text) {
auto width = (uint32_t)((*this->font)[c].width * this->font_size);
if(topleft_x + width > this->wrap_width) {
++count;
topleft_x = 0;
}
topleft_x += width;
}
return count;
}
}
void sosc::ui::Text::Render() { void sosc::ui::Text::Render() {
auto shdr = _font_ctx.shader; auto shdr = _font_ctx.shader;
@ -317,7 +339,7 @@ void sosc::ui::Text::Redraw() {
delete[]this->tex_coords; delete[]this->tex_coords;
this->tex_coords = new float[this->vertex_count * 2]; this->tex_coords = new float[this->vertex_count * 2];
uint32_t line_width = 0, top_x = 0, top_y = 0; uint32_t top_x = 0, top_y = 0;
for(int i = 0; i < this->text.length(); ++i) { for(int i = 0; i < this->text.length(); ++i) {
auto glyph = (*this->font)[this->text[i]]; auto glyph = (*this->font)[this->text[i]];
uint32_t width = (uint32_t)(this->font_size * glyph.width), uint32_t width = (uint32_t)(this->font_size * glyph.width),

View file

@ -6,13 +6,11 @@
#include <GLM/glm.hpp> #include <GLM/glm.hpp>
#include <GLM/gtc/matrix_transform.hpp> #include <GLM/gtc/matrix_transform.hpp>
#include <GLM/gtc/type_ptr.hpp> #include <GLM/gtc/type_ptr.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <GLM/gtx/string_cast.hpp>
#include <SDL_image.h> #include <SDL_image.h>
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <iostream> #include "ui/texture.hpp"
#include "shaders/_shader.hpp" #include "shaders/_shader.hpp"
namespace sosc { namespace sosc {
@ -96,6 +94,9 @@ public:
void SetPosition(uint32_t x, uint32_t y); void SetPosition(uint32_t x, uint32_t y);
void SetWrapWidth(uint32_t w); void SetWrapWidth(uint32_t w);
uint32_t GetHeight() const;
uint32_t GetLineCount() const;
void Render(); void Render();
void Destroy(); void Destroy();

View file

@ -0,0 +1,2 @@
#include "texture.hpp"

18
src/client/ui/texture.hpp Normal file
View file

@ -0,0 +1,18 @@
#ifndef SOSC_UI_TEXTURE_H
#define SOSC_UI_TEXTURE_H
#include <SDL.h>
#include <GL/glew.h>
namespace sosc {
namespace ui {
class Texture {
public:
private:
};
}}
#endif