Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Download Outerra Tech Demo. Unofficial Outerra Discord server, MicroProse Discord server for OWS.

Author Topic: showing images on canvas ?  (Read 11348 times)

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
showing images on canvas ?
« on: April 14, 2019, 11:53:56 am »

I am trying to show some images on the canvas using script found in some of outerra default models. It works to show the airspeed.dds image. I tried to edit this file in gimp or subtsitute it with another one made by me in gimp (.dds   DXT1 format generate mipmaps) and add also the corresponding .tga as I have seen there is also a airspeed.tga in the Anteworld/ui folder  but neither works. Nothing shows up. I only can get to show up the airspeed.dds or the set of images basic.dds with all of the images of the set showing together. How to create and show my own images on the canvas ?


Code: [Select]
var display_canvas,$sketch;

function init_vehicle()
{
...
 $sketch = this.sketch = this.$query_interface("ot::js::sketch.get");
}


function update_frame(dt, engine, brake, steering)
{

this.img = $sketch.load_image("ui/airspeed.dds");
   
$sketch.make_canvas_active(display_canvas);
var screen_size = world.screen_size();
$sketch.set_canvas_2d_offset({ x: screen_size.x*0, y: 0 });
$sketch.clear_canvas();
$sketch.draw_image(this.img, {x:300,y:300}, 0xffffffff);
}
« Last Edit: April 14, 2019, 11:57:14 am by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: showing images on canvas ?
« Reply #1 on: April 14, 2019, 01:17:50 pm »

airspeed.dds is in uncompressed ARGB format, did you try that one?
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: showing images on canvas ?
« Reply #2 on: April 14, 2019, 02:19:18 pm »

Thanks cameni ! Now that I exported it form gimp as uncompressed RBGA8 (no mipmap) it works !  Great !
« Last Edit: April 14, 2019, 03:33:10 pm by fly77 »
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: showing images on canvas ?
« Reply #3 on: April 27, 2019, 04:27:03 pm »

I have a HUD for a plane that I made using the  this.sketch.draw_text  command  as it gives the text clearly visible in different colors and allways in same place whatever the cameraview.
As I spawn a second instance of the same plane I'd like to show a fresh canvas..but it seems that this.sketch.clear_canvas() only clears the canvas of instance that created it. So the result after spawning a second instance of the plane is as bad as in the image below. No better result if I leave away the "this." How to completely remove the canvas when exiting the plane or when entering the new one so that a new plane (or other vehicle) finds a clear screen on which to display its canvas ?


Code: [Select]
function initialize(reload){
...
this.sketch = this.$query_interface("ot::js::sketch.get");
this.display_canvas = this.sketch.create_canvas(-1, { x: 0, y: 0 }, {x: 0, y: 0 });

}

function update_frame(dt){
...
this.sketch.make_canvas_active(this.display_canvas);
    screen_size = ot_world.screen_size();
    this.sketch.set_canvas_font('ui/xolonium_50_bold.fnt');
    this.sketch.clear_canvas();
     
    var sentence = "dynamic object hit: "+ hitscore;
    this.sketch.draw_text({ x:screen_size.x-sentence.length * (45), y: screen_size.y*(1-1/25)-50 }, 0xddff0000, sentence);
   
}

« Last Edit: April 27, 2019, 04:49:48 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: showing images on canvas ?
« Reply #4 on: April 29, 2019, 06:25:19 am »

Well, that's a disadvantage when scripts access global objects, you then need to manage it too. I think we already decided there will have to be canvas given to the active vehicle via vehicle api, that will be shared and managed (cleared).
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: showing images on canvas ?
« Reply #5 on: April 29, 2019, 11:12:35 am »

OK. Will try if I can somehow "manage it too", waiting for a more simple solution in the future.
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1761
Re: showing images on canvas ?
« Reply #6 on: December 30, 2019, 09:48:20 am »

Thinking about  "improvements" in the next release it would be very useful to have a fresh canvas for each spawned object so that text from one does not overlap onto text of the other object's canvas.
Logged