Please help me with Interface Stuff
BlitzMax Forums/BlitzMax Programming/Please help me with Interface Stuff
| ||
Hi. At moment i test my first Interface with the SDL Lib. But i had some unexplainable(for me) problems with Correctly Structur Import. Letīs begin : The SDL_Surface Structure http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSurface My Test Code Import "-lsdl.dll" extern "C" type SDL_Surface field flags:int field format:byte ptr field w:int,h:int field pitch:short field pixels:byte ptr field clip_rect:byte ptr field refcount:int end type Function SDL_Init(Flags:Int) Function SDL_SetVideoMode:SDL_Surface(Width:Int, Height:Int, Depth:Int, Flags:Int) Function SDL_Flip(Screen:SDL_Surface) Function SDL_FillRect(dst:SDL_Surface, dstrect:byte ptr, color:Int) end extern Const SDL_INIT_VIDEO = $00000020 Const SDL_HWSURFACE = $00000001 Const SDL_DOUBLEBUF = $40000000 Const SDL_FULLSCREEN = $80000000 if SDL_Init(SDL_INIT_VIDEO)=-1 end endif local ScreenSurface:SDL_Surface = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF) print ScreenSurface.w print ScreenSurface.h Repeat SDL_FillRect(ScreenSurface,null,$FFFFFF) SDL_Flip(ScreenSurface) FlushMem() Until KeyHit(KEY_ESCAPE) The Problem : This Code works without Errors. But the ScreenSurface Data are wrong. Prints : w: 600 h: 3200 I Think the Data is in disorder. But i dont know what i can do. Please help me a bit. Mfg Suco |
| ||
According the headers or SDL 1.2 SDL_video.h, the surface should look like this: struct SDL_Surface { Uint32 flags; /* Read-only */ SDL_PixelFormat *format; /* Read-only */ int w, h; /* Read-only */ Uint16 pitch; /* Read-only */ void *pixels; /* Read-write */ int offset; /* Private */ /* Hardware-specific surface info */ struct private_hwdata *hwdata; /* clipping information */ SDL_Rect clip_rect; /* Read-only */ Uint32 unused1; /* for binary compatibility */ /* Allow recursive locks */ Uint32 locked; /* Private */ /* info for fast blit mapping to other surfaces */ struct SDL_BlitMap *map; /* Private */ /* format version, bumped at every change to invalidate blit maps */ unsigned int format_version; /* Private */ /* Reference count -- used when freeing surface */ int refcount; /* Read-mostly */ } According that, the first 4 fields should be correct but after that, there are quite some fields missing. |
| ||
hi. Thats not the Problem. Type SDL_Surface Field flags:Int Field format:Byte Ptr Field w:Int, h:Int Field pitch:Short Field __unused_align_1:Short Field pixels:Byte Ptr Field offset:Int Field hwdata:Byte Ptr Field clip_rect_x:Short Field clip_rect_y:Short Field clip_rect_w:Short Field clip_rect_h:Short Field unused1:Int Field locked:Int Field map:Byte Ptr Field format_version:Int Field refcount:Int End Type The Structur on my normal Version. But its the Same problem......... It runs if i work with Byte Ptr and Memcopy to a Surface Instance like : local tmp:byte ptr = SDL_SetVideoMode(..) local ScreenSurface:SDL_Surface = new SDL_Surface memcopy ScreenSurface,tmp,sizeof(ScreenSurface) Works good. But not the best Solution i think. Mfg Suco |
| ||
Your problem is the SDL_SetVideoMode function returns a pointer to that structure. For some reason, this doesn't work (I get an unhandled memory exception in the catch): |
| ||
This does work, but makes no sense. There seems to be a problem with dereferencing a pointer of a user defined type. |
| ||
@suco-x: Do you have any plans on releasing a sdl BM-Module? I ask this because my carpc does support opengl only in some kind of compatibility mode which means if i create a program which only uses one DrawImage command the flip takes about 2 seconds to render ;-) Less then 1 fps is unusable even though i am not programming a game ;-) As i read, sdl uses DirectX on a Windows Pc, right? DirectX works fine on my carpc. Maybe that would be a solution for me, as my program only has to draw a few bitmapts on the screen ( a user interface), that's all. |
| ||
Hi I provided a first Version of one SDL Module some month ago. But i hate the Structure handling and stopped the development. I thought Mark say me a better way... Mfg Suco |
| ||
Hey Mirko, I'm into car PC as well! I've written the interface that I'm currently using in Blitz3D but am working on an improved version in Max. OpenGL seems to work fine on the Epia M10000. Don't they have the same graphics subsystem? Anyway, sorry to go off topic Suco... |