datentypenwirrwarr
Übersicht

hamztataBetreff: datentypenwirrwarr |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Also ich frage jetzt nicht, weil ich nichts lernen will, oder nichts lesen will.
Ich habe hier nen code für einen mod. Habe mir schon Ratschläge geholt und versucht diese umzusetzen. Eins voran, momentan sind vorallem die deklarartionen bzw. funktionen wichtig, die hinter getprocadress ein abschliessendes @x haben. Dort habe ich versucht den Speicher zu reservieren. Problem ist, der mod wird tadellos gebuilded, auch wenn ich ohne die modkennzeichnungen im header normal compiliere, keine fehler.aber es funktioniert nichts. Ich poste hier mal den aktuellen mod-convert vorschritt, und eins kann ich sagen xInitDraw beispielsweise geht. Könnte also auch mit übergebenen Strings zu tun haben, wobei dies doch eigentlich gehen sollte. xDrawText könnte ein problem haben.... vielleicht sieht ja jemand auf den ersten blick etwas falsch deklariertes.... Code: [AUSKLAPPEN] Module rubux.fi
Import brl.filesystem Import rubux.xors3d Import brl.blitz Import brl.retro ModuleInfo "Version: 1.72" ModuleInfo "Module Author: Heiko D." ModuleInfo "Site: xors3d.com" ModuleInfo "Copyright: LGPL" Extern "win32" Function FindWindowA%(class%,title$z) Function LoadLibraryA(lib$z) Function GetProcAddress:Byte Ptr(lib%,fname$z) End Extern 'Befehle wie xGetDevice() o.ä. welche nicht in diesem quellcode enthalten sind, beziehen sich auf den xors3d mod Global FiLibName$ = "FastImageXors.dll" Global xInitDraw_%(device%,def%) "win32" Global xDeinitDraw%() "win32" Global xStartDraw%() "win32" Global xEndDraw%() "win32" Global xSetCustomState%(operation%,value%) "win32" Global xSetCustomTextureState%(operation%,value%) "win32" Global xSetMipLevel%(level%) "win32" Global xSetBlend%(blend%) "win32" Global xSetAlpha%(alpha#) "win32" Global xSetColor%(r%,g%,b%) "win32" Global xSetCustomColor%(colorvertex0%,colorvertex1%,colorvertex2%,colorvertex3%) "win32" Global xSetRotation%(rotation#) "win32" Global xSetScale%(scalex#,scaley#) "win32" Global xSetTransform%(rotation#,scalex#,scaley#) "win32" Global xSetMatrix%(xx#,xy#,yx#,yy#) "win32" Global xSetHandle%(x%,y%) "win32" Global xSetOrigin%(x%,y%) "win32" Global xMidHandleImage%(image%) "win32" Global xSetImageHandle%(image%,x%,y%) "win32" Global xAutoMidHandleEx%(state%) "win32" Global xAutoImageFlags%(flags%) "win32" Global xSetLineWidth%(width#) "win32" Global xSetViewport%(x%,y%,width%,height%) "win32" Global xCreateImageEx_%(textures:Byte Ptr,width%,height%,flags%) "win32" Global xFreeImageEx_%(image%) "win32" Global xDrawImageEx_%(image%,x%,y%,flags%) "win32" Global xDrawImageRectEx_%(image%,x%,y%,width%,height%,flags%) "win32" Global xDrawImagePart_%(image%, x%, y%, width%, height%, partX%, partY%, partWidth%, partHeight%, frame%, wrap%) "win32" Global xDrawPoly_%(x%, y%, bank%, image%, frame%, color%) "win32" Global xDrawRect_%(x%, y%, width%, height%, fill%) "win32" Global xDrawRectSimple_%(x%, y%, width%, height%, fill%) "win32" Global xDrawLine%(x%, y%, x2%, y2%) "win32" Global xDrawLineSimple%(x%, y%, x2%, y2%) "win32" Global xDrawPlot%(x%, y%) "win32" Global xDrawOval%(x%, y%, width%, height%) "win32" Global xGetProperty_%(prop:Byte Ptr) "win32" Global xGetImageProperty_%(image%,imageproperty:Byte Ptr) "win32" Global xSetProjScale%(scaleX#, scaleY#) "win32" Global xSetProjRotation%(rotation#) "win32" Global xSetProjTransform%(rotation#, scaleX#, scaleY#) "win32" Global xSetProjOrigin%(x%, y%) "win32" Global xSetProjHandle%(x%, y%) "win32" Global xMidHandleProj%() "win32" Global xCreateImageFont%(font:Byte Ptr) "win32" Global xSetImageFont%(font%) "win32" Global xFreeImageFont_%(font%) "win32" Global xDrawText_%(text:Byte Ptr, x%, y%, centerX%, centerY%, maxWidth%) "win32" Global xDrawTextRect_%(text:Byte Ptr, x%, y%, w%, h%, centerX%, centerY%, lineSpacing%) "win32" Global xTextRectCount%() "win32" Global xTextRectMaxWidth%() "win32" Global xTextRectWidth%(StringNumber%) "win32" Global xStringWidthEx_%(text:Byte Ptr, maxWidth%) "win32" Global xStringHeightEx%(text:Byte Ptr) "win32" Global xGetFontProperty_%(font%, fontproperty:Byte Ptr) "win32" Global xTestRect_%(xPoint%, yPoint%, xRect%, yRect%, WidthRect%, HeightRect%, Locale%, Result:Byte Ptr, ResultFlag%) "win32" Global xTestOval_%(xPoint%, yPoint%, xOval%, yOval%, WidthOval%, HeightOval%, Locale%, Result:Byte Ptr, ResultFlag%) "win32" Global xTestImage_%(xPoint%, yPoint%, xImage%, yImage%, Image%, Locale%, Result:Byte Ptr, ResultFlag%) "win32" Global xTestRendered_%(xPoint%, yPoint%, Locale%, Result:Byte Ptr, ResultFlag%) "win32" Global xGetCustomTransform_%(handle%, matrix:Byte Ptr) "win32" Global xSetCustomTransform_%(handle%, matrix:Byte Ptr)"win32" Global lib% = LoadLibraryA(FiLibName) If lib% xInitDraw_ = GetProcAddress(lib,"InitDraw_") xDeinitDraw = GetProcAddress(lib,"DeinitDraw_") xStartDraw = GetProcAddress(lib,"StartDraw_") xEndDraw = GetProcAddress(lib,"EndDraw_") xSetCustomState = GetProcAddress(lib,"SetCustomState_") xSetCustomTextureState = GetProcAddress(lib,"SetCustomTextureState_") xSetMipLevel = GetProcAddress(lib,"SetMipLevel_") xSetBlend = GetProcAddress(lib,"SetBlend_") xSetAlpha = GetProcAddress(lib,"SetAlpha_") xSetColor = GetProcAddress(lib,"SetColor_") xSetCustomColor = GetProcAddress(lib,"SetCustomColor_") xSetRotation = GetProcAddress(lib,"SetRotation_") xSetScale = GetProcAddress(lib,"SetScale_") xSetTransform = GetProcAddress(lib,"SetTransform_") xSetMatrix = GetProcAddress(lib,"SetMatrix_") xSetHandle = GetProcAddress(lib,"SetHandle_") xSetOrigin = GetProcAddress(lib,"SetOrigin_") xMidHandleImage = GetProcAddress(lib,"MidHandleImage_") xSetImageHandle = GetProcAddress(lib,"SetImageHandle_") xAutoMidHandleEx = GetProcAddress(lib,"AutoMidHandleEx_") xAutoImageFlags = GetProcAddress(lib,"AutoImageFlags_") xSetLineWidth = GetProcAddress(lib,"SetLineWidth_") xSetViewport = GetProcAddress(lib,"SetViewport_") xCreateImageEx_ = GetProcAddress(lib,"CreateImageEx_") xFreeImageEx_ = GetProcAddress(lib,"FreeImageEx_") xDrawImageEx_ = GetProcAddress(lib,"DrawImageEx_") xDrawImageRectEx_ = GetProcAddress(lib,"DrawImageRectEx_") xDrawImagePart_ = GetProcAddress(lib,"DrawImagePart_") xDrawPoly_ = GetProcAddress(lib,"DrawPoly_") xDrawRect_ = GetProcAddress(lib,"DrawRect_") xDrawRectSimple_ = GetProcAddress(lib,"DrawRectSimple_") xDrawLine = GetProcAddress(lib,"DrawLine_") xDrawLineSimple = GetProcAddress(lib,"DrawLineSimple_") xDrawPlot = GetProcAddress(lib,"DrawPlot_") xDrawOval = GetProcAddress(lib,"DrawOval_") xGetProperty_ = GetProcAddress(lib,"GetProperty_") xGetImageProperty_ = GetProcAddress(lib,"GetImageProperty_") xSetProjScale = GetProcAddress(lib,"SetProjScale_") xSetProjRotation = GetProcAddress(lib,"SetProjRotation_") xSetProjTransform = GetProcAddress(lib,"SetProjTransform_") xSetProjOrigin = GetProcAddress(lib,"SetProjOrigin_") xSetProjHandle = GetProcAddress(lib,"SetProjHandle_") xMidHandleProj = GetProcAddress(lib,"MidHandleProj_") xCreateImageFont = GetProcAddress(lib,"CreateImageFont_") xSetImageFont = GetProcAddress(lib,"SetImageFont_") xFreeImageFont_ = GetProcAddress(lib,"FreeImageFont_") xDrawText_ = GetProcAddress(lib,"DrawTextEx_") xDrawTextRect_ = GetProcAddress(lib,"DrawTextRect_") xTextRectCount = GetProcAddress(lib,"TextRectCount_") xTextRectMaxWidth = GetProcAddress(lib,"TextRectMaxWidth_") xTextRectWidth = GetProcAddress(lib,"TextRectWidth_") xStringWidthEx_ = GetProcAddress(lib,"StringWidthEx_") xStringHeightEx = GetProcAddress(lib,"StringHeightEx_") xGetFontProperty_ = GetProcAddress(lib,"GetFontProperty_") xTestRect_ = GetProcAddress(lib,"TestRect_") xTestOval_ = GetProcAddress(lib,"TestOval_") xTestImage_ = GetProcAddress(lib,"TestImage_") xTestRendered_ = GetProcAddress(lib,"TestRendered_") xGetCustomTransform_ = GetProcAddress(lib,"GetCustomTransform_") xSetCustomTransform_ = GetProcAddress(lib,"SetCustomTransform_") Else RuntimeError("Invalid " + FiLibName) End End If Type FI_PropertyType Field Blend% Field Alpha#, Red%, Green%, Blue% Field ColorVertex0%, ColorVertex1%, ColorVertex2%, ColorVertex3% Field Rotation#, ScaleX#, ScaleY# Field MatrixXX#, MatrixXY#, MatrixYX#, MatrixYY# Field HandleX%, HandleY% Field OriginX%, OriginY% Field AutoHandle%, AutoFlags% Field LineWidth# Field ViewportX%, ViewportY%, ViewportWidth%, ViewportHeight% Field MipLevel% Field ProjScaleX#, ProjScaleY#, ProjRotation# Field ProjOriginX%, ProjOriginY% Field ProjHandleX%, ProjHandleY% Field Reserved0% Field Reserved1% End Type Global FI_Property:FI_PropertyType = New FI_PropertyType Type FI_ImagePropertyType Field HandleX% Field HandleY% Field Width% Field Height% Field Frames% Field Flags% Field Texture% Field Reserved0% Field Reserved1% End Type Global FI_ImageProperty:FI_ImagePropertyType = New FI_ImagePropertyType Type FI_FontPropertyType Field Width% Field Height% Field FirstChar% Field Kerning% Field Image% Field FrameWidth% Field FrameHeight% Field FrameCount% Field Chars[256] End Type Global FI_FontProperty:FI_FontPropertyType = New FI_FontPropertyType Type FI_TestType Field Result% Field ProjectedXX%, ProjectedYY% Field RectX%, RectY% Field RectU#, RectV# Field TextureX%, TextureY% Field Texture% Field Frame% Field Reserved1% End Type Global FI_Test:FI_TestType = New FI_TestType Function xSetCustomBlend(src%, dest%) xSetCustomState 15,0 'DX7 SetRenderState ( D3DRENDERSTATE_AlphaTestEnable, False ) xSetCustomState 27,1 'DX7 SetRenderState ( D3DRENDERSTATE_AlphaBlendEnable, True ) xSetCustomState 19,src 'DX7 SetRenderState ( D3DRENDERSTATE_SrcBlend, src ) xSetCustomState 20,dest 'DX7 SetRenderState ( D3DRENDERSTATE_DestBlend, dest ) End Function Type FI_SurfacesType Field Count% Field Array%[256] Field Texture% End Type Global FI_Surfaces:FI_SurfacesType = New FI_SurfacesType Function xCreateImageEx% (texture%, width%, height%, imageFlags%=FI_AUTOFLAGS) If texture<>0 Then FI_Surfaces.Texture = texture FI_Surfaces.Count = xGetTextureFrames(texture) If FI_Surfaces.Count>0 Then If FI_Surfaces.Count>256 Then FI_Surfaces.Count=256 For i=0 To FI_Surfaces.Count-1 FI_Surfaces.Array[i] = xGetTextureSurface(texture, i) Next Return xCreateImageEx_(FI_Surfaces, width, height, imageFlags) EndIf EndIf Return 0 End Function Function xLoadImageEx% (fileName:String, textureFlags%=0, imageFlags%=FI_AUTOFLAGS) If ImageInfo_ReadFile (fileName) Then Return xCreateImageEx ( xLoadTexture (fileName, textureFlags), ImageInfo_Width, ImageInfo_Height, imageFlags) EndIf Return 0 End Function Function xLoadAnimImageEx% ( fileName:Byte Ptr, textureFlags%, frameWidth%, frameHeight%, firstFrame%, frameCount%, imageFlags%=FI_AUTOFLAGS ) textureFlags = (textureFlags And $3F) Or $9 Return xCreateImageEx ( xLoadAnimTexture (fileName, textureFlags, frameWidth, frameHeight, firstFrame, frameCount), frameWidth, frameHeight, imageFlags) End Function Function xDrawImageEx% (image%, x%, y%, frame%=0) Return xDrawImageEx_(image, x, y, frame) End Function Function xDrawImageRectEx% (image%, x%, y%, width%, height%, frame%=0) Return xDrawImageRectEx_(image, x, y, width, height, frame) End Function Function xDrawImagePart% (image%, x%, y%, width%, height%, partX%=0, partY%=0, partWidth%=0, partHeight%=0, frame%=0, wrap%=FI_NOWRAP) Return xDrawImagePart_(image, x, y, width, height, partX, partY, partWidth, partHeight, frame, wrap) End Function Function xDrawPoly% (x%, y%, bank%, image%=0, frame%=0, color%=FI_NONE) Return xDrawPoly_(x, y, bank, image, frame, color) End Function Function xDrawRect% (x%, y%, width%, height%, fill%=1) xDrawRect_(x, y, width, height, fill) End Function Function xDrawRectSimple% (x%, y%, width%, height%, fill%=1) xDrawRectSimple_(x, y, width, height, fill) End Function Function xLoadImageFont% (filename:String, flags%=FI_SMOOTHFONT) Local f%, i, l:String, r:String, AnimTexture:String, AnimTextureFlags%, Texture% filename=Replace(filename,"/", "\") f = ReadFile(filename) If f=0 Then Return 0 FI_FontProperty.Width=0 FI_FontProperty.Height=0 FI_FontProperty.FirstChar=0 FI_FontProperty.Kerning=0 FI_FontProperty.Image=0 FI_FontProperty.FrameWidth=0 FI_FontProperty.FrameHeight=0 FI_FontProperty.FrameCount=0 For i=0 To 255 FI_FontProperty.Chars[i]=0 Next AnimTextureFlags=4 While Not Eof(f) l=Trim(ReadLine(f)) i=Instr(l,"=",1) If Len(l)>0 And Left(l,1)<>";" And i>0 Then r=Trim(Right(l,Len(l)-i)) l=Upper(Trim(Left(l,i-1))) Select l Case "ANIMTEXTURE" AnimTexture=r Case "ANIMTEXTUREFLAGS" AnimTextureFlags=Int(r) Case "FRAMEWIDTH" FI_FontProperty.FrameWidth=Int(r) Case "FRAMEHEIGHT" FI_FontProperty.FrameHeight=Int(r) Case "FRAMECOUNT" FI_FontProperty.FrameCount=Int(r) Case "WIDTH" FI_FontProperty.Width=Int(r) Case "HEIGHT" FI_FontProperty.Height=Int(r) Case "FIRSTCHAR" FI_FontProperty.FirstChar=Int(r) Case "KERNING" FI_FontProperty.Kerning=Int(r) Default If Int(l)>=0 And Int(l)<=255 Then FI_FontProperty.Chars[Int(l)]=Int(r) EndIf End Select EndIf Wend CloseFile f If Len(AnimTexture)>0 And FI_FontProperty.FrameWidth>0 And FI_FontProperty.FrameHeight>0 And FI_FontProperty.FrameCount>0 Then f=1 Repeat i=Instr(filename,"\",f) If i<>0 Then f=i+1 Until i=0 If flags=FI_SMOOTHFONT Then flags=FI_FILTEREDIMAGE Else flags=FI_NONE EndIf FI_FontProperty.Image = xLoadImageEx ( Left(filename,f-1)+AnimTexture, (AnimTextureFlags And $6) Or $39, flags) Return xCreateImageFont( FI_FontProperty ) EndIf Return 0 End Function Function xStringWidthEx% (txt:Byte Ptr, maxWidth%=10000) Return xStringWidthEx_(txt, maxWidth) End Function Function xDrawText% (txt:Byte Ptr, x%, y%, centerX%=0, centerY%=0, maxWidth%=10000) Return xDrawText_(txt, x, y, centerX, centerY, maxWidth) End Function Function xDrawTextRect% (txt:Byte Ptr, x%, y%, w%, h%, centerX%=0, centerY%=0, lineSpacing%=0) Return xDrawTextRect_(txt, x, y, w, h, centerX, centerY, lineSpacing) End Function Function xInitDraw% (def% = 0) Return xInitDraw_ ( xGetDevice() , def ) End Function Function xGetProperty% () Return xGetProperty_ (FI_Property) End Function Function xGetImageProperty% (image%) Return xGetImageProperty_ (image, FI_ImageProperty) End Function Function xGetFontProperty% (font%) Return xGetFontProperty_ (font, FI_FontProperty) End Function Function xTestRect% (xPoint%, yPoint%, xRect%, yRect%, WidthRect%, HeightRect%, Loc%=0) Return xTestRect_ (xPoint, yPoint, xRect, yRect, WidthRect, HeightRect, Loc, FI_Test, 1) End Function Function xTestOval% (xPoint%, yPoint%, xOval%, yOval%, WidthOval%, HeightOval%, Loc%=0) Return xTestOval_ (xPoint, yPoint, xOval, yOval, WidthOval, HeightOval, Loc, FI_Test, 1) End Function Function xTestImage% (xPoint%, yPoint%, xImage%, yImage%, Image%, alphaLevel%=0, Frame%=0, Loc%=0) If xTestImage_ (xPoint, yPoint, xImage, yImage, Image, Loc, FI_Test, 1) And alphaLevel>0 And FI_Test.Texture<>0 Then If ( xReadPixel( FI_Test.TextureX, FI_Test.TextureY, xTextureBuffer(FI_Test.Texture,Frame) ) Shr 24 ) < alphaLevel Then FI_Test.Result = 0 EndIf Return FI_Test.Result End Function Function xTestRendered% (xPoint%, yPoint%, alphaLevel%=0, Loc%=0) If xTestRendered_ (xPoint, yPoint, Loc, FI_Test, 1) And alphaLevel>0 And FI_Test.Texture<>0 Then If (xReadPixel( FI_Test.TextureX, FI_Test.TextureY, xTextureBuffer(FI_Test.Texture,FI_Test.Frame) ) Shr 24) < alphaLevel Then FI_Test.Result = 0 EndIf Return FI_Test.Result End Function Function xFreeImageEx% (image%, freeTexture%=0) If freeTexture<>0 And xGetImageProperty(image)<>0 And FI_ImageProperty.Texture<>0 Then xFreeTexture FI_ImageProperty.Texture xFreeImageEx_(image) End Function Function xFreeImageFont% (font%) If xGetFontProperty(font)<>0 And FI_FontProperty.Image<>0 Then If xGetImageProperty(FI_FontProperty.Image)<>0 And FI_ImageProperty.Texture<>0 Then xFreeTexture FI_ImageProperty.Texture EndIf xFreeImageFont_(font) End Function 'CreateImageEx Flags Const FI_AUTOFLAGS = -1 Const FI_NONE = 0 Const FI_MIDHANDLE = 1 Const FI_FILTEREDIMAGE = 2 Const FI_FILTERED = 2 'SetBlend Flags Const FI_SOLIDBLEND = 0 Const FI_ALPHABLEND = 1 Const FI_LIGHTBLEND = 2 Const FI_SHADEBLEND = 3 Const FI_MASKBLEND = 4 Const FI_MASKBLEND2 = 5 Const FI_INVALPHABLEND = 6 'ImageFonts Flags Const FI_SMOOTHFONT=1 'DrawImagePart Wrap Flags Const FI_NOWRAP = 0 Const FI_WRAPU = 1 Const FI_MIRRORU = 2 Const FI_WRAPV = 4 Const FI_MORRORV = 8 Const FI_WRAPUV = 5 Const FI_MIRRORUV = 10 'DrawPoly consts Const FI_POINTLIST = 1 Const FI_LINELIST = 2 Const FI_LINESTRIP = 3 Const FI_TRIANGLELIST = 4 Const FI_TRIANGLESTRIP = 5 Const FI_TRIANGLEFAN = 6 Const FI_COLOROVERLAY = 1 'Import "bbtype.bmx" 'Import "bbvkey.bmx" 'Image type constants Const imgtype_Unknown = 0 Const imgtype_BMP = 1 Const imgtype_PNG = 2 Const imgtype_JPEG = 3 Const imgtype_TGA = 4 Const imgtype_DDS = 5 'Globals Global ImageInfo_Type = imgtype_Unknown Global ImageInfo_Width Global ImageInfo_Height Global ImageInfo_Depth 'User functions Function ImageInfo_ReadFile(FileName$) If FileType(FileName)<>1 Return 'Init ImageInfo_Type = imgtype_Unknown ImageInfo_Width = 0 ImageInfo_Height = 0 ImageInfo_Depth = 0 Buffer = CreateBank(4) ImageFileSize = FileSize(FileName) If ImageFileSize<3 Then Buffer = 0 Return EndIf ImageFile = ReadFile(FileName) 'Start comparsion ReadBank(Buffer, ImageFile, 0, 4) 'Check PNG If (PeekByte(Buffer,0) = 137) And (PeekByte(Buffer,1) = 80) And (PeekByte(Buffer,2) = 78) Then ImageOk = ImageInfo_ReadPNG(ImageFile, ImageFileSize) EndIf 'Check BMP If (ImageOk = False) And (PeekByte(Buffer,0) = 66) And (PeekByte(Buffer,1) = 77) Then ImageOk = ImageInfo_ReadBMP(ImageFile, ImageFileSize) EndIf 'Check DDS If (ImageOk = False) And (PeekByte(Buffer,0) = 68) And (PeekByte(Buffer,1) = 68) And (PeekByte(Buffer,2) = 83) And (PeekByte(Buffer,3) = 32) Then ImageOk = ImageInfo_ReadDDS(ImageFile, ImageFileSize) EndIf 'Check TGA If ImageOk = False Then ImageOk = ImageInfo_ReadTGA(ImageFile, ImageFileSize) 'Check JPEG If ImageOk = False Then ImageOk = ImageInfo_ReadJPG(Buffer, ImageFile, ImageFileSize) CloseFile(ImageFile) Buffer = 0 Return ImageOk End Function 'Internal functions Function ImageInfo_ReadBMP(ImageFile, ImageFileSize) If ImageFileSize<29 Return ImageInfo_Type = imgtype_BMP SeekStream(ImageFile, 18) ImageInfo_Width = ReadShort(ImageFile) SeekStream(ImageFile, 22) ImageInfo_Height = ReadShort(ImageFile) SeekStream(ImageFile, 28) ImageInfo_Depth = ReadByte(ImageFile) Return True End Function Function ImageInfo_ReadDDS(ImageFile, ImageFileSize) If ImageFileSize<129 Return ImageInfo_Type = imgtype_DDS SeekStream(ImageFile, 12) ImageInfo_Height = ReadInt(ImageFile) 'SeekFile(ImageFile, 16) ImageInfo_Width = ReadInt(ImageFile) ReadInt(ImageFile) '20 Pitch 'SeekFile(ImageFile, 24) ImageInfo_Depth = ReadInt(ImageFile) Return True End Function Function ImageInfo_ReadPNG(ImageFile, ImageFileSize) If ImageFileSize<25 Return Local b Local c ImageInfo_Type = imgtype_PNG SeekStream(ImageFile, 24) b = ReadByte(ImageFile) c = ReadByte(ImageFile) 'Color depth Select c Case 0 ImageInfo_Depth = b' greyscale Case 2 ImageInfo_Depth = b * 3' RGB Case 3 ImageInfo_Depth = 8' Palette based Case 4 ImageInfo_Depth = b * 2' greyscale with alpha Case 6 ImageInfo_Depth = b * 4' RGB with alpha Default ImageInfo_Type = imgtype_Unknown End Select If ImageInfo_Type = imgtype_PNG Then seeked = SeekStream(ImageFile, 16) ImageInfo_Width = Swap32(ReadInt(ImageFile)) ImageInfo_Height = Swap32(ReadInt(ImageFile)) Return True EndIf End Function Function ImageInfo_ReadJPG(Buffer, ImageFile, ImageFileSize) Local i Local Pos = 0 Local BType 'find beginning of JPEG stream IsError = True While Pos<=ImageFileSize-4 SeekStream(ImageFile, Pos) For i=0 To 3; PokeByte Buffer, i, ReadByte(ImageFile); Next If (PeekByte(Buffer,0) = $FF) And (PeekByte(Buffer,1) = $D8) And (PeekByte(Buffer,2) = $FF) And (PeekByte(Buffer,3) = $E0) Then IsError = False Exit EndIf Pos = Pos + 1 Wend If IsError Return Pos = StreamPos(ImageFile) + Swap16(ReadShort(ImageFile)) 'loop through Each marker Until we find the C0 marker (Or C1 Or C2) which 'has the image information IsError = True SeekStream(ImageFile, Pos) While Not Eof(ImageFile) If ReadByte(ImageFile) = $FF BType = ReadByte(ImageFile) Pos = StreamPos(ImageFile) + Swap16(ReadShort(ImageFile)) ' if the type is from SOF0 to SOF3 If (BType >= $C0) And (BType <= $C3) i = ReadByte(ImageFile) ImageInfo_Height = Swap16(ReadShort(ImageFile)) ImageInfo_Width = Swap16(ReadShort(ImageFile)) ImageInfo_Depth = ReadByte(ImageFile) * 8 ImageInfo_Type = imgtype_JPEG IsError = False Exit EndIf ' Goto next marker SeekStream(ImageFile, Pos) EndIf Wend Return 1-IsError End Function Function ImageInfo_ReadTGA(ImageFile, ImageFileSize) If ImageFileSize<24+12 Return SeekStream(ImageFile, 0) If ReadByte(ImageFile)=0 And ReadByte(ImageFile)=0 And ReadByte(ImageFile)=2 ImageInfo_Type = imgtype_TGA Else Return EndIf SeekStream(ImageFile, 12) ImageInfo_Width = ReadShort(ImageFile) ImageInfo_Height = ReadShort(ImageFile) ImageInfo_Depth = ReadShort(ImageFile) Return True End Function Function Swap16%(Value%) Local b1 = Value & 255 Local b2 = (Value Shr 8) & 255 Return b1 Shl 8 | b2 End Function Function Swap32%(Value%) Local b1 = Value & 255' Local b2 = (Value Shr 8) & 255' Local b3 = (Value Shr 16) & 255' Local b4 = (Value Shr 24) & 255' b1 = b1 Shl 24 b2 = b2 Shl 16 b3 = b3 Shl 8 Return b1 | b2 | b3 | b4 End Function |
||
AvaGast |
![]() Antworten mit Zitat |
|
---|---|---|
Dein Code läuft nicht im SuperStrict Modus ... das ist schon mal schlecht. | ||
hamztata |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ähm ja, ich weiß.
liegt daran, daß ich erstmal dahintersteigen will was xInitDraw, XstartDraw-xEndDraw, und Xdrawtext betrifft. eigentlich erstmal nur dort nachschauen. denn ich hab nen testlauf, mit nur diesen 4 befehlen, und kein text wird angezeigt. wenn diese drei sachen gelöst wären, könnte ich den rest darauf basieren lassen.... xInitDraw scheint zu gehen, aber bei den anderen dreien bin ich mir nicht sicher. man hat mir gesagt ich solle ein @ bei den getprocadress anhängen, mach ich dies mit eben einer zahl, kommt Attempt to call uninitialized function pointer, denke also das war nicht richtig so |
||
AvaGast |
![]() Antworten mit Zitat |
|
---|---|---|
Ich vermute, Deine Chancen auf Hilfe stehen recht schlecht. Verdammt viel Code ... das meiste ist extern und nicht einsehbar. Keine Chance, es selber zu testen ... ect.
Naja, ich drück Dir dennoch die Daumen. |
||
hamztata |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
wenns hilft kann ich beide mods uppen.
damit wäre nix mehr extern. und nen beispiel dazu, wo besagte befehle funktionieren "sollten". [edit] hier beide mods und das beispiel... up.rar - 1.07MB |
||
klepto2 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hi, versuch mal hier:
Global xDrawText_%(text:Byte Ptr, x%, y%, centerX%, centerY%, maxWidth%) "win32" das Byte Ptr inf $z zu ändern, oder schreibe eine Wrapfunktion wie sowas: Code: [AUSKLAPPEN] Function xDrawText:Int(text:String,x%,y%,cx%,cy%,mW%) return xDrawText_(text.ToCString(),x,y,cx,cy,mW) end Function ich vermute mal du übergibst das ganze an eine c dll, und c arbeitet standardmäßig mit nullterminierten strings, Blitzmax allerdings nicht. |
||
Matrix Screensaver
Console Modul für BlitzMax KLPacker Modul für BlitzMax HomePage : http://www.brsoftware.de.vu |
![]() |
BtbN |
![]() Antworten mit Zitat ![]() |
---|---|---|
Eine Funktion wie du sie da gemacht hast ist nen 1a memleak, weil der übergebene C-String niemals wieder freigegeben wird und bei jedem aufruf erneut allociert wird. | ||
hamztata |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ich hab im xText() vom xors3d mod, der dabei ist auch schon geschaut, dort wird aber nix besonderes übergeben, daher rätsel ich ja auch noch.
aber klepto, lad dir einfach mal in meinem vorherigen post das paket runter, da ist alles dabei.und die fi.bmx ist das problem. und ein testbeispiel ist auch dabei mit nur wenigen befehlen..... |
||
klepto2 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Werde ich mal machen, der code oben ist btw nur schnell hingeschustert gewesen. Bin hier auf der arbeit und kanns erst nachher testen. Die Funktion sollte auch nur nen anhaltspunkt sein wo der Fehler liegen könnte. | ||
Matrix Screensaver
Console Modul für BlitzMax KLPacker Modul für BlitzMax HomePage : http://www.brsoftware.de.vu |
hamztata |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
jo danke dir.
wenn du es dir anschaust später.xors3d.bmx funktioniert tadellos, nur meine fi.bmx eben nicht. teste mal einfach mein testbeispiel, dort hab ich auch schon die entsprechenden befehle markiert bzw. oben hingeschrieben.man kann also das problem ziemlich stark eingrenzen. danke dir |
||
klepto2 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Also ne theorie habe ich schonmal, kann mich aber im Moment leider nicht wirklich darum kümmern.
Aber als anhaltspunkt: Du nimmst ja B3D als Vorlage. Bei B3D bekommt man für Texturen etc ein int handle, bei Bmax anscheinend nicht. Darum versucht CreateImageEx_ auf nicht vorhandende Daten zuzugreifen. Ich würde mal folgendes probieren CreateTexture oder wie das auch immer heißt, einfach mal nen Byte Ptr zurückgeben lassen anstelle eines ints. |
||
Matrix Screensaver
Console Modul für BlitzMax KLPacker Modul für BlitzMax HomePage : http://www.brsoftware.de.vu |
hamztata |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ich hab zwar jetzt nicht den teil im code gefunden den du meinst, aber etwas in der richtung könnte tatsächlich sein.
es wird ja ein type also eine structur erstellt, mit daten gefüllt und an die dll übergeben. so sollte es zumindest sein. wenn ich jedoch mittels xGetFontProperty(font) diesen type abfrage und hinterher ein : xText 10, 20, "testimage" +FI_FontProperty.Image, dann kommt die meldung: unhandled memeory exeption error(oder so ähnlich, habs mit nich gemerkt) jedenfall im debug erscheint nun diese fehlermeldung beim compilieren....bad refs:obj=$3b8d60 refs=$0. ich als bm neuling kann nun nicht wirklich was damit anfangen, aber sieht so aus, als ob refs= $0 sein sollte. |
||
klepto2 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Code: [AUSKLAPPEN] ' Texture Function xLoadTexture%(path:Byte Ptr,flag% = 0) Return xLoadTexture_(path,flag) End Function Function xCreateTexture%(w%,h%,fl% = 9,fr% = 1) Return xCreateTexture_(w,h,fl,fr) End Function Function xEntityTexture(entity%,tex%,Frame% = 0,index% = 0) xEntityTexture_(entity,tex,Frame,index) End Function Function xTextureName:String(tex%) Local CharSet:Byte Ptr=xTextureName_(tex) Local Name$,CharI% Repeat If CharSet[CharI]=Null Return Name Name:+Chr(Int(CharSet[CharI])) CharI:+1 Forever End Function Diesen part in XORS3D.bmx meinte ich, dort die Rückgabe von int auf Byte Ptr ändern sowie alle weiteren Verweise auf die Texturen in anderen Funktionen ebenfalls auf Byte Ptr ändern. Btw, der Wrapper ist in nicht gerade der gelungenste und verschluckt unMengen an freien Resourcen. Warum zb ist alles 2 * gewrapped? Bei manchen Funktionen kann ich es ja verstehen, aber alle? und Dann diese Int handle benutzung, das ist auch nicht gerade Speedförderlich. Vorallem weil von der dll eh Type Pointer zurückgegeben werden. Back to Topic: Wie gesagt, kann es im Moment nicht testen, aber bei mir ist dein Wrapper immer genau hier: Code: [AUSKLAPPEN] Function xLoadImageEx% (fileName:String, textureFlags%=0, imageFlags%=FI_AUTOFLAGS) If ImageInfo_ReadFile (fileName) Then Return xCreateImageEx ( xLoadTexture (fileName, textureFlags), ImageInfo_Width, ImageInfo_Height, imageFlags) EndIf Return 0 End Function abgeschmiert, und zwar bei xLoadTexture. Am WE kann ich mir das ja mal genauer anschauen. |
||
Matrix Screensaver
Console Modul für BlitzMax KLPacker Modul für BlitzMax HomePage : http://www.brsoftware.de.vu |
hamztata |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
ich dachts mir schon.
ich kenn einen der hat den wrapper schon fertig, nur der sitzt in london und kann grad nix senden, weil seine platte nich mit seinem mac klarkommt. und der hat nix davon gesagt, daß er auch was an der xors3d ändern musste, sondern nur an der fi.bmx ich werds probieren, aber wenn du dirs am we anschauen könntest, wäre super |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group