did some stuff, will probably refactor later
This commit is contained in:
parent
10ee4fcbd9
commit
bc4ec556e2
46 changed files with 1013 additions and 35635 deletions
|
@ -17,9 +17,62 @@
|
|||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <mm/mman.h>
|
||||
// TODO: Remove this if statement once I fix stb_truetype compilation
|
||||
#if 0
|
||||
|
||||
//#define STBTT_malloc(x,u) ((void)(u),mem_alloc(x))
|
||||
//#define STBTT_free(x,u) ((void)(u),mem_free(x))
|
||||
//#define STB_TRUETYPE_IMPLEMENTATION
|
||||
//#include <ui/stb_truetype.h>
|
||||
#include <mm/mman.h>
|
||||
#include <arch/lib/math.h>
|
||||
#include <lib/string.h>
|
||||
#include <lib/assert.h>
|
||||
#include <vfs/vfs.h>
|
||||
#include <print.h>
|
||||
|
||||
__attribute__((used)) static volatile int _fltused = 0;
|
||||
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
|
||||
#define STBTT_ifloor(x) _ifloor(x)
|
||||
#define STBTT_iceil(x) _iceil(x)
|
||||
#define STBTT_sqrt(x) _sqrt(x)
|
||||
#define STBTT_pow(x, y) _pow(x, y)
|
||||
#define STBTT_fmod(x, y) _fmod(x, y)
|
||||
#define STBTT_cos(x) _cos(x)
|
||||
#define STBTT_acos(x) _acos(x)
|
||||
#define STBTT_fabs(x) __builtin_fabs(x)
|
||||
|
||||
#define STBTT_malloc(x, u) ((void)(u), mem_alloc(x))
|
||||
#define STBTT_free(x, u) ((void)(u), mem_free(x))
|
||||
|
||||
#define STBTT_assert(x) assert(x, #x)
|
||||
#define STBTT_strlen(x) strlen(x)
|
||||
|
||||
#define STBTT_memcpy memcpy
|
||||
#define STBTT_memset memset
|
||||
|
||||
#include "stb_truetype.h"
|
||||
|
||||
unsigned char *font_buf = NULL;
|
||||
stbtt_fontinfo font_info;
|
||||
float font_scale;
|
||||
int font_ascent, font_descent;
|
||||
int font_linegap;
|
||||
int font_size;
|
||||
|
||||
void font_init(char *font_path, int initial_size)
|
||||
{
|
||||
vfs_read(font_path, &font_buf);
|
||||
if (!font_buf) {
|
||||
debug("Font not loaded, returning...\n");
|
||||
return;
|
||||
}
|
||||
|
||||
font_size = initial_size;
|
||||
|
||||
stbtt_InitFont(&font_info, &font_buf, 0);
|
||||
font_scale = stbtt_ScaleForPixelHeight(&font_info, font_size);
|
||||
stbtt_GetFontVMetrics(&font_info, &font_ascent, &font_descent, &font_linegap);
|
||||
font_ascent *= font_scale;
|
||||
font_descent *= font_scale;
|
||||
}
|
||||
|
||||
#endif
|
5079
boot/common/ui/stb_truetype.h
Normal file
5079
boot/common/ui/stb_truetype.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -18,39 +18,39 @@
|
|||
/*********************************************************************************/
|
||||
|
||||
#include <ui/framebuffer.h>
|
||||
#include <ui/mouse.h>
|
||||
#include <ui/font.h>
|
||||
#include <ui/ui.h>
|
||||
#include <config/config.h>
|
||||
|
||||
#include <print.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct ui_config {
|
||||
uintptr_t fb_addr;
|
||||
struct fb_mode *fb_modes;
|
||||
int total_modes;
|
||||
int current_mode;
|
||||
};
|
||||
|
||||
struct ui_config config;
|
||||
|
||||
void ui_init()
|
||||
{
|
||||
struct fb_mode *available_fb_modes = NULL;
|
||||
int total_modes = 0;
|
||||
int current_mode = 0;
|
||||
struct ui_context ctx;
|
||||
|
||||
if (!get_framebuffer(&config.fb_addr, &config.fb_modes, &config.total_modes, &config.current_mode)) {
|
||||
if (!get_framebuffer(&ctx.fb_addr, &ctx.fb_modes, &ctx.total_modes, &ctx.current_mode)) {
|
||||
debug("Failed to acquire a framebuffer!\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
debug("Dumping framebuffer information\n");
|
||||
debug("--------------------------------\n");
|
||||
debug("Address: 0x%llx\n", config.fb_addr);
|
||||
debug("Address: 0x%llx\n", ctx.fb_addr);
|
||||
|
||||
for (int i = 0; i < config.total_modes; i++) {
|
||||
debug("\nMode %u:%s\n", i, (i == config.current_mode) ? " (current)" : "");
|
||||
debug("Resolution: %ux%u\n", config.fb_modes[i].width, config.fb_modes[i].height);
|
||||
debug("Bits Per Pixel: %u\n", config.fb_modes[i].bpp);
|
||||
debug("Pitch: %u\n", config.fb_modes[i].pitch);
|
||||
for (int i = 0; i < ctx.total_modes; i++) {
|
||||
debug("\nMode %u:%s\n", i, (i == ctx.current_mode) ? " (current)" : "");
|
||||
debug("Resolution: %ux%u\n", ctx.fb_modes[i].width, ctx.fb_modes[i].height);
|
||||
debug("Bits Per Pixel: %u\n", ctx.fb_modes[i].bpp);
|
||||
debug("Pitch: %u\n", ctx.fb_modes[i].pitch);
|
||||
debug("Format: %s\n", ctx.fb_modes[i].format == FB_RGBA ? "RGBA" : "BGRA");
|
||||
}
|
||||
|
||||
while(1);
|
||||
}
|
||||
//font_init("\\AxBoot\\fonts\\DreamOrphans.ttf", 20);
|
||||
|
||||
//while (1) {
|
||||
//get_mouse(&m_x, &m_y, &m_but);
|
||||
//debug("Mouse X = %u | Mouse Y = %u\n", m_x, m_y);
|
||||
//}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue