From 17fa4c91e46a40e7cd614d51ff5950039c586581 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 28 Oct 2019 15:42:20 +0200 Subject: [PATCH] Remove immediate mode emulation It's not very useful anymore and starting to get in the way of other things. --- source/font.cpp | 11 +---------- source/font.h | 14 -------------- source/immediate.cpp | 42 ------------------------------------------ source/immediate.h | 34 ---------------------------------- 4 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 source/immediate.cpp delete mode 100644 source/immediate.h diff --git a/source/font.cpp b/source/font.cpp index 623f1ebe..5990c57d 100644 --- a/source/font.cpp +++ b/source/font.cpp @@ -3,8 +3,7 @@ #include "bindable.h" #include "gl.h" #include "font.h" -#include "immediate.h" -#include "primitivetype.h" +#include "primitivebuilder.h" #include "texture2d.h" using namespace std; @@ -64,14 +63,6 @@ float Font::get_string_width(const string &str, StringCodec::Decoder &dec) const return x; } -void Font::draw_string(const string &str, StringCodec::Decoder &dec, const Color &color) const -{ - BindRestore bind_tex(get_texture()); - Immediate imm((TEXCOORD2, COLOR4_UBYTE, VERTEX2)); - imm.color(color); - build_string(str, dec, imm); -} - void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveBuilder &bld) const { VertexBuilder::PushMatrix push_mtx(bld); diff --git a/source/font.h b/source/font.h index a4fc71ae..9f040dc9 100644 --- a/source/font.h +++ b/source/font.h @@ -105,20 +105,6 @@ public: float get_string_width(const std::string &str) const { return get_string_width(str); } - /** Draws a string to the framebuffer with Immediate. It is drawn with size - 1.0; set up matrices for the desired size before the call. */ - void draw_string(const std::string &, StringCodec::Decoder &, const Color & = Color()) const; - - template - void draw_string(const std::string &str, const Color &color = Color()) const - { - typename C::Decoder dec; - draw_string(str, dec, color); - } - - void draw_string(const std::string &str, const Color &color = Color()) const - { draw_string(str, color); } - /** Builds the primitives for a string. Two-dimensional vertex and texture coordinates are generated. Size 1.0 is used for building; set up the builder's matrix before the call. The texture is not bound, to avoid diff --git a/source/immediate.cpp b/source/immediate.cpp deleted file mode 100644 index cf1be08e..00000000 --- a/source/immediate.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "batch.h" -#include "error.h" -#include "immediate.h" - -namespace Msp { -namespace GL { - -Immediate::Immediate(VertexFormat f): - PrimitiveBuilder(array), - array(f) -{ - array.use_buffer(0); -} - -void Immediate::reset() -{ - if(in_batch) - throw invalid_operation("Immediate::reset"); - - array.clear(); -} - -void Immediate::begin_() -{ - indices.clear(); -} - -void Immediate::end_() -{ - Batch batch(type); - batch.append(indices); - array.apply(); - batch.draw(); -} - -void Immediate::element_(unsigned i) -{ - indices.push_back(i); -} - -} // namespace GL -} // namespace Msp diff --git a/source/immediate.h b/source/immediate.h deleted file mode 100644 index 40e25cd6..00000000 --- a/source/immediate.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MSP_GL_IMMEDIATE_H_ -#define MSP_GL_IMMEDIATE_H_ - -#include "primitivebuilder.h" - -namespace Msp { -namespace GL { - -/** -Draws primitives on the screen. This works similarly to the OpenGL immediate -mode: call begin() to start a batch of primitives, specify vertices, and call -end() to terminate the batch. However, unlike OpenGL immediate mode, vertices -are not drawn as they are specified. Instead, they are accumulated in a -VertexArray and drawn when end() is called. -*/ -class Immediate: public PrimitiveBuilder -{ -private: - VertexArray array; - std::vector indices; - -public: - Immediate(VertexFormat); - void reset(); -private: - virtual void begin_(); - virtual void end_(); - virtual void element_(unsigned); -}; - -} // namespace GL -} // namespace Msp - -#endif -- 2.43.0