Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Feb 2008
Offline Last Active Today, 08:03 PM

Posts I've Made

In Topic: My Texture to HBITMAP function leaks and I don't know why...

22 May 2016 - 05:33 PM

// assuming std::vector<uint8_t> CDirectXWrapper::image_buffer;

image_buffer.resize(textureDesc.Width * textureDesc.Height * 4); // may or may not trigger realloc
uint8_t* destination = image_buffer.data();

In Topic: My Texture to HBITMAP function leaks and I don't know why...

22 May 2016 - 05:16 PM

For starters, you assign new[]’d memory to destination, but you don’t delete[] it. You may also consider using std::vector instead, so you only need to make an allocation for every time the source image grows, instead of allocating every frame.

In Topic: c++: sprintf but return chars. Possible?

22 May 2016 - 11:27 AM

You could abuse operator,:

void doStuff(const char*);

int main() {
    char buf[200];
Disclaimer: Don’t actually do this.

In Topic: my C++ console 3D fps Game on Windows from scratch

20 May 2016 - 02:46 PM

Now translate it into ANSI escape sequences and provide it on a port you can telnet to.

So, the worst case to represent a single cell would be 15 bytes:

2  "\x1B["             // Opening escape sequence
1  "7"                 // Reverse video
3  ";31"               // Red foreground
3  ";41"               // Red background
2  ";1"                // Bold foreground (to bright red)
1  "m"                 // Closing escape sequence
3  "\xE2\x96\x93"      // UTF-8 sequence for 75% fill (▓)
And for a terminal with 60 rows and 80 columns, and assuming 15 bytes per cell, that would be 72.0 KB/frame (not including cursor positioning), and 2.16 MB/s for a modest 30 fps. We would need to analyze a few sample “images” of course, because state can be shared across neighboring cells.

In any case, it’d give my 2400-baud modem a run for its money, that’s for sure. Definitely worth it for full-frame animated GIFs for terminals!

In Topic: Trying to draw area from image fails.

16 May 2016 - 07:06 PM

Integer division: 1 / 3 is 0.

Consider using float literals wherever you expect to have a non-integer result:

float topborder    = (1.f / n)	  * (t - 1);
float bottomborder = 1 - ((1.f / n) * (n - t));