mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-11 11:18:40 +00:00
testing with framebuffer/ssaa, fixed font spacings
This commit is contained in:
parent
4f8b8c3ec2
commit
149543016b
|
|
@ -187,6 +187,7 @@ void font_from_file(
|
|||
memcpy(font->glyphs, pos, font->glyph_count * sizeof(Glyph));
|
||||
|
||||
#if OPENGL
|
||||
// @todo Implement y-offset correction
|
||||
for (int32 i = 0; i < font->glyph_count; ++i) {
|
||||
float temp = font->glyphs[i].coords.y1;
|
||||
font->glyphs[i].coords.y1 = 1.0f - font->glyphs[i].coords.y2;
|
||||
|
|
|
|||
|
|
@ -404,7 +404,6 @@ f32 vertex_text_create(
|
|||
f32 offset_x = x;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int32 character = utf8_get_char_at(text, i);
|
||||
|
||||
if (character == '\n') {
|
||||
y += font->line_height * scale;
|
||||
offset_x = x;
|
||||
|
|
@ -425,13 +424,16 @@ f32 vertex_text_create(
|
|||
continue;
|
||||
}
|
||||
|
||||
f32 offset_y = y + glyph->metrics.offset_y * scale;
|
||||
offset_x += glyph->metrics.offset_x * scale;
|
||||
|
||||
vertex_rect_create(
|
||||
vertices, index, zindex,
|
||||
offset_x, y, glyph->metrics.width * scale, glyph->metrics.height * scale, UI_ALIGN_H_LEFT, UI_ALIGN_V_BOTTOM,
|
||||
offset_x, offset_y, glyph->metrics.width * scale, glyph->metrics.height * scale, UI_ALIGN_H_LEFT, UI_ALIGN_V_BOTTOM,
|
||||
color_index, glyph->coords.x1, glyph->coords.y1, glyph->coords.x2, glyph->coords.y2
|
||||
);
|
||||
|
||||
offset_x += (glyph->metrics.width + glyph->metrics.offset_x) * scale;
|
||||
offset_x += (glyph->metrics.width + glyph->metrics.advance_x) * scale;
|
||||
}
|
||||
|
||||
// @question How and where to cut off text out of view (here or somewhere else)
|
||||
|
|
@ -545,13 +547,16 @@ f32 ui_text_create(
|
|||
continue;
|
||||
}
|
||||
|
||||
f32 offset_y2 = offset_y + glyph->metrics.offset_y * scale;
|
||||
offset_x += glyph->metrics.offset_x * scale;
|
||||
|
||||
vertex_rect_create(
|
||||
vertices, index, zindex,
|
||||
offset_x, offset_y, glyph->metrics.width * scale, glyph->metrics.height * scale, UI_ALIGN_H_LEFT, UI_ALIGN_V_BOTTOM,
|
||||
offset_x, offset_y2, glyph->metrics.width * scale, glyph->metrics.height * scale, UI_ALIGN_H_LEFT, UI_ALIGN_V_BOTTOM,
|
||||
color_index->value_int, glyph->coords.x1, glyph->coords.y1, glyph->coords.x2, glyph->coords.y2
|
||||
);
|
||||
|
||||
offset_x += (glyph->metrics.width + glyph->metrics.offset_x) * scale;
|
||||
offset_x += (glyph->metrics.width + glyph->metrics.advance_x) * scale;
|
||||
}
|
||||
|
||||
element->vertex_count = *index - start;
|
||||
|
|
|
|||
|
|
@ -726,6 +726,81 @@
|
|||
#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
|
||||
#define GL_PROGRAM_BINARY_FORMATS 0x87FF
|
||||
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
|
||||
#define GL_FRAMEBUFFER_DEFAULT 0x8218
|
||||
#define GL_FRAMEBUFFER_UNDEFINED 0x8219
|
||||
#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
|
||||
#define GL_INDEX 0x8222
|
||||
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
|
||||
#define GL_DEPTH_STENCIL 0x84F9
|
||||
#define GL_UNSIGNED_INT_24_8 0x84FA
|
||||
#define GL_DEPTH24_STENCIL8 0x88F0
|
||||
#define GL_TEXTURE_STENCIL_SIZE 0x88F1
|
||||
#define GL_UNSIGNED_NORMALIZED 0x8C17
|
||||
#define GL_SRGB 0x8C40
|
||||
#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
|
||||
#define GL_FRAMEBUFFER_BINDING 0x8CA6
|
||||
#define GL_RENDERBUFFER_BINDING 0x8CA7
|
||||
#define GL_READ_FRAMEBUFFER 0x8CA8
|
||||
#define GL_DRAW_FRAMEBUFFER 0x8CA9
|
||||
#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
|
||||
#define GL_RENDERBUFFER_SAMPLES 0x8CAB
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
|
||||
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
|
||||
#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
|
||||
#define GL_COLOR_ATTACHMENT0 0x8CE0
|
||||
#define GL_COLOR_ATTACHMENT1 0x8CE1
|
||||
#define GL_COLOR_ATTACHMENT2 0x8CE2
|
||||
#define GL_COLOR_ATTACHMENT3 0x8CE3
|
||||
#define GL_COLOR_ATTACHMENT4 0x8CE4
|
||||
#define GL_COLOR_ATTACHMENT5 0x8CE5
|
||||
#define GL_COLOR_ATTACHMENT6 0x8CE6
|
||||
#define GL_COLOR_ATTACHMENT7 0x8CE7
|
||||
#define GL_COLOR_ATTACHMENT8 0x8CE8
|
||||
#define GL_COLOR_ATTACHMENT9 0x8CE9
|
||||
#define GL_COLOR_ATTACHMENT10 0x8CEA
|
||||
#define GL_COLOR_ATTACHMENT11 0x8CEB
|
||||
#define GL_COLOR_ATTACHMENT12 0x8CEC
|
||||
#define GL_COLOR_ATTACHMENT13 0x8CED
|
||||
#define GL_COLOR_ATTACHMENT14 0x8CEE
|
||||
#define GL_COLOR_ATTACHMENT15 0x8CEF
|
||||
#define GL_DEPTH_ATTACHMENT 0x8D00
|
||||
#define GL_STENCIL_ATTACHMENT 0x8D20
|
||||
#define GL_FRAMEBUFFER 0x8D40
|
||||
#define GL_RENDERBUFFER 0x8D41
|
||||
#define GL_RENDERBUFFER_WIDTH 0x8D42
|
||||
#define GL_RENDERBUFFER_HEIGHT 0x8D43
|
||||
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
|
||||
#define GL_STENCIL_INDEX1 0x8D46
|
||||
#define GL_STENCIL_INDEX4 0x8D47
|
||||
#define GL_STENCIL_INDEX8 0x8D48
|
||||
#define GL_STENCIL_INDEX16 0x8D49
|
||||
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
|
||||
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
|
||||
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
|
||||
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
|
||||
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
|
||||
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
|
||||
#define GL_MAX_SAMPLES 0x8D57
|
||||
|
||||
typedef char GLchar;
|
||||
typedef ptrdiff_t GLsizeiptr;
|
||||
typedef ptrdiff_t GLintptr;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ void change_viewport(Window* w, int32 offset_x = 0, int32 offset_y = 0)
|
|||
}
|
||||
|
||||
inline
|
||||
void vsync_set(bool on)
|
||||
void vsync_set(int32 on)
|
||||
{
|
||||
wglSwapIntervalEXT((int32) on);
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ void load_texture_to_gpu(const Texture* texture, int32 mipmap_level = 0)
|
|||
}
|
||||
|
||||
inline
|
||||
void texture_use(const Texture* texture, uint32 texture_unit)
|
||||
void texture_use(const Texture* texture)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + texture->sample_id);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint) texture->id);
|
||||
|
|
@ -454,6 +454,17 @@ uint32 gpuapi_buffer_generate_dynamic(int32 size, const void* data)
|
|||
return vbo;
|
||||
}
|
||||
|
||||
inline
|
||||
uint32 gpuapi_framebuffer_generate()
|
||||
{
|
||||
uint32 fbo;
|
||||
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
return fbo;
|
||||
}
|
||||
|
||||
inline
|
||||
void gpuapi_buffer_update_dynamic(uint32 vbo, int32 size, const void* data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1167,6 +1167,18 @@ static type_glBufferSubData* glBufferSubData;
|
|||
typedef void WINAPI type_glGenBuffers(GLsizei n, GLuint *buffers);
|
||||
static type_glGenBuffers* glGenBuffers;
|
||||
|
||||
typedef void WINAPI type_glGenRenderbuffers(GLsizei n, GLuint *renderbuffers);
|
||||
static type_glGenRenderbuffers* glGenRenderbuffers;
|
||||
|
||||
typedef void WINAPI type_glBindRenderbuffer(GLenum target, GLuint renderbuffer);
|
||||
static type_glBindRenderbuffer* glBindRenderbuffer;
|
||||
|
||||
typedef void WINAPI type_glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
static type_glRenderbufferStorage* glRenderbufferStorage;
|
||||
|
||||
typedef void WINAPI type_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
|
||||
static type_glFramebufferRenderbuffer* glFramebufferRenderbuffer;
|
||||
|
||||
typedef void WINAPI type_glBufferData(GLenum target, GLsizeiptr size, const void *data, GLenum usage);
|
||||
static type_glBufferData* glBufferData;
|
||||
|
||||
|
|
@ -1233,6 +1245,7 @@ static type_glProgramParameteri* glProgramParameteri;
|
|||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
|
||||
// @question Why is this even here? Shouldn't this be in Opengl.h?
|
||||
#define GL_SHADER_STORAGE_BARRIER_BIT 0x2000
|
||||
#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39
|
||||
#define GL_SHADER_STORAGE_BUFFER 0x90D2
|
||||
|
|
@ -1342,7 +1355,7 @@ void set_pixel_format(HDC hdc, int32 multisampling = 0)
|
|||
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
|
||||
WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, GL_TRUE,
|
||||
WGL_SAMPLE_BUFFERS_ARB, (int32) (multisampling > 0),
|
||||
WGL_SAMPLES_ARB, multisampling, // 4x MSAA
|
||||
WGL_SAMPLES_ARB, multisampling, // MSAA
|
||||
0,
|
||||
};
|
||||
|
||||
|
|
@ -1491,6 +1504,10 @@ void opengl_init_gl()
|
|||
glBindBufferBase = (type_glBindBufferBase *) wglGetProcAddress("glBindBufferBase");
|
||||
glBufferSubData = (type_glBufferSubData *) wglGetProcAddress("glBufferSubData");
|
||||
glGenBuffers = (type_glGenBuffers *) wglGetProcAddress("glGenBuffers");
|
||||
glGenRenderbuffers = (type_glGenRenderbuffers *) wglGetProcAddress("glGenRenderbuffers");
|
||||
glBindRenderbuffer = (type_glBindRenderbuffer *) wglGetProcAddress("glBindRenderbuffer");
|
||||
glRenderbufferStorage = (type_glRenderbufferStorage *) wglGetProcAddress("glRenderbufferStorage");
|
||||
glFramebufferRenderbuffer = (type_glFramebufferRenderbuffer *) wglGetProcAddress("glFramebufferRenderbuffer");
|
||||
glBufferData = (type_glBufferData *) wglGetProcAddress("glBufferData");
|
||||
glActiveTexture = (type_glActiveTexture *) wglGetProcAddress("glActiveTexture");
|
||||
glDeleteProgram = (type_glDeleteProgram *) wglGetProcAddress("glDeleteProgram");
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
struct Shader {
|
||||
uint32 shader_id;
|
||||
uint32 shader_locations[10];
|
||||
uint32 shader_locations[7];
|
||||
byte shader_data[16];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#define TOS_MODELS_SETTINGS_H
|
||||
|
||||
#include "../../stdlib/Types.h"
|
||||
#include "../../gpuapi/AntiAliasing.h"
|
||||
#include "../chat/ChatStatus.h"
|
||||
#include "setting_types.h"
|
||||
#include "../../module/Module.h"
|
||||
|
|
@ -120,7 +121,9 @@ struct CSettings {
|
|||
byte gpu_contrast;
|
||||
byte gpu_gamma;
|
||||
f32 gpu_fov;
|
||||
byte gpu_sync = SETTING_TYPE_DISABLED;
|
||||
int8 gpu_sync;
|
||||
AntiAliasingType gpu_aa_type;
|
||||
int8 gpu_aa_samples;
|
||||
|
||||
byte gpu_render_distance_terrain = 10;
|
||||
byte gpu_render_distance_terrain_secondary = 10;
|
||||
|
|
@ -395,7 +398,7 @@ void load_settings(CSettings* __restrict client_settings, char* data)
|
|||
while (*pos != '\0') {
|
||||
// Skip all whitespaces and new lines
|
||||
int32 skip;
|
||||
while ((skip = is_eol(pos)) || (skip = (int32) is_whitespace(*pos))) {
|
||||
while ((skip = (int32) is_whitespace(*pos)) || (skip = is_eol(pos))) {
|
||||
pos += skip;
|
||||
}
|
||||
|
||||
|
|
@ -486,6 +489,11 @@ void load_settings(CSettings* __restrict client_settings, char* data)
|
|||
} else if (strncmp(name, "_shadow_type", sizeof("_shadow_type") - 1) == 0) {
|
||||
} else if (strncmp(name, "_sharpening", sizeof("_sharpening") - 1) == 0) {
|
||||
} else if (strncmp(name, "_sync", sizeof("_sync") - 1) == 0) {
|
||||
client_settings->gpu_sync = (int8) atoi(pos);
|
||||
} else if (strncmp(name, "_aa_type", sizeof("_aa_type") - 1) == 0) {
|
||||
client_settings->gpu_aa_type = (AntiAliasingType) atoi(pos);
|
||||
} else if (strncmp(name, "_aa_samples", sizeof("_aa_samples") - 1) == 0) {
|
||||
client_settings->gpu_aa_samples = (int8) atoi(pos);
|
||||
} else if (strncmp(name, "_terrain_quality", sizeof("_terrain_quality") - 1) == 0) {
|
||||
} else if (strncmp(name, "_texture_quality", sizeof("_texture_quality") - 1) == 0) {
|
||||
} else if (strncmp(name, "_type", sizeof("_type") - 1) == 0) {
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
texutre_count_8192x8192
|
||||
texutre_count_4096x4096
|
||||
texutre_count_2048x2048
|
||||
texutre_count_1024x1024
|
||||
texutre_count_512x512
|
||||
texutre_count_256x256
|
||||
texutre_count_128x128
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
gpu_type
|
||||
gpu_fps
|
||||
|
||||
gpu_sync
|
||||
|
||||
gpu_number_of_npc_characters
|
||||
gpu_number_of_player_characters
|
||||
gpu_number_of_monster_characters
|
||||
|
||||
gpu_render_distance_terrain
|
||||
gpu_render_distance_terrain_secondary
|
||||
gpu_render_distance_terrain_tertiary
|
||||
gpu_render_distance_models
|
||||
gpu_render_distance_monster
|
||||
gpu_render_distance_npc
|
||||
gpu_render_distance_player
|
||||
|
||||
player_cache
|
||||
monster_cache
|
||||
npc_cache
|
||||
guild_cache
|
||||
message_cache
|
||||
|
|
@ -36,12 +36,16 @@ int rawinput_init_mousekeyboard(HWND hwnd, Input* __restrict states, RingMemory*
|
|||
{
|
||||
uint32 device_count;
|
||||
GetRawInputDeviceList(NULL, &device_count, sizeof(RAWINPUTDEVICELIST));
|
||||
PRAWINPUTDEVICELIST pRawInputDeviceList = (PRAWINPUTDEVICELIST) ring_get_memory(ring, sizeof(RAWINPUTDEVICELIST) * device_count, 4);
|
||||
if (device_count == 0 || device_count > 1000) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRAWINPUTDEVICELIST pRawInputDeviceList = (PRAWINPUTDEVICELIST) ring_get_memory(ring, sizeof(RAWINPUTDEVICELIST) * device_count, 8);
|
||||
device_count = GetRawInputDeviceList(pRawInputDeviceList, &device_count, sizeof(RAWINPUTDEVICELIST));
|
||||
|
||||
// We always want at least one empty input device slot
|
||||
// @todo Change so that we store the actual number of devices
|
||||
if (device_count == 0) {
|
||||
if (device_count == 0 || device_count > 1000) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -108,12 +112,16 @@ int rawinput_init_controllers(HWND hwnd, Input* __restrict states, RingMemory* r
|
|||
{
|
||||
uint32 device_count;
|
||||
GetRawInputDeviceList(NULL, &device_count, sizeof(RAWINPUTDEVICELIST));
|
||||
PRAWINPUTDEVICELIST pRawInputDeviceList = (PRAWINPUTDEVICELIST) ring_get_memory(ring, sizeof(RAWINPUTDEVICELIST) * device_count, 4);
|
||||
if (device_count == 0 || device_count > 1000) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRAWINPUTDEVICELIST pRawInputDeviceList = (PRAWINPUTDEVICELIST) ring_get_memory(ring, sizeof(RAWINPUTDEVICELIST) * device_count, 8);
|
||||
device_count = GetRawInputDeviceList(pRawInputDeviceList, &device_count, sizeof(RAWINPUTDEVICELIST));
|
||||
|
||||
// We always want at least one empty input device slot
|
||||
// @todo Change so that we store the actual number of devices
|
||||
if (device_count == 0) {
|
||||
if (device_count == 0 || device_count > 1000) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user