void RenderFrame() { D3DCOLOR bgColour = 0xFF0000FF; // 배경색상 - 파랑 gpD3DDevice->Clear(0, NULL, (D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER), bgColour, 1.0f, 0); gpD3DDevice->BeginScene(); { RenderScene(); // 3D 물체등을 그린다. RenderInfo(); // 디버그 정보 등을 출력한다. } gpD3DDevice->EndScene(); gpD3DDevice->Present(NULL, NULL, NULL, NULL); }
void RenderFrame() { D3DCOLOR bgColor = 0xFF0000FF; // background color - blue gpD3DDevice->Clear(0, NULL, (D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER), bgColor, 1.0f, 0); gpD3DDevice->BeginScene(); { RenderScene(); // draw 3D objects and so on RenderInfo(); // display debug info } gpD3DDevice->EndScene(); gpD3DDevice->Present(NULL, NULL, NULL, NULL); }
void IApplication::RenderFrame() { D3DCOLOR bgColour = 0xFF0000FF; m_pD3DDevice->Clear(0, NULL, (D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER), bgColour, 1.0f, 0); m_pD3DDevice->BeginScene(); { RenderScene(); RenderInfo(); } m_pD3DDevice->EndScene(); m_pD3DDevice->Present(NULL, NULL, NULL, NULL); }
void ScreenManager::renderBackground(SDL_Surface *img, SDL_Rect rect){ Utility::renderToScreen(this->render, img, RenderInfo(NULL,rect,0.0,SDL_FLIP_NONE)); }
void GL2ChunkRenderer::applyChunkVisuals(ChunkVisuals chunkVisuals) { numQuads = 0; for (Quad quad : chunkVisuals.quads) { vec2f texs[4]; GL2TextureManager::Entry tex_entry = ((GL2Renderer *) renderer)->getTextureManager()->get(quad.faceType, quad.bc, quad.faceDir); GL2TextureManager::getTextureCoords(tex_entry.index, tex_entry.type, texs); faceIndexBuffer[numQuads] = FaceIndexData{tex_entry.tex, numQuads}; vb[numQuads].normal[0] = DIRS[quad.faceDir][0]; vb[numQuads].normal[1] = DIRS[quad.faceDir][1]; vb[numQuads].normal[2] = DIRS[quad.faceDir][2]; for (int j = 0; j < 4; j++) { vb[numQuads].tex[j][0] = texs[j][0]; vb[numQuads].tex[j][1] = texs[j][1]; float light = 1.0f - quad.shadowLevels[j] * 0.2f; vb[numQuads].color[j][0] = light; vb[numQuads].color[j][1] = light; vb[numQuads].color[j][2] = light; vec3f vertex = (quad.icc.cast<int>() + DIR_QUAD_CORNER_CYCLES_3D[quad.faceDir][j]).cast<float>(); vb[numQuads].vertex[j][0] = vertex[0]; vb[numQuads].vertex[j][1] = vertex[1]; vb[numQuads].vertex[j][2] = vertex[2]; } ++numQuads; } auto it = renderInfos.find(chunkVisuals.cc); if (numQuads > 0) { if (it == renderInfos.end()) { auto pair = renderInfos.insert({chunkVisuals.cc, RenderInfo()}); it = pair.first; } if (it->second.dl == 0) { it->second.dl = glGenLists(1); } std::sort(&faceIndexBuffer[0], &faceIndexBuffer[numQuads], [](const FaceIndexData &l, const FaceIndexData &r) { return l.tex < r.tex; }); glNewList(it->second.dl, GL_COMPILE); GLuint lastTex = 0; for (int facei = 0; facei < numQuads; ++facei) { const FaceIndexData *fid = &faceIndexBuffer[facei]; const FaceVertexData *fvd = &vb[fid->index]; if (fid->tex != lastTex) { glBindTexture(GL_TEXTURE_2D, fid->tex); lastTex = fid->tex; } glBegin(GL_QUADS); glNormal3f(fvd->normal[0], fvd->normal[1], fvd->normal[2]); for (int j = 0; j < 4; j++) { glTexCoord2f(fvd->tex[j][0], fvd->tex[j][1]); glColor3f(fvd->color[j][0], fvd->color[j][1], fvd->color[j][2]); glVertex3f(fvd->vertex[j][0], fvd->vertex[j][1], fvd->vertex[j][2]); } glEnd(); } glEndList(); LOG_OPENGL_ERROR; } else if (it != renderInfos.end()) { if (it->second.dl != 0) { GL(DeleteLists(it->second.dl, 1)) } renderInfos.erase(it); } }
std::string TR::InitializeSystem(void) { if (textRenderer != 0) { return "System was already initialized."; } ClearAllRenderingErrors(); tempTex.Create(); //Transform matrices and render info. textRendererCam.GetViewTransform(viewMat); textRendererCam.GetOrthoProjection(projMat); textRendererInfo = RenderInfo(0.0f, &textRendererCam, &viewMat, &projMat); //Material. textRendererParams.clear(); SerializedMaterial matData(DrawingQuad::GetVertexInputData()); //Use a simple vertex shader that just uses world position -- in other words, // the visible range in world space is just the volume from {-1, -1, -1} to {1, 1, 1}. //It also outputs UVs for the fragment shader to use. DataLine vIn_Pos(VertexInputNode::GetInstance(), 0), vIn_UV(VertexInputNode::GetInstance(), 1); DataNode::Ptr objPosToWorld(new SpaceConverterNode(DataLine(VertexInputNode::GetInstanceName()), SpaceConverterNode::ST_OBJECT, SpaceConverterNode::ST_WORLD, SpaceConverterNode::DT_POSITION, "objPosToWorld")); DataNode::Ptr vertexPosOut(new CombineVectorNode(DataLine(objPosToWorld->GetName()), DataLine(1.0f))); matData.MaterialOuts.VertexPosOutput = vertexPosOut; //The fragment shader just samples from the texture containing the text char // and uses its "red" value because it's a grayscale texture. matData.MaterialOuts.VertexOutputs.push_back(ShaderOutput("vOut_UV", vIn_UV)); DataLine fIn_UV(FragmentInputNode::GetInstance(), 0); DataNode::Ptr textSampler(new TextureSample2DNode(fIn_UV, textSamplerName, "textSampler")); DataLine textSamplerRGBA(textSampler, TextureSample2DNode::GetOutputIndex(CO_AllChannels)); DataNode::Ptr textColor(new SwizzleNode(textSamplerRGBA, SwizzleNode::C_X, SwizzleNode::C_X, SwizzleNode::C_X, SwizzleNode::C_X, "swizzleTextSample")); matData.MaterialOuts.FragmentOutputs.push_back(ShaderOutput("fOut_Color", textColor)); BlendMode blending = BlendMode::GetTransparent(); ShaderGenerator::GeneratedMaterial genM = ShaderGenerator::GenerateMaterial(matData, textRendererParams, blending); if (!genM.ErrorMessage.empty()) { return "Error generating text renderer material: " + genM.ErrorMessage; } textRenderer = genM.Mat; return ""; }
#include "TextRenderer.h" #include "../Data Nodes/DataNodes.hpp" #include "../../Rendering/Basic Rendering/RenderingState.h" #include "../Basic Rendering/BlendMode.h" #include "../Data Nodes/ShaderGenerator.h" #include "../../Rendering/Basic Rendering/ScreenClearer.h" typedef TextRenderer TR; Material* TR::textRenderer = 0; UniformDictionary TR::textRendererParams = UniformDictionary(); RenderInfo TR::textRendererInfo = RenderInfo(0, 0, 0, 0); Camera TR::textRendererCam = Camera(); Matrix4f TR::viewMat = Matrix4f(), TR::projMat = Matrix4f(); MTexture2D TR::tempTex(TextureSampleSettings2D(FT_NEAREST, WT_CLAMP), PS_8U_GREYSCALE, false); const char* textSamplerName = "u_charSampler"; std::string TR::InitializeSystem(void) { if (textRenderer != 0) { return "System was already initialized."; }