Page 1 of 1

cypher and PB ?

Posted: Tue Jul 13, 2004 4:18 pm
by eddy
Did anyone try cypher ?

Posted: Tue Jul 13, 2004 4:33 pm
by Codemonger
I bought Cipher when it first came out for a sub $100 price last year, it has some really amazing "c" programming code and comes with some great tools for creating a 3D project. Cipher would actually be able to be compiled with lcc-win just fine, but it uses it's own layer for dll use. Unfortunately its not a simple dll that you can call functions from it has its own layers and i think this was done to be able to run on any system using a virtual machine. Anyway I don't think Cipher would be a good contender for PB unless you are a "c" programmer, and you can rework the code to fit your needs.

Posted: Tue Jul 13, 2004 11:35 pm
by Moonshine
Just recently I had a go at getting TrueVision3d to work in PB (becuase of the COM nature of it), but had problems with the Init command because it expected a form handle for fullscren mode. Have you tried it Codemonger?

Posted: Wed Jul 14, 2004 1:15 am
by Codemonger
funny thing i have tried truevision once in PB ... but i don't think it was successful. I think that was back when PB didn't have good enough support for COM objects, also i think truevision did not have c++ header files available, at that time it was mainly for VB , i think. But truevision would be cool to get working in PB. The form handle should just be the window handle. that's all thats required for fullscreen or windowed mode, maybe you where passing the wrong thing ... If you ever post any code i'll be around to check it out.

Posted: Wed Jul 14, 2004 1:26 am
by Shannara
Could also do a search online for the open source version of TrueVision (back when it was open sourcE), it's all VB source, but hey.. its out there..

Posted: Wed Jul 14, 2004 12:40 pm
by Moonshine
Cheers CodeMonger. The trouble was I had problems because I wanted to keep it secret and couldnt ask anyone for help. I made use aXend's Interface Generator and his COM library also. Here's the code I got up to, believe me its messy (because after trying for ages I just added allsorts in vain attempts to get it working). I dont recommend you run this, but if you do you'll need to use Ctrl+Alt+Del to exit it, then remove all instances of the PB Compiler from the task manager's processes list. Memory leaks all round made me give up hopes of ever getting this to work, until I looked at the "pbidetest2.doc" in my root C dire, which was:

Code: Select all

