Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Godlord

Members
  • Posts

    5689
  • Joined

  • Last visited

    Never

Everything posted by Godlord

  1. When sending data across the wire, or when writing data to a disk, I'd also keep endianness and portability (although, it doesn't really matter much for C#, as the language is proprietary) in mind. Except for some proprietary and mostly exotic protocols the internet generally uses big endian, rather than little endian. On top of that, I'd personally avoid the terms **short**, **int** and **long** as the bit-widths are implicit, even though they have been standardised in C#. Therefore, they are only useful when referring to variables on the host, and not when dealing with portable data. However, whether you actually do this is up to you. Since you are using C# anyway, it doesn't really matter (unless you are expecting that your data is going to be used elsewhere). Yours faithfully, S.J.R. van Schaik.
  2. > Thanks Stephan, I'll try this out right away. I'm guessing I'd just removed those empty bytes of data when I'm prepared to transfer the buffer. > > Regards, > > GP Aren't you able to just tell how many bytes you want to send? Yours faithfully, S.J.R. van Schaik.
  3. At this moment you are just allocating a buffer that is just large enough to store your data in. The problem with that is that this linear behaviour (as you actually increment the size with one byte for every byte you add) causes the buffer to be re-allocated every time data is being added to the buffer. Rather than re-allocating the buffer in a linear fashion, you should re-allocate it in an exponential fashion (i.e. twice the previous size, or the next power of two, as your data may not fit). That way those additional re-allocations are being prevented. Furthermore, preserving just the right amount of storage, prevents re-allocations from occurring in general. Yours faithfully, S.J.R. van Schaik.
  4. I'm wondering why you are allocating the size you need (linear allocation), rather than the next power of two for that size (exponential allocation). Especially, since allocation and copying memory are slow operations. Yours faithfully, S.J.R. van Schaik.
  5. > She still lost her virginity to a carrot, though. She must have become a veganist by now. Yours faithfully, S.J.R. van Schaik.
  6. Why aren't you using version control software such as Git or Mercurial? Yours faithfully, S.J.R. van Schaik.
  7. Mozilla Firefox with [Pentadactyl](http://5digits.org/pentadactyl/) and [TabKit 2nd Edition](https://addons.mozilla.org/en-us/firefox/addon/tabkit-2nd-edition/). Yours faithfully, S.J.R. van Schaik.
  8. > First, In C programming memory is managed with the malloc() function but what if somehow an error occurs when you try to allocate memory for something? It depends on the operating system your programme is running on. Generally, if malloc fails, it will return NULL, which is an indication that libc was unable to allocate sufficient memory. However, most operating systems, will simply swap away pages from memory to a storage device, in order to allocate more space, until there is no swap space left, in which case the operating system will start killing processes. > I know in C++ they added the smart pointers to help with C++ memory allocation but I was wondering on C. Smart pointers are a concept that is entirely based on exploiting the rather implicit behaviour of C++. Since pointers themselves are allocated on the stack, some C++ programmers decided to implement an actual class for pointers, where the destructor is used to check if the memory that is being pointed to, is still being referenced to by other pointers. In case the pointer of which the destructor is called, is the last pointer to reference that memory region, it will free that memory region automagically. That way, since the destructor will be called when the pointer is freed, which happens at the end of scope, the memory you have allocated will be freed for you. > Second, Isn't it possible to apply Object Oriented principles to C as well? i'm starting to see a lot of people as of this year and idk about next changing back to C. I guess it could be the challenge of using such principles in C? Writing object-oriented C code is as simple as using structures, and functions that generally operate on those structures. The major difference being that the syntax is a bit more explicit than for actual object-oriented programming languages. More advanced concepts can be implemented as well, such as inheritance and virtual or overridable functions, through typecasting and function pointers, respectively. However, most of the more advanced concepts are avoided outside libraries. > why don't people actually make games with C? There are actually quite a few games that have been written in C. However, as C++ supports most of the features that C has to offer, and as C++ is more implicit, it is often used instead. Albeit, not for libraries, because C++ isn't as portable as C. > Third, Compared to the other languages, is C more easier to port or can it just run on different operating systems? I know windows and linux can but things like ios, android, ect… Applicatons programmed in C can be ported to just about every operating system (noticeable exceptions being operating systems that run virtual machines, and do not allow native code to be executed, such as Windows Mobile 7). Yours faithfully, S.J.R. van Schaik.
  9. Godlord

    [C++] Basics

    Dev-Cpp is an IDE, not a compiler. The compiler that is being shipped with Dev-Cpp by default is MinGW, which is a port of GCC for Microsoft Windows. Yours faithfully S.J.R. van Schaik.
  10. Godlord

    C++

    If you are a newcomer to programming, and don't know what language to choose. You definitely want to start out with a language like Python. For most people it is one of the most simplistic and straight-forward languages, and it will actually guide you through most of the basics you have to know before approaching most other programming languages, considering it enforces you to indent your code, and considering it presents the object-oriented paradigm in a transparent and comprehensible fashion. Despite the language being very easy to learn, it is actually incredibly powerful, once you start using the numerous libraries that are being offered for Python, which is an enormous asset of using Python: you will get rewarding results for your efforts, which is what most people want. After learning Python, you have quite a few choices. You can move on towards an imperative programming language such as C, or you can actually learn about functional and declarative programming. The latter two are useful as they actually broaden your view, causing you to use idioms common to those paradigms when programming in a different language that doesn't directly support that paradigm. An example of this is the use of function pointers in C, which is a concept originating from functional programming. Interesting languages to learn are Haskell, Lisp (or Clojure), Erlang, Io, Scala and Prolog. Be aware that they are hard to get into, once you are used to different paradigms. The prior is an easily accessible powerhouse, where having been introduced to Python before, will make it easier for anyone to learn. I personally think that possible the hardest thing to grasp would be pointers. As for C++, I would personally avoid it. If you want to write good C++ code, you'll either end up writing overengineered code (that has numerous inexplicable bugs crawling in it), or code that looks extremely familiar to C, but that isn't exactly C code, just because you wanted to prevent all those inexplicable bugs, which are mostly caused by obscurities. The other problem is that it is incredibly hard to read someone else's C++ code (I don't blame you, even compilers have this exact issue), which isn't a problem if you are working all by yourself, but it definitely is when working on projects. If you don't have to write C++ code any time soon, then I recommend you to check out [this website](http://yosefk.com/c++fqa/). Albeit a bit harsh on some points, it definitely is a good summary of all the problems you may encounter in C++. On the other hand, I also recommend you to read it if you are about to write C++ code, in which case you'll know how to write C++ code without a lot of surprises. Yours faithfully S.J.R. van Schaik.
  11. Godlord

    C++

    As a programmer you want to stay away from plain text editors such as Notepad, or RTF-based text editors such as Wordpad. They don't offer any features to aid you when you are programming. You will definitely want line numbers, horizontal guides (one that is located at 80 columns), proper identation settings (tabs/spaces, automatically align properly when pressing enter) and syntax high-lighting. In addition to that, you will also want a tab-based and/or a tile-based editor. On Linux that means you are fine with editors such as vim, emacs, and Gedit, which are usually shipped with your distribution. On Microsoft Windows, on the other hand, you are likely to be using an IDE, if you are not using a UNIX-environment. Whilst it is true that C++ compilers have been freely available on various platforms for quite a while now, it is also true that some compilers are better than others depending on what you want to do with them. MinGW and CygWin, for instance, are quite poor at producing proper binaries for Microsoft Windows, and aren't able to easily interface with most of the libraries that are used on Microsoft Windows, because that's not what they where made for. They were made for UNIX enthusiasts who want to run their programmes specifically written for UNIX on Microsoft Windows (the prime example being Git, which includes OpenSSH as well as some other UNIX utilities). That leaves you with the Microsoft Visual C/C++ compiler, if you want to support Microsoft Windows properly, considering that most other compilers are obsolete, or commercial (so is Microsoft Visual C/C++ to some extent). On platforms such as Linux, Mac OS X, Solaris, FreeBSD, and just about every UNIX-platform you have the choice between GCC, which is the de facto compiler suite for UNIX, or LLVM. Both being free options, in that case, you'll have an advantange, if you are developing cross-platform software. Yours faithfully S.J.R. van Schaik.
  12. Godlord

    C++

    It's good to know that the amount of respect you bring up for someone is closely tied to your consideration of how someone is highly opiniationated and narrow-minded. At least, I am not forced to live with people with similar considerations. Yours faithfully S.J.R. van Schaik.
  13. Godlord

    C++

    Oh, I am definitely not against the choice of the programming language, in fact I actually applaud it, since once people actually start using other programming languages as well, they will realise why they should have avoided this particular one, in the first place. Yours faithfully S.J.R. van Schaik.
  14. Godlord

    C++

    No, that's what you think it said. Allow me to actually enlighten my statement for you, considering you won't be able to interpret it properly. I've said that anyone who claims to know C++, and that is beyond the basics, to the point where that person has a lot of experience with the language, and who also claims that the language is easy, that is, easy to grasp for anyone to that same point as the person claiming it or anything similar, doesn't know the language too well, which means that he actually knows as much as the basics of the programming language. By pointing out that the people in this thread think that if you know the basics of the language, that the language is actually easier to comprehend, you have just confirmed my statement, once again. If you don't see how, or why, then please do stop bothering. As for the matter on colleges and universities, and please let's make that distinction, they are professional and academic respectively. That means that for the latter, there is no particular interest in teaching students how to programme in a professional fashion. For the prior, on the other hand, there is an interest in teaching students how to programme in a professional fashion, i.e. preparing a student for a job. That doesn't mean that any of the professional students will know how to write well-thought and formal C++ code, because it is complicated to do so, and it is even more complicated to actually teach someone how to do that. Capable academic students on the other hand will do a far better job at it, but are hard to find, especially because most academic students end up in the professional world instead. Furthermore, there is nobody who will teach you all the ambiguities that are C++, there is nobody who will teach you when you should use what design pattern (except for a few colleges) and there is definitely nobody who will step you through the entire documentation of the Boost library, since these are things you'll learn by experience, something which no teacher will be able to teach you, other than trial and error itself, and even then, you won't be able to write well-thought and formal C++ code, because the language is just an overcomplicated overambiguous mess that makes you cry blood. It's exactly that why C, Java and Python are popular choices amongst colleges and universities, unless they are trying to target a certain niche. Yours faithfully S.J.R. van Schaik.
  15. Godlord

    C++

    > In that case thousands of students everywhere in Computer Programs should have failed their classes. Learning the basics is easy, otherwise it would not be a single semester course at most colleges. I don't see how whether someone is able to learn the basics or not has anything to do with my exact statement. If you just know the basics, you don't know the programming language too well, in which case you just confirmed my statement. In addition to that, universities don't demand you to know a lot about any programming language at all. None of them require you to actually know how to programme professionally in any given programming language. All they expect from you is that you can pick up any programming language easily, and know most basic concepts. For instance, my university offers a course on C programming, they don't expect you to know how to use function pointers, they just expect you to know that they do exist. Similarly, for the course on Java programming, they don't expect you to know how to use generics, just that they do exist. Yours faithfully S.J.R. van Schaik.
  16. The course I have on image processing has been keeping me busy lately, so I thought that I might as well post some results. In this thread I will include both the original and the processed images, as well as a brief description of the process. These images have been processed by scripts I have written in Python using numpy and scipy, those will however not be included for the while being. If you do feel like experimenting with image processing, but don't have suffiencent knowledge about linear and/or geometric algebra, then OpenCV is a pretty good solution. I do not recommend Python, however, unless you want to programme the exact mathematical process (which is why I have been using Python, numpy and scipy), considering Python is slow (it usually takes a few seconds to warp most of these images). **Original.** ![](http://sphotos-e.ak.fbcdn.net/hphotos-ak-ash4/422908_10151060465338616_1429435508_n.jpg) **Result upon applying an affine transformation.** ![](http://a3.sphotos.ak.fbcdn.net/hphotos-ak-ash4/422908_10151060465348616_322444515_n.jpg) **Original.** ![](http://a8.sphotos.ak.fbcdn.net/hphotos-ak-ash4/422908_10151060465353616_514999111_n.jpg) **Result upon applying a projective transformation using the four corner points of the poster. I have also written a similar script that finds the homography instead, and uses that to warp the image, and the result is the same.** ![](http://sphotos-f.ak.fbcdn.net/hphotos-ak-ash4/422908_10151060465358616_1051484653_n.jpg) **Original. The effect is caused by the lens, and is usually known as radial distortion.** ![](http://sphotos-d.ak.fbcdn.net/hphotos-ak-snc7/422908_10151060465363616_1992972364_n.jpg) **Result upon applying a radial transformation. The result is close to that of when the image is taken with a proper lens, or a pin-hole camera, but some artifacts will remain visible.** ![](http://a2.sphotos.ak.fbcdn.net/hphotos-ak-snc6/207949_10151060466193616_621511988_n.jpg) **Original.** ![](http://sphotos-d.ak.fbcdn.net/hphotos-ak-ash4/377972_10150430400988616_597508035_n.jpg) **Result upon applying the same radial transformation, albeit with different parameters.** ![](http://a3.sphotos.ak.fbcdn.net/hphotos-ak-snc6/207949_10151060466198616_302215228_n.jpg) Yours faithfully S.J.R. van Schaik.
  17. Godlord

    C++

    Anyone who claims to know C++, and consider it to be easy at the same time, doesn't really know the language too well. Yours faithfully S.J.R. van Schaik.
  18. > To translate Eclipse, you'll need to edit the strings in VB6 (Visual Basic 6, programming language Eclipse is written in). Note that VB6 does not, by default support UTF-8\. Some Czech characters, such as ř or í, won't work. You'll have to find a workaround to support it. Neither does Microsoft Windows support UTF-8, other than providing an API for converting that format to the formats it does support. Microsoft Windows offers native support for ASCII, and for UTF-16 LE since Microsoft Windows XP (Microsoft Windows NT and 2000 use UCS-2 instead). I reckon that you meant to say that Microsoft Visual Basic 6.0 doesn't offer support for Unicode, instead of UTF-8\. The reason being that Microsoft Visual Basic 6.0 was released before Windows NT and its derivatives. Yours faithfully S.J.R. van Schaik.
  19. > Visual Basic 6 isn't available to download from Microsoft. Google around for a download link. It is, actually, but only to those who have a MSDN subscription. Although, if you don't have that, your best bet would be to torrent it. Yours faithfully S.J.R. van Schaik.
  20. Godlord

    College

    My government does grant me money for my education, actually. Yours faithfully S.J.R. van Schaik.
  21. > Wow that's a long code XD no idea how it works but it looks fancy ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons//smile.png) It only does two things: * Declare the ShellExecute function (i.e. telling Microsoft Visual Basic 6.0 that it exists, what its arguments look like, and where to find it). * Call that function to open the URL (internally, the function will use the registry to actually open it with the right programme). Yours faithfully S.J.R. van Schaik.
  22. > ``` > Private Sub cmdWeb_click () > > Shell ("Explorer YOUR WEBSITE") > > End Sub > ``` It's a better idea to open the default browser instead. As shown in [this article](http://support.microsoft.com/kb/224816), the code looks somewhat like: ``` Private Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Sub WebsiteButton_Click() Call ShellExecute(Me.hwnd, "open", "http://www.google.com/", _ vbNullString, vbNullString, vbNormal) End Sub ``` Yours faithfully S.J.R. van Schaik.
  23. Godlord

    PNG in EO 3.0

    I don't see the reason to use GDI+ over GDI in this particular case. Even though the support for alpha-channel images is fairly limited, it does exist within GDI. However, it will be quite the tedious task to actually implement it without a sufficient amount of programming experience, especially in a niche language like Microsoft Visual Basic 6. The first task is to actually be able to load PNG-images. The most general approach to this is to actually use libpng, for which sufficient documentation and code samples are present. Do keep in mind that the majority of these samples will be written in C. Once the code has been written to load PNG-images, you'll be left with an array of bytes that represents the actual image, similar to an uncompressed bitmap, which you can then pass to [CreateBitmap](http://msdn.microsoft.com/en-us/library/dd183485%28v=vs.85%29) or any of the related functions to create an actual GDI bitmap. Here's the tricky part though, as the image contains an alpha channel, and as every channel does consume eight bits, you'll have to specify that every pixel will consume thirty-two bits in total. Normally, GDI will simply ignore this channel for most operations, or even reset it to zero values, so sometimes you do have to be careful. After you've got a GDI bitmap, you can then draw it via the use of [AlphaBlend](http://msdn.microsoft.com/en-us/library/dd183351%28VS.85%29.aspx), or [TransparentBlt](http://msdn.microsoft.com/en-us/library/windows/desktop/dd145141%28v=vs.85%29.aspx). The prior seems to be favoured over the latter though. There should be some articles that cover this entirely, but most of them will make use of C. Ideally, it should also be possible to create a control in Microsoft Visual Basic 6.0 that wraps this up for you, similar to the actual picture controls that Microsoft Visual Basic 6.0 has to offer. Yours faithfully S.J.R. van Schaik.
  24. > Now write a shader that will accomplish the same tasks. A lot of modern rendering is done through shaders,it'd be good to get the hang of it sooner ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons//tongue.png) Yes, vertex and fragment shader programming are preferred over the fixed function pipeline, because they make great use of parallelism, and because they offer both a huge amount of flexibility and performance, but I really discourage jumping straight into the subject, unless you are already experienced with both linear algebra and graphics programming itself, since that makes it easier to actually comprehend shader programming to begin with. Yours faithfully S.J.R. van Schaik.
  25. That what you will attempt not to explore, will remain covered by a mere shadow of ignorance and injustice. Yours faithfully S.J.R. van Schaik.
×
×
  • Create New...