Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int KIT_TTM_ClearCanvas3D(KIT_TTM_Canvas3D* canvas, uint8_t r,uint8_t g,uint8_t b){
- int errorCode, color=0x00000000 | (b<<16) | (g<<8) | r; //0xAABBGGRR
- if(!canvas) return SDL_SetError("\"canvas\" is a NULL pointer");
- if(!canvas->locked) if((errorCode=KIT_TTM_LockCanvas3D(canvas))) return errorCode;
- int canvasArea=canvas->pitch*canvas->h; //=sizeof(SDL_Color/int/float) * width*height
- int* pixels=canvas->pixels;
- if(canvas->autoZReset && canvas->zBuffer) KIT_TTM_ResetCanvas3DZBuffer(canvas);
- else return SDL_SetError("\"canvas->zBuffer\" is a NULL pointer");
- //if r==g && g==b, r==b also, so therefore all 3 are equal
- if(r==g && g==b) memset(pixels,r,canvasArea);
- else { canvasArea/=sizeof(SDL_Color); //now it's just width*height
- for(int i=0; i<canvasArea; ++i) pixels[i]=color;
- }
- if(canvas->autoUnlock) KIT_TTM_UnlockCanvas3D(canvas);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement