Author Topic: Using _MEM to set screen pixels (Question for Steve McNeill)  (Read 3142 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Using _MEM to set screen pixels (Question for Steve McNeill)
« on: January 28, 2020, 09:56:55 am »
Steve, I'm about to start a project where I will put images to the screen using _MEM processing.  I'll view again your videos 1&2 to remind myself of the exact methods to change the RGB values of individual pixels.  But I'm wondering when the actual screen gets updated with the new values.  If I were using _HARDWARE imaging, I'd have a _DISPLAY at every processing loop to update the screen, but I assume that _DISPLAY is not required (and is inappropriate) for _MEM screen methods.  Do I just set the _LIMIT value of my program to whatever is required for the correct processing rate and the screen will get updated at the computer/screen refresh rate, ie we leave the graphics setting at the default  _AUTODISPLAY? - Qwerkey's dim question of the week no. 20,348!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Using _MEM to set screen pixels (Question for Steve McNeill)
« Reply #1 on: January 28, 2020, 10:40:26 am »
Hi. You must use MEM on a software image, then convert it to hardware and then this hardware image displaying with the _DISPLAY statement. If you do not do this (with a hardware image!), The graphics card driver crashes and the program crashes.

Try it: WARNING! This program crashes your graphic driver and QB64 IDE!

Code: QB64: [Select]
  1. himage = _COPYIMAGE(_SCREENIMAGE, 33)
  2. SCREEN _NEWIMAGE(1024, 768, 32)
  3.  
  4.     _MAPTRIANGLE (0, 0)-(1024, 0)-(0, 768), himage TO(-1, 1, -2)-(1, 1, -2)-(-1, -1, -2), 0
  5.  
  6.  

For runing it CORRECTLY, in loop must be _DISPLAY statement used!
« Last Edit: January 28, 2020, 11:50:43 am by Petr »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Using _MEM to set screen pixels (Question for Steve McNeill)
« Reply #2 on: January 28, 2020, 12:24:49 pm »
Petr, if all else fails I will use the method as you suggest (and which I have previously done): _MEM edit a software image (same size as screen), copy to _HARDWARE, _PUTIMAGE hardware image, _DISPLAY.  That should keep the processor busy!
But I thought that "Steve's" _MEM edit of the screen image directly would be more efficient, if only I knew how to do it correctly.

Offline Gets

  • Newbie
  • Posts: 28
    • View Profile
Re: Using _MEM to set screen pixels (Question for Steve McNeill)
« Reply #3 on: January 30, 2020, 01:38:56 pm »
Might be best to just not use hardware acceleration in this case? The speed boost is nice but it comes at the expense of sacrificing a lot of QB64's basic graphical capabilities.