Advertisement

SetGammaRamp problems #2

Started by January 20, 2000 01:17 PM
3 comments, last by bosjoh 25 years, 1 month ago
I am setting the gamma ramp to create a fading effect and blue (when it is night). I have this example piece of code: void setblack(){ LPDIRECTDRAWGAMMACONTROL dgamma; DDGAMMARAMP gdata; unsigned short rp;//vars dsurface->QueryInterface(IID_IDirectDrawGammaControl,(LPVOID*)&dgamma); for (rp=0;rp<256;rp++){ gdata.red[rp]=0; gdata.green[rp]=0; gdata.blue[rp]=0; }; if(dgamma->SetGammaRamp(DDSGR_CALIBRATE,&gdata); }; The problem is that the method SetGammaRamp returnes not DD_OK. Is this a lack of a video card feature (I have an S3 virge 4MB, and a trust voodoo dragon 2) or am I missing something? Is there a better function for the thing I am trying to do, and does this function require 3dfx? Or should I use conventional methods (pixel substraction)? BTW, I am working in 800x600 16 bit (5-5-5).
I believe the CALIBRATE tag is only supported on certain cards. I don't have my source in front of me, but off the top of my head I don't remember the CALIBRATE tag.

Joseph Fernald wrote a great article that explained how to do gamma fades here on gamedev; take a peek at his code:

http://www.gamedev.net/reference/programming/features/gamma/




Mason McCuskey
Spin Studios - home of Quaternion, 2000 GDC Indie Games Fest Finalist!
www.spin-studios.com

Edited by - mason on 1/20/00 5:43:05 PM
Founder, Cuttlefish Industries
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!
Advertisement
Not all cards support calibrate and some cards don''t support gamma control at all in DX (Monster 3D II for one).

Exactly what error code is being returned?

--Shannon Schlomer, BLAZE Technologies, Inc.
--Shannon Schlomer, BLAZE Technologies, Inc.
I''ve read the article and I believe that my code isn''t different than that in the article. I don''t have the compiler at hand (my computer crashed) so I don''t know the error code it''s returning. In the article there is a line that says that when it isn''t supported by hardware the system simulates it (well, actually windows does). Maybe I should use LPDIRECTDRAW7 in stead of just LPDIRECTDRAW.
The problem is also occuring when I call GetGammaRamp. It returnes an DDERR_INVALIDPARAMS error. To make things clear here is all the code...

void initgraph(void){
WNDCLASS windclass;
windclass.style=0;
windclass.lpfnWndProc=wndmsghandler;
windclass.cbClsExtra=0;
windclass.cbWndExtra=0;
windclass.hInstance=instancehandle;
windclass.hIcon=LoadIcon(instancehandle,IDI_APPLICATION);
windclass.hCursor=LoadCursor(instancehandle,IDC_ARROW);
windclass.hbrBackground=(HBRUSH__*)GetStockObject(LTGRAY_BRUSH);
windclass.lpszMenuName=NULL;
windclass.lpszClassName="game";
RegisterClass(&windclass);
windowhandle=CreateWindow("game","initializing game",WS_OVERLAPPED,CW_USEDEFAULT,0,0,0,NULL,NULL,instancehandle,NULL);
ShowWindow(windowhandle,SW_SHOWMAXIMIZED);
if (DirectDrawCreate(NULL,&ddraw,NULL)!=DD_OK) return(false);
if (ddraw->SetCooperativeLevel(windowhandle,DDSCL_EXCLUSIVE/DDSCL_FULLSCREEN)!=DD_OK) return(false);
if (ddraw->SetDisplayMode(800,600,16)!=DD_OK) return(false);
memset(&ddesc,0,sizeof(ddesc));
ddesc.dwSize=sizeof(ddesc);
ddesc.dwFlags=DDSD_CAPS/DDSD_BACKBUFFERCOUNT;
ddesc.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE/DDSCAPS_FLIP/DDSCAPS_COMPLEX;
ddesc.dwBackBufferCount=1;
if (ddraw->CreateSurface(&ddesc,&dsurface,NULL)!=DD_OK) return(false);
dcaps.dwCaps=DDSCAPS_BACKBUFFER;
if (dsurface->GetAttachedSurface(&dcaps,&dbackbuf)!=DD_OK) return(false);
if(dsurface->QueryInterface(IID_IDirectDrawGammaControl,(LPVOID *)&dgamma)!=DD_OK) return(false);
if(dgamma->GetGammaRamp(0,&orggdata)!=DD_OK) return(false);
return(true);
};//initialize graphics

This topic is closed to new replies.

Advertisement