Not run (dll and window3d)

Just starting out? Need help? Post your questions and find answers here.
slagusev
New User
New User
Posts: 8
Joined: Fri Nov 29, 2013 2:24 am

Not run (dll and window3d)

Post by slagusev »

Create DLL

Code: Select all

ProcedureDLL win3d(Height.i, Width.i, Title.s)
If OpenWindow3D(0, 100,100,Height.i,Width.i,Title.s)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event3D_CloseWindow
Quit =1
EndIf
Until Quit = 1
EndIf
EndProcedure
Use in prog.

Code: Select all

If OpenLibrary(0, "win3d.dll")
CallFunction(0, "win3d", 800, 600, @"3D View")
CloseLibrary(0)
EndIf
Run -> [ERROR] Invalid memory access. (Write error at adress 9)

how to solve the problem?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Not run (dll and window3d)

Post by IdeasVacuum »

The error is caused by @"3D View"
Use @ to reference a pre-defined string:

Code: Select all

Define sMyString.s = "3D View"
CallFunction(0, "win3d", 800, 600, @sMyString)
Not sure the DLL will actually work though, since mostly the 3D stuff is dependent on a lib.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
TI-994A
Addict
Addict
Posts: 2741
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Not run (dll and window3d)

Post by TI-994A »

Hi slagusev. The OpenWindow3D() function is more complex than PureBasic's standard OpenWindow(). In order to use it, the 3D engine has to be initialised, along with the sprite, keyboard and mouse environments, and it will only work within a screen. Furthermore, the 3D GUI elements have to be loaded using the Add3DArchive() function, with the path properly set. Here's an example adapted from PureBasic's help file:

(win3D.dll)

Code: Select all

ProcedureDLL win3D(width, height, title.s)
  Enumeration 
    #MainWindow
    #Window3D
    #Button3D
  EndEnumeration
  
  If InitEngine3D() And InitSprite() And InitKeyboard() And InitMouse()
    Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/GUI", #PB_3DArchive_FileSystem)
    wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
    OpenWindow(#MainWindow, 0, 0, width, height, "OpenWindow3D() Example", wFlags)
    OpenWindowedScreen(WindowID(#MainWindow), 0, 0, width, height, 0, 0, 0)
    CreateCamera(0, 0, 0, 100, 100)
    OpenWindow3D(#Window3D, 10, 10, 300, 100, "The 3D Window...")
    ButtonGadget3D(#Button3D, 150, 40, 120, 25, "Quit")
    ShowGUI(200, 1)
    alive3D = 1
    Repeat
      If ExamineKeyboard() And ExamineMouse()
        Input$ = KeyboardInkey()
        If alive3D
          InputEvent3D(MouseX(), MouseY(), MouseButton(#PB_MouseButton_Left), Input$, 0)
        EndIf
      EndIf
      Repeat
        Event = WindowEvent3D()
        Select Event
          Case #PB_Event3D_CloseWindow
            ShowGUI(128, 0)
            CloseWindow3D(#Window3D)
            SetWindowTitle(#MainWindow, "3D window closed - press ESC to end...")
            alive3D = 0
          Case #PB_Event3D_Gadget
            appQuit = 1
        EndSelect
      Until Event = 0
      RenderWorld()
      FlipBuffers()    
    Until KeyboardPushed(#PB_Key_Escape) Or appQuit = 1
  EndIf
EndProcedure
(the test code)

Code: Select all

If OpenLibrary(0, "win3D.dll")
  CallFunction(0, "win3D", 640, 480, @"OpenWindow3D() Example")
  CloseLibrary(0)
EndIf
Hope it helps! :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply