QQuickShapeGenericStrokeFillNode::QQuickShapeGenericStrokeFillNode(QQuickWindow *window) : m_material(nullptr) { setFlag(QSGNode::OwnsGeometry, true); setGeometry(new QSGGeometry(QSGGeometry::defaultAttributes_ColoredPoint2D(), 0, 0)); activateMaterial(window, MatSolidColor); #ifdef QSG_RUNTIME_DESCRIPTION qsgnode_set_description(this, QLatin1String("stroke-fill")); #endif }
void DeviceGraphicsDX11Renderer::drawParticles ( const Matrix4 &transform, ParticlesResource *particles, MaterialResource *material, DTuint first, DTuint num ) { if (material && particles) { activateMaterial(material); Matrix4 t = _modelview * transform; DeviceGraphicsDX11Shader::setConstantValue(_modelview_uniform, (DTubyte *) &t, sizeof(Matrix4) ); DeviceGraphicsDX11Shader::setConstantValue(_projection_uniform, (DTubyte *) &_projection, sizeof(Matrix4) ); DeviceGraphicsDX11Shader::setConstantValue(_camera_uniform, (DTubyte *) &_camera, sizeof(Matrix4) ); DeviceGraphicsDX11Particles *ogl_particles = getParticlesCached(particles); ogl_particles->drawRange(first, num); } }
void DeviceGraphicsDX11Renderer::drawBatch ( const Matrix4 &transform, GeometryResource *geometry, MaterialResource *material, Array<Matrix4> *skeleton) { if (geometry) { if (material) activateMaterial(material); Matrix4 t = _modelview * transform; //::glUniformMatrix4fv(_modelview_uniform, 1, GL_FALSE, (GLfloat*) &t); //::glUniformMatrix4fv(_projection_uniform, 1, GL_FALSE, (GLfloat*) &_projection); //::glUniformMatrix4fv(_camera_uniform, 1, GL_FALSE, (GLfloat*) &_camera); Array<GeometryResource::Batch> &batches = geometry->getBatches(); DeviceGraphicsDX11Geometry *ogl_geometry = getGeometryCached(geometry); for (DTuint i = 0; i < batches.size(); ++i) { GeometryResource::Batch &b = batches[i]; // Upload skeleton if (skeleton) { Array<Matrix4> transforms; transforms.resize(b.weight_to_joint.size()); for (DTuint i = 0; i < b.weight_to_joint.size(); ++i) { transforms[i] = (*skeleton)[b.weight_to_joint[i]]; } DeviceGraphicsDX11Shader *shader = getShaderCached(material->getShader()); //DTint skeleton_uniform = shader->getUniform(DeviceGraphicsDX11Shader::UNIFORM_SKELETON); //if (skeleton_uniform != -1) //::glUniformMatrix4fv(skeleton_uniform, transforms.size(), GL_FALSE, (GLfloat*) &transforms[0]); } ogl_geometry->drawRange(b.first_index, b.num_indices); } } }
void DeviceGraphicsDX11Renderer::drawRawBatchScreenSpace ( const Matrix4 &transform, Vector3 *v, Vector3 *n, Texcoord2 *t1, Texcoord2 *t2, Color *c, DTuint num, MaterialResource *material, BatchType batch_type) { Matrix4 projection; // Same as //::glOrthof(0.0F,1.0F,0.0F,1.0F,-1.0F,1.0F); projection._m11 = 2.0F; projection._m12 = 0.0F; projection._m13 = 0.0F; projection._m14 = -1.0F; projection._m21 = 0.0F; projection._m22 = 2.0F; projection._m23 = 0.0F; projection._m24 = -1.0F; projection._m31 = 0.0F; projection._m32 = 0.0F; projection._m33 = -1.0F; projection._m34 = 0.0F; projection._m41 = 0.0F; projection._m42 = 0.0F; projection._m43 = 0.0F; projection._m44 = 1.0F; if (material) activateMaterial(material); DeviceGraphicsDX11Shader::setConstantValue(_modelview_uniform, (DTubyte *) &transform, sizeof(Matrix4) ); DeviceGraphicsDX11Shader::setConstantValue(_projection_uniform, (DTubyte *) &projection, sizeof(Matrix4) ); DeviceGraphicsDX11Shader::setConstantValue(_camera_uniform, (DTubyte *) &_camera, sizeof(Matrix4) ); UINT startSlot = 0; UINT numBuffers = 0; ID3D11Buffer* buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = {NULL}; UINT strides[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = {0}; UINT offsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = {0}; D3D11_MAPPED_SUBRESOURCE res; _d3dContext->Map(_vertices,0,D3D11_MAP_WRITE_DISCARD,0,&res); ::memcpy(res.pData,v,sizeof(Vector3)*num); _d3dContext->Unmap(_vertices,0); buffers[ShaderResource::ATTRIB_POSITION] = _vertices; strides[ShaderResource::ATTRIB_POSITION] = sizeof(Vector3); if (n) { _d3dContext->Map(_normals,0,D3D11_MAP_WRITE_DISCARD,0,&res); ::memcpy(res.pData,n,sizeof(Vector3)*num); _d3dContext->Unmap(_normals,0); buffers[ShaderResource::ATTRIB_NORMAL] = _normals; strides[ShaderResource::ATTRIB_NORMAL] = sizeof(Vector3); } if (t1) { _d3dContext->Map(_texcoords1,0,D3D11_MAP_WRITE_DISCARD,0,&res); ::memcpy(res.pData,t1,sizeof(Texcoord2)*num); _d3dContext->Unmap(_texcoords1,0); buffers[ShaderResource::ATTRIB_TEXCOORD0] = _texcoords1; strides[ShaderResource::ATTRIB_TEXCOORD0] = sizeof(Texcoord2); } if (t2) { _d3dContext->Map(_texcoords2,0,D3D11_MAP_WRITE_DISCARD,0,&res); ::memcpy(res.pData,t2,sizeof(Texcoord2)*num); _d3dContext->Unmap(_texcoords2,0); buffers[ShaderResource::ATTRIB_TEXCOORD1] = _texcoords2; strides[ShaderResource::ATTRIB_TEXCOORD1] = sizeof(Texcoord2); } if (c) { _d3dContext->Map(_colors,0,D3D11_MAP_WRITE_DISCARD,0,&res); ::memcpy(res.pData,c,sizeof(Color)*num); _d3dContext->Unmap(_colors,0); buffers[ShaderResource::ATTRIB_COLOR] = _colors; strides[ShaderResource::ATTRIB_COLOR] = sizeof(Color); } // Resolve offsets DTuint offset = 0; for (DTuint i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i) { offsets[i] = offset; offset += strides[i]; } // Bind buffers _d3dContext->IASetVertexBuffers(0,ShaderResource::NUM_ATTRIBS,buffers,strides,offsets); // draw primitives D3D11_PRIMITIVE_TOPOLOGY primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; if (batch_type == BATCH_TRI_STRIP) { primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; } else if (batch_type == BATCH_TRI_POLY) { primType = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST; } else if (batch_type == BATCH_LINES) { primType = D3D11_PRIMITIVE_TOPOLOGY_LINELIST; } else if (batch_type == BATCH_LINE_LOOP) { primType = D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP; } else if (batch_type == BATCH_POINTS) { primType = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; } else { Assert(0); } _d3dContext->IASetPrimitiveTopology(primType); _d3dContext->Draw(num,0); }