From 2f19e886be54cf2d7fb4a88ca308efc82c1b59d5 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sat, 10 Dec 2016 20:39:17 +0900 Subject: [PATCH] Fix GRPF size --- SMILEBASIC/console.d | 8 ++++---- SMILEBASIC/graphic.d | 15 +++++++-------- SMILEBASIC/petitcomputer.d | 4 ++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/SMILEBASIC/console.d b/SMILEBASIC/console.d index 787927a..3ce20ab 100644 --- a/SMILEBASIC/console.d +++ b/SMILEBASIC/console.d @@ -224,10 +224,10 @@ class Console ConsoleAttribute rot = ch.attr & ConsoleAttribute.TROT270; int z = ch.z; glColor4ubv(cast(ubyte*)&fore); - float tx1 = (rect.x) / 512f - 1; - float ty1 = (rect.y + 8) / 512f - 1; - float tx2 = (rect.x + 8) / 512f - 1; - float ty2 = (rect.y) / 512f - 1; + float tx1 = (rect.x) / (cast(float)petitcom.graphic.GRPFWidth) - 1; + float ty1 = (rect.y + 8) / (cast(float)petitcom.graphic.GRPFHeight) - 1; + float tx2 = (rect.x + 8) / (cast(float)petitcom.graphic.GRPFWidth) - 1; + float ty2 = (rect.y) / (cast(float)petitcom.graphic.GRPFHeight) - 1; int x1 = x * 8; int x2 = x * 8 + 8; int y1 = y * 8; diff --git a/SMILEBASIC/graphic.d b/SMILEBASIC/graphic.d index f973963..3be2ed9 100644 --- a/SMILEBASIC/graphic.d +++ b/SMILEBASIC/graphic.d @@ -63,8 +63,8 @@ struct DrawMessage class Graphic { PetitComputer petitcom; - protected int width; - protected int height; + int width; + int height; this(PetitComputer p) { petitcom = p; @@ -90,7 +90,6 @@ class Graphic } void initGraphicPages() { - petitcom.console.GRPF = createGRPF(petitcom.fontFile); GRP = new GraphicPage[6]; for(int i = 0; i < 4; i++) { @@ -106,7 +105,6 @@ class Graphic g.createTexture(petitcom.renderer, petitcom.textureScaleMode); g.createBuffer(); } - petitcom.console.GRPF.createTexture(petitcom.renderer, petitcom.textureScaleMode); } GraphicPage createGRPF(string file) { @@ -405,13 +403,14 @@ class Graphic x += 8; } } + int GRPFWidth, GRPFHeight; void drawCharacter(int x, int y, wchar character) { auto rect = petitcom.console.fontTable[character]; - float tx1 = (rect.x) / (cast(float)width) - 1; - float ty1 = (rect.y + 8) / (cast(float)height) - 1; - float tx2 = (rect.x + 8) / (cast(float)width) - 1; - float ty2 = (rect.y) / (cast(float)height) - 1; + float tx1 = (rect.x) / (cast(float)GRPFWidth) - 1; + float ty1 = (rect.y + 8) / (cast(float)GRPFHeight) - 1; + float tx2 = (rect.x + 8) / (cast(float)GRPFWidth) - 1; + float ty2 = (rect.y) / (cast(float)GRPFHeight) - 1; glTexCoord2f(tx1 , ty1); glVertex3i(x, y + 8, 0); glTexCoord2f(tx1, ty2); diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index da0aeca..0410746 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -550,6 +550,10 @@ class PetitComputer writeln(SDL_GetError.to!string); return; } + console.GRPF = graphic.createGRPF(fontFile); + graphic.GRPFWidth = console.GRPF.surface.w; + graphic.GRPFHeight = console.GRPF.surface.h; + console.GRPF.createTexture(renderer, textureScaleMode); chScreen(0, 0, 400, 240); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_DEPTH_TEST);