//------------------------------------------------------------------------ bool HostProcessData::prepare (IComponent& component, int32 bufferSamples, int32 _symbolicSampleSize) { if (checkIfReallocationNeeded (component, bufferSamples, _symbolicSampleSize)) { unprepare (); symbolicSampleSize = _symbolicSampleSize; channelBufferOwner = bufferSamples > 0; numInputs = createBuffers (component, inputs, kInput, bufferSamples); numOutputs = createBuffers (component, outputs, kOutput, bufferSamples); } else { // reset silence flags for (int32 i = 0; i < numInputs; i++) { inputs[i].silenceFlags = 0; } for (int32 i = 0; i < numOutputs; i++) { outputs[i].silenceFlags = 0; } } return true; }
void SmokeRenderer::setWindowSize(int w, int h) { mAspect = (float) mWindowW / (float) mWindowH; mInvFocalLen = tan(mFov*0.5*NV_PI/180.0); createBuffers(w, h); }
const float *Mesh::getNormalBuffer(uint &numVertices) { if (!m_cached) createBuffers(); numVertices = m_numVertices; return m_normalBuffer; }
void Mesh::initTriangles(GLuint shader, std::vector<Tri> tris, const glm::vec3 *verts) { m_mappingSize = tris.size() * 3; GLuint memsize = m_mappingSize * 8 * sizeof(float); createBuffers(shader, memsize); setTriangles(tris, verts); }
void MyGLWidget::initializeGL () { // glew és necessari per cridar funcions de les darreres versions d'OpenGL glewExperimental = GL_TRUE; glewInit(); glGetError(); // Reinicia la variable d'error d'OpenGL glClearColor (0.5, 0.7, 1.0, 1.0); // defineix color de fons (d'esborrat) //afegim shaders QGLShader fs (QGLShader::Fragment,this); fs.compileSourceFile ("./fragshad.frag"); QGLShader vs (QGLShader::Vertex,this); vs.compileSourceFile ("./vertshad.vert"); QGLShaderProgram program(this); program.addShader(&fs); program.addShader(&vs); program.link(); program.bind(); //creem els buffers createBuffers(); }
// Init HRESULT CFW1GlyphVertexDrawer::initVertexDrawer( IFW1Factory *pFW1Factory, ID3D11Device *pDevice, UINT vertexBufferSize ) { HRESULT hResult = initBaseObject(pFW1Factory); if(FAILED(hResult)) return hResult; if(pDevice == NULL) return E_INVALIDARG; pDevice->AddRef(); m_pDevice = pDevice; D3D_FEATURE_LEVEL featureLevel = m_pDevice->GetFeatureLevel(); m_vertexBufferSize = 4096 * 16; if(vertexBufferSize >= 1024) { if(featureLevel < D3D_FEATURE_LEVEL_9_2) vertexBufferSize = std::min(vertexBufferSize, 512U*1024U); m_vertexBufferSize = vertexBufferSize; } m_maxIndexCount = (m_vertexBufferSize * 3) / (2 * sizeof(QuadVertex)); if(m_maxIndexCount < 64) m_maxIndexCount = 64; // Create device buffers hResult = createBuffers(); if(SUCCEEDED(hResult)) hResult = S_OK; return hResult; }
void Terrain::create(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const std::string& heightmapFilename, const std::string& blendmapFilename) { m_blendmap.texels.clear(); Utilities::loadPNG(blendmapFilename, m_blendmap); m_width = m_blendmap.width; m_depth = m_blendmap.height; UINT size = (m_width + 1) * (m_depth + 1); std::vector<unsigned char> in(size); std::ifstream file; file.open(heightmapFilename, std::ios_base::binary); if (file) { file.read((char*)&in[0], (std::streamsize)in.size()); file.close(); } m_heightmap.clear(); m_heightmap.resize(size); for (UINT i = 0; i < size; i++) m_heightmap[i] = (float)in[i]; smooth(); createBuffers(device, deviceContext); m_currentHeightmapFilepath = heightmapFilename; m_currentBlendmapFilepath = blendmapFilename; }
void CVK::Plane::create( glm::vec3 a, glm::vec3 b, glm::vec3 c, glm::vec3 d, glm::vec2 tca, glm::vec2 tcb, glm::vec2 tcc, glm::vec2 tcd) { m_vertices.push_back( glm::vec4(a, 1.0f)); m_vertices.push_back( glm::vec4(b, 1.0f)); m_vertices.push_back( glm::vec4(c, 1.0f)); m_vertices.push_back( glm::vec4(d, 1.0f)); glm::vec3 n = glm::normalize( glm::cross( b-a, c-a)); m_normals.push_back( n); m_normals.push_back( n); m_normals.push_back( n); m_normals.push_back( n); m_uvs.push_back( tca); m_uvs.push_back( tcb); m_uvs.push_back( tcc); m_uvs.push_back( tcd); m_points = 4; m_index.push_back( 0); m_index.push_back( 1); m_index.push_back( 2); m_index.push_back( 2); m_index.push_back( 3); m_index.push_back( 0); m_indices = 6; createBuffers(); }
void ParticleSystem::setBufferSize(uint32 size) { if (size == 0 || size > MAX_PARTICLES) throw love::Exception("Invalid buffer size"); deleteBuffers(); createBuffers(size); reset(); }
void MyGLWidget::initializeGL () { // Cal inicialitzar l'ús de les funcions d'OpenGL initializeOpenGLFunctions(); glClearColor(0.5, 0.7, 1.0, 1.0); // defineix color de fons (d'esborrat) carregaShaders(); createBuffers(); }
void MyGLWidget::initializeGL () { // glew és necessari per cridar funcions de les darreres versions d'OpenGL glewExperimental = GL_TRUE; glewInit(); glGetError(); // Reinicia la variable d'error d'OpenGL glClearColor (0.5, 0.7, 1.0, 1.0); // defineix color de fons (d'esborrat) createBuffers(); }
void D3D10App::onSize(const int w, const int h){ BaseApp::onSize(w, h); if (device != NULL){ deleteBuffers(); swapChain->ResizeBuffers(1, width, height, backBufferFormat, 0); createBuffers(); ((Direct3D10Renderer *) renderer)->setFrameBuffer(backBufferRTV, depthBufferDSV); } }
void Mesh::initStrip(GLuint shader, GLuint w, GLuint h, const glm::vec3 *verts, const glm::vec3 *norms) { assert(w > 1 && h > 1); m_w = w; m_h = h; setMappings(); GLuint memsize = m_mappingSize * 8 * sizeof(float); createBuffers(shader, memsize); setVerts(verts, norms); }
void validate() { if(!invalid) return; if(!vertexBuffer || !indexBuffer) createBuffers(); sendVertices(); sendIndices(); invalid = false; }
void D3D11App::onSize(const int w, const int h) { BaseApp::onSize(w, h); if (device != NULL) { const bool sampleBackBuffer = (backBufferTexture != TEXTURE_NONE); deleteBuffers(); HRESULT hr = swapChain->ResizeBuffers(1, width, height, backBufferFormat, 0); createBuffers(sampleBackBuffer); } }
void MyGLWidget::initializeGL () { // glew és necessari per cridar funcions de les darreres versions d'OpenGL glewExperimental = GL_TRUE; glewInit(); glGetError(); // Reinicia la variable d'error d'OpenGL glClearColor (0.5, 0.7, 1.0, 1.0); // defineix color de fons (d'esborrat) glEnable(GL_DEPTH_TEST); carregaShaders(); createBuffers(); projectTransform(); viewTransform(); }
/** Constructor from vector of MeshVertex and triangles @param[in] vertices a list of the vertices @param[in] triangles a list of the triangles with indexed vertices */ Mesh::Mesh(vector<MeshVertex> vertices, vector<unsigned short> triangles) : mvbo{0}, vao{0}, ibo{0}, scaleFactor{1} { meshVertices = std::move(vertices); this->triangles = std::move(triangles); #ifdef GUINITY_DEBUG nCount++; #endif createBuffers(); }
GPUParticle::GPUParticle(unsigned int MAX) { //GPU Stuff uiMaxParticles = MAX; gpParticles = new GPUParticleS[ uiMaxParticles ]; uivao[0] = 0; uivao[1] = 0; uivbo[0] = 0; uivbo[1] = 0; uiActiveBuffer = 0; uiOtherBuffer = 0; createBuffers(); createUpdateShader(); createDrawShader(); setTextureID(0); }
//-------------------------------------------------------------- // reset the display void mgDX9Display::displayReset() { mgDebug("reset display"); // reset the D3D Device, losing all graphics state deleteBuffers(); // set current size of window m_state->m_presentParms.BackBufferWidth = m_graphicsWidth; m_state->m_presentParms.BackBufferHeight = m_graphicsHeight; HRESULT hr = mg_d3dDevice->Reset(&m_state->m_presentParms); if (hr == S_OK) createBuffers(); }
bool DX9Renderer::DX9PrepareBuffers(const Group& group) { if (!checkBuffers(group)) { if (isBuffersCreationEnabled()) { destroyBuffers(group); createBuffers(group); return true; } return false; } return true; }
bool LppRenderer::initialize( int width, int height ) { assert(!_initialized && width>0 && height>0); _width = width; _height = height; bool success = true; if( !createBuffers() ) { success = false; } _initialized = success; return success; }
void ShadingBufferSet::initialize(int width, int height, gl::Texture& depth_tex) { std::array<BufferSpec, 2> buffers = {{ // tex internal_format format type attachment {&depth_tex, 0, 0, 0, GL_DEPTH_ATTACHMENT}, {&accum_tex, GL_R11F_G11F_B10F, GL_RGBA, GL_FLOAT, GL_COLOR_ATTACHMENT0} }}; createBuffers(width, height, &buffers[1], 1); attachBuffers(fbo, buffers.data(), buffers.size()); static const GLenum render_targets[1] = { GL_COLOR_ATTACHMENT0 }; glDrawBuffers(1, render_targets); }
OBJModel::OBJModel(const QString& path) { const std::string tmpPath = path.toStdString(); const char* c_path = tmpPath.c_str(); mesh_loader_result_t result = NewMeshFromOBJFile(c_path); if (result.status == MESH_LOADER_SUCCESS) { qDebug() << "Loaded Mesh!"; createBuffers(&result.mesh); } else { qDebug() << "Error loading mesh:" << result.status; } DeleteMesh(&result.mesh); }
void StereoAutoFocuser::autoFocus( CameraStereo *cam, const Area &area, GLuint buffer ) { if( ! cam->isStereoEnabled() ) return; // create or resize buffers createBuffers( area ); // blit (multi-sampled) depth buffer to (non-multi-sampled) auto focus fbo // (they need to be the same size for this to work!) { SaveFramebufferBinding saveFboBinding; Area dstArea = mFboLarge.getBounds(); glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, buffer ); glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, mFboLarge.getId() ); glBlitFramebufferEXT( area.getX1(), area.getY1(), area.getX2(), area.getY2(), dstArea.getX1(), dstArea.getY1(), dstArea.getX2(), dstArea.getY2(), GL_DEPTH_BUFFER_BIT, GL_NEAREST ); } // create a downsampled copy for the auto focus test mFboLarge.blitTo( mFboSmall, mFboLarge.getBounds(), mFboSmall.getBounds(), GL_NEAREST, GL_DEPTH_BUFFER_BIT ); // load depth samples into buffer glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, mFboSmall.getId() ); glReadPixels(0, 0, AF_WIDTH, AF_HEIGHT, GL_DEPTH_COMPONENT, GL_FLOAT, &mBuffer.front()); mFboSmall.unbindFramebuffer(); // find minimum value std::vector<GLfloat>::const_iterator itr = std::min_element(mBuffer.begin(), mBuffer.end()); size_t p = itr - mBuffer.begin(); mNearest.x = 0.5f + (int) ( (p % AF_WIDTH) / (float) AF_WIDTH * mArea.getWidth() ); mNearest.y = 0.5f + (int) ( (p / AF_WIDTH) / (float) AF_HEIGHT * mArea.getHeight() ); // convert to actual distance from camera float nearClip = cam->getNearClip(); float farClip = cam->getFarClip(); float depth = 2.0f * (*itr) - 1.0f; mNearest.z = 2.0f * nearClip * farClip / ( farClip + nearClip - depth * ( farClip - nearClip ) ); // perform auto focussing float z = math<float>::max( nearClip, mNearest.z * mDepth ); cam->setConvergence( cam->getConvergence() + mSpeed * ( z - cam->getConvergence() ), true ); }
void ChunkBase::generateVertices() { if (mIsModified) { if (mVertices != 0) { delete mVertices; mVertices = 0; } if (mIndices != 0) { delete mIndices; mIndices = 0; } std::vector<CubeFace*> visFaces; visFaces.reserve(DefaultFaces); getVisibleFaces(visFaces); uint32_t nFaces = static_cast<uint32_t> (visFaces.size()); if (nFaces == 0) { isEmpty = true; return; } isEmpty = false; createBuffers(nFaces); uint32_t vBufIndex = 0; uint32_t iBufIndex = 0; uint32_t curVertex = 0; while (!visFaces.empty()) { CubeFace* curFace = visFaces.back(); visFaces.pop_back(); writeFaceVertices(curFace, &mVertices[vBufIndex]); writeFaceIndices(curVertex, &mIndices[iBufIndex]); vBufIndex += VertexSize * 4; curVertex += 4; iBufIndex += 6; delete curFace; } mIsModified = false; } }
void GBufferSet::initialize(int width, int height) { std::array<BufferSpec, 3> buffers = {{ // tex internal_format format type attachment {&depth_tex, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH_STENCIL_ATTACHMENT}, {&diffuse_tex, GL_SRGB8_ALPHA8, GL_RGBA, GL_FLOAT, GL_COLOR_ATTACHMENT0}, {&normal_tex, GL_RGB10_A2, GL_RGBA, GL_FLOAT, GL_COLOR_ATTACHMENT1} }}; createBuffers(width, height, buffers.data(), buffers.size()); attachBuffers(fbo, buffers.data(), buffers.size()); static const GLenum render_targets[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; glDrawBuffers(2, render_targets); }
HRESULT MeshGroup::createDeviceStuffs(ID3D11Device* device) { HRESULT hr = S_OK; hr = createBuffers(device); if (FAILED(hr)) return hr; ShaderManager shaderManager = ShaderManager::sharedShaderManager(); for (auto kv : materials) { MeshMaterial *material = kv.second; if (material->hasTexture) { material->pixelShader = shaderManager.pixelShaderForTexture(device); } else { material->pixelShader = shaderManager.pixelShaderForNoTexture(device); } } }
void CVK::Sphere::create( glm::vec3 center, float radius, int resolution) { // iniatialize the variable we are going to use float u, v; float phi, theta; float x, y, z; int offset = 0, i, j; // create points for ( j = 0; j <= resolution; j++) //theta for ( i = 0; i <= resolution; i++) //phi { u = i /(float)resolution; phi = 2* glm::pi<float>() * u; v = j /(float)resolution; theta = glm::pi<float>() * v; x = m_Center.x + radius * sin(theta) * sin(phi); y = m_Center.y + radius * cos(theta); z = m_Center.z + radius * sin(theta) * cos(phi); m_vertices.push_back(glm::vec4( x, y, z, 1.0f)); m_normals.push_back(glm::vec3( x, y, z) / radius); m_uvs.push_back(glm::vec2( u, 1-v)); } m_points = m_vertices.size(); // create index list for ( j = 0; j < resolution; j++) { for ( i = 0; i < resolution; i++) { // 1. Triangle m_index.push_back( offset + i ); m_index.push_back( offset + i + resolution+1); m_index.push_back( offset + i + resolution+1 + 1); // 2. Triangle m_index.push_back( offset + i + resolution+1 + 1); m_index.push_back( offset + i + 1); m_index.push_back( offset + i ); } offset += resolution+1; } m_indices = m_index.size(); createBuffers(); }
bool PluginViewPrivate::resizeBuffers(NPSurfaceFormat format, int width, int height) { bool success = true; // If there is no buffer created, then try to create it. if (!m_pluginBufferSize.width() || !m_pluginBufferSize.height()) return createBuffers(format, width, height); if (!width || !height) return destroyBuffers(); PthreadMutexLocker backLock(&m_backBufferMutex); PthreadWriteLocker frontLock(&m_frontBufferRwLock); for (int i = 0; i < PLUGIN_BUFFERS && success; i++) { success &= BlackBerry::Platform::Graphics::reallocBuffer(m_pluginBuffers[i], BlackBerry::Platform::IntSize(width, height), toBufferType(format)); } if (success) { m_pluginBufferSize = IntSize(width, height); m_pluginBufferType = toBufferType(format); return true; } // Attempt to undo if we failed to get the new size/format. We can't guarantee // we will get it back though. if (!m_pluginBufferSize.width() || !m_pluginBufferSize.height()) { destroyBuffers(); return false; } bool undone = true; for (int i = 0; i < PLUGIN_BUFFERS; i++) { undone &= BlackBerry::Platform::Graphics::reallocBuffer(m_pluginBuffers[i], m_pluginBufferSize, m_pluginBufferType); } // If we fail to undo, delete the buffers altogether. if (!undone) destroyBuffers(); return false; }
void Terrain::create(ID3D11Device* device, ID3D11DeviceContext* deviceContext, const UINT width, const UINT depth) { m_width = width; m_depth = depth; m_heightmap.clear(); m_heightmap.resize((m_width + 1) * (m_depth + 1), 0); m_blendmap.texels.clear(); m_blendmap.texels.resize(m_width * m_depth, XMFLOAT4(0.f, 0.f, 0.f, 0.f)); m_blendmap.width = m_width; m_blendmap.height = m_depth; m_blendmap.colorType = PNG_COLOR_TYPE_RGB_ALPHA; m_blendmap.bitDepth = 8; createBuffers(device, deviceContext); }