Author Topic: Understanding hardware images  (Read 7172 times)

0 Members and 1 Guest are viewing this topic.

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Understanding hardware images
« on: April 17, 2019, 08:30:15 pm »
I can't post my whole program code, but I'm going crazy trying to figure this out.  I have a loop which calls my graphics drawing routines.  It was working fine until recently, after I made some changes in my graphics routine.  Now I am left with no graphics being drawn to the screen unless I add a CLS in the rendering loop, which I do not want.

Code: QB64: [Select]
  1.    DO
  2.  
  3.       CLS
  4.  
  5.       CALL Timer_Update
  6.       CALL Update_Objects
  7.       CALL Render_Objects
  8.  
  9.       _DISPLAY
  10.       _LIMIT FPS
  11.  
  12.  

With the CLS in the loop, things are drawn to the screen just fine.  If I remove the CLS then my screen is empty.  It used to work either way.  If I didn't use CLS and had no background image, it would leave trails behind the images as they moved around the screen (as expected).  But I have no idea why the screen is completely blank now.  My first thought was a rogue PRINT statement somewhere that is pushing the graphics off the top of the screen, but even if I manually issue the _PUTIMAGE then END during the loop, it still doesn't display anything on the screen.  Is there some way that the default output handle could be changed that CLS fixes?  I'm all out of ideas.

Any clues how not having a CLS statement could prevent images being drawn to the screen with _PUTIMAGE?
« Last Edit: April 18, 2019, 01:52:10 am by Raven_Singularity »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Why would not using CLS block image drawing?
« Reply #1 on: April 17, 2019, 08:38:09 pm »
The _PUTIMAGE and END method, for testing, isn’t working because of _DISPLAY.  You’d at least want to _PUTIMAGE, _DISPLAY, and then END, so you’d display the changes to the screen.

If you think it’s a PRINT pushing things off the screen, simply change that CLS to a LOCATE 1,1, for testing.  It might help confirm the issue.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would not using CLS block image drawing?
« Reply #2 on: April 17, 2019, 08:41:25 pm »
I have already tried LOCATE 1, 1 in the loop, and a _DISPLAY before the END, but neither made any difference.  I am able to read text I PRINT right before the END, without using _DISPLAY.  Is PRINT different than graphics?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Why would not using CLS block image drawing?
« Reply #3 on: April 17, 2019, 08:46:28 pm »
I have already tried LOCATE 1, 1 in the loop, and a _DISPLAY before the END, but neither made any difference.  I am able to read text I PRINT right before the END, without using _DISPLAY.  Is PRINT different than graphics?

No. It probably just means the program is ending before the first _DISPLAY statement is reached.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would not using CLS block image drawing?
« Reply #4 on: April 17, 2019, 08:51:21 pm »
Nah.  Even a few thousand cycles into the render loop it still behaves that way.  PRINT "Hello world": END is always displaying it for me.

Code: QB64: [Select]

Text is visible upon END.

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would not using CLS block image drawing?
« Reply #5 on: April 17, 2019, 09:26:49 pm »
So I've narrowed down the issue.  It is about how CLS and SCREEN work with translucent background colours, and I don't get it.


This code displays the spaceship fine:

Code: QB64: [Select]
  1. CLS 0, _RGBA(255, 0, 0, 0)
  2. CALL Render_Objects


This code displays a solid red screen and no spaceship:

Code: QB64: [Select]
  1. CLS 0, _RGBA(255, 0, 0, 255)
  2. CALL Render_Objects


And this code displays a half-translucent red screen obscuring the spaceship:

Code: QB64: [Select]
  1. CLS 0, _RGBA(255, 0, 0, 255)
  2. CALL Render_Objects


Why is the SCREEN background colour being rendered in front of _PUTIMAGE images?


Edit 1:

Note: Render_Objects does nothing but call _PUTIMAGE with the correct parameters.


Edit 2:

The part that's really confusing me is my app had no issues rendering onto an opaque dark blue-grey background up until recently.  Was there anything that changed between 1.2 and 1.3 that affects how translucency of the screen background is handled?  Hmmm.
« Last Edit: April 17, 2019, 09:35:53 pm by Raven_Singularity »

FellippeHeitor

  • Guest
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #6 on: April 17, 2019, 09:53:26 pm »
Have your images by any chance been converted into hardware images?

https://qb64.org/wiki/DISPLAYORDER
« Last Edit: April 17, 2019, 09:55:03 pm by FellippeHeitor »

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #7 on: April 17, 2019, 09:57:58 pm »
Yes, though I don't exactly understand what that does to the images.  I think that means they render faster on the video card using OpenGL?

Code: QB64: [Select]

But that doesn't explain why the SCREEN background appears in front of my images, or does it?  How?

FellippeHeitor

  • Guest
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #8 on: April 17, 2019, 10:02:11 pm »
With that command you are specifying the render order. If that line is in your code you are instructing QB64 to place hardware images below software rendering. Try it with _SOFTWARE first then _HARDWARE:

_DISPLAYORDER _SOFTWARE, _HARDWARE

The screen background is a software render, that's why.

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #9 on: April 17, 2019, 10:05:13 pm »
If that's the case, then I entirely misunderstood the purpose of _DISPLAYORDER.

I thought _DISPLAYORDER specifies which output renderer to use by default, and if not available to fall back to the next renderer.  The help pages for a lot of these things are really sparse and vague.

I will try poking around at it and see if I can get it to work.  Thank you for the help.


Edit 1:

Secondary question: why is the my screen background not a hardware image?

I set up the screen with the following:

Code: QB64: [Select]
  1.    Main_Screen = _NEWIMAGE(Screen_Width, Screen_Height, 32)
  2.    SCREEN Main_Screen, 33
  3.    _DEST Main_Screen
  4.    CLS 0, C_App_Background

Shouldn't that make my main screen a hardware image?
« Last Edit: April 17, 2019, 10:28:57 pm by Raven_Singularity »

FellippeHeitor

  • Guest
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #10 on: April 17, 2019, 10:27:33 pm »
No. Second parameter to SCREEN does nothing http://www.qb64.org/wiki/SCREEN

If you want to work solely with hardware images, use displayorder with only the hardware switch (also as per the wiki page) and make a hardware image for the bg, which you'll place before the other images.

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #11 on: April 17, 2019, 10:30:45 pm »
I wrote this just before you answered:


Looking at the help page for SCREEN, I'm not sure what that 33 I put in is supposed to be doing.

"The empty comma disables color when any value is used. DO NOT USE! Include the comma ONLY when using page flipping."

Apparently the 33 is in that "don't use" value, hmm.

I guess my question is, "How do I make my screen background a hardware image?"



So, if I only use _DISPLAYORDER _HARDWARE that forces everything to use hardware?  What happens at that point when I do CLS?

FellippeHeitor

  • Guest
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #12 on: April 17, 2019, 10:32:20 pm »
Quote
So, if I only use _DISPLAYORDER _HARDWARE that forces everything to use hardware?

No. If you do that you prevent any software images from ever being rendered, BG included. In that scenario, CLS is useless too.

Offline Raven_Singularity

  • Forum Regular
  • Posts: 158
    • View Profile
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #13 on: April 17, 2019, 10:35:53 pm »
Is text always rendered as SOFTWARE?

I don't see text if I use _HARDWARE only.
« Last Edit: April 17, 2019, 10:39:27 pm by Raven_Singularity »

FellippeHeitor

  • Guest
Re: Why would _PUTIMAGE appear behind the CLS background colour?
« Reply #14 on: April 17, 2019, 10:38:31 pm »
Yes, text is always rendered as software.