Welcome, Guest. Please login or register.

Author Topic: "Close Window" tutorial errors  (Read 3883 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: "Close Window" tutorial errors
« Reply #14 from previous page: May 12, 2003, 08:18:30 PM »
Quote

Just add the GimmeZeroZero flag, then Intuition does that for you.


I wouldn't do that. GZZ window uses more RAM and slows down system.
My Amigas: A500, Mac Mini and PowerBook
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: "Close Window" tutorial errors
« Reply #15 on: May 12, 2003, 08:45:32 PM »
Quote

There is one additional major difference, mostly important for lazy (bad) programmers: malloc() does resource tracking. You can return from the program without explicitely calling free() and the startup code will return all allocated memory. Each AllocVec() *must* be matched by a FreeVec().


Advanced programmer should prefer AllocPooled() call over AllocMem()/AllocVec() calls IMO. No more memory leaks (just remember DeletePool() on exit) and you also avoid memory fragmentation when doing small allocations.
My Amigas: A500, Mac Mini and PowerBook
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: "Close Window" tutorial errors
« Reply #16 on: May 12, 2003, 09:26:28 PM »
Quote

itix wrote:
Advanced programmer should prefer AllocPooled() call over AllocMem()/AllocVec() calls IMO. No more memory leaks (just remember DeletePool() on exit) and you also avoid memory fragmentation when doing small allocations.


Precisely why I program through an abstraction layer. Changing the internals of my Mem interface class is easy and doesn't break any of my application code (which also compiles under winblows, not that I'm maintainig it much just now)...
int p; // A
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: "Close Window" tutorial errors
« Reply #17 on: May 13, 2003, 02:32:24 PM »
Quote

Changing the internals of my Mem interface class is easy and doesn't break any of my application code


now i'm curious, a bunch of #ifdefs? i'm targetting a mini-game for os4 along the lines of minesweeper (along those lines meaning, just a small game that gets really hard so you can play it instead of working) ... but of course if i'm beginning coding it in 3.1 then it might get released for that too :-) ...
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: "Close Window" tutorial errors
« Reply #18 on: May 13, 2003, 03:07:51 PM »
Hi Cycloid,

Nope, not conditional compilation as such. What I mean is I can just go in to my mem class and rewrite the internals. As long as I keep the same public interface to the class, nothing that uses it needs to change.

The public interface to the class is the same in the 68K, PPCWarpOS, linux and Win32 versions.

So changing the Amiga68K version's internal implementation from AllocVec() to allocVecPooled() or whatever may be an improvement but I don't have to worry about rifling through loads of application code and changing stuff.

For example, suppose my applications use Mem::alloc(), Mem::copy(), Mem::swap32() etc...example.
How class Mem works internally is not their concern, and nor should it be.
Its just your basic C++ encapsulation approach.

You can do the same thing in C too, just define a bunch of your own functions that are implementation dependent and then use them for everything else. Pretty standard really - thats all the ANSI C-library does anywayy ;-)

-edit-

Sorry I seem to have pulled this thread off topic


int p; // A
 

Offline cycloidTopic starter

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: "Close Window" tutorial errors
« Reply #19 on: May 15, 2003, 01:05:17 PM »
heh, i think i baited you off topic though.. but it looks like we're the only one's in here so that's ok :-)

that's pretty much what i suspected and i have a sudden urge to write a nice MM C++ class now. but i think i should get on with trying to load sprites and display them in my new window
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: "Close Window" tutorial errors
« Reply #20 on: May 15, 2003, 03:01:43 PM »
Call me heretical but I like to hide away all the amiga stuff behind (portable) class interfaces. You won't even see so much as a ULONG in my application code... However, the fun is writing the amiga implementation, of course :-)

Nowadays, even my actual applications are classes. For example, here's the drawtest class definition that I used for the Warp3D thing...

  


class GfxTestApp : public AppBase, public Windowed {
  private:
    static char text[64];
    MilliClock timer;
    sint32 width;
    sint32 height;
    Rasterizer* gfx;
    DrawVertex* vertices;
    bool quit;
    bool flat;
    bool cull;
    bool zbuff;

    void genMesh(sint32 dx, sint32 dy);v
    void dumpPixelInfo(PixelDescriptor *pxl);
    void testMesh1();
    void testMesh2();

  protected:
    // Overridden from AppBase
    sint32 initApplication();
    sint32 runApplication();

    // Overriden from Windowed
    void keyPressNonPrintable(sint32 code);

  public:
    GfxTestApp();
    ~GfxTestApp();
};


int p; // A