Userlibs

Everything else that doesn't fall into one of the other PB categories.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Polo wrote: [...]
and that's that stuff which doesn't work
and tinman already told you why.
don't get me wrong, but are you sure you know what you're doing there?

however, if you really want to use your code as a library which could also mean flexibility to a certain degree,
I would define the PFD inside PureBasic and pass this to the function.

Code: Select all

pfd.PIXELFORMATDESCRIPTOR
pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags  = #PFD_DRAW_TO_WINDOW | #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER
pfd\iPixelType = #PFD_TYPE_RGBA
.
.
.
.
etc.
see what I mean?

on the other hand, you won't need the PFD outside of your function, so why bother with that?
Good programmers don't comment their code. It was hard to write, should be hard to read.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I put that :

Code: Select all

    PIXELFORMATDESCRIPTOR pfd;
    int pixelformat;

    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
    pfd.nVersion = 1;
    pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
    pfd.dwLayerMask = PFD_MAIN_PLANE;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 16;
    pfd.cDepthBits = 16;
And VC++ say :
error C2275: 'PIXELFORMATDESCRIPTOR' : illegal use of this type as an expression

There's still an error
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

I think this is a bug VC++

http://support.microsoft.com/default.as ... -US;166513
Using a typedef cast in the member initialization of a class may cause the following errors:

error C2275: 'test::run' : illegal use of this type as an expression
error C2146: syntax error : missing ')' before identifier 'arg'
error C2612: trailing '.*|->*' illegal in base/member initializer list
error C2059: syntax error : ')'
error C2143: syntax error : missing ';' before '{'
fatal error C1004: unexpected end of file found
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I don't thinks so : I have VC++ 6.0, it's supposed to be corrected on this version ...
And it say an error if the extension is .C and when it's .CPP it works :?
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Polo wrote:I don't thinks so : I have VC++ 6.0, it's supposed to be corrected on this version ...
And it say an error if the extension is .C and when it's .CPP it works :?
I know the PIXELFORMATDESCRIPTOR is supposed to be a typedef for "struct whatever" but perhaps the compiler still wants you to put "struct PIXELFORMATDESCRIPTOR" as the parameter to sizeof.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

I put that :

struct PIXELFORMATDESCRIPTOR pfd;
int pixelformat;

pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
pfd.dwLayerMask = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 16;
pfd.cDepthBits = 16;

And in errors, there are :

l77 error C2143: syntax error : missing ';' before 'type'
l78 error C2143: syntax error : missing ';' before 'type'
l80 error C2065: 'pfd' : undeclared identifier
l80 error C2224: left of '.nSize' must have struct/union type
l81 error C2224: left of '.nVersion' must have struct/union type
l82 error C2224: left of '.dwFlags' must have struct/union type
l83 error C2224: left of '.dwLayerMask' must have struct/union type
l84 error C2224: left of '.iPixelType' must have struct/union type
l85 error C2224: left of '.cColorBits' must have struct/union type
l86 error C2224: left of '.cDepthBits' must have struct/union type

The most funny thing is that it worked on LCC :(
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Just a question, did you included the OpenGL header ?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Ok, I give ya all my code :)

Code: Select all

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <stdio.h>


#ifdef PURELIBRARY
	extern HINSTANCE PB_Instance;
#else
	HINSTANCE PB_Instance;
#endif

HDC hdc;
HGLRC hrc;

extern void _stdcall PB_InitGL(HWND hWnd, int width, int height)
{
hdc = GetDC(hWnd);

struct PIXELFORMATDESCRIPTOR pfd;
int pixelformat;

pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;
pfd.dwLayerMask = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 16;
pfd.cDepthBits = 16;

//pixelformat = ChoosePixelFormat(hdc, &pfd);
//SetPixelFormat(hdc, pixelformat, &pfd);
//hrc = wglCreateContext(hdc);
//wglMakeCurrent(hdc, hrc);

}

So I include the openGL header ...
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I just removed the 'struct' and all works correctly. So I think you have a broken installation somewhere (tested with VC++ 6)
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Do you compile it as a .C file and not .CPP ??
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Ha, I overlooked that. But it works with a .c too, the compiler is just C compliant, so you have to put all the declaration BEFORE any expression. So move the 'hdc = GetDC(hWnd);' after the declarations and it will work.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Thank you Fred, it works !!
I'll remember that ! :D
rajivlodha
New User
New User
Posts: 2
Joined: Fri Jul 25, 2003 10:02 am

Post by rajivlodha »

i want to create a TAPI Application using DECV++, can any body help me regarding this ?? i am also trying to load the TAPI32.DLL using DEVC++, but its also seems impossoble for me,

please somebody help me or provide me with some links on my email address or on the form - rajivlodha@hotmail.com

thank you

rajiv
rajivlodha
New User
New User
Posts: 2
Joined: Fri Jul 25, 2003 10:02 am

why does devC++ fails

Post by rajivlodha »

hello guys, thank u for all ur contributions,

but i have one problem, for any application - a simple 'C' linked list or a VC++ project, fails to compile on devC++ 5.0, whats the problem, there are no documents / tutorials for devC++,

i am depressed, i was also following the book of charles petzold (win sdk), but codes from that book are also not compiling,

i am new to devC++. what do u suggest, do i have to move for vc 6.0 ??

:(
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Try the devc mailing list for help.
Post Reply