setgraphics and keydown

BlitzMax Forums/BlitzMax Programming/setgraphics and keydown

BinaryBurst(Posted 2016) [#1]
This code tries to render two windows and ends when escape key is hit.
SetGraphicsDriver D3D9Max2DDriver()
g1:tgraphics=CreateGraphics(300,300,0,60,GRAPHICS_BACKBUFFER)
g2:tgraphics=CreateGraphics(300,300,0,60,GRAPHICS_BACKBUFFER)

While Not KeyDown(key_escape)

	SetGraphics(g1)
	Plot(10,10)
	Flip(1)
	
	SetGraphics(g2)
	Plot(10,10)
	Flip(1)

Wend


It doesn't end when I hit escape. What am I doing wrong? :)


BinaryBurst(Posted 2016) [#2]
Fixed it.
SetGraphicsDriver D3D9Max2DDriver()
g1:tgraphics=CreateGraphics(300,300,0,60,GRAPHICS_BACKBUFFER)
g2:tgraphics=CreateGraphics(300,300,0,60,GRAPHICS_BACKBUFFER)

Repeat

	SetGraphics(g1)
	Plot(10,10)
	Flip(1)
	
	SetGraphics(g2)
	Plot(10,10)
	Flip(1)
	
	
	PollEvent()
	If CurrentEvent And CurrentEvent.id=EVENT_KEYDOWN And CurrentEvent.data=key_escape Then End
Forever



TomToad(Posted 2016) [#3]
Another way to do it
SetGraphicsDriver D3D9Max2DDriver()
g1:tgraphics=CreateGraphics(300,300,0,60,GRAPHICS_BACKBUFFER)
g2:tgraphics=CreateGraphics(300,300,0,60,GRAPHICS_BACKBUFFER)
EnablePolledInput

While Not KeyDown(key_escape)

	SetGraphics(g1)
	Plot(10,10)
	Flip(1)
	
	SetGraphics(g2)
	Plot(10,10)
	Flip(1)

Wend



Taron(Posted 2016) [#4]
This works, too:



dw817(Posted 2016) [#5]
One is questioning why to use 2 different visible graphic modes, Taron ? Or ... Is the 1st page not visible. Did you crack the code for hidden page retrieval ?



Hmm ... No, it doesn't do that. So the question remains. Why create and use 2 screens ?


Taron(Posted 2016) [#6]
Because someone might want to do a more elaborate GUI, for example. You could have one window as viewport, say for level design, and the other window would supply GUI stuff or other views or anything you'd want independently.


dw817(Posted 2016) [#7]
Taron, how would you place one graphic page beneath or in front of the other ?