Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using _MapTriangle in Small Virtual Screens
#1
I'm kinda stumped. I haven't ever used _MapTriangle (except via RotoZoom), but I saw what @Petr did here (#6) and wanted to create a Star Wars-esque, parallax-looking chunk of screen to display some game info. I can't get the small, copied hardware image to display on a bigger screen no matter what I try. Also, as I wrote in the codebox, why does the "virt" hardware image persist onscreen without being in a display loop? 

Thanks for any help on this.

Code: (Select All)
Dim As Long Image, virt
Screen _NewImage(160, 120, 32) '                                                                a wee screen
$Color:32
Color Yellow

_PrintString (_Width \ 2 - _PrintWidth("TESTING!") \ 2, _Height \ 2), "TESTING!" '              print something
Image = _CopyImage(_Display, 33) '                                                              make it a hardware image
_Delay 2: Sound 2000, .1

For a = 1 To 50 '                                                                              make it lean back, parallax
    _MapTriangle (0, 0)-(0, 119)-(159, 119), Image To(-8, 8, -12)-(-8, -8, -4)-(8, -8, -4), 0
    _MapTriangle (0, 0)-(159, 119)-(159, 0), Image To(-8, 8, -12)-(8, -8, -4)-(8, 8, -12), 0
    _Display '                                                                                  render it for a few cycles
    _Limit 20
    virt = _CopyImage(_Display, 33) '                                                          copy it to another hardware image
Next
Sound 400, .1

_ScreenMove 600, 400 '                                                                          move screen and display the copy

_PutImage , virt '              Why doesn't this hardware image need a loop to display? Or a _Display command?

_Delay 2.5 '                    AND WHY CAN'T I GET THIS VIRT IMAGE TO APPEAR ON ANOTHER, BIGGER SCREEN?!

System
Reply
#2
Looks to me like you're making a copy of the software screen, but /i don't see any point where you're clearing the software screen.  Since it was already drawn upon, wouldn't the image stay upon it until you cleared it yourself?

Also remember that Image is a hardware image, so it's not actually displaying on your _DISPLAY; it's displaying on its own hardware layer.  That virt = _CopyImage is copying a blank screen for you, from what my brain is telling me initially, without getting out of bed and actually running and testing things on the PC personally.  Big Grin   I'm being lazy and trying to diagnose issues while resting my poor back and playing on my iPad.  Wink
Reply
#3
Ahh, okay, thanks for the armchair analysis, Steve! I think I get it now. I'll noodle around and see if I can make it work.
Now go back to resting your body.   Wink
Reply
#4
(07-04-2025, 05:54 AM)NakedApe Wrote: Ahh, okay, thanks for the armchair analysis, Steve! I think I get it now. I'll noodle around and see if I can make it work.
Now go back to resting your body.   Wink

See if this helps explain what you're doing wrong here:

Code: (Select All)
Dim As Long Image, virt
Screen _NewImage(160, 120, 32) '                                                                a wee screen
$Color:32
Color Yellow

_PrintString (_Width \ 2 - _PrintWidth("TESTING!") \ 2, _Height \ 2), "TESTING!" '              print something
Image = _CopyImage(_Display, 33) '                                                              make it a hardware image
_Delay 2: Sound 2000, .1

'Steve changes explained as we go along here:
'First, move virt outside the loop.  No need to make endless copies inside the loop when we're only using the final one
'The loop doesn't change any values, so it's not tilting slowly or anything..
'It's just spending 2.5 a seconds to showcase the same thing repeatedly
'and make 50 hardware copies of the same software image (the display with the _PRINTSTRING text above written on it)

_MapTriangle (0, 0)-(0, 119)-(159, 119), Image To(-8, 8, -12)-(-8, -8, -4)-(8, -8, -4), 0
_MapTriangle (0, 0)-(159, 119)-(159, 0), Image To(-8, 8, -12)-(8, -8, -4)-(8, 8, -12), 0
_Display '                                                                                  render it for a few cycles

_Delay 2.5 'By adding this delay here, we generate the same 2.5 seconds of viewing pleasure


'Note that we only drew on the hardware layer.  Our software layter still holds that same "TESTING"
'which was placed on it by the _PRINTSTRING statement above.
'It's just *hidden* by the hardware overlay which is OVER it at the moment.

virt = _CopyImage(_Display, 33) '                                                          copy it to another hardware image

'And thus, that _COPYIMAGE just made a copy of that non-titled "TESTING!" which is on the display.
'(The display which is hidden with the hardware overlay of the tilted text over it.)


'Then, since we're using the main screen to draw our normal text, we should clear it afterwards.  Note that the tilted text is ONLY on the hardware layer as IMAGE is a hardware image from copyimage, 33
Cls , 0 'This clears it
_Display 'And this updates the display to show it clear
'Without the _DISPLAY, we wouldn't update the screen with the CLS statement above it

Sound 400, .1

_ScreenMove 600, 400 '                                                                          move screen and display the copy


_Delay 2.5 'A pause added here so we can now see that we DO, indeed have a blank screen

_PutImage , virt '              Why doesn't this hardware image need a loop to display? Or a _Display command?


'Note that this delay shows that the _PUTIMAGE doesn't do anything for us...
'At least, not until the next _DISPLAY statement updates the screen and shows the hardware buffer
_Delay 2.5 '                    AND WHY CAN'T I GET THIS VIRT IMAGE TO APPEAR ON ANOTHER, BIGGER SCREEN?!



_Display 'This shows it as it should exist for us now -- the normal text which we last copied from the software screen

_Delay 2.5 'And this gives us time to see it

System

Copy that into the IDE and read over the comments.  It explains the flow of what you're doing, and the changes I made to highlight those issues.

What you want to do is:
1) Just make yourself a _NEWIMAGE the same size as your display screen.
2) Make a copy of that image while it's still blank.  You now have two blank images to work with.
3) Draw the text on that first image normally, so you don't corrupt your display.
3) Use the first image as a reference point to _MAPTRIANGLE the desired tilt onto the second image.
4) NOW make a hardware image of that second, tilted image.
5) Free up both those temporary software screens that you no longer need.

