]> git.localhorst.tv Git - blank.git/blobdiff - src/app/init.cpp
implemented font redering
[blank.git] / src / app / init.cpp
index a56674c309506b5ac8f0876be5338b8241dfebf3..6fa2dfd6c0b9722c2856de9cc528ac035fdaac7b 100644 (file)
@@ -3,6 +3,7 @@
 #include <algorithm>
 #include <SDL.h>
 #include <SDL_image.h>
+#include <SDL_ttf.h>
 #include <stdexcept>
 #include <string>
 #include <GL/glew.h>
@@ -46,6 +47,17 @@ InitIMG::~InitIMG() {
 }
 
 
+InitTTF::InitTTF() {
+       if (TTF_Init() != 0) {
+               sdl_error("TTF_Init()");
+       }
+}
+
+InitTTF::~InitTTF() {
+       TTF_Quit();
+}
+
+
 InitGL::InitGL(bool double_buffer, int sample_size) {
        if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) != 0) {
                sdl_error("SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3)");
@@ -158,6 +170,15 @@ void GLContext::EnableBackfaceCulling() noexcept {
        glEnable(GL_CULL_FACE);
 }
 
+void GLContext::EnableAlphaBlending() noexcept {
+       glEnable(GL_BLEND);
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
+void GLContext::DisableAlphaBlending() noexcept {
+       glDisable(GL_BLEND);
+}
+
 void GLContext::Clear() noexcept {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 }