Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
WebGL (1.0). Using multiple programs to render both a 3D object and a small drawing application

We are currently working on a project, which requires us to render a 3D object and a small drawing application next to each other. We are drawing them in the same canvas and use viewport and scissor to give them their separate area. So far, we have managed to render both, but our drawing application does not draw the points that are put into the buffer (it works when used on it's own).

We are currently using the approach described in the WebGL fundamentals guide: https://webglfundamentals.org/webgl/lessons/webgl-drawing-multiple-things.html

At Init time:

  • create all shaders and programs and look up locations.
  • create buffers and upload vertex data.
  • create textures and upload texture data.

At Render Time

  • clear and set the viewport and other global state (enable depth testing, turn on culling, etc..)
  • For each thing you want to draw
    • call gl.useProgram for the program needed to draw.
    • setup attributes for the thing you want to draw
      • for each attribute call gl.bindBuffer, gl.vertexAttribPointer, gl.enableVertexAttribArray
    • setup uniforms for the thing you want to draw
      • call gl.uniformXXX for each uniform
      • call gl.activeTexture and gl.bindTexture to assign textures to texture units.
    • call gl.drawArrays or gl.drawElements

In the pseudo implementation as seen below, the clicks in the drawing application (event handler not shown, but working) are registered and put into the buffer (the program used at this time is the correct one and the correct buffer is bound before the subdata is added), but when we reach the point of rendering, the points ect. are not appearing?

function render(){
  switchProgram()
  render3Dobject()

  switchProgram()
  renderDrawingApplication()
}

function switchProgram(){
  gl.enable(gl.SCISSOR_TEST);
  
  // Set viewport and scissor. 

  // Bind buffer
  // Set vertexAttributePointer
  // EnableVertexAttributeArray

  // Setup uniform textures. 

}

function render3Dobject(){
  // Handle rotation, matrices ect. 
  // Draw object using DrawElements. 
}

function renderDrawingApplication(){
  // Draw all points and objects from drawing program using drawArrays. 
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda