Powerbasic Museum 2020-B

IT-Consultant: Patrice Terrier => C++ programming (SDK style) => Topic started by: Patrice Terrier on October 29, 2013, 07:33:42 PM

Title: Charting 64-bit
Post by: Patrice Terrier on October 29, 2013, 07:33:42 PM
This project is to test the 64-bit version of the GDImage WGL_CreateWindow API.

The purpose of this graphic control is to provide a native GPU container, able to support advanced OpenGL extensions to produce state of the art antialiasing and amazing glass effects.

The output offers the same rendering quality in 3D than in 2D.

The main advantage of OpenGL is that it would work on any OS platform, this is the reason why it has my preference over DirectX and D2D, and the code is always the same what ever the language used. :)

The size of the resulting 64-bit EXE is rather small, only 91 Kb (thanks to the SDK coding style)  ;D

The attached C++ project has been built with VS2010, the binary EXE and graphic resources are within the \Release subfolder.

Added:
Forget to say that you need to have a good graphic card to run the OpenGL extensions, this project has been tested on a nVIDIA GEFORCE GT 650M with 2GB.
Title: Re: Charting 64-bit
Post by: James C. Fuller on October 29, 2013, 08:14:02 PM
Patrice,
The project converted to VS12 Express no problem and after I commented out a few library #pragmas that weren't needed and changed the path to the GDImage64.Lib it built and ran fine.
  Good stuff.

James
Title: Re: Charting 64-bit
Post by: Patrice Terrier on October 29, 2013, 08:52:28 PM
James--

Thanks for the feedback.

...
Title: Re: Charting 64-bit
Post by: Aslan Babakhanov on October 30, 2013, 07:10:28 AM
Nice demo indeed.
On my laptop dell e6420 with W7 64 bit, it's using about 50MB of memory.
The chart is moving smoothly when you zooming to the max.
Title: Re: Charting 64-bit
Post by: James C. Fuller on October 31, 2013, 02:58:00 PM
Patrice,
  No matter how pretty you make it I still dislike C++ so .... :)
http://bc9.bcxbasic.com/bc9ChartSpec.htm

I do advocate the use of C++ for anyone going forward but for an old man like me who has been using BASIC for almost 40 years: I don't have enough brain cells left to retain .... where was I ??

The attachment includes all the files incuding the 64bit unicode app created with bc9Basic and VS12.

Again great stuff Patrice

James
Title: Re: Charting 64-bit
Post by: Patrice Terrier on October 31, 2013, 06:28:18 PM
James--

I am curious to know how BC9 would translate this piece of code to C++


si.cbSize = SIZEOF(si)
si.fMask  = %SIF_ALL
CALL GetScrollInfo(hParent, %SB_VERT, si)
CALL GetScrollBarInfo(hParent, %OBJID_VSCROLL, sbi)
dxy1 = sbi.rcScrollBar.nTop + sbi.dxyLineButton
dxy2 = sbi.rcScrollBar.nBottom - sbi.dxyLineButton

dxy = (MIN&(MAX&(p.Y, dxy1), dxy2) - dxy1) * ((si.nMax - si.nMin) / (dxy2 - dxy1))


dxy, dxy1, dxy2 are LONG
Title: Re: Charting 64-bit
Post by: Jim Dunn on October 31, 2013, 07:55:27 PM
EDITED: to just show the snippet

I just ran BC9 on your code, got this:

static PCHAR   *g_argv;
static int     g_argc;
static long    dxy;
static long    dxy1;
static long    dxy2;

double MAX (double a, double b)
{
  if(a>b)
  return a;
  return b;
}

double MIN (double a, double b)
{
  if(a<b)
  return a;
  return b;
}

int main(int argc, char *argv[])
{
g_argc = argc;
g_argv = argv;
si.cbSize= sizeof( si);
si.fMask=SIF_ALL;
GetScrollInfo(hParent,SB_VERT,si);
GetScrollBarInfo(hParent,OBJID_VSCROLL,sbi);
dxy1= sbi.rcScrollBar.nTop+ sbi.dxyLineButton;
dxy2= sbi.rcScrollBar.nBottom- sbi.dxyLineButton;
dxy=( MIN&( MAX&( p.Y, dxy1), dxy2)- dxy1)*(( si.nMax- si.nMin)/( dxy2- dxy1));
return 0;
}
Title: Re: Charting 64-bit
Post by: Patrice Terrier on October 31, 2013, 08:54:49 PM
Here is how it should be translated to C++
dxy = (min(max(p.x, dxy1), dxy2) - dxy1) * ((si.nMax - si.nMin) / (float) ( dxy2 - dxy1));
Title: Re: Charting 64-bit
Post by: James C. Fuller on October 31, 2013, 09:19:44 PM
I also need to add C++ min/max instead of the BCX library MIN/MAX double.

James
Title: Re: Charting 64-bit
Post by: James C. Fuller on November 02, 2013, 11:15:59 AM
Patrice,
  What is the reason for your STRL$ function?
  to_wstring seems to do the same thing on all numeric types.

  wcscpy_s(zTxt, (WCHAR*) STRL(nI * 10).c_str()) To
    wcscpy_s(zTxt, to_wstring(nI * 10).c_str())

  ws += STRL((long) (rChartZoom * 100)) To
    ws += to_wstring(rChartZoom * 100)



James
Title: Re: Charting 64-bit
Post by: Patrice Terrier on November 02, 2013, 12:29:27 PM
James

Now i remember why i wrote STRL$, it works with VS2010, while to_wstring doesn't (only since C++11).  :(

Also working directly with WCHAR means smaller overhead.
Title: Re: Charting 64-bit
Post by: James C. Fuller on November 02, 2013, 02:36:15 PM
Patrice,
  When are you going to upgrade to Visual Studio 2013?
It states you can install it side-by-side with any other version.

What version cl do you have? (_MSC_VER)
My Win7 SDK version is 1600 While VS12 (aka Visual Studio 2013) is 1800.
I assume Visual Studio 2012 is 1700?

James
Title: Re: Charting 64-bit
Post by: James C. Fuller on November 02, 2013, 03:45:45 PM
Patrice,
  This should work for all  using sstr(N) for string and wstr(N) for wstring.

James


#if _MSC_VER < 1800
template <typename T>
string sstr ( T Number )
{
stringstream ss;
ss << Number;
return ss.str();
}

template <typename T>
wstring wstr ( T Number )
{
wstringstream wss;
wss << Number;
return wss.str();
}
#else
#define sstr(x) to_string(x)
#define wstr(x) to_wstring(x)
#endif

Title: Re: Charting 64-bit
Post by: Patrice Terrier on November 02, 2013, 04:39:54 PM
QuoteWhen are you going to upgrade to Visual Studio 2013?
I am waiting for the official release of the Pro version.