X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fglwidget.cpp;h=0e7adc70e1d5efc20ebe8832d9a8d858199e33b3;hp=57699b379ee1b9ff137ec8ff4c0b76acf755e606;hb=48410b113dd2036e69dbf723a39ec9af02fc9b12;hpb=561e062c8724752601cb9f9370321930fd5aeed1 diff --git a/radiant/glwidget.cpp b/radiant/glwidget.cpp index 57699b37..0e7adc70 100644 --- a/radiant/glwidget.cpp +++ b/radiant/glwidget.cpp @@ -34,9 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#ifndef _WIN32 #include -#endif #include "glwidget.h" #include "qgl.h" @@ -212,108 +210,48 @@ gboolean WINAPI gtk_glwidget_make_current (GtkWidget *widget) } -#ifdef _WIN32 - -GLuint font_list_base; -static gchar font_string[] = "courier 8"; -static gint font_height; -static int font_created = 0; - -#else - // Think about rewriting this font stuff to use OpenGL display lists and glBitmap(). // Bit maps together with display lists may offer a performance increase, but // they would not allow antialiased fonts. +#ifdef _WIN32 +static const char font_string[] = "Courier bold"; +static const int font_height = 9; +#else static const char font_string[] = "Monospace"; static const int font_height = 10; +#endif static int font_ascent = -1; static int font_descent = -1; static int y_offset_bitmap_render_pango_units = -1; static PangoContext *ft2_context = NULL; static int _debug_font_created = 0; -#endif - // Units are pixels. Returns a positive value [most likely]. int gtk_glwidget_font_ascent() { -#ifdef _WIN32 - - return 6; // Approximation. - -#else - if (!_debug_font_created) { Error("Programming error: gtk_glwidget_font_ascent() called but font does not exist; " "you should have called gtk_glwidget_create_font() first"); } return font_ascent; - -#endif } // Units are pixels. Returns a positive value [most likely]. int gtk_glwidget_font_descent() { -#ifdef _WIN32 - - return 0; // Approximation. - -#else - if (!_debug_font_created) { Error("Programming error: gtk_glwidget_font_descent() called but font does not exist; " "you should have called gtk_glwidget_create_font() first"); } return font_descent; - -#endif } -#ifdef _WIN32 - -void gtk_glwidget_create_font_win_internal() -{ - if (font_created) return; - font_created = 1; - - PangoFontDescription *font_desc; - PangoFont *font; - PangoFontMetrics *font_metrics; - - font_list_base = qglGenLists (256); - - font_desc = pango_font_description_from_string (font_string); - - font = gdk_gl_font_use_pango_font (font_desc, 0, 256, font_list_base); - - if(font != NULL) - { - font_metrics = pango_font_get_metrics (font, NULL); - - font_height = pango_font_metrics_get_ascent (font_metrics) + - pango_font_metrics_get_descent (font_metrics); - font_height = PANGO_PIXELS (font_height); - - pango_font_metrics_unref (font_metrics); - } - - pango_font_description_free (font_desc); -} - -#endif void gtk_glwidget_create_font() { -#ifdef _WIN32 - - // Do nothing. - -#else - PangoFontDescription *font_desc; PangoLayout *layout; PangoRectangle log_rect; @@ -336,15 +274,6 @@ void gtk_glwidget_create_font() layout = pango_layout_new(ft2_context); -#ifdef _WIN32 - - PangoLayoutIter *iter; - iter = pango_layout_get_iter(layout); - font_ascent_pango_units = pango_layout_iter_get_baseline(iter); - pango_layout_iter_free(iter); - -#else - // I don't believe that's standard preprocessor syntax? #if !PANGO_VERSION_CHECK(1,22,0) PangoLayoutIter *iter; @@ -353,8 +282,6 @@ void gtk_glwidget_create_font() pango_layout_iter_free(iter); #else font_ascent_pango_units = pango_layout_get_baseline(layout); -#endif - #endif pango_layout_get_extents(layout, NULL, &log_rect); @@ -364,18 +291,10 @@ void gtk_glwidget_create_font() font_ascent = PANGO_PIXELS_CEIL(font_ascent_pango_units); font_descent = PANGO_PIXELS_CEIL(font_descent_pango_units); y_offset_bitmap_render_pango_units = (font_ascent * PANGO_SCALE) - font_ascent_pango_units; - -#endif } void gtk_glwidget_destroy_font() { -#ifdef _WIN32 - - // Do nothing. - -#else - if (!_debug_font_created) { Error("Programming error: gtk_glwidget_destroy_font() called when font " "does not exist"); @@ -386,8 +305,6 @@ void gtk_glwidget_destroy_font() y_offset_bitmap_render_pango_units = -1; g_object_unref(G_OBJECT(ft2_context)); _debug_font_created = 0; - -#endif } @@ -403,14 +320,6 @@ void gtk_glwidget_destroy_font() // Google for "glDrawPixels clipping". void gtk_glwidget_print_string(const char *s) { -#ifdef _WIN32 - - gtk_glwidget_create_font_win_internal(); - qglListBase(font_list_base); - qglCallLists(strlen(s), GL_UNSIGNED_BYTE, (unsigned char *)s); - -#else - // The idea for this code initially came from the font-pangoft2.c example that comes with GtkGLExt. PangoLayout *layout; @@ -484,24 +393,12 @@ void gtk_glwidget_print_string(const char *s) } g_object_unref(G_OBJECT(layout)); - -#endif } void gtk_glwidget_print_char(char s) { -#ifdef _WIN32 - - gtk_glwidget_create_font_win_internal(); - qglListBase(font_list_base); - qglCallLists(1, GL_UNSIGNED_BYTE, (unsigned char *) &s); - -#else - char str[2]; str[0] = s; str[1] = '\0'; gtk_glwidget_print_string(str); - -#endif }