Structs for bitmaps
I copied some code from one function to another and now I get this-
UCHAR blue = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 0]) >> 3,
green = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 1]) >> 3,
red = (bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 2]) >> 3;
(585) : error C2228: left of '.buffer' must have class/struct/union type
(586) : error C2228: left of '.buffer' must have class/struct/union type
(587) : error C2228: left of '.buffer' must have class/struct/union type
the bitmap struct was made outside of a function, if that makes any difference.
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Edited by - felisandria on February 21, 2002 10:36:08 AM
Have you declared bitmap as a variable ?
IE.
A struct is just a type definition, used like ''int'' or ''char''.
,Jay
IE.
BITMAP bitmap;
A struct is just a type definition, used like ''int'' or ''char''.
,Jay
What API are you using?
------------------------------
Simple DirectMedia Layer:
Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
------------------------------
Simple DirectMedia Layer:
Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)
OpenGL:
Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
quote:Original post by Jason Zelos
Have you declared bitmap as a variable ?
IE.
BITMAP bitmap;
A struct is just a type definition, used like ''int'' or ''char''.
,Jay
thats what I ment that I did! what''s an API?
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
quote:Original post by PPCThug
what''s an API?
That game dictionary is actually useful for something!
quote:Application Program Interface. A set of routines which acts as a go-between for the operating system and a program. For instance, DirectX is a Windows API.
I think I'm with you, if you are defining blue I would use a macro like :
Blue = RGB (R, G, B)
in directX
if you want to shift bits and combine them, use a bitwise OR (| in C++ I think).
IE:
Assuming dword is 32 bits (or at least 24) and each call returns and 8 bit value.
eg.
,Jay
Edited by - Jason Zelos on February 20, 2002 6:00:19 PM
Blue = RGB (R, G, B)
in directX
if you want to shift bits and combine them, use a bitwise OR (| in C++ I think).
IE:
DWORD Colour = ((bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 0]) >> 16)) | ((bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 1]) >> 8)| ((bitmap.buffer[index_y*SCREENWIDTH*3 + index_x*3 + 2]));
Assuming dword is 32 bits (or at least 24) and each call returns and 8 bit value.
eg.
Red = 11111111 >> 16 00000000 00000000 00000000 11111111Green = 11000000 >> 8 00000000 00000000 11000000 11111111Blue = 00000011 00000000 00000011 11000000 11111111
,Jay
Edited by - Jason Zelos on February 20, 2002 6:00:19 PM
I just saw your other post, this is the line that creates the pixel (16 bit format).
The reason for the error, as near as I can make out is that you are defining bitmap in Game_Main() as a local variable and not in the function where you have moved your code to. Try copying that across too.
You will need to declare the other vars in the function as well.
,Jay
USHORT pixel = _RGB16BIT565(red,green,blue);
The reason for the error, as near as I can make out is that you are defining bitmap in Game_Main() as a local variable and not in the function where you have moved your code to. Try copying that across too.
You will need to declare the other vars in the function as well.
,Jay
actually that''s a small part of code that''s supposed to copy a bitmap into a directdraw surface. and I didn''t have a problem with it untill I moved it to a nother function.
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
int Game_Main(){ if (iWindowClosed) return(0); if (KEYDOWN(VK_ESCAPE)) SendMessage(hwnd, WM_DESTROY,0,0); DDraw_Fill_Surface(lpddsback, erasecolor); if (FAILED(lpddsback->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL))) return(0); DDRAW_INIT_STRUCT(ddbltfx); if (FAILED(lpddsback->Blt(NULL, lpddsmmenu, NULL, DDBLT_WAIT, NULL))) return(0); if (FAILED(lpddsback->Unlock(NULL))) return(0); while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT))); return(1);} // end game main
I still don''t see anything in game main that the code would need.
MSVC++ 6.0 intro
DX 8.0a DX SDK 6.1
win98
#define WIN32_LEAN_AND_MEAN
the Particle Projection Cannon fires a shimmering blue bolt, much like a cross between lightning and a sine wave that ripples along its path.
Is the struct definition and the bitmap declaration global in the same module (.cpp file) as the new function. Could you include the code from the void NewFunction (void) { to the end }.
,Jay
,Jay
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement