Graphics Functions Return Errors
Graphics Functions Return Errors
I am able to open a window and draw lines in it.
The functions DrawImage() and DrawText() return "Invalid memory access" errors.
What am I doing wrong?
The code works fine in Windows 7.
The functions DrawImage() and DrawText() return "Invalid memory access" errors.
What am I doing wrong?
The code works fine in Windows 7.
- StarBootics
- Addict

- Posts: 1006
- Joined: Sun Jul 07, 2013 11:35 am
- Location: Canada
Re: Graphics Functions Return Errors
Without a code snippet, it's very difficult to help you.
Best regards
StarBootics
Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Re: Graphics Functions Return Errors
DrawText on WindowOutput don´t with gtk3, use subsystem gtk2...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Graphics Functions Return Errors
Compiling with gtk2 returned the following error:
Code: Select all
Window.a(OpenWindow.o): In function `SetAcceptFocusTimerCallback':
OpenWindow.c:(.text+0xa): undefined reference to `gtk_window_set_accept_focus'
Window.a(OpenWindow.o): In function `ConfigureHandler':
OpenWindow.c:(.text+0x39): undefined reference to `g_type_check_instance_cast'
OpenWindow.c:(.text+0x48): undefined reference to `g_object_get_data'
OpenWindow.c:(.text+0x5e): undefined reference to `g_type_check_instance_cast'
OpenWindow.c:(.text+0x70): undefined reference to `g_object_set_data'
...
collect2: error: ld returned 1 exit statusRe: Graphics Functions Return Errors
Here is a simple test program. The window can't be drawn into. LineXY does nothing. DrawText() results in "Invalid memory access"
Another test program that doesn't work, taken from an example in the documentation:
Code: Select all
OpenWindow(0, 0, 0, 640, 480, "PureBasic Test", #PB_Window_SystemMenu)
SetWindowColor(0,$880000)
StartDrawing(WindowOutput(0))
LineXY(0,0, 100,100,$ffffff)
;DrawText(50,50,"Here I am")
StopDrawing()
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
CloseWindow(0)
End
EndSelect
ForEverCode: Select all
If OpenWindow(0, 0, 0, 220, 100, "Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StartDrawing(WindowOutput(0))
Box(10, 10, 50, 50, RGB(255, 0, 0))
StopDrawing()
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: Graphics Functions Return Errors
If you want to directly draw into a window you have to detect all redraw events (and depending on the OS also resize events and possibly others) in your window and redraw all the content following each redraw event. It's the same problem you may experience in Linux, MacOS and Windows!
You are right that your 2nd example (seems) to work on Windows 7. But just add the flag #PB_Window_SizeGadget to your window definition, run the modified example and resize the window to its smallest possible size. Then resize it to a bigger size and you will see that the content won't be drawn again...
I have modified your second example to work with Windows 7 and Linux with both Gtk2 and Gtk3 (tested with Linux Mint 17.3 x64 "Rosa" with Cinnamon):
PS: You should always state your Linux distribution, whether 32 bit or 64 bit and your desktop manager (for example Gnome 3, KDE, Cinnamon, Xfce, LXDE, MATE, etc.) in order to being better able to help you and because some Linux problems might depend on your distribution or desktop manager... 
You are right that your 2nd example (seems) to work on Windows 7. But just add the flag #PB_Window_SizeGadget to your window definition, run the modified example and resize the window to its smallest possible size. Then resize it to a bigger size and you will see that the content won't be drawn again...
I have modified your second example to work with Windows 7 and Linux with both Gtk2 and Gtk3 (tested with Linux Mint 17.3 x64 "Rosa" with Cinnamon):
Code: Select all
OpenWindow(0, 100, 100, 220, 100, "Example...")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Repaint
StartDrawing(WindowOutput(0))
Box(10, 10, 50, 50, RGB(255, 0, 0))
StopDrawing()
EndSelect
ForEverRe: Graphics Functions Return Errors
Here is your example program. It doesn't work unless you comment out DrawText().
I am having a similar problem with DrawImage().
This is on Linux Mint Rosa, 64 bits, Cinnamon
I am having a similar problem with DrawImage().
Code: Select all
OpenWindow(0, 100, 100, 220, 100, "Example...")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Repaint
StartDrawing(WindowOutput(0))
Box(10, 10, 50, 50, RGB(255, 0, 0))
Drawtext(20,20,"Here I am")
StopDrawing()
EndSelect
ForEverRe: Graphics Functions Return Errors
I can confirm this problem for Gtk3 (tested on Linux Mint 17.3 x64 "Rosa" with Cinnamon and Ubuntu 14.04 x64 with KDE). You currently have to use subsystem "gtk2" for DrawText() to work. mk-soft has already pointed this out:chris319 wrote:Here is your example program. It doesn't work unless you comment out DrawText().
The same holds true for DrawImage()...mk-soft wrote:DrawText on WindowOutput don´t with gtk3, use subsystem gtk2...
Re: Graphics Functions Return Errors
I don't even have gtk3 on this machine.
As I have pointed out:
As I have pointed out:
Compiling with gtk2 returns the following error:Code: Select all
In function `SetAcceptFocusTimerCallback': OpenWindow.c:(.text+0xa): undefined reference to `gtk_window_set_accept_focus' Window.a(OpenWindow.o): In function `ConfigureHandler': OpenWindow.c:(.text+0x39): undefined reference to `g_type_check_instance_cast' OpenWindow.c:(.text+0x48): undefined reference to `g_object_get_data' OpenWindow.c:(.text+0x5e): undefined reference to `g_type_check_instance_cast' OpenWindow.c:(.text+0x70): undefined reference to `g_object_set_data' collect2: error: ld returned 1 exit status
Re: Graphics Functions Return Errors
That's simply wrong. You told us that you are testing on Linux Mint Rosa x64 with Cinnamon. Linux Mint 17.3 "Rosa" is using Gtk 3.10.8 as is documented on Distrowatch in this table under the headline "Package" in the row "gtk+ (3.20.6)" for "17.3 rosa". ("3.20.6" is the most current version of Gtk3.)chris319 wrote:I don't even have gtk3 on this machine.
Your compiling errors result because you are using subsystem "gtk2" without having installed the necessary libgtk2 dev package. So please open a console and install the missing libgtk2.0-dev:
Code: Select all
sudo apt-get install libgtk2.0-devRe: Graphics Functions Return Errors
That fixed the problem, thank you.

