1. Need Win Guru/Tester
- Posted by "C. K. Lester" <cklester at yahoo.com> Jan 13, 2003
- 512 views
Windows gurus... Please go here and test the available code: http://www.cklester.com/euphoric/win32lib_sdl_test.htm The program simply attempts to open an SDL resizable window from within a IDE-generated win32lib program. When I click <Close> the program crashes with some memory error. RobC, could you please check this as well?! Thanks, ck
2. Re: Need Win Guru/Tester
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jan 13, 2003
- 494 views
On Mon, 13 Jan 2003 12:10:41 -0600, "C. K. Lester" <cklester at yahoo.com> wrote: > >Windows gurus... Please go here and test the available code: > >http://www.cklester.com/euphoric/win32lib_sdl_test.htm > >The program simply attempts to open an SDL resizable window from within = a >IDE-generated win32lib program. When I click <Close> the program crashes >with some memory error. RobC, could you please check this as well?! > change: setHandler( bttn_Close, w32HClick, routine_id("PushButton2_onClick")) to: setHandler( bttn_Close, w32HClick, routine_id("bttn_Close_onClick")) at the end of sdl_done() I added: done=3D1 and also put an extra exit line in the main loop as follows: while done=3D0 do SDL_PumpEvents() if done then exit end if --<< here Pete
3. Re: Need Win Guru/Tester
- Posted by "C. K. Lester" <cklester at yahoo.com> Jan 13, 2003
- 462 views
Pete! Thanks so much! After I sent that last post, I realized that my loop should probably be more controlled... that I really didn't have a hook into it (like you did with the done variable). However, didn't know where to go with it so I'm glad you responded. How would you resolve this, however: the loop uses done, but then it exits if done is true inside the actual looping code. What I'm thinking is that it can be optimized or done differently so there aren't two tests for done in the same loop code. while done=0 do -- here's done SDL_PumpEvents() if done then exit end if -- here's done Again, much appreciated! -ck ----- Original Message ----- From: "Pete Lomax" <petelomax at blueyonder.co.uk> To: "EUforum" <EUforum at topica.com> Sent: Monday, January 13, 2003 1:03 PM Subject: Re: Need Win Guru/Tester On Mon, 13 Jan 2003 12:10:41 -0600, "C. K. Lester" <cklester at yahoo.com> wrote: > >Windows gurus... Please go here and test the available code: > >http://www.cklester.com/euphoric/win32lib_sdl_test.htm > >The program simply attempts to open an SDL resizable window from within a >IDE-generated win32lib program. When I click <Close> the program crashes >with some memory error. RobC, could you please check this as well?! > change: setHandler( bttn_Close, w32HClick, routine_id("PushButton2_onClick")) to: setHandler( bttn_Close, w32HClick, routine_id("bttn_Close_onClick")) at the end of sdl_done() I added: done=1 and also put an extra exit line in the main loop as follows: while done=0 do SDL_PumpEvents() if done then exit end if --<< here Pete ==^^=============================================================== This email was sent to: cklester at yahoo.com TOPICA - Start your own email discussion group. FREE!
4. Re: Need Win Guru/Tester
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jan 14, 2003
- 471 views
On Mon, 13 Jan 2003 16:51:01 -0600, "C. K. Lester" <cklester at yahoo.com> wrote: >Pete! Thanks so much! No prob. You owe me a favour or two by now though ;) He he >How would you resolve this, however: the loop uses done, but then it = exits >if done is true inside the actual looping code. What I'm thinking is = that it >can be optimized or done differently so there aren't two tests for done = in >the same loop code. > >while done=3D0 do -- here's done > SDL_PumpEvents() > if done then exit end if -- here's done Personally I probably wouldn't bother. I don't know -er anything- about the SDL_ processing innards. When you resort to using an external library (including windows dll files which I use) the overheads of a few local lines are zip compared to just one unnecessary call. The only hints I have come from recent use of win32lib's doEvents(0). It took me an embarrassing while to realise this, but any flags etc I could check could _only_ have been altered as an indirect consequence of that call. I could write 20GB of data to disk, calculate PI to a trillion decimal places, and no other line of my code could *possibly* have been executed, hence none of my flags changed until just after calling doEvents(0). Guess where I put my tests. I also found it quite prohibitively expensive to start calling doEvents(0) too often. At one point I introduced a counter to basically draw 100 things between each call to doEvents(0)/check for termination condition. The routine itself is not at fault; it's not especially slow; but it is utterly pointless to call it more that 25 times a second. The human eye, mice, keyboards, joysticks, etc do not respond any (or much) faster than that. SDL_PumpEvents() may or may not be similar to doEvents(). I didn't realise the name similarity when I last posted. Pete
5. Re: Need Win Guru/Tester
- Posted by jordah at btopenworld.com Jan 14, 2003
- 467 views
BTW, Why is it you lock the surface and unlock it?. Is that to prevent flicker or some other app drawing on the windowed surface. Also, why do you lock and unlock the surface twice in every pumped message? check out the code below and in initme(). It would be best/faster if you locked and unlocked once ----------------------------------- procedure initme() r1=0 g1=0 b1=0 rt=rand(3) gt=rand(3) bt=rand(3) ns=rand(7)+2 count=0 -- dummy = SDL_LockSurface(surface) if dummy = -1 then puts(1, "SDL_LockSurface had a hissy fit!\n") end if poke(rect,{0,0,0,0,128,2,224,1}) dummy=SDL_FillRect(surface,rect,SDL_MapRGB(format,0,0,0)) if dummy = -1 then puts(1, "SDL_FillRect had a hissy fit!\n") end if --SDL_UnlockSurface(surface) end procedure ----------------------------------- global procedure sdl_show() dummy = SDL_Init(SDL_INIT_VIDEO) if dummy = -1 then puts(1, "SDL_Init had a hissy fit!\n") end if --surface = SDL_SetVideoMode(640,480,32,SDL_FULLSCREEN) surface = SDL_SetVideoMode(640,480,32,SDL_RESIZABLE) format=peek4u(surface+4) pixels=peek4u(surface+20) rect=allocate(8) initme() done=0 -- use the PumpEvents and GetMouseState to see if a mouse button has been pressed while done=0 do SDL_PumpEvents() keystate=SDL_GetKeyState(NULL) if peek(keystate+SDLK_SPACE)>0 then count=10001 end if SDL_PumpEvents() dummy=SDL_GetMouseState(0,0) if dummy = -1 then puts(1, "SDL_GetMouseState had a hissy fit!\n") end if dummy = SDL_LockSurface(surface) if dummy = -1 then puts(1, "SDL_LockSurface had a hissy fit!\n") end if a=rand(1000)-500 a=(a/500)*PI a=a/ns r=rand(160)+rand(160) s=ptor(a,r) x=s[1]+320 y=s[2]+240 if rt=1 then r1=floor(a*256/PI) end if if rt=2 then r1=x+y end if if rt=3 then b1=floor(r) end if if gt=1 then g1=floor(a*256/PI) end if if gt=2 then g1=x+y end if if gt=3 then g1=floor(r) end if if bt=1 then b1=floor(a*256/PI) end if if bt=2 then b1=x+y end if if bt=3 then b1=floor(r) end if c=SDL_MapRGB(format,remainder(r1,256),remainder(g1,256),remainder(b1,256)) if c = -1 then puts(1, "SDL_MapRGB had a hissy fit!\n") end if cs=int_to_bytes(c) for a1=0 to ns-1 do s=ptor(a+(a1*PI)/(ns/2),r) x=s[1]+320 if x<0 then x=0 end if if x>639 then x=639 end if y=s[2]+240 if y<0 then y=0 end if if y>479 then y=479 end if poke(pixels+(x+(y*640))*4,cs) s=ptor((a1*PI)/(ns/2)-a,r) x=s[1]+320 if x<0 then x=0 end if if x>639 then x=639 end if y=s[2]+240 if y<0 then y=0 end if if y>479 then y=479 end if poke(pixels+(x+(y*640))*4,cs) end for -- OK, let's unlock the screen surface SDL_UpdateRect(surface,0,0,0,0) SDL_UnlockSurface(surface) count += 1 if count>10000 then initme() end if end while end procedure ----- Original Message ----- From: "C. K. Lester" <cklester at yahoo.com> To: "EUforum" <EUforum at topica.com> Sent: Monday, January 13, 2003 6:10 PM Subject: Need Win Guru/Tester > > Windows gurus... Please go here and test the available code: > > http://www.cklester.com/euphoric/win32lib_sdl_test.htm > > The program simply attempts to open an SDL resizable window from within a > IDE-generated win32lib program. When I click <Close> the program crashes > with some memory error. RobC, could you please check this as well?! > > Thanks, > ck > > > > TOPICA - Start your own email discussion group. FREE! >
6. Re: Need Win Guru/Tester
- Posted by jordah at btopenworld.com Jan 14, 2003
- 479 views
while not done do SDL_PumpEvents() -- This line below is never called -- if done then exit end if -- here's done > ----- Original Message ----- From: "C. K. Lester" <cklester at yahoo.com> To: "EUforum" <EUforum at topica.com> Subject: Re: Need Win Guru/Tester > > Pete! Thanks so much! > > After I sent that last post, I realized that my loop should probably be more > controlled... that I really didn't have a hook into it (like you did with > the done variable). However, didn't know where to go with it so I'm glad you > responded. > > How would you resolve this, however: the loop uses done, but then it exits > if done is true inside the actual looping code. What I'm thinking is that it > can be optimized or done differently so there aren't two tests for done in > the same loop code. > > while done=0 do -- here's done > SDL_PumpEvents() > if done then exit end if -- here's done > > > Again, much appreciated! > > -ck > > ----- Original Message ----- > From: "Pete Lomax" <petelomax at blueyonder.co.uk> > To: "EUforum" <EUforum at topica.com> > Sent: Monday, January 13, 2003 1:03 PM > Subject: Re: Need Win Guru/Tester > > > On Mon, 13 Jan 2003 12:10:41 -0600, "C. K. Lester" > <cklester at yahoo.com> wrote: > > > > >Windows gurus... Please go here and test the available code: > > > >http://www.cklester.com/euphoric/win32lib_sdl_test.htm > > > >The program simply attempts to open an SDL resizable window from within a > >IDE-generated win32lib program. When I click <Close> the program crashes > >with some memory error. RobC, could you please check this as well?! > > > change: > setHandler( bttn_Close, w32HClick, routine_id("PushButton2_onClick")) > to: > setHandler( bttn_Close, w32HClick, routine_id("bttn_Close_onClick")) > > at the end of sdl_done() I added: > done=1 > > and also put an extra exit line in the main loop as follows: > > while done=0 do > SDL_PumpEvents() > if done then exit end if --<< here > > Pete > > ==^^=============================================================== > This email was sent to: cklester at yahoo.com > > > TOPICA - Start your own email discussion group. FREE! > > > > TOPICA - Start your own email discussion group. FREE! >