Possible to change color of render draw_text? (DEF-2697)(SOLVED)

Is it possible to change the color of the text that the render script can draw? I know it’s just for debugging purposes, but that dark blue is really hard to read on any medium or dark background.

Nope, it’s hardcoded. I guess we should make it configurable just as for draw_line.

Edit: Added a ticket for this (DEF-2697)

5 Likes

OK, thanks. Actually it’s kind of nice to not have to specify a color every time, but it would be nice if it was configurable. Ideally, both draw_line and draw_text would have a hardcoded default value and an optional color argument.

3 Likes

Exactly! That’s a nice backward compatible improvement.

2 Likes

I would absolutely love to see this in a future update. To be true, I really like to have even my debug screens look nice :wink:

3 Likes

Still needed! Just make it an extra options vec3 at the end for the color…

2 Likes

+1

1 Like

Yup, bumping this again. Trying to add some debugging stuff, but being stuck with this dark blue color really stinks.

1 Like

We’ll discuss this in our next planning session on Monday.

3 Likes

+1

1 Like

Still want this!

1 Like

+1

1 Like

We will add a new message and deprecate the old one (it will no longer be documented):

msg.post("@render:", "draw_debug_text", { text = "", position = vmath.vector3(), color = vmath.vector4() })

11

8 Likes

A workaround for those who find the debug texts too small (0.5x) on the retina display.

To scale debug texts you need DefOS and the following code in the render script:

local function get_display_info()
  local dummy_info = { mode = { scaling_factor = 1 } }

  local current_display_id = defos.get_current_display_id()
  if not current_display_id then
    return dummy_info
  end

  local current_display_info = defos.get_displays()[current_display_id]
  return current_display_info or dummy_info
end

function init(self)
  ...
  self.text_pred = render.predicate({ 'text' })
  self.display_info = get_display_info()
end

function update(self)
  ...
  local display_scale = self.display_info.mode.scaling_factor or 1
  local debug_text_projection = vmath.matrix4_orthographic(0, render.get_window_width() / display_scale, 0, render.get_window_height() / display_scale, -1, 1)
  render.set_projection(debug_text_projection)
  render.draw(self.text_pred)
end

function on_message(self, message_id, message)
  ...
  if message_id == hash('window_resized') then
    self.display_info = get_display_info()
  end
  ...
end

But also remember to scale the debug text’s position by display_info.mode.scaling_factor, otherwise it will be shifted on the retina display.

5 Likes