obj_Engine\Init3DFullscreen(#Temp_Width, #Temp_Height, #Temp_Depth, #Temp_EnableTnL, #Temp_EnableVSync, #TV_DEPTHBUFFER_16BITS, #Temp_Gamma, WindowID) _
This made me think that it was the init routine which was causing the problems, but initializing a window for fullscreen caused problems because I didnt know how to handle it. This file was also in my root C dir, "tv3d_debug.txt":

Code: Select all

-----------------------------------------------------------
    Engine started at 07-12-2004 15:10:59
-----------------------------------------------------------
07-12-2004 15:10:59 | ########################
07-12-2004 15:10:59 | # TVUTIL62 initialized #
07-12-2004 15:10:59 | ########################
07-12-2004 15:10:59 | TVUTIL62 : Version 6 Revision 100 
07-12-2004 15:10:59 | TVUTIL62 File Path C:\WINDOWS\System32\tvutil62.dll
07-12-2004 15:10:59 | DEVICE INIT : Problem in the IntForm.Show part
07-12-2004 15:10:59 | VENDOR INFO : Video card :NVIDIA GeForce FX 5200   / 4318
07-12-2004 15:10:59 | INITIALIZE : Starting Engine version 0.6.0 rc3 * LIMITED VERSION * 
07-12-2004 15:10:59 | DEVICE INIT : Create the device with 800x600 ane the DX8 format 22 / Depth Buffer : 32
07-12-2004 15:10:59 | DEVICE INIT : Pure device 3d card detected. Unsupported by the engine at this time.
07-12-2004 15:10:59 | DEVICE INIT : Your device supports Single pass Multitexturing. Pixel Shaders & Lightmapping will use it
07-12-2004 15:10:59 | DEVICE INIT : MIXED HARDWARE/SOFTWARE USED
07-12-2004 15:11:00 | VIEWPORT MANAGER : Main viewport initialization
07-12-2004 15:11:00 | VIEWPORT MANAGER : Main viewport initialized (800x600)
07-12-2004 15:11:00 | DEVICE INIT : Average Free Texture memory : 366 MB
07-12-2004 15:11:00 | DEVICE INIT : Device initialized without problem.
07-12-2004 15:11:00 | CAMERA FACTORY : Initialized
07-12-2004 15:11:00 | DEVICE INIT : Create Matrices
07-12-2004 15:11:00 | DEVICE INIT : Viewport size (800 600)
07-12-2004 15:11:00 | DEVICE INIT : Set the viewport...
07-12-2004 15:11:00 | DEVICE INIT : Initialize Vertex shaders
07-12-2004 15:11:00 | MD2 SYSTEM : Preparing md2 vertex shader
07-12-2004 15:11:00 | MD2 SYSTEM : MD2 Vertex Shader created.
07-12-2004 15:11:00 | MDL SYSTEM : Vertex Shader created.
07-12-2004 15:11:00 | TEXTURE REQUIREMENTS CHECKING : D3DFMT_R5G6B5 : Yes
07-12-2004 15:11:00 | TEXTURE REQUIREMENTS CHECKING : D3DFMT_A1R5G6B5 : Yes
07-12-2004 15:11:00 | DEVICE INIT : DOT3 Bumpmapping supported
07-12-2004 15:11:00 | DEVICE INIT : Initialization finished ...
07-12-2004 15:11:00 | INPUT MANAGER : Global initialization
And finally, heres the very messy and ugly code I wrote. Wade through it at will:

Code: Select all

; Attempt to interface TrueVision 3d Engine with PureBasic
; All code (C)2004 Lee S. Ackerley
; 28th June 2004
; ========================================================

; Include the interface files
 XIncludeFile "TV3D_Interfaces.pbi"
 XIncludeFile "TV3DMedia_Interfaces.pbi"
 XIncludeFile "tv3dcpp.pbi"
 

; Declare temporary constants
 #Temp_Width = 800
 #Temp_Height = 600
 #Temp_Depth = 32
 #Temp_EnableTnL = #TRUE
 #Temp_EnableVSync = 0
 #Temp_Gamma = 1
 #Temp_Hwnd = #NULL
 #TRUE = 1
 #FALSE = 0
 
 
 Enumeration
  #Window_0
 EndEnumeration


; Temp Windows message structure
 Structure tv_MSG
   hwnd.l
   message.l
   wParam.l
   lParam.l
   time.l
;  pt.POINT
 EndStructure


; Declare Procedures
  Declare TV3D_Initialize()
  Declare TV3D_Release()


; Declare the required pointers to the interface objects
  Global obj_Engine._TVEngine
  Global obj_Input._TVInputEngine
; Global *gp_Globals._TVGlobals    ; Not required at the moment
; Global *gp_Scene._TVScene        ; Not required at the moment

  Global OutputID = ScreenOutput()

  Global *p_Message
  Global g_message.tv_MSG
  
;  If OpenWindow(#Window_0, 216, 0, 640, 480, #PB_Window_Invisible | #PB_Window_ScreenCentered, "")
; 
; Initialize the engine
;     WindowID = WindowID(#Window_0) 

    TV3D_Initialize()


; /// TEMPORARY - Initialize keyboard input
 If InitKeyboard()

; /// MAIN LOOP BEGIN
 Repeat
 

    While g_message\message <> #WM_QUIT
      
      *p_Message = g_message\message
  
      If PeekMessage_(*p_Message, NULL, 0, 0, #PM_REMOVE)
      
        TranslateMessage_(*p_Message)
        DispatchMessage_(*p_Message)
      
      EndIf

        Gosub sub_Render
        Gosub sub_Input
        
    ; /// TEMPORARY - emergency PB input for escape
        If KeyboardPushed(#PB_Key_Escape)
          
          ReleaseObject(obj_Input)
            obj_Input = NULL
    
          ReleaseObject(obj_Engine)
            obj_Engine = NULL
          
          *p_Message = NULL

          End
        EndIf
    
    Wend
    
 
 ForEver
 
 
 Else
    MessageRequester ("Error", "Cannot initialize keyboard input", #PB_MessageRequester_Ok)
 EndIf
 
;  Else
;  
;     MessageRequester("Error", "Cannot open window", #PB_MessageRequester_Ok)
;     
;     ReleaseObject(obj_Input)
;             obj_Input = NULL
;     
;           ReleaseObject(obj_Engine)
;             obj_Engine = NULL
;           
;           *p_Message = NULL
; 
;           End
;  EndIf
 
; /// MAIN LOOP END


;  ===========
;- SUBROUTINES
;  ===========

; /// Render subroutine
 sub_Render:


; Render : Draw everything between the 'Clear' and 'RenderToScreen' functions
    obj_Engine\Clear(#FALSE)
    obj_Engine\RenderToScreen()


 Return


; /// Input subroutine
 sub_Input:


; Monitor input : If the escape key is pressed, release then engine and end the program
    If obj_Input\IsKeyPressed(#TV_KEY_ESCAPE)
                
            TV3D_Release()
            PostQuitMessage_(0)
            End
    EndIf


 Return


;  ==========
;- PROCEDURES
;  ==========

; /// Initialize the TV3D Engine
 Procedure TV3D_Initialize()

; Initialize COM /// Must be done FIRST before engine is initialized \\\ (* May not be right *)
;CoInitialize_(#NULL)

    
; Create TV Engine object / open fullscreen mode / Display FPS / Place watermark at bottom right at
; opacity of 70%
    obj_Engine = CreateObject("TrueVision3D.TVEngine")
    
        obj_Engine\Init3DFullscreen(#Temp_Width, #Temp_Height, #Temp_Depth, #Temp_EnableTnL, #Temp_EnableVSync, #TV_DEPTHBUFFER_BESTBUFFER, #Temp_Gamma, OutputID) 
        obj_Engine\put_DisplayFPS(#TRUE)
        obj_Engine\SetWatermarkParameters(#TV_WATERMARK_TOPRIGHT, 0.7)

; Create Input Engine object
    obj_Input = CreateObject("TrueVision3D.TVInputEngine")


 EndProcedure


; /// Release the TV3D Engine safely
 Procedure TV3D_Release()
; *REMEMBER* COM objects should be released in reverse creation order

; Release Input Engine object
    ReleaseObject(obj_Input)
    ;obj_Input\Release()
        obj_Input = NULL
    
; Release TV Engine object
    ReleaseObject(obj_Engine)
    ;obj_Engine\Release()
        obj_Engine = NULL
    

;UnInitialize COM /// Must be done LAST to safely release engine \\\ (* May not be right *)
;CoUninitialize_()


 EndProcedure

Posted: Wed Jul 14, 2004 1:46 pm
by Codemonger
Heres the problem : (but their could be more)

Code: Select all

Global OutputID = ScreenOutput() 
should be:

Code: Select all

Global OutputID = WindowID() 
I believe ScreenOutput was sending a HDC to the variable OutputID ... what you need is the HWND, or windows handle of the window you would like truevision to use for fullscreen. This is the first problem i noticed although their could be others. But give it a shot.

Posted: Wed Jul 14, 2004 2:14 pm
by Moonshine
I think I tried that before but that was the last sourcecode that I saved, I tried to use a pointer to the screen but it didnt work. The windowhandle had no effect if I remember.

Like I said it's mess and I should've read through it before I pasted it...