void BloomEffect::Impl::BlurMultipass( RenderTextureArray& renderTextures ) { sf::Vector2u textureSize = renderTextures[ 0 ].getSize(); for ( std::size_t count = 0; count < 2; ++count ) { Blur( renderTextures[ 0 ], renderTextures[ 1 ], sf::Vector2f( 0.f, 1.f / textureSize.y ) ); Blur( renderTextures[ 1 ], renderTextures[ 0 ], sf::Vector2f( 1.f / textureSize.x, 0.f ) ); } }
void FilterBrush::BrushMove(const Point source, const Point target) { ImpressionistDoc* pDoc = GetDocument(); ImpressionistUI* dlg = pDoc->m_pUI; if (pDoc == NULL) { printf("FilterBrush::BrushMove document is NULL\n"); return; } int size = pDoc->getSize(); double opacity = pDoc->getOpac(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (isBlur){ glPointSize(2); glBegin(GL_POINTS); Blur(source, opacity); glVertex2d(target.x, target.y); glEnd(); } else{ glPointSize(2); glBegin(GL_POINTS); Sharpen(source, opacity); glVertex2d(target.x, target.y); glEnd(); } }
// Sets the disabled status of the form control. void ElementFormControl::SetDisabled(bool disable) { if (disable) { SetAttribute("disabled", ""); Blur(); } else RemoveAttribute("disabled"); }
void KinectTool::DoToolUpdate() { _reader->ProcessDepth();//both can be paralelized, but //sync point here for process depth. //memfence, in a way float* depth_ptr = _reader->GetDepth();//Flikers //Blur. Blur( depth_ptr, _tmp_blured_image );//Makes it emen more flikering, but it should be done. //memfence again _msh->UpdateDepth( depth_ptr ); //memfence again //or you can combine both calls into one ( basically same happens there ), BUT with blur I see no way to do it. //So the best way to parralelize it - SIMD-like paralelization inside of each function. }
// creates a cursor shadow from a cursor bitmap void MAS::Cursor::MakeShadow() { int x, y, i; Point pOffset(PADDING, PADDING); Point pOrigin(0,0); for (i=0; i<frameCount; i++) { Bitmap bmp; if (MAS::Settings::mouseShadow) { bmp.Create(Size(sprite[i]->w() + 2*PADDING, sprite[i]->h() + 2*PADDING), Bitmap::MEMORY); // create the alpha channel for the shadow by masking the cursor and bluring the results Bitmap alpha(bmp.size(), Bitmap::MEMORY); alpha.Clear(Color::transparent); sprite[i]->Blit(alpha, pOrigin, pOffset, sprite[i]->size()); for (y=0; y<bmp.h(); y++) { for (x=0; x<bmp.w(); x++) { Point p(x,y); if (alpha.Getpixel(p) == Color::transparent) alpha.Putpixel(p, Color::black); else alpha.Putpixel(p, Color::white); } } Blur(alpha, PADDING); // write the alpha channel to the shadow bitmap for (y=0; y<bmp.h(); y++) { for (x=0; x<bmp.w(); x++) { Point p(x,y); bmp.Putpixel(p, Color(shadowColor.r(), shadowColor.g(), shadowColor.b(), alpha.Getpixel(p).r())); } } alpha.Destroy(); } else { bmp.Create(1, 1); bmp.Putpixel(0, 0, Color::transparent); } Bitmap *result = new Bitmap(bmp.w(), bmp.h()); bmp.Blit(*result, 0, 0, 0, 0, bmp.w(), bmp.h()); shadow.push_back(result); } }
//Draw our post process effects using ping pong void Renderer::DrawPostProcess(){ glDisable(GL_DEPTH_TEST); SetupPPMatrices(); glBindFramebuffer(GL_FRAMEBUFFER, processFBO); if (sobel) Sobel(); if (sobelDepth) SobelDepth(); if (quantizeCol) QuantizeCol(); if (fog) Fog(); if (bloom) Bloom(); if (dubVis) DoubleVision(); if (blur) Blur(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glUseProgram(0); glEnable(GL_DEPTH_TEST); }
int AlgorithmHough::DoYourJob(Magick::Image& image) { BW(image); std::cout<<"BW"<<std::endl; Accu(image); std::cout<<"Ac"<<std::endl; Blur(Accu.Accumulator); std::cout<<"Bl"<<std::endl; HoughResult max=Accu.Maximum(); std::cout<<"Max"<<std::endl; Magick::Image result(image.size(), Magick::Color("white")); result.modifyImage(); Magick::Pixels pixelCache(result); Magick::PixelPacket* pixels=pixelCache.set(0,0,image.columns(),image.rows()); for(int x=0; x<image.columns(); x++) for(int y=0; y<image.rows(); y++) { double fi_f=max.Fi-90; double r_=double(x)*cos(fi_f*3.14/180.0)+double(y)*sin(fi_f*3.14/180.0); int pixelIndex=x+y*image.columns(); if(r_<0) //jak wyżej continue; if(round(r_)==max.R) pixels[pixelIndex].red=pixels[pixelIndex].blue=pixels[pixelIndex].green=0; else pixels[pixelIndex].red=pixels[pixelIndex].blue=pixels[pixelIndex].green=(1<<QuantumDepth)-1; } pixelCache.sync(); image=result; std::cout<<"R: "<<max.R<<" FI: "<<max.Fi<<" Value: "<<max.Value<<std::endl; return 0; }
void task_glow_precalc() { FIMULTIBITMAP* anim = inputanim; float thresh=0.5; float gain=2.0; float blur=1.5; int frameskip=1; sscanf(args[1].c_str(), "%f", &thresh); sscanf(args[2].c_str(), "%f", &gain); sscanf(args[3].c_str(), "%f", &blur); sscanf(args[4].c_str(), "%i", &frameskip); int frameCount = FreeImage_GetPageCount(anim); vector<double> fb; for (int frame=0; frame<frameCount/frameskip; frame++) { FIBITMAP* fiBitmap = FreeImage_LockPage(anim, frame*frameskip); FIBITMAP* grayBitmap = FreeImage_ConvertToGreyscale(fiBitmap); FreeImage_UnlockPage(anim, fiBitmap, FALSE); int width = FreeImage_GetWidth(grayBitmap); int height = FreeImage_GetHeight(grayBitmap); // put into an array of doubles (phew) fb.resize(width*height); for (int y=0; y<height; y++) { BYTE* src = FreeImage_GetScanLine(grayBitmap, y); double* dst = &fb[y*width]; for (int x=0; x<width; x++) { *dst++ = *src++ * (1.0/255); } } // threshold for (int i=0; i<(int)fb.size(); i++) { double& v = fb[i]; v = (v-thresh)*gain; if (v<0) v=0; } // blur Blur(fb, width, height, blur); // put it back into greyBitmap for (int y=0; y<height; y++) { BYTE* dst = FreeImage_GetScanLine(grayBitmap, y); double* src = &fb[y*width]; for (int x=0; x<width; x++) { double v = *src++ * 256; if (v<0) v=0; if (v>255) v=255; *dst++ = int(v); } } // downsample it to glowgrid FIBITMAP* smallBitmap = FreeImage_Rescale(grayBitmap, GLOWGRID_W, GLOWGRID_H, FILTER_BSPLINE); // print result (should use 4bpp not 8?) for (int y=0; y<GLOWGRID_H; y++) { BYTE* src = FreeImage_GetScanLine(smallBitmap, y); for (int x=0; x<GLOWGRID_W; x++) { putchar( *src++ ); } } } }
TGfxImage * Perlin_Noise(const int iSizeX, const int iSizeY) { TGfxImage * pImage = Noise(iSizeX, iSizeY); pImage = Blur(pImage, iSizeX, iSizeY); return pImage; }
void FBlurShader::BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) { Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false); }
GLColorBuffer GLDepthOfFieldFilter::Filter(GLColorBuffer input, float blurDepthRange, float vignetteBlur, float globalBlur) { SPADES_MARK_FUNCTION(); IGLDevice *dev = renderer->GetGLDevice(); GLQuadRenderer qr(dev); int w = dev->ScreenWidth(); int h = dev->ScreenHeight(); dev->Enable(IGLDevice::Blend, false); GLColorBuffer coc; globalBlur = std::min(globalBlur * 3.f, 1.f); { GLProfiler p(dev, "CoC Computation"); coc = GenerateCoC(blurDepthRange, vignetteBlur, globalBlur); } float maxCoc = (float)std::max(w, h) / 100.f; float cos60 = cosf(static_cast<float>(M_PI) / 3.f); float sin60 = sinf(static_cast<float>(M_PI) / 3.f); maxCoc *= .7f + vignetteBlur * 0.5f; maxCoc *= 1.f + 3.f * globalBlur; // reduce resolution to make it faster int divide = 1; int siz = std::max(w, h); GLColorBuffer lowbuf = input; while(siz >= 768) { divide <<= 1; siz >>= 1; lowbuf = UnderSample(lowbuf); } maxCoc /= (float)divide; dev->Viewport(0, 0, w / divide, h / divide); GLColorBuffer buf1, buf2; { GLProfiler p(dev, "Blur 1"); buf1 = Blur(lowbuf, coc, MakeVector2(0.f, -1.f) * maxCoc); } { GLProfiler p(dev, "Blur 2"); buf2 = Blur(lowbuf, coc, MakeVector2(-sin60, cos60) * maxCoc); lowbuf.Release(); } { GLProfiler p(dev, "Mix 1"); buf2 = AddMix(buf1, buf2); } //return buf2; { GLProfiler p(dev, "Blur 3"); buf1 = Blur(buf1, coc, MakeVector2(-sin60, cos60) * maxCoc); } { GLProfiler p(dev, "Blur 4"); buf2 = Blur(buf2, coc, MakeVector2(sin60, cos60) * maxCoc); } dev->Viewport(0, 0, w, h); { GLProfiler p(dev, "Mix 2"); GLColorBuffer output = FinalMix(input, buf1, buf2, coc); return output; } }
void PixelBufferClass::CalcOutput(int EffectPeriod, const std::vector<bool> & validLayers) { xlColor color; HSVValue hsv; int curStep; // blur all the layers if necessary ... before the merge? for (int layer = 0; layer < numLayers; layer++) { // do gausian blur if (layers[layer]->blur > 1) { Blur(layers[layer]); } if (layers[layer]->RotoZoom > 0) { RotoZoom(layers[layer]); } } for(int ii=0; ii < numLayers; ii++) { double fadeInFactor=1, fadeOutFactor=1; layers[ii]->fadeFactor = 1.0; layers[ii]->inMaskFactor = 1.0; layers[ii]->outMaskFactor = 1.0; if( layers[ii]->fadeInSteps > 0 || layers[ii]->fadeOutSteps > 0) { int effStartPer, effEndPer; layers[ii]->buffer.GetEffectPeriods( effStartPer, effEndPer); if (EffectPeriod < (effStartPer)+layers[ii]->fadeInSteps) { curStep = EffectPeriod - effStartPer + 1; fadeInFactor = (double)curStep/(double)layers[ii]->fadeInSteps; } if (EffectPeriod > (effEndPer)-layers[ii]->fadeOutSteps) { curStep = EffectPeriod - (effEndPer-layers[ii]->fadeOutSteps); fadeOutFactor = 1-(double)curStep/(double)layers[ii]->fadeOutSteps; } //calc fades if (STR_FADE == layers[ii]->inTransitionType) { if (fadeInFactor<1) { layers[ii]->fadeFactor = fadeInFactor; } } if (STR_FADE == layers[ii]->outTransitionType) { if (fadeOutFactor<1) { if (STR_FADE == layers[ii]->inTransitionType && fadeInFactor<1) { layers[ii]->fadeFactor = (fadeInFactor+fadeOutFactor)/(double)2.0; } else { layers[ii]->fadeFactor = fadeOutFactor; } } } if (STR_FADE != layers[ii]->inTransitionType) { layers[ii]->inMaskFactor = fadeInFactor; } if (STR_FADE != layers[ii]->outTransitionType) { layers[ii]->outMaskFactor = fadeOutFactor; } layers[ii]->calculateMask(); } else { layers[ii]->mask.clear(); } } // layer calculation and map to output size_t NodeCount = layers[0]->Nodes.size(); for(size_t i = 0; i < NodeCount; i++) { if (!layers[0]->Nodes[i]->IsVisible()) { // unmapped pixel - set to black layers[0]->Nodes[i]->SetColor(xlBLACK); } else { // get blend of two effects GetMixedColor(i, color, validLayers); // Apply dimming curve DimmingCurve *curve = layers[0]->Nodes[i]->model->modelDimmingCurve; if (curve != nullptr) { curve->apply(color); } // set color for physical output layers[0]->Nodes[i]->SetColor(color); } } }
NS_IMETHODIMP EditorEventListener::HandleEvent(nsIDOMEvent* aEvent) { NS_ENSURE_TRUE(mEditorBase, NS_ERROR_FAILURE); nsCOMPtr<nsIEditor> kungFuDeathGrip = mEditorBase; Unused << kungFuDeathGrip; // mEditorBase is not referred to in this function WidgetEvent* internalEvent = aEvent->WidgetEventPtr(); // Let's handle each event with the message of the internal event of the // coming event. If the DOM event was created with improper interface, // e.g., keydown event is created with |new MouseEvent("keydown", {});|, // its message is always 0. Therefore, we can ban such strange event easy. // However, we need to handle strange "focus" and "blur" event. See the // following code of this switch statement. // NOTE: Each event handler may require specific event interface. Before // calling it, this queries the specific interface. If it would fail, // each event handler would just ignore the event. So, in this method, // you don't need to check if the QI succeeded before each call. switch (internalEvent->mMessage) { // dragenter case eDragEnter: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return DragEnter(dragEvent); } // dragover case eDragOver: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return DragOver(dragEvent); } // dragexit case eDragExit: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return DragExit(dragEvent); } // drop case eDrop: { nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent); return Drop(dragEvent); } #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH // keydown case eKeyDown: { nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent); return KeyDown(keyEvent); } // keyup case eKeyUp: { nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent); return KeyUp(keyEvent); } #endif // #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH // keypress case eKeyPress: { nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent); return KeyPress(keyEvent); } // mousedown case eMouseDown: { nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent); NS_ENSURE_TRUE(mouseEvent, NS_OK); // EditorEventListener may receive (1) all mousedown, mouseup and click // events, (2) only mousedown event or (3) only mouseup event. // mMouseDownOrUpConsumedByIME is used only for ignoring click event if // preceding mousedown and/or mouseup event is consumed by IME. // Therefore, even if case #2 or case #3 occurs, // mMouseDownOrUpConsumedByIME is true here. Therefore, we should always // overwrite it here. mMouseDownOrUpConsumedByIME = NotifyIMEOfMouseButtonEvent(mouseEvent); return mMouseDownOrUpConsumedByIME ? NS_OK : MouseDown(mouseEvent); } // mouseup case eMouseUp: { nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent); NS_ENSURE_TRUE(mouseEvent, NS_OK); // See above comment in the eMouseDown case, first. // This code assumes that case #1 is occuring. However, if case #3 may // occurs after case #2 and the mousedown is consumed, // mMouseDownOrUpConsumedByIME is true even though EditorEventListener // has not received the preceding mousedown event of this mouseup event. // So, mMouseDownOrUpConsumedByIME may be invalid here. However, // this is not a matter because mMouseDownOrUpConsumedByIME is referred // only by eMouseClick case but click event is fired only in case #1. // So, before a click event is fired, mMouseDownOrUpConsumedByIME is // always initialized in the eMouseDown case if it's referred. if (NotifyIMEOfMouseButtonEvent(mouseEvent)) { mMouseDownOrUpConsumedByIME = true; } return mMouseDownOrUpConsumedByIME ? NS_OK : MouseUp(mouseEvent); } // click case eMouseClick: { nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aEvent); NS_ENSURE_TRUE(mouseEvent, NS_OK); // If the preceding mousedown event or mouseup event was consumed, // editor shouldn't handle this click event. if (mMouseDownOrUpConsumedByIME) { mMouseDownOrUpConsumedByIME = false; mouseEvent->AsEvent()->PreventDefault(); return NS_OK; } return MouseClick(mouseEvent); } // focus case eFocus: return Focus(aEvent); // blur case eBlur: return Blur(aEvent); // text case eCompositionChange: return HandleText(aEvent); // compositionstart case eCompositionStart: return HandleStartComposition(aEvent); // compositionend case eCompositionEnd: HandleEndComposition(aEvent); return NS_OK; default: break; } nsAutoString eventType; aEvent->GetType(eventType); // We should accept "focus" and "blur" event even if it's synthesized with // wrong interface for compatibility with older Gecko. if (eventType.EqualsLiteral("focus")) { return Focus(aEvent); } if (eventType.EqualsLiteral("blur")) { return Blur(aEvent); } #ifdef DEBUG nsPrintfCString assertMessage("Editor doesn't handle \"%s\" event " "because its internal event doesn't have proper message", NS_ConvertUTF16toUTF8(eventType).get()); NS_ASSERTION(false, assertMessage.get()); #endif return NS_OK; }
//************************************************************************************************************* void Render(float alpha, float elapsedtime) { LPDIRECT3DSURFACE9 oldtarget = NULL; D3DXMATRIX vp, inv, tmp1, tmp2; D3DXVECTOR3 axis(0, 1, 0); D3DXVECTOR3 eye(0, 0, -5); D3DXVECTOR3 look(0, 0, 0); D3DXVECTOR3 up(0, 1, 0); D3DXVECTOR2 cangle = cameraangle.smooth(alpha); D3DXVECTOR2 oangle = objectangle.smooth(alpha); float expo = exposure.smooth(alpha); D3DXMatrixRotationYawPitchRoll(&world, cangle.x, cangle.y, 0); D3DXVec3TransformCoord(&eye, &eye, &world); D3DXMatrixLookAtLH(&view, &eye, &look, &up); D3DXMatrixMultiply(&vp, &view, &proj); D3DXMatrixInverse(&inv, NULL, &view); memcpy(&eye, inv.m[3], 3 * sizeof(float)); if( mesh == mesh1 ) { // skullocc D3DXMatrixScaling(&world, 0.4f, 0.4f, 0.4f); world._42 = -1.5f; } else if( mesh == mesh2 ) { // knot D3DXMatrixScaling(&world, 0.8f, 0.8f, 0.8f); } else { // teapot D3DXMatrixScaling(&world, 1.5f, 1.5f, 1.5f); } D3DXMatrixRotationYawPitchRoll(&tmp1, oangle.x, oangle.y, 0); D3DXMatrixMultiply(&world, &world, &tmp1); D3DXMatrixInverse(&inv, NULL, &world); fresnel->SetVector("eyePos", (D3DXVECTOR4*)&eye); fresnel->SetMatrix("matWorld", &world); fresnel->SetMatrix("matWorldInv", &inv); fresnel->SetMatrix("matViewProj", &vp); D3DXMatrixScaling(&world, 20, 20, 20); skyeffect->SetMatrix("matWorld", &world); D3DXMatrixIdentity(&world); skyeffect->SetMatrix("matWorldSky", &world); skyeffect->SetMatrix("matViewProj", &vp); memcpy(tmpvert, quadvertices, 36 * sizeof(float)); if( SUCCEEDED(device->BeginScene()) ) { device->SetRenderState(D3DRS_SRGBWRITEENABLE, false); device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); // STEP 1: render sky device->GetRenderTarget(0, &oldtarget); if( firstframe ) { device->SetRenderTarget(0, aftersurfaces[0]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0); device->SetRenderTarget(0, aftersurfaces[1]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0); device->SetRenderTarget(0, avglumsurfaces[4]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0); device->SetRenderTarget(0, avglumsurfaces[5]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0); firstframe = false; } device->SetRenderTarget(0, scenesurface); device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0); device->SetRenderState(D3DRS_ZENABLE, FALSE); device->SetTexture(0, skytexture); skyeffect->Begin(NULL, 0); skyeffect->BeginPass(0); { skymesh->DrawSubset(0); } skyeffect->EndPass(); skyeffect->End(); device->SetRenderState(D3DRS_ZENABLE, TRUE); // STEP 2: render object device->SetTexture(0, texture); device->SetTexture(1, fresneltexture); device->SetTexture(2, skytexture); device->SetTexture(3, roughspecular); fresnel->Begin(NULL, 0); fresnel->BeginPass(0); { mesh->DrawSubset(0); } fresnel->EndPass(); fresnel->End(); device->SetVertexDeclaration(vertexdecl); // STEP 3: measure average luminance MeasureLuminance(); // STEP 4: adapt luminance to eye AdaptLuminance(elapsedtime); // STEP 5: bright pass BrightPass(); // STEP 6: downsample bright pass texture DownSample(); // STEP 7: blur downsampled textures Blur(); // STEP 8: ghost LensFlare(); // STEP 9: star Star(); // STEP 10: final combine hdreffect->SetTechnique("final"); hdreffect->SetFloat("targetluminance", targetluminance); device->SetRenderTarget(0, oldtarget); device->SetTexture(0, scenetarget); // scene device->SetTexture(1, blurtargets[0]); // blur device->SetTexture(2, blurtargets[1]); // star device->SetTexture(3, ghosttargets[0]); // ghost device->SetTexture(4, afterimages[1 - afterimagetex]); device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); device->SetRenderState(D3DRS_SRGBWRITEENABLE, true); oldtarget->Release(); hdreffect->Begin(NULL, 0); hdreffect->BeginPass(0); { device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, sizeof(D3DXVECTOR4) + sizeof(D3DXVECTOR2)); } hdreffect->EndPass(); hdreffect->End(); if( drawhelp ) { // render text device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1); device->SetRenderState(D3DRS_ZENABLE, FALSE); device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); device->SetTexture(0, text); device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float)); device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); device->SetRenderState(D3DRS_ZENABLE, TRUE); } // clean up device->SetTexture(1, NULL); device->SetTexture(2, NULL); device->SetTexture(3, NULL); device->SetTexture(4, NULL); device->SetTexture(5, NULL); device->EndScene(); } device->Present(NULL, NULL, NULL, NULL); }
int main( void ) { uint32_t width, height; uint32_t imagecount = 0; uint32_t testimagesatinitialization = 0; Image blank; srand( time( NULL ) ); for(width=0; width< NUM_REELS; width++) { g.uiSpeedCounter[width] = 0; g.uiSpeedStep[width] = 2; g.idx[width]= 0; } g.pdi = GetDisplayInterface(); g.pii = GetImageInterface(); //SetSystemLog( SYSLOG_FILE, stdout ); SetSystemLoggingLevel( 1000 + LOG_NOISE); GetDisplaySize( &width, &height );; g.render = OpenDisplaySizedAt( 0, width, height, 0, 0 ); UpdateDisplay(g.render); g.surface = GetDisplayImage( g.render ); SetMouseHandler( g.render, MouseMethod, 0 ); // blank = LoadImageFile( WIDE("blankimage.jpg")); blank = MakeImageFile(96,96); ClearImageTo( blank, BASE_COLOR_CYAN ); g.playagain=LoadImageFile( WIDE("%images%/playagain.jpg")); g.playing =LoadImageFile( WIDE("%images%/playing.jpg")); g.background = LoadImageFile( WIDE("%images%/background.jpg") ); // g.background = blank; g.strip = LoadImageFile( WIDE("%images%/slot_strip.jpg") ); g.nReels = NUM_REELS; { Image icons[NUM_ICONS]; int n, m; INDEX idx; for( n = 0; n < NUM_ICONS; n++ ) { icons[n] = MakeSubImage( g.strip, 96 * n, 0, 96, 96 ); } n = width = imagecount = height = 0; while(imagecount < NUM_IMAGES ) { idx = rand()%NUM_ICONS; g.images[imagecount] = icons[idx]; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; for( m = 0; m < (( rand()%2 ) ); m++) { g.images[imagecount] = blank; if( testimagesatinitialization ) { BlotImage( g.surface, g.images[imagecount], width * 96, height * 96 ); width++; if(!( width % 8 )) { width=0; height++; } } imagecount++; } if( testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } } if( !testimagesatinitialization ) { SyncRender( g.render); UpdateDisplay(g.render); } for( n = 0; n < NUM_BLURS; n++ ) { g.blurs[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); g.dodges[n] = MakeImageFile( 96, (NUM_PICS) * 96 ); for( m = 0; m < NUM_IMAGES; m++ ) { idx = rand()%NUM_IMAGES; g.reel[0][m] = g.images[idx]; } Blur( g.blurs[n], g.reel[0] ); DodgeEx( g.dodges[n], g.reel[0] , 2); } for( n = 0; n < NUM_REELS; n++) { g.subsurface[n] = MakeSubImage( g.surface , REEL_OFSX + REEL_STEPX * n , REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS_IN_WINDOW) ); g.testsurface[n] = MakeSubImage( g.surface, REEL_OFSX + REEL_STEPX * n + 480, REEL_OFSY , REEL_WIDTH, (96 * NUM_PICS) ); } g.statussurface = MakeSubImage( g.surface , 490, 10 , 140, 68 ); g.backgroundsurface = MakeSubImage( g.surface , 0, 0 , 640, 460 ); } g.flags.bBackgroundInitialized = 0; ThreadTo( ReadInput, 0 ); { uint32_t start = GetTickCount(); xlprintf(LOG_NOISE)("Started at %lu" , start); g.ofs = 0; while( 1 ) { if( g.flags.bSpinning ) { DrawSpinningReels(FALSE); } #ifndef __ARM__ // scale to approx unit speeds.. WakeableSleep( 250 ); //WakeableSleep( 33); #endif } } CloseDisplay( g.render ); UnmakeImageFile( g.strip ); return 0; }