setgraphics and keydown
BlitzMax Forums/BlitzMax Programming/setgraphics and keydown
| ||
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? :) |
| ||
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 |
| ||
Another way to do itSetGraphicsDriver 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 |
| ||
This works, too: |
| ||
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 ? |
| ||
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. |
| ||
Taron, how would you place one graphic page beneath or in front of the other ? |