Author Topic: TCLib update for Patrice  (Read 11902 times)

0 Members and 1 Guest are viewing this topic.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
TCLib update for Patrice
« on: March 08, 2017, 12:04:58 PM »
Patrice,
  I added sin,cos,acos,asin,atan,atan2,sqrt,time,rand,srand,fmod,fmodf to TCLib.
If there are other ones you need for testing let me know.
I am going to add most all the math functions but I want to install the new Visual Studio 2017 community today.

James

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: TCLib update for Patrice
« Reply #1 on: March 08, 2017, 07:25:22 PM »
James

That doesn't work by me, from inside the IDE, no DllMain external symbol.
and a bunch of unresolved external

Did you try to compile the DLL project that was in my zip?

Thanks anyway ;)


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #2 on: March 08, 2017, 08:45:23 PM »
Patrice,
  You have to be careful with your #includes and not #include files that in turn #include the standard <c lib headers>.
This appears to be the case with mfapi.h amd shlwapi.h
Probably just not worth the effort with the type of apps/dlls you write.

James

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #3 on: March 08, 2017, 09:55:11 PM »
Patrice,
  There are no issues with the GL.h and GLU.h.
Maybe if you prototyped just the calls from mfapi.h and shlwapi.h you use I could figure it out.
I am close I think ?? :)

James
 
 

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: TCLib update for Patrice
« Reply #4 on: March 09, 2017, 10:41:31 AM »
i shall make another try later this day, after adding the missing DllMain entry point.

thanks
« Last Edit: March 09, 2017, 10:44:08 AM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #5 on: March 09, 2017, 11:00:50 AM »
Patrice,
  Try to make another standard Visual studio project like the one you posted without including  mfapi.h and shlwapi.h, instead add the prototypes of the functions used in the source. I forgot to add tan (DUH) to TCLib so that will fail until I update and post a new TCLib.
Also there are a couple of calls in IsFileImage that are not supported (yet):
_wsplitpath_s
wcsncat_s
wcsstr

James



Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: TCLib update for Patrice
« Reply #6 on: March 09, 2017, 01:42:31 PM »
rand, and srand are causing me havoc
--> redefinition, previous definition was 'function'.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #7 on: March 09, 2017, 05:17:33 PM »
Patrice,
  Yeah that is one of the issues you have to be aware of. One of your includes is also including the sdk <stdlib.h>
It's going to take a bit more planning on your part on managing #include files and prototypes.
What I would suggest if/when you decide to continue is to create tour own versions of includes you need and put them in the TCLib folder.
I have a mixed version (bc9/c++) of your dll compiled but don't quite know what to do with it to test?
It comes in at 12k.

James


Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: TCLib update for Patrice
« Reply #8 on: March 09, 2017, 05:20:09 PM »
I don't know how to resolve these 3 link errors (see the attached screen shot)

...
« Last Edit: March 09, 2017, 05:22:39 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #9 on: March 09, 2017, 05:44:16 PM »
Patrice,
  I updated the library and it should help.
Attached is the new library and includes along with my version of your dll.
To compile: TBLIBDLL.BAT LB01

James

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #10 on: March 09, 2017, 05:56:31 PM »
I just noticed I hadn't finished up work in IsFileImage so it will not work as is.

James

Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: TCLib update for Patrice
« Reply #11 on: March 09, 2017, 06:23:50 PM »
I could remove the IsFileImage function, because in that specific case, a texture should be always a valid image file name.

I have written my own replacement for PathCombine, based on direct use of the RtlMoveMemory

Code: [Select]
void Path_Combine(OUT WCHAR* zResource, IN WCHAR* path, IN WCHAR* combine) {
    long offset = (long) wcslen(path) * sizeof(WCHAR);
    ZeroMemory(zResource, MAX_PATH);
    MoveMemory(zResource, path, offset);
    MoveMemory(&zResource[offset / 2], &combine[0], (long) wcslen(combine) * sizeof(WCHAR));
}


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
Re: TCLib update for Patrice
« Reply #12 on: March 09, 2017, 07:04:05 PM »
Patrice,
  It's just the header files that are giving the problems.

Make your own for shlwapi.h in case you need something in the future and use #pragma comment(lib,"shlwapi.lib")

EXTERN_C LPWSTR  PathCombineA(_Out_writes_(MAX_PATH) LPWSTR pszDest, _In_opt_ LPCTSTR pszDir, _In_opt_ LPCTSTR pszFile);
EXTERN_C LPWSTR  PathCombineW(_Out_writes_(MAX_PATH) LPWSTR pszDest, _In_opt_ LPCWSTR pszDir, _In_opt_ LPCWSTR pszFile);
#ifdef UNICODE
#define PathCombine  PathCombineW
#else
#define PathCombine  PathCombineA
#endif
#define _MAX_DRIVE 3
#define _MAX_DIR 256
#define _MAX_FNAME 256
#define _MAX_EXT 256

James




Offline Patrice Terrier

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2003
    • www.zapsolution.com
Re: TCLib update for Patrice
« Reply #13 on: March 09, 2017, 07:30:09 PM »
James--

From 108 Kb down to 13 Kb, that's amazing!!!

However in Math.h,  i still couldn't use
extern int (__cdecl* rand)(void);
extern void (__cdecl* srand)(unsigned int);

because of error C2365:  previous definition was function

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Frederick J. Harris

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 941
    • Frederick J. Harris
Re: TCLib update for Patrice
« Reply #14 on: March 09, 2017, 07:33:37 PM »
Does this help...

Code: [Select]
#ifdef TCLib
   int rand(void)
   {
    static unsigned int next = 1;
    next = next * 1103515245 + 12345;
    return (unsigned int)(next>>16) & RAND_MAX;
   }
#endif


size_t Rnd(int iMin, int iMax)
{
 double dblRange=iMax-iMin;
 double dblMaxFactor=dblRange/RAND_MAX;
 double dblRandomNumber=(double)rand();

 return iMin+dblMaxFactor*dblRandomNumber;
}

I was working with that some time ago.  I forget the details, and I forget where RAND_MAX is defined.  Possibly in stdlib.h.  My Rnd() function above is a quick and dirty interpretation of PowerBASIC's Rnd(), where one can specify a min and max value.  It just scales stuff about using stdlib's rand.  It worked OK for the use I made of it.  Random number generation can get to be a tricky subject if you let it!
« Last Edit: March 09, 2017, 07:41:22 PM by Frederick J. Harris »