bool SkOSWindow::attachANGLE(int msaaSampleCount, AttachmentInfo* info) { if (EGL_NO_DISPLAY == fDisplay) { bool bResult = create_ANGLE((HWND)fHWND, msaaSampleCount, &fDisplay, &fContext, &fSurface, &fConfig); if (false == bResult) { return false; } SkAutoTUnref<const GrGLInterface> intf(GrGLCreateANGLEInterface()); if (intf) { ANGLE_GL_CALL(intf, ClearStencil(0)); ANGLE_GL_CALL(intf, ClearColor(0, 0, 0, 0)); ANGLE_GL_CALL(intf, StencilMask(0xffffffff)); ANGLE_GL_CALL(intf, Clear(GL_STENCIL_BUFFER_BIT |GL_COLOR_BUFFER_BIT)); } } if (eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { eglGetConfigAttrib(fDisplay, fConfig, EGL_STENCIL_SIZE, &info->fStencilBits); eglGetConfigAttrib(fDisplay, fConfig, EGL_SAMPLES, &info->fSampleCount); SkAutoTUnref<const GrGLInterface> intf(GrGLCreateANGLEInterface()); if (intf ) { ANGLE_GL_CALL(intf, Viewport(0, 0, SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()))); } return true; } return false; }
void FlatDX::PopulateCommandList(const size_t i) { const auto CL = GraphicsCommandLists[i].Get(); const auto SCR = SwapChainResources[i].Get(); const auto SCHandle = GetCPUDescriptorHandle(SwapChainDescriptorHeap.Get(), D3D12_DESCRIPTOR_HEAP_TYPE_RTV, static_cast<UINT>(i)); const auto CA = CommandAllocators[0].Get(); VERIFY_SUCCEEDED(CL->Reset(CA, PipelineState.Get())); { CL->RSSetViewports(static_cast<UINT>(Viewports.size()), Viewports.data()); CL->RSSetScissorRects(static_cast<UINT>(ScissorRects.size()), ScissorRects.data()); ResourceBarrier(CL, SCR, D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); { ClearColor(CL, SCHandle, DirectX::Colors::SkyBlue); { const std::vector<D3D12_CPU_DESCRIPTOR_HANDLE> RTDescriptorHandles = { SCHandle }; CL->OMSetRenderTargets(static_cast<UINT>(RTDescriptorHandles.size()), RTDescriptorHandles.data(), FALSE, nullptr); } CL->SetGraphicsRootSignature(RootSignature.Get()); CL->IASetPrimitiveTopology(GetPrimitiveTopology()); CL->ExecuteIndirect(IndirectCommandSignature.Get(), 1, IndirectBufferResource.Get(), 0, nullptr, 0); } ResourceBarrier(CL, SCR, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT); } VERIFY_SUCCEEDED(CL->Close()); }
bool SkOSWindow::attachCommandBuffer(int msaaSampleCount, AttachmentInfo* info) { if (!fCommandBuffer) { fCommandBuffer = SkCommandBufferGLContext::Create((HWND)fHWND, msaaSampleCount); if (!fCommandBuffer) return false; SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface()); if (intf) { GL_CALL(intf, ClearStencil(0)); GL_CALL(intf, ClearColor(0, 0, 0, 0)); GL_CALL(intf, StencilMask(0xffffffff)); GL_CALL(intf, Clear(GL_STENCIL_BUFFER_BIT |GL_COLOR_BUFFER_BIT)); } } if (fCommandBuffer->makeCurrent()) { info->fStencilBits = fCommandBuffer->getStencilBits(); info->fSampleCount = fCommandBuffer->getSampleCount(); SkAutoTUnref<const GrGLInterface> intf(GrGLCreateCommandBufferInterface()); if (intf ) { GL_CALL(intf, Viewport(0, 0, SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()))); } return true; } return false; }
bool SkOSWindow::attachANGLE(int msaaSampleCount, AttachmentInfo* info) { if (EGL_NO_DISPLAY == fDisplay) { bool bResult = create_ANGLE((HWND)fHWND, msaaSampleCount, &fDisplay, &fContext, &fSurface, &fConfig); if (false == bResult) { return false; } fANGLEInterface.reset(get_angle_gl_interface()); if (!fANGLEInterface) { this->detachANGLE(); return false; } GL_CALL(fANGLEInterface, ClearStencil(0)); GL_CALL(fANGLEInterface, ClearColor(0, 0, 0, 0)); GL_CALL(fANGLEInterface, StencilMask(0xffffffff)); GL_CALL(fANGLEInterface, Clear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT)); } if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { this->detachANGLE(); return false; } eglGetConfigAttrib(fDisplay, fConfig, EGL_STENCIL_SIZE, &info->fStencilBits); eglGetConfigAttrib(fDisplay, fConfig, EGL_SAMPLES, &info->fSampleCount); GL_CALL(fANGLEInterface, Viewport(0, 0, SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()))); return true; }
void GL::SetClearColor(const Color& aColor) { MOZ_ASSERT(IsCurrent()); if (!memcmp(&mClearColor, &aColor, sizeof(Color))) { return; } if (aColor.a == 1) { ClearColor(aColor.r, aColor.g, aColor.b, 1); } else { const float a = aColor.a; ClearColor(a * aColor.r, a * aColor.g, a * aColor.b, a); } mClearColor = aColor; }
void Menu() { char level[SIZE]; char levelBeg[]="beginner"; char levelAdv[]="advance"; char ch; int i = 0,j = 0; int checkBeg = 0, checkAdv = 0; int levelSign = 0; printf("\nDo you want to play beginner or advance level (beginner/advance)? :"); while ((ch = getchar()) != '\n') { level[i] = ch; i++; } level[i] = '\0'; for (i = 0; i < SIZE; i++) { if ( level[i] != levelBeg[i] ) checkBeg = 1; if ( level[i] != levelAdv[i] ) checkAdv = 1; } if (checkBeg == 0) levelSign = 3; if (checkAdv == 0) levelSign = 5; if (levelSign == 0) { printf("\a\nWARNING: You should enter \'beginner\' or \'advance\'\n"); Menu(); } else { ClearColor(); // Clearing all color PutButtons(levelSign); // putting buttons according to the level MakeCode(levelSign); } }
void UCodecMovieFallback::GetFrame( class FTextureMovieResource* InTextureMovieResource ) { CurrentTime += 1.f / GetFrameRate(); if( CurrentTime > PlaybackDuration ) { CurrentTime = 0.f; } if( InTextureMovieResource && InTextureMovieResource->IsInitialized() ) { FLinearColor ClearColor(1.f,CurrentTime/PlaybackDuration,0.f,1.f); RHISetRenderTarget(InTextureMovieResource->GetRenderTargetTexture(),FTextureRHIRef()); RHIClear(true,ClearColor,false,0.f,false,0, FIntRect()); RHICopyToResolveTarget(InTextureMovieResource->GetRenderTargetTexture(),InTextureMovieResource->TextureRHI,false,FResolveParams()); } }
void AsciiRenderer::CreateBuffers(const unsigned int width, const unsigned int height) { assert(width != 0); assert(height != 0); m_Width = width; m_Height = height; m_ColorBuffer = new char*[height]; m_DepthBuffer = new float*[height]; for(unsigned int y = 0; y < height; ++y) { m_ColorBuffer[y] = new char[width]; m_DepthBuffer[y] = new float[width]; } ClearColor(); ClearDepth(); }
int main() { printf("\n\t\t\t ****PURBLE GAME****\n"); initwindow(700,380,"Purble Game"); outtextxy(438,50, "\a PURBLE GAME \a"); setfillstyle(5,7); // head color fillellipse( 200, 125, 125, 100 ); // head ClearColor(); Menu(); system("pause"); return 0; }
void NormalMapVK::PopulateCommandBuffer(const size_t i) { const auto CB = CommandPools[0].second[i];//CommandBuffers[i]; //const auto SCB = SecondaryCommandBuffers[i]; const auto FB = Framebuffers[i]; const auto Image = SwapchainImages[i]; const VkCommandBufferBeginInfo BeginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, 0, nullptr }; VERIFY_SUCCEEDED(vkBeginCommandBuffer(CB, &BeginInfo)); { vkCmdSetViewport(CB, 0, static_cast<uint32_t>(Viewports.size()), Viewports.data()); vkCmdSetScissor(CB, 0, static_cast<uint32_t>(ScissorRects.size()), ScissorRects.data()); ClearColor(CB, Image, Colors::SkyBlue); const VkRenderPassBeginInfo RenderPassBeginInfo = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, RenderPass, FB, ScissorRects[0], 0, nullptr }; vkCmdBeginRenderPass(CB, &RenderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); { if (!DescriptorSets.empty()) { vkCmdBindDescriptorSets(CB, VK_PIPELINE_BIND_POINT_GRAPHICS, PipelineLayout, 0, static_cast<uint32_t>(DescriptorSets.size()), DescriptorSets.data(), 0, nullptr); } vkCmdBindPipeline(CB, VK_PIPELINE_BIND_POINT_GRAPHICS, Pipeline); vkCmdDrawIndirect(CB, IndirectBuffer, 0, 1, 0); } vkCmdEndRenderPass(CB); } VERIFY_SUCCEEDED(vkEndCommandBuffer(CB)); }
void GLCpuPosInstancedArraysBench::setup(const GrGLContext* ctx) { const GrGLInterface* gl = ctx->interface(); fTexture = SetupFramebuffer(gl, kScreenWidth, kScreenHeight); fProgram = this->setupShader(ctx); // setup matrices int index = 0; SkMatrix viewMatrices[kNumTri]; setup_matrices(kNumTri, [&index, &viewMatrices](const SkMatrix& m) { viewMatrices[index++] = m; }); // setup VAO GR_GL_CALL(gl, GenVertexArrays(1, &fVAO)); GR_GL_CALL(gl, BindVertexArray(fVAO)); switch (fVboSetup) { case kUseOne_VboSetup: this->setupSingleVbo(gl, viewMatrices); break; case kUseTwo_VboSetup: this->setupDoubleVbo(gl, viewMatrices); break; case kUseInstance_VboSetup: this->setupInstanceVbo(gl, viewMatrices); break; } // clear screen GR_GL_CALL(gl, ClearColor(0.03f, 0.03f, 0.03f, 1.0f)); GR_GL_CALL(gl, Clear(GR_GL_COLOR_BUFFER_BIT)); // set us up to draw GR_GL_CALL(gl, UseProgram(fProgram)); GR_GL_CALL(gl, BindVertexArray(fVAO)); }
void GLGpuPosInstancedArraysBench::setup(const GrGLInterface* gl) { setup_framebuffer(gl, kScreenWidth, kScreenHeight); // compile and use shaders GrGLint shaderProgram = compile_shader(gl, gpu_vertex_shader, fragment_shader); // translations int index = 0; GrGLfloat viewMatrices[fNumQuads * fSkMatrixNumCells]; setup_matrices(fNumQuads, [&index, &viewMatrices](const SkMatrix& m) { GrGLGetMatrix<3>(&viewMatrices[index], m); index += fSkMatrixNumCells; }); // Constants for our various shader programs GrGLfloat quad_vertices[] = { // Positions // Colors -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f }; // update vertex data GrGLuint quadVAO, quadVBO; GR_GL_CALL(gl, GenVertexArrays(1, &quadVAO)); GR_GL_CALL(gl, GenBuffers(1, &quadVBO)); GR_GL_CALL(gl, BindVertexArray(quadVAO)); GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, quadVBO)); GR_GL_CALL(gl, EnableVertexAttribArray(0)); GR_GL_CALL(gl, VertexAttribPointer(0, 2, GR_GL_FLOAT, GR_GL_FALSE, 5 * sizeof(GrGLfloat), (GrGLvoid*)0)); GR_GL_CALL(gl, EnableVertexAttribArray(1)); GR_GL_CALL(gl, VertexAttribPointer(1, 3, GR_GL_FLOAT, GR_GL_FALSE, 5 * sizeof(GrGLfloat), (GrGLvoid*)(2 * sizeof(GrGLfloat)))); GR_GL_CALL(gl, BufferData(GR_GL_ARRAY_BUFFER, sizeof(quad_vertices), quad_vertices, GR_GL_STATIC_DRAW)); // Also set instance data GrGLuint instanceVBO; GR_GL_CALL(gl, GenBuffers(1, &instanceVBO)); GR_GL_CALL(gl, BindBuffer(GR_GL_ARRAY_BUFFER, instanceVBO)); GR_GL_CALL(gl, BufferData(GR_GL_ARRAY_BUFFER, sizeof(GrGLfloat) * fSkMatrixNumCells * fNumQuads, &viewMatrices[0], GR_GL_STATIC_DRAW)); GR_GL_CALL(gl, EnableVertexAttribArray(2)); GR_GL_CALL(gl, EnableVertexAttribArray(3)); GR_GL_CALL(gl, EnableVertexAttribArray(4)); GR_GL_CALL(gl, VertexAttribPointer(2, 3, GR_GL_FLOAT, GR_GL_FALSE, 9 * sizeof(GrGLfloat), (GrGLvoid*)0)); GR_GL_CALL(gl, VertexAttribPointer(3, 3, GR_GL_FLOAT, GR_GL_FALSE, 9 * sizeof(GrGLfloat), (GrGLvoid*)(3 * sizeof(GrGLfloat)))); GR_GL_CALL(gl, VertexAttribPointer(4, 3, GR_GL_FLOAT, GR_GL_FALSE, 9 * sizeof(GrGLfloat), (GrGLvoid*)(6 * sizeof(GrGLfloat)))); GR_GL_CALL(gl, VertexAttribDivisor(2, 1)); GR_GL_CALL(gl, VertexAttribDivisor(3, 1)); GR_GL_CALL(gl, VertexAttribDivisor(4, 1)); // draw GR_GL_CALL(gl, ClearColor(0.03f, 0.03f, 0.03f, 1.0f)); GR_GL_CALL(gl, Clear(GR_GL_COLOR_BUFFER_BIT)); // set us up to draw GR_GL_CALL(gl, UseProgram(shaderProgram)); GR_GL_CALL(gl, BindVertexArray(quadVAO)); }
GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { CONTEXT_EXEC(ClearColor(red, green, blue, alpha)); }
/** * \brief Initialize a (new or reused) OpenGL context. * set global gl-related variables to their default values */ static int initGl(uint32_t d_width, uint32_t d_height) { int scale_type = mipmap_gen ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR; autodetectGlExtensions(); gl_target = use_rectangle == 1 ? GL_TEXTURE_RECTANGLE : GL_TEXTURE_2D; yuvconvtype = use_yuv | lscale << YUV_LUM_SCALER_SHIFT | cscale << YUV_CHROM_SCALER_SHIFT; texSize(image_width, image_height, &texture_width, &texture_height); Disable(GL_BLEND); Disable(GL_DEPTH_TEST); DepthMask(GL_FALSE); Disable(GL_CULL_FACE); Enable(gl_target); DrawBuffer(vo_doublebuffering?GL_BACK:GL_FRONT); TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n", texture_width, texture_height); if (is_yuv) { int i; int xs, ys; mp_get_chroma_shift(image_format, &xs, &ys); GenTextures(21, default_texs); default_texs[21] = 0; for (i = 0; i < 7; i++) { ActiveTexture(GL_TEXTURE1 + i); BindTexture(GL_TEXTURE_2D, default_texs[i]); BindTexture(GL_TEXTURE_RECTANGLE, default_texs[i + 7]); BindTexture(GL_TEXTURE_3D, default_texs[i + 14]); } ActiveTexture(GL_TEXTURE1); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, texture_width >> xs, texture_height >> ys, 128); if (mipmap_gen) TexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); ActiveTexture(GL_TEXTURE2); glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, texture_width >> xs, texture_height >> ys, 128); if (mipmap_gen) TexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); ActiveTexture(GL_TEXTURE0); BindTexture(gl_target, 0); } if (is_yuv || custom_prog) { if ((MASK_NOT_COMBINERS & (1 << use_yuv)) || custom_prog) { if (!GenPrograms || !BindProgram) { mp_msg(MSGT_VO, MSGL_ERR, "[gl] fragment program functions missing!\n"); } else { GenPrograms(1, &fragprog); BindProgram(GL_FRAGMENT_PROGRAM, fragprog); } } update_yuvconv(); } glCreateClearTex(gl_target, gl_texfmt, gl_format, gl_type, scale_type, texture_width, texture_height, 0); if (mipmap_gen) TexParameteri(gl_target, GL_GENERATE_MIPMAP, GL_TRUE); resize(d_width, d_height); ClearColor( 0.0f,0.0f,0.0f,0.0f ); Clear( GL_COLOR_BUFFER_BIT ); if (SwapInterval && swap_interval >= 0) SwapInterval(swap_interval); return 1; }