Hello again Cloggy,
Here is a sample of code with which I am working:
global technique = 2: ` Set to 1 to use GET IMAGE, or to 2 to use the experimental dynamic image editing functionality
global d3dtext = 1: ` Set to 1 to use D3D text drawing functions or 0 to use DBP's native text commands
set display mode 1280, 1024, 16
sync on: sync rate 0
set text font "courier new": set text size 14 : set text transparent: set text to normal
ink rgb(255, 255, 255), 0
cls
set bitmap format 21: ` Allows all future bitmaps created to maintain transparency information (alpha channel)
create bitmap 1, screen width(), screen height()
cls
set current bitmap 0
d3d_init
f$ = "times new roman"
d3d_font 1, f$, 12, 0, 0, 0
do
drawwindows()
sync
loop
end
function drawwindows()
x1 = 100
y1 = 100
x2 = 600
y2 = 300
winsizex = abs(x2 - x1)
winsizey = abs(y2 - y1)
if technique = 1
set current bitmap 1
else
set bitmap format 21
create bitmap 2, screen width(), screen height()
make camera 1
set camera to image 1, 999, winsizex+2, winsizey+35, 2: ` This makes camera 1 look at image 999
clear camera view 1
set current bitmap -1: ` This causes all further graphical output to be drawn to the image being viewed by the camera number specified here (absolute value), thus dynamically modifying the image in question.
endif
d3dcolor(0, 255)
d3d_box 0, 0, screen width(), screen height()
d3dcolor(8, 255)
d3d_box 1, 1, winsizex+1, winsizey+34
d3dcolor(15, 255)
d3d_line 0, 0, winsizex+1, 0
d3d_line winsizex+1, 0, winsizex+1, winsizey+34
d3d_line winsizex+1, winsizey+34, 0, winsizey+34
d3d_line 0, winsizey+34, 0, 0
d3d_line 1, 16, winsizex+1, 16
d3d_line 1, winsizey+17, winsizex+1, winsizey+17
if d3dtext
` Use D3D to draw caption and status text to windows
d3d_starttext
d3dcolor(15, 255)
d3d_boxtext 1, 5, 2, winsizex-20, 15, 0, 0, "WINDOW CAPTION"
d3dcolor(7, 255)
d3d_boxtext 1, 5, winsizey+18, winsizex-20, winsizey+23, 0, 0, "Status text"
d3d_endtext
else
` Use DBP to draw caption and status text to windows
color(15)
text 5, 2, "WINDOW CAPTION"
color(7)
text 5, winsizey+18, "Status text"
endif
` Draw contents of window
ox = 10
oy = 20
if d3dtext
d3dcolor(15, 255)
d3d_starttext
d3d_text 1, ox, oy, 0, "This is a string"
d3d_endtext
else
color(15)
text ox, oy, "This is a string"
endif
` Draw the final composite to the screen
image = 999
if technique = 1
get image image, 0, 0, winsizex+2, winsizey+35, 1
endif
sprite 2, 1, 1, image
hide sprite 2
offset sprite 2, image width(image)/2, image height(image)/2
set current bitmap 0
paste sprite 2, 500, 200
` Technique 2 requires resource cleanup, ready for the next composite window to be drawn
if technique = 2
delete camera 1
delete bitmap 2
endif
set current bitmap 0
endfunction
function color(c)
if c = 0 then ink rgb(0, 0, 0), 0
if c = 1 then ink rgb(0, 0, 150), 0
if c = 2 then ink rgb(0, 150, 0), 0
if c = 3 then ink rgb(0, 150, 150), 0
if c = 4 then ink rgb(150, 0, 0), 0
if c = 5 then ink rgb(150, 0, 150), 0
if c = 6 then ink rgb(200, 150, 0), 0
if c = 7 then ink rgb(150, 150, 150), 0
if c = 8 then ink rgb(100, 100, 100), 0
if c = 9 then ink rgb(0, 100, 255), 0
if c = 10 then ink rgb(0, 255, 0), 0
if c = 11 then ink rgb(0, 255, 255), 0
if c = 12 then ink rgb(255, 0, 0), 0
if c = 13 then ink rgb(255, 0, 255), 0
if c = 14 then ink rgb(255, 255, 0), 0
if c = 15 then ink rgb(255, 255, 255), 0
endfunction
function d3dcolor(c, a)
if c = 0 then d3d_color 0, 0, 0, a
if c = 1 then d3d_color 0, 0, 150, a
if c = 2 then d3d_color 0, 150, 0, a
if c = 3 then d3d_color 0, 150, 150, a
if c = 4 then d3d_color 150, 0, 0, a
if c = 5 then d3d_color 150, 0, 150, a
if c = 6 then d3d_color 200, 150, 0, a
if c = 7 then d3d_color 150, 150, 150, a
if c = 8 then d3d_color 100, 100, 100, a
if c = 9 then d3d_color 0, 100, 255, a
if c = 10 then d3d_color 0, 255, 0, a
if c = 11 then d3d_color 0, 255, 255, a
if c = 12 then d3d_color 255, 0, 0, a
if c = 13 then d3d_color 255, 0, 255, a
if c = 14 then d3d_color 255, 255, 0, a
if c = 15 then d3d_color 255, 255, 255, a
endfunction
There are two flags used in the first two lines of this code. Each one toggles between two different methods of doing things; the first is which method of text drawing to use (DBP native or D3DFunc), and the other is which method of drawing the window to the screen to use (GET IMAGE or a dynamic image manipulation technique). All combinations work as expected except for the one I most want to use, which is D3DFunc + Dynamic image manipulation (technique = 2, d3dtext = 1). Try the four different possibilities and see for yourself.
For clarification, here is the usage of the two flags:
The flag D3DTEXT can be either 0 or 1:
0 - No D3DFunc calls are made whatsoever, and all text output is done using DBP's native text commands.
1 - No native DBP text commands are called, and all text output is done using D3DFunc.
The flag TECHNIQUE can be either 1 or 2:
1 - The graphics will be drawn to bitmap 1, then a GET IMAGE is used to grab the window, return to bitmap 0 and paste it to the displayable screen. In this mode, both types of text drawing function correctly and as expected.
2 - A means of dynamically editing an image at runtime to avoid using GET IMAGE (because it's slow). We use bitmap 2, and point camera 1 at it, then we set the current bitmap to -1, which causes all further graphical output to be placed directly onto the image that camera 1 is pointing at. If you're unfamiliar with it, there's some more information on the technique here:
http://forum.thegamecreators.com/?m=forum_view&t=158110&b=1. When using this technique, DBP's native text commands function as expected, but D3DFunc fails with the effects I described in my post immediately above.
Again, the faulty combination is technique 2, d3dtext 1. Clearly there is some combination of commands that this permutation uses which is causing the faulty display of text - OR something important is being omitted in this combination only. Am i making a mistake somewhere, or is it a bug in D3DFunc?
Either way, any help would be much appreciated.
[EDIT]: Cleaned up the code sample a bit.