Alpha as user var for collision detection

Started by
1 comment, last by oliver67 20 years ago
I''m trying to use the alpha value for collision detection for a small 2d game. Every object will be drawned additionally to the rgb color with an individual alpha value using vertex4f. Alphatesting is disabled. Before drawing the moving bullets, I''m looking for the alpha value at the bullet''s new position in order to check, if there''s already an object. If there''s one, e.g. I can deactivate the object known by the local alpha value. That''s the theory. In praxis, readpixels(...RGBA...)always returns 0.0 for alpha. But obviously there is an object drawned before at the position, as the rgb value differs from 0/0/0 (but strangely only every fourth frame update). Do I have to make some initialisation for using the alpha channel? I''m working with doublebuffer and activated RGBA with 32bit. Thanks in advance for any hints! Regards Oliver
Advertisement
The only thing that comes to mind is make sure you have Destination Alpha enabled...(Alpha Buffer in the Pixel Format Descriptor)

PIXELFORMATDESCRIPTOR pfd =					//pfd Tells Windows How We Want Things To Be	{	sizeof (PIXELFORMATDESCRIPTOR),	// Size Of This Pixel Format Descriptor		1,			// Version Number		PFD_DRAW_TO_WINDOW |	// Format Must Support Window		PFD_SUPPORT_OPENGL |	// Format Must Support OpenGL		PFD_DOUBLEBUFFER,	// Must Support Double Buffering		PFD_TYPE_RGBA,		// Request An RGBA Format		window->init.bitsPerPixel,// Select Our Color Depth		0, 0, 0, 0, 0, 0,	// Color Bits Ignored		1,			// ALPHA BUFFER		0,			// Shift Bit Ignored		0,			// No Accumulation Buffer		0, 0, 0, 0,		// Accumulation Bits Ignored		24,			// 24Bit Z-Buffer (Depth Buffer)  		8,			// 8Bit Stencil Buffer		0,			// No Auxiliary Buffer		PFD_MAIN_PLANE,		// Main Drawing Layer		0,			// Reserved		0, 0, 0			// Layer Masks Ignored	}; 
Waramp.Before you insult a man, walk a mile in his shoes.That way, when you do insult him, you'll be a mile away, and you'll have his shoes.
Thanks, I''ve tried this, but without any success.

Anyway, I''ve written out the set bits used by red, green, blue and alpha within a pixel (glGetIntegerv), and always got 8, 8, 8 and 0. Thus, alpha isn''t activated yet.
I''ve also set then accum-bits to 0, and got 16. My PixelFormatDescriptor is identical to yours.

Any further hints ?

Regards

Oliver


This topic is closed to new replies.

Advertisement