You'll now have your hardware text titled onto an image that you can _PUTIMAGE wherever you want onto your screen.  (Or, over the whole screen as you do with that last _PUTIMAGE ,virt statement.
Reply
#5
Thanks for taking the time to explain that! I’ll give it another go. Happy 4th. And +1
Reply
#6
Okay, Steve @SMcNeill, I've messed with this some more. What you didn't notice was that I was asking _MapTriangle to do a 3D render, which requires a hardware image to start. I can't get the resulting tilted hardware image copied to or written to a new screen - or keep it the right size - because it only seems to work when I _MapTriangle to the main screen. What the high-dilly-ho is goin on?  Big Grin  Thanx

Code: (Select All)
Option _Explicit
Dim As Long Image, virt, final
Dim As Integer a, b
Screen _NewImage(1920, 1080, 32)

virt = _NewImage(160, 120, 32)
Image = _CopyImage(virt, 32)
final = _CopyImage(virt, 32)

_PrintString (_Width(virt) \ 2 - _PrintWidth("TESTING!") \ 2, _Height(virt) \ 2), "TESTING!", virt
Image = _CopyImage(virt, 33) '    <<<<<<<<<<<<<<<<  you have to make this a hardware image here in order to call _MapTriangle to perform a 3D render
_Delay .6
Sound 2000, .1

For a = 1 To 90
    Cls
    b = b + 1
    _PutImage (400 + b, 400), Image
    _PrintString (400 + b, 500), "Small Hardware Image put to main screen"
    _Display
    _Limit 30
Next

Cls , 0

_MapTriangle (0, 0)-(0, 119)-(159, 119), Image To(-8, 8, -12)-(-8, -8, -4)-(8, -8, -4), 0 ' can a hardware image be placed in a new screen using _MapTriangle?
_MapTriangle (0, 0)-(159, 119)-(159, 0), Image To(-8, 8, -12)-(8, -8, -4)-(8, 8, -12), 0 '  ... it works going to the primry screen here ...
_PrintString (480, 900), "Tilted Hardware Image" '                                    ^ PUTTING "final" HERE INSTEAD OF ZERO GIVES AN ERROR
_Display

Sound 1000, .1 '                                                ** I wanna save the tilted hardware image and keep it small **
_Delay 2.6


'Do
'_PutImage (200, 300), final, 0
'_Display
'_Limit 30
'Loop Until _KeyHit

_FreeImage virt: _FreeImage Image: _FreeImage final

System
Reply
#7
OK, I got it. It helps to really read the wiki entry carefully. When I defined the "final" screen as a hardware image with _CopyImage, then it accepted the mapped triangles.  All is good.
Reply
#8
+1 for reading the wiki and sorting it out on your own while we were fireworking, drinking, and then sleeping like drunken bears.  It's amazing how few people will actually do that.  Big Grin
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  _MAPTRIANGLE EXAMPLES NakedApe 22 1,167 01-25-2026, 05:43 PM
Last Post: ahenry3068
  A Question About _MAPTRIANGLE Magdha 2 369 11-02-2025, 11:37 AM
Last Post: Magdha
  Locate command on the ttf graphical screens Helium5793 5 695 03-09-2025, 05:47 PM
Last Post: SMcNeill
  open multiple screens at once drewdavis 2 777 09-09-2024, 08:08 AM
Last Post: Pete
  Does _MapTriangle work in a user defined Window? bplus 12 2,210 02-16-2024, 01:40 AM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)