A month or so ago in the Games & Graphics forum there was a question posted about changing colours on the screen by changing the palette entries. Basically they were saying you used to be able to do it in DOS and could you do it in DirectX? At least one respondent said that you could, and I thought I'd test it out but have had no luck so far.
The original question was VB-based, and I'm using C, so I didn't reply to the other thread. I just remembered it today though and thought I'd see if anyone had any idea how to do it. This is the code I'm using at the moment:
Code:int Game_Main(void *parms = NULL, int num_parms = 0) { // this is the main loop of the game // test if user is hitting ESC and send WM_CLOSE if (KEYDOWN(VK_ESCAPE)) SendMessage(main_window_handle,WM_CLOSE,0,0); memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); int mempitch = ddsd.lPitch; UCHAR *video_buffer = (UCHAR *)ddsd.lpSurface; // Now rows and columns are accessed in the form // video_buffer[row + column*mempitch] static int doneonce = 0; if (!doneonce) { for(int row=0; row<640; row++) for(int column=0; column<480; column++) video_buffer[row + column*mempitch] = rand() % 256; doneonce = 1; } for(int colour=1; colour<255; colour++) { palette[colour].peRed = rand() % 256; palette[colour].peGreen = rand() % 256; palette[colour].peBlue = rand() % 256; palette[colour].peFlags = PC_NOCOLLAPSE; } lpdd4->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256 | DDPCAPS_INITIALIZE, palette, &lpddpal, NULL); lpddsprimary->SetPalette(lpddpal); lpddsprimary->Unlock(NULL); // return success or failure return(1); } // end Game_Main




Reply With Quote