ja tenim el control de la finestra i de la imatge
treballant en les tecles de funcio
This commit is contained in:
@@ -3,54 +3,23 @@
|
||||
#include <fstream>
|
||||
|
||||
#include "core/jfile.hpp"
|
||||
#include "core/jshader.hpp"
|
||||
#include "core/screen.hpp"
|
||||
#include "external/gif.h"
|
||||
|
||||
#define SCREEN_WIDTH 960
|
||||
#define SCREEN_HEIGHT 720
|
||||
|
||||
JD8_Surface screen = NULL;
|
||||
JD8_Palette main_palette = NULL;
|
||||
Uint32 *pixel_data = NULL;
|
||||
|
||||
int screenWidth = 320;
|
||||
int screenHeight = 200;
|
||||
|
||||
Uint32 contadorFPS = 0;
|
||||
Uint32 tempsFPS = SDL_GetTicks();
|
||||
char *fps = (char *)malloc(10);
|
||||
|
||||
SDL_Window *sdlWindow = NULL;
|
||||
SDL_Renderer *sdlRenderer = NULL;
|
||||
SDL_Texture *sdlTexture = NULL;
|
||||
SDL_Texture *backBuffer = NULL;
|
||||
|
||||
void JD8_Init(const char *title) {
|
||||
void JD8_Init() {
|
||||
screen = (JD8_Surface)calloc(1, 64000);
|
||||
main_palette = (JD8_Palette)calloc(1, 768);
|
||||
pixel_data = (Uint32 *)calloc(1, 320 * 200 * 4); // 1048576 );
|
||||
|
||||
sdlWindow = SDL_CreateWindow(title, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL);
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
|
||||
// SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
|
||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, NULL);
|
||||
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, 320, 200);
|
||||
backBuffer = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, 320, 200);
|
||||
|
||||
int filesize = 0;
|
||||
char *buffer = file_getfilebuffer("crtpi.glsl", filesize, true);
|
||||
|
||||
shader::init(sdlWindow, backBuffer, buffer);
|
||||
free(buffer);
|
||||
pixel_data = (Uint32 *)calloc(1, 320 * 200 * 4);
|
||||
}
|
||||
|
||||
void JD8_Quit() {
|
||||
if (screen != NULL) free(screen);
|
||||
if (main_palette != NULL) free(main_palette);
|
||||
if (pixel_data != NULL) free(pixel_data);
|
||||
SDL_DestroyRenderer(sdlRenderer);
|
||||
SDL_DestroyWindow(sdlWindow);
|
||||
}
|
||||
|
||||
void JD8_ClearScreen(Uint8 color) {
|
||||
@@ -177,8 +146,6 @@ void JD8_BlitCKToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Rect rect{0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
||||
|
||||
void JD8_Flip() {
|
||||
for (int x = 0; x < 320; x++) {
|
||||
for (int y = 0; y < 200; y++) {
|
||||
@@ -186,11 +153,7 @@ void JD8_Flip() {
|
||||
pixel_data[x + (y * 320)] = color;
|
||||
}
|
||||
}
|
||||
SDL_UpdateTexture(sdlTexture, NULL, pixel_data, 320 * sizeof(Uint32));
|
||||
SDL_SetRenderTarget(sdlRenderer, backBuffer);
|
||||
SDL_RenderTexture(sdlRenderer, sdlTexture, NULL, NULL);
|
||||
shader::render();
|
||||
// SDL_RenderPresent(sdlRenderer);
|
||||
Screen::get()->present(pixel_data);
|
||||
}
|
||||
|
||||
void JD8_FreeSurface(JD8_Surface surface) {
|
||||
|
||||
Reference in New Issue
Block a user