Canvas Text Drawing
BlitzMax Forums/MaxGUI Module/Canvas Text Drawing
| ||
Hello, I'm using a canvas to draw text on screen, but I ran into a problem. It only draws texts that are large ( like "This text is super long compared to the other one") and only draws half to none of smaller sized texts (like "Hello World"). Is something wrong with the drawtext, setgraphics, cls, flip, or something else? |
| ||
Post some code. |
| ||
This result shows all of the text on screenMethod Draw() SetGraphics CanvasGraphics(screen) Cls DrawText "This is really really long text that is probably all going to be shown on screen", 0, 0 Flip End Method But this code shows only " r d" when the text is "Hello World" Method Draw() SetGraphics CanvasGraphics(screen) Cls DrawText "Hello World", 0, 0 Flip End Method |
| ||
Try to add this line underneath SetGraphics SetViewport 0,0,GadgetWidth( screen ),GadgetHeight( screen ) |
| ||
That still didn't fix it |
| ||
Also, when I try to add different strings, I get a really weird response. This result shows a really strange string it shows MyEEging EdiMyiEnginyiv,i1.0.0ityst So is it a text reading glitch in blitz max? |
| ||
I suggest posting a bare bones working example that shows the problem happening. This could be another problem in your code somewhere - overwriting pixmap memory or something bizarre. |
| ||
Here's the code for my window type. MAKE SURE TO IMPORT MAXGUI.DRIVERS Type TwistedGame2D Abstract Field Window:TGadget '// Our main window Field Flags:Int '// The flag for our main window Field screen:tgadget Field Title:String '// The title at the top of the window Field Width:Int '// The width of our window Field Height:Int '// The height of out window Field Hertz:Int = 60 '// The hertz of our window Field Fullscreen:Byte = False '// Whether or not our window is in full screen Field DrawMouse:Byte = True '// Whether or not we draw our mouse Field OverScan:Float = .1 '// (CONSOLE EXPORTING) The "overscan" of the TV's "safe area". Normally can't claculate it, so I put it at 10% Field bgcolorR:Int Field bgcolorG:Int Field bgcolorB:Int Field Timer:Tgadget Method Initialize() End Method Method Update() End Method Method LoadContent() End Method Method UnloadContent() End Method Method Draw() End Method End Type And Here's the code for displaying the window: global VERSION:string = "1.0.0" '// My engine already contains this, this is for forum purposes only Type TGame2D Extends TwistedGame2D Method initialize() flags:| WINDOW_CENTER flags:| WINDOW_TITLEBAR Width = 800 Height = 600 overscan = 0.0 Title = "Twisted Engine v. " + VERSION window = CreateWindow(Title, 0,0,Width,Height,window, flags) screen = CreateCanvas(0, 0 , width, height, window) CreateTimer hertz End Method Method Update() While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE UnloadContent() End Case EVENT_TIMERTICK RedrawGadget(screen) Case EVENT_GADGETPAINT DRAW() End Select Wend End Method Method Draw() SetGraphics CanvasGraphics(screen) SetVirtualResolution Width, Height SetViewport 0,0,GadgetWidth( screen ),GadgetHeight( screen ) Cls DrawText "Hello World"+ " My Engine v. " + VERSION +" test", 0, 0 Flip End Method End Type Global Game2D:TGame2D = New TGame2D Game2D.initialize() Game2D.Update() Hope this helps you! |
| ||
runs perfect on my machine. some ideas for testing: 1. this is not correct: window = CreateWindow(Title, 0,0,Width,Height,window, flags) window has no parent: window = CreateWindow(Title, 0,0,Width,Height,NULL, flags) 2. Try FLIP 0 3. tell us the BlitzMax-Version, graphic card, etc... 4. Try 15Hz 5. try screen = CreateCanvas(50, 50 , 700, 500, window) 6. try to switch off: a.) SetVirtualResolution Width, Height b.) SetViewport 0,0,GadgetWidth( screen ),GadgetHeight( screen ) c.) Case EVENT_TIMERTICK RedrawGadget(screen) |
| ||
Works ok here too. Win8 with an NVidia, and a Win7 with Radeon. All is ok. Good suggestions to try from midimaster. 7. SetGraphicsDriver to something else if on a windows machine. |
| ||
The flip 0 got it. Thanks for all of your help guys! |