Chrashing with 3dengine?

Everything else that doesn't fall into one of the other PB categories.
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Chrashing with 3dengine?

Post by Dreglor »

my program is crashing in 2 werid spots...
my program is 1 part of 2 part program one takes images and script file and outputs a material file and the other is there to view the file on some billboards just to see how it comes out well the compiler seams to output perfectly i can sperate the text and images again and i've debugged the reading code and that seams to read the right values.
all seams working until it tryies to flip the buffers,
i get a vc++ runtime error (which i know is comming from the engine3d.dll)
and thats were it halts
comment out the flipbuffers it works just fine with the execption of no output on the window.
after thinking it was somthing with the material settings i found if i change
"AddMaterialLayer(0,TextureID(Texcount),LayerBlend)" to "AddMaterialLayer(0,TextureID(Texcount))" removing the optinal paramter on line 106
the error changes from vc++ error to windows crashing box

here's a zip with both programs (with sources) and my test files
note:
msf is the script
cmf is the compiled

any help here would be highly appecated :)
i hope this isn't a bug with pb or orge
~Dreglor
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

DOH! forgot to link it :oops:
bug.zip
~Dreglor
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

Replace

Code: Select all

OpenWindowedScreen(WindowID(),150,0,640,480,0,0,0)
by

Code: Select all

OpenWindowedScreen(WindowID(),150,0,640,460,0,0,0)
or

Code: Select all

OpenWindowedScreen(WindowID(),150,0,640,480-MenuHeight(),0,0,0)
and it work
Please correct my english
http://purebasic.developpez.com/
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

Thanks kinda werid that the menu would set it off :roll:
~Dreglor
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

I Now have a problem were on line 88 (may Not be exact) were "DisplaySprite(0,0,0)" is supose to convert the sprite into a texure (Becasue theres no CatchTexture Command) it doesn't seam to draw the sprite it just leaves the texture black now if i draw a box of some color it shows up why doesn't the sprite show up?

Code: Select all

Procedure LoadMat(File.s)
  If FileSize(File)<=0
    ProcedureReturn 0
  EndIf
  If OpenFile(0,File)=0
    ProcedureReturn -1
  EndIf
  LayerNum.b=ReadByte()
  DynLight.b=ReadByte()
  Ambient.l=ReadLong()
  MatBlend.b=ReadByte()
  Diffuse.l=ReadLong()
  Specular.l=ReadLong()
  fristtime.b=1
  For Layer=0 To LayerNum
    LayerBlend.b=ReadByte()
    AngleSpeed.f=ReadFloat()
    ScrollXSpeed.f=ReadFloat()
    ScrollYSpeed.f=ReadFloat()
    Lenght.l=ReadLong()
    TexBuffer=AllocateMemory(Lenght)
    If TexBuffer=0
      ProcedureReturn -2
    EndIf
    ReadData(TexBuffer,Lenght)
    If CatchSprite(0,TexBuffer)=0
      ProcedureReturn -3
    EndIf
    ;SaveSprite(0,"Test"+Str(Layer)+".bmp")
    If CreateTexture(Texcount,SpriteWidth(0),SpriteHeight(0))=0
      FreeSprite(0)
      ProcedureReturn -4
    EndIf
    StartDrawing(TextureOutput(Texcount))
    DisplaySprite(0,0,0) ;<----------------------------------------- line 88
    StopDrawing()
    FreeSprite(0)
    If fristtime=1
      If CreateMaterial(0,TextureID(Texcount))=0
        ProcedureReturn -5
      EndIf
      fristtime=0
      ;Debug "Creating Base Material"
    Else
      AddMaterialLayer(0,TextureID(Texcount),LayerBlend)
      ;Debug "Adding Layer with Blending of "+Str(LayerBlend)
    EndIf
    If AngleSpeed<>0
      RotateMaterial(0,AngleSpeed,#PB_Material_Animated,Layer)
      ;Debug "Giving a angle speed of "+Str(AngleSpeed)
    EndIf
    If ScrollXSpeed<>0 Or ScrollYSpeed<>0
      ScrollMaterial(0,ScrollXSpeed,ScrollYSpeed,#PB_Material_Animated,Layer)
      ;Debug "Giving a x y speed of "+Str(ScrollXSpeed)+" And "+Str(ScrollYSpeed)
    EndIf
  Next Layer
  DisableMaterialLighting(0,DynLight)
  ;Debug "Disable Material Lighting = "+Str(DynLight)
  MaterialAmbientColor(0,Ambient)
  ;Debug "Ambient Lighting = "+Str(Red(Ambient))+","+Str(Green(Ambient))+","+Str(Blue(Ambient))
  MaterialBlendingMode(0,MatBlend)
  ;Debug "Material Blending Mode = "+Str(MatBlend)
  MaterialDiffuseColor(0,Diffuse)
  ;Debug "Diffuse Lighting = "+Str(Red(Diffuse))+","+Str(Green(Diffuse))+","+Str(Blue(Diffuse))
  MaterialSpecularColor(0,Specular)
  ;Debug "Specular Lighting = "+Str(Red(Specular))+","+Str(Green(Specular))+","+Str(Blue(Specular))
  Texcount+1
  CloseFile(0)
  ProcedureReturn 1
EndProcedure
~Dreglor
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

Replace CatchSprite() by CatchImage()

Code: Select all

StartDrawing(TextureOutput(Texcount)) 
DrawImage()    
; DisplaySprite(0,0,0) ;<----------------------------------------- line 88 
    StopDrawing() 
Last edited by Comtois on Fri Dec 10, 2004 11:21 pm, edited 1 time in total.
Please correct my english
http://purebasic.developpez.com/
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

Thanks again :D
~Dreglor
Post Reply