Page 3 of 3

Posted: Fri Jun 20, 2003 5:52 pm
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?

Posted: Fri Jun 20, 2003 6:50 pm
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

Posted: Fri Jun 20, 2003 10:02 pm
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

Posted: Sat Jun 21, 2003 8:08 am
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 :?

Posted: Sun Jun 22, 2003 11:45 pm
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.

Posted: Mon Jun 23, 2003 9:09 am
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 :(

Posted: Mon Jun 23, 2003 11:10 am
by Fred
Just a question, did you included the OpenGL header ?

Posted: Mon Jun 23, 2003 12:46 pm
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 ...

Posted: Mon Jun 23, 2003 1:04 pm
by Fred
I just removed the 'struct' and all works correctly. So I think you have a broken installation somewhere (tested with VC++ 6)

Posted: Mon Jun 23, 2003 1:14 pm
by Polo
Do you compile it as a .C file and not .CPP ??

Posted: Mon Jun 23, 2003 2:06 pm
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.

Posted: Mon Jun 23, 2003 2:27 pm
by Polo
Thank you Fred, it works !!
I'll remember that ! :D

Posted: Fri Jul 25, 2003 11:17 am
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

why does devC++ fails

Posted: Wed Oct 15, 2003 7:19 pm
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 ??

:(

Posted: Wed Oct 15, 2003 11:08 pm
by dmoc
Try the devc mailing list for help.