working on iOS
This commit is contained in:
parent
3a083fd3c8
commit
72df95f7bb
@ -3,6 +3,7 @@
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
#include "iOSViewController.h"
|
||||
#include "iOSViewDelegate.h"
|
||||
#include "WindowData_IOS.h"
|
||||
#include <MiniFB.h>
|
||||
#include <MiniFB_internal.h>
|
||||
@ -35,8 +36,7 @@ create_window_data(unsigned width, unsigned height) {
|
||||
window_data->window_width = [UIScreen mainScreen].bounds.size.width * scale;
|
||||
window_data->window_height = [UIScreen mainScreen].bounds.size.height * scale;
|
||||
|
||||
window_data->dst_width = width;
|
||||
window_data->dst_height = height;
|
||||
calc_dst_factor(window_data, width, height);
|
||||
|
||||
window_data->buffer_width = width;
|
||||
window_data->buffer_height = height;
|
||||
@ -191,6 +191,7 @@ mfb_set_viewport(struct mfb_window *window, unsigned offset_x, unsigned offset_y
|
||||
window_data->dst_offset_y = offset_y;
|
||||
window_data->dst_width = width;
|
||||
window_data->dst_height = height;
|
||||
calc_dst_factor(window_data, window_data->window_width, window_data->window_height);
|
||||
|
||||
float x1 = ((float) offset_x / window_data->window_width) * 2.0f - 1.0f;
|
||||
float x2 = (((float) offset_x + width) / window_data->window_width) * 2.0f - 1.0f;
|
||||
|
@ -240,9 +240,12 @@ NSString *g_shader_src = kShader(
|
||||
|
||||
//-------------------------------------
|
||||
- (void) mtkView:(nonnull MTKView *)view drawableSizeWillChange:(CGSize)size {
|
||||
(void) view;
|
||||
// Respond to drawable size or orientation changes here
|
||||
window_data->window_width = size.width;
|
||||
window_data->window_height = size.height;
|
||||
float scale = [UIScreen mainScreen].scale;
|
||||
|
||||
window_data->window_width = size.width * scale;
|
||||
window_data->window_height = size.height * scale;
|
||||
resize_dst(window_data, size.width, size.height);
|
||||
|
||||
kCall(resize_func, size.width, size.height);
|
||||
|
@ -43,6 +43,7 @@ resize(struct mfb_window *window, int width, int height) {
|
||||
kUnused(window);
|
||||
g_width = width;
|
||||
g_height = height;
|
||||
g_buffer = realloc(g_buffer, g_width * g_height * 4);
|
||||
NSLog(@"Resize %d, %d", width, height);
|
||||
}
|
||||
|
||||
@ -95,6 +96,9 @@ resize(struct mfb_window *window, int width, int height) {
|
||||
g_height = [UIScreen mainScreen].bounds.size.height * g_scale;
|
||||
g_window = mfb_open("noise", g_width, g_height);
|
||||
if(g_window != 0x0) {
|
||||
g_width -= 100;
|
||||
g_height -= 100;
|
||||
mfb_set_viewport(g_window, 50, 50, g_width, g_height);
|
||||
g_buffer = malloc(g_width * g_height * 4);
|
||||
mfb_set_mouse_move_callback(g_window, mouse_move);
|
||||
mfb_set_mouse_button_callback(g_window, mouse_btn);
|
||||
|
Loading…
Reference in New Issue
Block a user