Results 1 to 7 of 7

Thread: opengl bezier surface

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: opengl bezier surface

    Additionally, use new instead of malloc.
    "If you lie to the compiler, it will get its revenge." - Henry Spencer

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: opengl bezier surface

    Additionally, use new instead of malloc.
    The big thing is to use new with delete or malloc with free. As long as you use one pair you should be fine. What makes new better than malloc besides it is C++ where malloc is more of a C function? I always use new for Qt objects and malloc when dynamically creating arrays.

    If you use the 3-dimensional array make sure to free/delete every pointer and not just the overlying pointer.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: opengl bezier surface

    Quote Originally Posted by ToddAtWSU View Post
    What makes new better than malloc besides it is C++ where malloc is more of a C function?
    The main difference is that new operator invokes objects' constructors, while malloc() doesn't (same for free() vs. delete).

    Also it can throw an exception when allocation fails and you don't need any sizeofs or casts, so the code is cleaner.

  4. The following user says thank you to jacek for this useful post:

    ToddAtWSU (22nd February 2007)

  5. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Talking Re: opengl bezier surface

    Quote Originally Posted by jacek View Post
    The main difference is that new operator invokes objects' constructors, while malloc() doesn't (same for free() vs. delete).

    Also it can throw an exception when allocation fails and you don't need any sizeofs or casts, so the code is cleaner.
    I always wondered what the difference was but never had an opportunity to look it up when I was thinking about it. Thanks!

Similar Threads

  1. Does OpenGL be supported in opensource of Qt-4.1.2?
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2006, 10:46
  2. OpenGl 2d
    By Lele in forum Qt Programming
    Replies: 10
    Last Post: 9th May 2006, 21:37
  3. help on openGL context
    By mickey in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2006, 19:21
  4. Qt's optimized OpenGL context switching
    By sverhoff in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 16:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.