Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Jan 2001
Offline Last Active Today, 06:53 AM

#5316562 Drawing solid triangle

Posted by on Today, 12:01 AM

Your rasterizer only work so long as x0,y0 is at the top. Your code doesn't take the case of a horizontal top edge into consideration and fails at this point. This is why your cube is only being rendered as right triangles with the apex at the top.

#5316278 Moving from plain "ascii" to XML?

Posted by on 22 October 2016 - 06:38 PM


I'll go for my own format where I can 'learn' from other formats.
*sigh* There are tons of libs that you can literally call 'load(path)' and it returns a key-value structure. YAML/JSON/XML schemas are as complex or simple as you want them to be, they're very flexible. You already spent more time in coding that piece of code than in what it takes to download one and link it to your project, "I shouldn't make it complex" is the opposite of rolling your own. 



This ^^^

Look at ini file parsers. They sound like they'll do what you're looking for: https://www.google.com/#q=simple+ini+file+parser+c%2B%2B

#5315288 Compiling GTK+ in Visual Studio?

Posted by on 15 October 2016 - 01:10 AM

I found a way to get GTK working in Code Blocks, but I've given up on Visual Studio. I've noticed a trend lately in open source APIs. It seems like everyone is going over to the vastly more complex Linux development methods for all supported platforms, no matter if such methods are native to said platforms. You seriously have to download tools to emulate Linux (beyond basic a command line) in order to compile GTK and Cairo on Windows. Why? Why is it necessary to use a command line to compile an API into a binary? Heck, IDEs exist on Linux. I've used them!


Sorry for the rant, but geez! This is nuts!

#5293874 Breaking out of a nested loop

Posted by on 27 May 2016 - 04:24 PM

you have to set j back to zero tho else it does the job. Also this is how assembly would work

Oh crap! :unsure:

#5293863 Breaking out of a nested loop

Posted by on 27 May 2016 - 02:53 PM

Just replace the for loops with if goto pairs so that goto won't look so lonely.


int i = 0, j = 0;
        if(i - 1 == j + 1)
            goto outer;
    if(j < 10)
        goto loop;
    j = 0;
    if(i < 10)
        goto loop;


Seems pretty clean to me!

[edit] Fixed glaringly obvious and embarrassing mistake...

#5286132 Yo dawg, I herd u liek gd.net

Posted by on 10 April 2016 - 08:36 AM

I'm going to don my tinfoil hat and say that that wasn't made by any administrator here...

#5264126 Looking for a free 2D engine

Posted by on 29 November 2015 - 11:35 AM

I haven't used it, but Godot Engine looks quite powerful and it's free.

#5262077 Member function pointers?

Posted by on 14 November 2015 - 09:24 PM

If you use C++11 onward, you  should use std::function and combine it with std::bind.

class AnotherObject
   std::function<void(void)> callback;

class TestObject
   void MyFunction() {};

int main()
   AnotherObject ao;
   ao.callback = std::bind(&TestObject::MyFunction, &ao);

#5261217 How hard it is to live from games as indie developer?

Posted by on 09 November 2015 - 03:26 PM

I remember reading an article written by the lead programmer of an indie project on iOS. His project (not a game) was an overnight sensation with over 10,000 downloads. The amount of money he made through those sales totaled something like $300 USD.
I wish I kept the link!sad.png

#5260936 Connecting to SQL Server

Posted by on 07 November 2015 - 03:55 PM

Please quit posting the same thing over and over. The servers are having difficulty at the moment. Give it time to update.

#5260343 bmp Loader class

Posted by on 03 November 2015 - 11:36 AM

What I do for storing images/textures is keeping them in a format of my own. Of course, that's probably not useful to you but, why not post it?

To add to what Alundra said...

You start by making up a header format. It doesn't have to be long or complicated:
image_width : 4 bytes
image_height : 4 bytes
bytes_per_pixel : 1 byte
In code, it would be:
struct image_header{
long image_width;
long image_height;
char bytes_per_pixel;
To write the file, you write out the correct number of bytes for each header field and then the image data from your buffer. I prefer not to make assumptions about integer size and thus header size. "long" may or may not be 4 bytes, depending in the platform, but can be guaranteed to be no less than four bytes. Always explicitly write out the correct number of bytes per field and never rely on "sizeof(image_header)" when reading the file. On some 64-bit systems, "long" might be 8 bytes, in which case reading or writing "sizeof(long)" will not get you what you expect.

Reading is the reverse of writing.

#5259998 How do I re-size a binary file?

Posted by on 01 November 2015 - 10:24 AM

Why are you trying to resize "Batman Arkham Asylum" assets?

That is interesting...

#5259949 bmp Loader class

Posted by on 31 October 2015 - 07:15 PM

Yes bmp sucks but I feel so close. This code works perfectly with bmp only one flaw when I try to free the pixels I get heap corruption. !!! 
The only reason I use this format because I dont want to overload my head with compression and decompression, as I understand and correct me if am wrong everything else including targa uses compression.

Compression is optional in TGA files. I've never used it.

#5259910 bmp Loader class

Posted by on 31 October 2015 - 02:09 PM

There is also DevIL to consider.

#5259895 bmp Loader class

Posted by on 31 October 2015 - 11:24 AM

First off, I wouldn't recommend using BMP as a texture storage and loading format. Ideally, you'd create your own format, but barring that, I'd use TGA. It is far easier to load as the format just makes sense. BMP is highly screwed up, as you've noticed. The pixels are not stored as you would expect. Padding *may* be added per scanline, which makes looking at the file with a hex editor all but useless.


If you are insistent on using BMP, do some studying:






It is not a programmer-friendly format.