add more mac stuff
parent
1daf59732f
commit
57a2eff6c1
|
@ -1 +1,2 @@
|
|||
build/
|
||||
*.swp
|
||||
|
|
|
@ -4,6 +4,18 @@ project(xormod C)
|
|||
|
||||
find_package(SDL2)
|
||||
|
||||
if(APPLE)
|
||||
set(DETECTED_ACCEL_PLATFORM "METAL")
|
||||
else()
|
||||
set(DETECTED_ACCEL_PLATFORM "OPENGL")
|
||||
endif()
|
||||
|
||||
set(ACCEL_PLATFORM ${DETECTED_ACCEL_PLATFORM} CACHE STRING "Acceleration")
|
||||
|
||||
configure_file("platform.h.in" "config/platform.h")
|
||||
|
||||
include_directories("${CMAKE_BINARY_DIR}/config")
|
||||
|
||||
add_executable(xormod
|
||||
"xormod.c"
|
||||
"font.c"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#define ACCEL_PLATFORM SDL_WINDOW_${ACCEL_PLATFORM}
|
||||
#define ACCEL_PLATFORM_STR "${ACCEL_PLATFORM}"
|
20
xormod.c
20
xormod.c
|
@ -1,5 +1,6 @@
|
|||
#include "font.h"
|
||||
#include "EGA8x8.h"
|
||||
#include "platform.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <SDL.h>
|
||||
|
@ -35,11 +36,12 @@ static Picture *Picture_new(SDL_Renderer *rend,
|
|||
p->y2 = y + h;
|
||||
p->w = w;
|
||||
p->h = h;
|
||||
p->pixels = malloc(w * h * sizeof(uint32_t));
|
||||
p->color = color;
|
||||
|
||||
int stride = (w + 7) / 8 * 8;
|
||||
p->pixels = malloc(stride * h * sizeof(uint32_t));
|
||||
p->surface = SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
p->pixels, w, h, 32, w * sizeof(uint32_t),
|
||||
p->pixels, w, h, 32, stride * sizeof(uint32_t),
|
||||
SDL_PIXELFORMAT_RGBA32);
|
||||
|
||||
Picture_render(p, rend);
|
||||
|
@ -84,7 +86,7 @@ int main() {
|
|||
|
||||
SDL_Window *window = SDL_CreateWindow("xormod",
|
||||
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h,
|
||||
SDL_WINDOW_OPENGL /*SDL_WINDOW_FULLSCREEN */);
|
||||
ACCEL_PLATFORM | SDL_WINDOW_FULLSCREEN);
|
||||
if (window == NULL) {
|
||||
fprintf(stderr, "Can't open window: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
|
@ -93,7 +95,7 @@ int main() {
|
|||
SDL_GetWindowSize(window, &w, &h);
|
||||
|
||||
SDL_Renderer *rend = SDL_CreateRenderer(window, -1,
|
||||
/*SDL_RENDERER_PRESENTVSYNC | */SDL_RENDERER_ACCELERATED);
|
||||
SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||
|
||||
SDL_Texture *font = load_font(rend);
|
||||
|
||||
|
@ -114,16 +116,16 @@ int main() {
|
|||
break;
|
||||
}
|
||||
if (keys[SDL_SCANCODE_LEFT]) {
|
||||
off.x -= 5;
|
||||
off.x -= 16;
|
||||
}
|
||||
if (keys[SDL_SCANCODE_RIGHT]) {
|
||||
off.x += 5;
|
||||
off.x += 16;
|
||||
}
|
||||
if (keys[SDL_SCANCODE_UP]) {
|
||||
off.y -= 5;
|
||||
off.y -= 16;
|
||||
}
|
||||
if (keys[SDL_SCANCODE_DOWN]) {
|
||||
off.y += 5;
|
||||
off.y += 16;
|
||||
}
|
||||
|
||||
struct int2 mouse;
|
||||
|
@ -196,6 +198,8 @@ int main() {
|
|||
// draw_text(rend, font, buf, len, RC(2+i, 1), 255, 255, 255);
|
||||
//}
|
||||
|
||||
//draw_text(rend, font, ACCEL_PLATFORM_STR, sizeof(ACCEL_PLATFORM_STR), RC(1,1), 255, 255, 255);
|
||||
|
||||
SDL_RenderPresent(rend);
|
||||
|
||||
SDL_Event e;
|
||||
|
|
Loading…
Reference in New Issue