mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-11 11:18:40 +00:00
fix framebuffer resize and impl. ctrl+v
This commit is contained in:
parent
a02963607d
commit
38f9178831
|
|
@ -165,6 +165,11 @@ void texture_use(const Texture* texture)
|
||||||
glBindTexture(texture_data_type, (GLuint) texture->id);
|
glBindTexture(texture_data_type, (GLuint) texture->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void texture_delete(Texture* texture) {
|
||||||
|
glDeleteTextures(1, &texture->id);
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void draw_triangles_3d(VertexRef* vertices, GLuint buffer, int32 count) {
|
void draw_triangles_3d(VertexRef* vertices, GLuint buffer, int32 count) {
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||||
|
|
|
||||||
|
|
@ -551,6 +551,9 @@ static type_glDeleteShader* glDeleteShader;
|
||||||
typedef void WINAPI type_glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers);
|
typedef void WINAPI type_glDeleteFramebuffers(GLsizei n, const GLuint *framebuffers);
|
||||||
static type_glDeleteFramebuffers* glDeleteFramebuffers;
|
static type_glDeleteFramebuffers* glDeleteFramebuffers;
|
||||||
|
|
||||||
|
typedef void WINAPI type_glDeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers);
|
||||||
|
static type_glDeleteRenderbuffers* glDeleteRenderbuffers;
|
||||||
|
|
||||||
typedef void WINAPI type_glDrawBuffers(GLsizei n, const GLenum *bufs);
|
typedef void WINAPI type_glDrawBuffers(GLsizei n, const GLenum *bufs);
|
||||||
static type_glDrawBuffers* glDrawBuffers;
|
static type_glDrawBuffers* glDrawBuffers;
|
||||||
|
|
||||||
|
|
@ -824,6 +827,7 @@ void opengl_init_gl()
|
||||||
glDeleteVertexArrays = (type_glDeleteVertexArrays *) wglGetProcAddress("glDeleteVertexArrays");
|
glDeleteVertexArrays = (type_glDeleteVertexArrays *) wglGetProcAddress("glDeleteVertexArrays");
|
||||||
glDeleteShader = (type_glDeleteShader *) wglGetProcAddress("glDeleteShader");
|
glDeleteShader = (type_glDeleteShader *) wglGetProcAddress("glDeleteShader");
|
||||||
glDeleteFramebuffers = (type_glDeleteFramebuffers *) wglGetProcAddress("glDeleteFramebuffers");
|
glDeleteFramebuffers = (type_glDeleteFramebuffers *) wglGetProcAddress("glDeleteFramebuffers");
|
||||||
|
glDeleteRenderbuffers = (type_glDeleteRenderbuffers *) wglGetProcAddress("glDeleteRenderbuffers");
|
||||||
glDrawBuffers = (type_glDrawBuffers *) wglGetProcAddress("glDrawBuffers");
|
glDrawBuffers = (type_glDrawBuffers *) wglGetProcAddress("glDrawBuffers");
|
||||||
glTexImage3D = (type_glTexImage3D *) wglGetProcAddress("glTexImage3D");
|
glTexImage3D = (type_glTexImage3D *) wglGetProcAddress("glTexImage3D");
|
||||||
glTexSubImage3D = (type_glTexSubImage3D *) wglGetProcAddress("glTexSubImage3D");
|
glTexSubImage3D = (type_glTexSubImage3D *) wglGetProcAddress("glTexSubImage3D");
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "../stdlib/Types.h"
|
#include "../stdlib/Types.h"
|
||||||
#include "../utils/BitUtils.h"
|
#include "../utils/BitUtils.h"
|
||||||
|
#include "../utils/StringUtils.h"
|
||||||
#include "../memory/BufferMemory.h"
|
#include "../memory/BufferMemory.h"
|
||||||
#include "ControllerInput.h"
|
#include "ControllerInput.h"
|
||||||
#include "InputConnectionType.h"
|
#include "InputConnectionType.h"
|
||||||
|
|
@ -163,7 +164,7 @@ struct Input {
|
||||||
// @todo this should probably be somewhere else
|
// @todo this should probably be somewhere else
|
||||||
// @todo don't we need multiple deadzones? triggers, sticks
|
// @todo don't we need multiple deadzones? triggers, sticks
|
||||||
uint32 deadzone = 10;
|
uint32 deadzone = 10;
|
||||||
uint32 characters[10];
|
char text[512];
|
||||||
|
|
||||||
// This data is passed to the hotkey callback
|
// This data is passed to the hotkey callback
|
||||||
void* callback_data;
|
void* callback_data;
|
||||||
|
|
@ -518,9 +519,9 @@ void input_hotkey_state(Input* input)
|
||||||
|
|
||||||
// Check typing mode
|
// Check typing mode
|
||||||
if (input->general_states & INPUT_STATE_GENERAL_TYPING_MODE) {
|
if (input->general_states & INPUT_STATE_GENERAL_TYPING_MODE) {
|
||||||
// @todo If this function becomes threaded we must maintain the input characters as a persistent state
|
*input->text = '\0';
|
||||||
int32 input_characters = 0;
|
int32 input_characters = 0;
|
||||||
memset(input->characters, 0, sizeof(uint32) * ARRAY_COUNT(input->characters));
|
uint32 characters[10];
|
||||||
|
|
||||||
// Create keyboard state array
|
// Create keyboard state array
|
||||||
byte keyboard_state[256] = {};
|
byte keyboard_state[256] = {};
|
||||||
|
|
@ -541,7 +542,7 @@ void input_hotkey_state(Input* input)
|
||||||
&& (state->active_keys[key_state].scan_code & INPUT_KEYBOARD_PREFIX)
|
&& (state->active_keys[key_state].scan_code & INPUT_KEYBOARD_PREFIX)
|
||||||
&& state->active_keys[key_state].key_state != KEY_PRESS_TYPE_RELEASED
|
&& state->active_keys[key_state].key_state != KEY_PRESS_TYPE_RELEASED
|
||||||
) {
|
) {
|
||||||
if (input_characters >= ARRAY_COUNT(input->characters)) {
|
if (input_characters >= ARRAY_COUNT(characters)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -554,22 +555,31 @@ void input_hotkey_state(Input* input)
|
||||||
// Is the pressed key a keyboard input
|
// Is the pressed key a keyboard input
|
||||||
if (!code) {
|
if (!code) {
|
||||||
// Is not text -> we have to reset characters
|
// Is not text -> we have to reset characters
|
||||||
memset(input->characters, 0, sizeof(uint32) * input_characters);
|
memset(characters, 0, sizeof(uint32) * input_characters);
|
||||||
input_characters = 0;
|
input_characters = 0;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
input->characters[input_characters++] = code;
|
characters[input_characters++] = code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_characters) {
|
if (input_characters) {
|
||||||
|
// Mark keys
|
||||||
for (int32 key_state = 0; key_state < MAX_KEY_PRESS_TYPES; ++key_state) {
|
for (int32 key_state = 0; key_state < MAX_KEY_PRESS_TYPES; ++key_state) {
|
||||||
state->active_keys[key_state].is_processed = true;
|
state->active_keys[key_state].is_processed = true;
|
||||||
state->active_keys[key_state].time = 0; // @todo fix
|
state->active_keys[key_state].time = 0; // @todo fix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create text from input
|
||||||
|
char* pos = input->text;
|
||||||
|
for (int32 i = 0; i < ARRAY_COUNT(characters); ++i) {
|
||||||
|
pos += utf8_decode(characters[i], pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pos = '\0';
|
||||||
|
|
||||||
input_clean_state(state->active_keys);
|
input_clean_state(state->active_keys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@
|
||||||
#ifndef TOS_UTILS_LINUX_H
|
#ifndef TOS_UTILS_LINUX_H
|
||||||
#define TOS_UTILS_LINUX_H
|
#define TOS_UTILS_LINUX_H
|
||||||
|
|
||||||
|
#include "../../stdlib/Types.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#include "../../stdlib/Types.h"
|
|
||||||
|
|
||||||
int32 sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...) {
|
int32 sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...) {
|
||||||
int32 result;
|
int32 result;
|
||||||
|
|
@ -36,4 +38,46 @@ int32 sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clipboard_get(char* text, int32 max_length)
|
||||||
|
{
|
||||||
|
*text = '\0';
|
||||||
|
|
||||||
|
Display *display = XOpenDisplay(NULL);
|
||||||
|
if (display == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Atom clipboard = XInternAtom(display, "CLIPBOARD", false);
|
||||||
|
Atom utf8_string = XInternAtom(display, "UTF8_STRING", false);
|
||||||
|
Atom xa_string = XInternAtom(display, "STRING", false);
|
||||||
|
Window window = XDefaultRootWindow(display);
|
||||||
|
|
||||||
|
XConvertSelection(display, clipboard, utf8_string, xa_string, window, CurrentTime);
|
||||||
|
XEvent event;
|
||||||
|
XNextEvent(display, &event);
|
||||||
|
|
||||||
|
if (event.type == SelectionNotify) {
|
||||||
|
if (event.xselection.property) {
|
||||||
|
Atom type;
|
||||||
|
int32 format;
|
||||||
|
unsigned long nitems, bytes_after;
|
||||||
|
byte* data = NULL;
|
||||||
|
|
||||||
|
XGetWindowProperty(
|
||||||
|
display, event.xselection.requestor,
|
||||||
|
event.xselection.property, 0, (~0L), false,
|
||||||
|
AnyPropertyType, &type, &format, &nitems,
|
||||||
|
&bytes_after, &data
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
str_copy_short(text, clipboard_text, max_length);
|
||||||
|
XFree(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XCloseDisplay(display);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
37
platform/win32/Clipboard.h
Normal file
37
platform/win32/Clipboard.h
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
* Jingga
|
||||||
|
*
|
||||||
|
* @copyright Jingga
|
||||||
|
* @license OMS License 2.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
#ifndef TOS_PLATFORM_WIN32_CLIPBOARD_H
|
||||||
|
#define TOS_PLATFORM_WIN32_CLIPBOARD_H
|
||||||
|
|
||||||
|
#include "../../stdlib/Types.h"
|
||||||
|
#include "../../utils/StringUtils.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define strtok_r strtok_s
|
||||||
|
|
||||||
|
void clipboard_get(char* text, int32 max_length)
|
||||||
|
{
|
||||||
|
*text = '\0';
|
||||||
|
if (OpenClipboard(NULL)) {
|
||||||
|
HANDLE clipboard_data = GetClipboardData(CF_TEXT);
|
||||||
|
if (clipboard_data) {
|
||||||
|
const char* clipboard_text = (const char*) GlobalLock(clipboard_data);
|
||||||
|
if (clipboard_text) {
|
||||||
|
str_copy_short(text, clipboard_text, max_length);
|
||||||
|
GlobalUnlock(clipboard_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#define TOS_PLATFORM_WIN32_UTILS_H
|
#define TOS_PLATFORM_WIN32_UTILS_H
|
||||||
|
|
||||||
#include "../../stdlib/Types.h"
|
#include "../../stdlib/Types.h"
|
||||||
|
#include "../../utils/StringUtils.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user