Commit 9a71ed1944172abba494938d4d618f4ccca08942

Thomas de Grivel 2022-02-25T08:06:16

fix viewport

diff --git a/lib/exterm.ex b/lib/exterm.ex
index bccf0a1..7af4eaa 100644
--- a/lib/exterm.ex
+++ b/lib/exterm.ex
@@ -3,7 +3,7 @@ defmodule Exterm do
   use Bitwise
 
   @title 'exterm'
-  @size {800, 600}
+  @size {721, 433}
 
   def start_link(opts) do
     {_ref, _num, _type, pid} = :wx_object.start_link(__MODULE__, opts, [])
@@ -96,7 +96,6 @@ defmodule Exterm do
   end
 
   def handle_event({:wx, _, _, _, {:wxKey, :char, _, _, code, _, _, _, _, _, _, _}}, state) do
-    IO.inspect([code])
     state = state
     |> state_input_char([code])
     :wx.batch(fn -> render(state) end)
@@ -145,12 +144,10 @@ defmodule Exterm do
 
   defp resize_gl_scene(width, height) do
     IO.inspect({:resize_gl_scene, width, height})
-    width = width * 2
-    height = height * 2
-    :gl.viewport(0, 0, width, height)
+    :gl.viewport(0, 0, width * 2, height * 2)
     :gl.matrixMode(:gl_const.gl_projection)
     :gl.loadIdentity()
-    :gl.ortho(0.0, width + 0.0, 0.0, height + 0.0, -1000.0, 1000.0)
+    :gl.ortho(0.0, width + 0.0, 0.0, height + 0.0, -100.0, 100.0)
     :gl.matrixMode(:gl_const.gl_modelview)
     :gl.loadIdentity()
     :ok
@@ -164,12 +161,12 @@ defmodule Exterm do
         Exterm.Font.load_glyph(font.regular, c)
       end)
     end)
-    :gl.clearColor(0.0, 0.0, 0.0, 0.0)
+    :gl.clearColor(0.5, 0.5, 0.5, 0.0)
     :gl.clear(:gl_const.gl_color_buffer_bit)
     lists
     |> Enum.with_index()
     |> Enum.each(fn {line, i} ->
-      :gl.rasterPos2f(0.0, i * 32.0 + 64.0)
+      :gl.rasterPos2f(0.0, i * 16.0 + 32.0)
       :gl.callLists(line)
     end)
   end
@@ -201,7 +198,6 @@ defmodule Exterm do
     r = if r == 0, do: 8, else: r
     acc1 = 1..r
     |> Enum.reduce(acc, fn _, acc -> [32 | acc] end)
-    IO.inspect([len: len, r: r, acc1: acc1])
     wrap([rest | rest1], w, lines, x + r, acc1)
   end
   def wrap([[c | rest] | rest1], w, lines, x, acc) do
diff --git a/lib/exterm/font.ex b/lib/exterm/font.ex
index c1772b5..faa51e6 100644
--- a/lib/exterm/font.ex
+++ b/lib/exterm/font.ex
@@ -39,7 +39,7 @@ defmodule Exterm.Font do
       size = w * h * 8
       :ok = :gl.readPixels(0, 0, w, h, :gl_const.gl_red, :gl_const.gl_unsigned_byte, pixels = <<0::integer-size(size)>>)
       :ok = :gl.newList(id, :gl_const.gl_compile)
-      :ok = :gl.drawPixels(w, h, :gl_const.gl_luminance, :gl_const.gl_unsigned_byte, pixels)
+      :ok = :gl.drawPixels(w - 3, h, :gl_const.gl_luminance, :gl_const.gl_unsigned_byte, pixels)
       :ok = :gl.bitmap(0, 0, 0.0, 0.0, 18.0, 0.0, <<0>>)
       :ok = :gl.endList()
       id
@@ -66,8 +66,8 @@ defmodule Exterm.Font do
     ttf = ttf(font.family)
     if glyph = TTF.glyph(ttf, codepoint) do
       :gl.pushMatrix()
-      :gl.translatef(3.0, 9.0, 0.0)
-      :gl.scalef(0.014, 0.014, 0.0)
+      :gl.translatef(1.0, 5.0, 0.0)
+      :gl.scalef(0.007, 0.007, 0.0)
       Enum.each(glyph.contours, fn contour ->
         :gl.begin(:gl_const.gl_line_loop)
         Enum.each(TTF.Glyph.contour_segments(contour), fn control_point ->