Branch
Hash :
36df94af
Author :
Thomas de Grivel
Date :
2025-03-02T16:13:53
Change copyright wording and extend to 2025
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/* kc3
* Copyright from 2022 to 2025 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include "../../window.h"
#include "../gl_font.h"
#include "../gl_lines.h"
#include "../mat4.h"
#include "../gl_ortho.h"
#include "../gl_square.h"
#include "../gl_text.h"
#include "../gl_sprite.h"
#include "../window_sdl2.h"
#include "kubz.h"
#include "menu.h"
#define MENU_TEXT_LINES 4
static const s_rgba menu_color = {1.0f, 1.0f, 1.0f, 0.5f};
static s_gl_text menu_gl_text[MENU_TEXT_LINES] = {0};
static const char * menu_text[MENU_TEXT_LINES] = {
"Menu",
"",
"ESC Return to game",
"Q Exit game"
};
static const s_rgb menu_text_color[2] = {
{0.8f, 0.8f, 0.8f},
{0.0f, 0.0f, 0.0f}
};
bool menu_render (s_window_sdl2 *window)
{
sw i;
if (! menu_gl_text->font) {
i = 0;
while (i < MENU_TEXT_LINES) {
if (! gl_text_init_1(menu_gl_text + i,
&g_font_courier_new,
menu_text[i]))
return false;
if (! gl_text_update(menu_gl_text + i))
return false;
i++;
}
}
gl_ortho_color(&g_ortho, menu_color.r, menu_color.g, menu_color.b,
menu_color.a);
gl_ortho_rect(&g_ortho, 20.0f, 20.0f,
window->w - 40.0f, window->h - 40.0f);
i = 0;
while (i < MENU_TEXT_LINES) {
gl_ortho_text_render_outline(&g_ortho, menu_gl_text + i,
40, window->h - 60 - i * 20,
menu_text_color, menu_text_color + 1);
i++;
}
return true;
}