Author Topic: Hardware1?  (Read 3463 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Hardware1?
« on: September 15, 2018, 02:29:55 am »
Quick question:  How do we access the 2nd hardware screen again?  _DISPLAYORDER tells us we have 2 hardware screens, and I remember using the in the past, but I don't recall the syntax now.

_COPYIMAGE(image,34)??
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Gets

  • Newbie
  • Posts: 28
    • View Profile
Re: Hardware1?
« Reply #1 on: September 15, 2018, 03:35:21 am »
Set the destination for a hardware image to 1 and it will be displayed on that screen, I think. I don't remember anything else

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Hardware1?
« Reply #2 on: September 15, 2018, 04:03:14 am »
_DISPLAYORDER _HARDWARE
or
_DISPLAYORDER _HARDWARE1

it is what you meant?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Hardware1?
« Reply #3 on: September 15, 2018, 11:50:39 am »
_DISPLAYORDER _HARDWARE
or
_DISPLAYORDER _HARDWARE1

it is what you meant?

Not quite.   

QB64 has 2 different hardware screens which we can put images on to layer them, as well as the software screen and the one for OpenGL generated images.  Imagine 4 drawings -- a circle, triangle, square, and scribbles...  With each one on a different screen, we can use _DISPLAYORDER to set them to layer however we want.  The square might draw over the circle, but be under the triangle, with the scribbles on top of them all...

We just draw to put stuff on the software screen.   LINE, PSET, CIRCLE, ect...
We use GL commands in _SUBGL to put stuff on the GL-screen.
We use _COPYIMAGE(image,33) or _NEWIMAGE(x,y,33) to put stuff on the HARDWARE screen.

But what's the syntax to put stuff on that second hardware screen?  _HARDWARE1?

What simple step am I forgetting to designate the difference in which one I want to draw/copy to?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Hardware1?
« Reply #4 on: September 15, 2018, 11:50:53 am »
Well this is interesting. Something I missed in the _DISPLAYORDER wiki entry and never even knew about.

Does anyone have code to show how to take advantage of the second hardware screen?
In order to understand recursion, one must first understand recursion.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Hardware1?
« Reply #5 on: September 15, 2018, 11:55:07 am »
Well this is interesting. Something I missed in the _DISPLAYORDER wiki entry and never even knew about.

Does anyone have code to show how to take advantage of the second hardware screen?

I do...

On the [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] forums, where I did a demo on _DISPLAYORDER in the past. 

Problem is, I can't quite remember how it worked now.  I was thinking it was just a simple difference of using 33 or 34 to designate the two screens, but I was having issues with that last night when I tried it.  I may have to dig into the source some to see how to properly use the second hardware screen again.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: Hardware1?
« Reply #6 on: September 15, 2018, 12:31:26 pm »
There's no mode 34, that's for certain.

By looking at the code, (in internal/c/libqb/gui.cpp) it seems like _HARDWARE and _HARDWARE1 are the same layer that can be overlaid twice, so that you could have _HARDWARE, _SOFTWARE, _HARDWARE1 and then have a hardware surface sandwich filled with a software screen or _GL screen.

To be confirmed, but it really seems so from what I've found.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Hardware1?
« Reply #7 on: September 15, 2018, 12:51:06 pm »
I was snooping around in that file too and noticed something. I'm not a C++ programmer first of all, so I could be totally incorrect on this.

However, it appears the 'else' statement on line 214 has no associated closing brace.

On line 225 another 'if' statement starts with an opening brace.

The section appears to have something to do with stretching a letter box view and square pixels.

Edit: maybe the closing brace on line 244 is the one I'm missing? The indenting is a bit strange.

Never mind - Notepad++ was closing some of them. Line 244 is the associated brace.
« Last Edit: September 15, 2018, 01:04:20 pm by TerryRitchie »
In order to understand recursion, one must first understand recursion.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Hardware1?
« Reply #8 on: September 15, 2018, 01:14:03 pm »
Try this way

press spacebar for layers selecting
Code: QB64: [Select]
  1.  
  2. 'four layers: software, hardware, GL, hardware2
  3.  
  4.  
  5. soft& = _NEWIMAGE(320, 240, 32)
  6. hard& = _NEWIMAGE(320, 240, 32)
  7. hard2& = _NEWIMAGE(320, 240, 32)
  8.  
  9.  
  10. SCREEN _NEWIMAGE(800, 600, 32)
  11.  
  12. _DEST soft&
  13. CIRCLE (160, 120), 90, _RGB32(255, 255, 255)
  14.  
  15. _DEST hard&
  16. LINE (20, 20)-(300, 220), _RGB32(0, 0, 255), BF
  17. hardw& = _COPYIMAGE(hard&, 33)
  18.  
  19. _DEST hard2&
  20. LINE (0, 0)-(319, 239), _RGB32(255, 255, 255), BF
  21. hardw2& = _COPYIMAGE(hard2&, 33)
  22. _FREEIMAGE hard2&
  23.  
  24.  
  25.  
  26. DO WHILE I$ <> CHR$(27)
  27.     I$ = INKEY$
  28.     IF I$ = CHR$(32) THEN selec = selec + 1: IF selec > 3 THEN selec = 0
  29.     SELECT CASE selec
  30.         CASE 0
  31.             _DISPLAYORDER _GLRENDER
  32.  
  33.         CASE 1
  34.             _DISPLAYORDER _HARDWARE , _HARDWARE1
  35.             _PUTIMAGE (0, 0), hardw&
  36.  
  37.         CASE 2
  38.             _DISPLAYORDER _HARDWARE1 , _HARDWARE
  39.             _PUTIMAGE (0, 0), hardw2&
  40.  
  41.  
  42.         CASE 3
  43.             CLS
  44.             PRINT "software", soft&
  45.             _PUTIMAGE , soft&
  46.  
  47.  
  48.  
  49.  
  50.     END SELECT
  51.  
  52.  
  53.     _DISPLAY 'NEED FOR HARDWARE!!!!
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. SUB _GL
  63.  
  64.     'for opengl
  65.  
  66.     ' GLubyte bitmap[24]={                      //bitmap size 10 x 12 pixels
  67.     DIM bitmap(24) AS _UNSIGNED _BYTE
  68.     RESTORE value
  69.     '--------------------------------- Glubyte QB64 method --------------------------------
  70.     FOR LoadArray = 0 TO 23
  71.         READ value$
  72.         hexadecimal$ = "&H" + RIGHT$(value$, 2)
  73.         bitmap(LoadArray) = VAL(hexadecimal$)
  74.     NEXT
  75.     value:
  76.     DATA 0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00 '// begin is in left down corner              SEE TO LINE 47 HOW TO WRITE CORRECTLY THIS ARRAY FOR USE WITH _OFFSET!!!! (last parameter for _glBitmap)
  77.     DATA 0xc0,0x00,0xff,0x00,0xff,0x00,0xc0,0x00
  78.     DATA 0xc0,0x00,0xc0,0x00,0xff,0xc0,0xff,0xc0
  79.     '--------------------------------- Glubyte end -----------------------------------------
  80.  
  81.  
  82.  
  83.     _glPixelStorei _GL_UNPACK_ALIGNMENT, 1 '      // every pixel sort to bytes
  84.     _glClearColor 0.0F, 0.0F, 0.0F, 0.0F '       // background color
  85.  
  86.  
  87.  
  88.  
  89.  
  90.     _glViewport 0, 0, _DESKTOPWIDTH, _DESKTOPHEIGHT '                    // you see complete window
  91.     _glMatrixMode _GL_PROJECTION '               // modification matrix begin
  92.     _glLoadIdentity '                          //  clear matrix (create identity)
  93.     _glOrtho 0, _DESKTOPWIDTH, 0, _DESKTOPHEIGHT, -1, 1 '
  94.  
  95.  
  96.     _glClear _GL_COLOR_BUFFER_BIT '              // clear all colors in color buffer
  97.  
  98.     _glBegin _GL_TRIANGLES '                      // draw RGB triangle in background
  99.     _glColor3f 1.0F, 0.0F, 0.0F
  100.     _glVertex2i 0, 0
  101.     _glColor3f 0.0F, 1.0F, 0.0F
  102.     _glVertex2i 400, 0
  103.     _glColor3f 0.0F, 0.0F, 1.0F
  104.     _glVertex2i 200, 300
  105.     _glEnd
  106.  
  107.     _glColor3f 1.0F, 1.0F, 1.0F '                // white color for first bitmap
  108.     _glRasterPos2i 200, 200 '                    // position for first bitmap
  109.     _glBitmap 10, 12, 0.0F, 0.0F, 0.0F, 0.0F, _OFFSET(bitmap()) '// draw bitmap
  110.  
  111.     _glColor3f 0.0F, 0.0F, 0.5F '                // darkblue color for second bitmap
  112.     _glRasterPos2i 50, 10 '                      // position for second bitmap
  113.     _glBitmap 10, 12, 0.0F, 0.0F, 0.0F, 0.0F, _OFFSET(bitmap()) ' draw second bitmap
  114.  
  115.     _glRasterPos2i 350, 10 '                     // ATTENTION, here is color set after glRasterPos2i(),
  116.     _glColor3f 0.5F, 0.0F, 0.0F '                // also color for next bitmap is the same as in previous case
  117.     _glBitmap 10, 12, 0.0F, 0.0F, 0.0F, 0.0F, _OFFSET(bitmap()) ' vykresleni bitmapy
  118.  
  119.     _glFlush '                                  // create and draw all to screen
  120.  
  121.  
  122.