Jump to content
  • Advertisement

gondoo

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

104 Neutral

About gondoo

  • Rank
    Newbie
  1. I solved it. Everything was alright. I was missing a "var" where the materials are added. Just in case somebody downloaded the code.  for( *here* mat in mesh.materials){ var material = mesh.materials[mat]; var prog = LoadShaderProgram(gl,material.vertexShader, material.fragmentShader, function(prog){that.ProgramLoaded(gl,prog);}); mesh.materialsToLoad = mesh.materials.length; mesh.programs.push(prog); //return true; }
  2. Nevermind. The answer is no, and apparently an obvious no.
  3. Newbie question   If I use different shader programs for two different meshes within the same frame of the loop, would one of the objects disappear? My loop works like this:    - Scene.Draw()   - object.draw()   - object.draw() - Loop!   I'm calling gl.useProgram() on each object.draw() too. I'm guessing it's a lot more optimal using the same shader program when possible. 
  4.     Thanks for the answer, I was afraid it was too much code, but I've added both javascript files. I've removed the matrix libs to make everything shorter. ForgeApp, is where I preload everything, and the ForgeSDK is where the API is.   ForgeSDK: https://dl.dropboxusercontent.com/u/23066256/ForgeSDK.js ForgeApp: https://dl.dropboxusercontent.com/u/23066256/ForgeApp.js   I have a feeling it's something right beneath my nose, and I can't see it. 
  5. If I've added this thread to the wrong forum category, my apologies, I'm new here and to WebGL   My problem is hopefully simple. I'm able to render several amounts of the same mesh, but when I try adding a different one: webGL only draws one object. Again, I could for loop and create 100 of the same mesh and put them in different positions, scales, and no problem. But if I try adding one more mesh, it draws the "first one" I called:   meshA = new Mesh(); <--- this one meshB = new Mesh();   In fact, I could switch them over, and it would draw a different mesh, as long as it's the first one.   I'll post some psuedo code in order to visualize the anatomy of my application, but if it's too much, I'll try to make a list here.    Anatomy (no libs):    1) Engine Starts after Body.onload, and I create 2 meshes, I also create two Object3D objects. Which are pretty much like GameObjects in Unity.    Once images, sounds, etc are loaded, a callback is fired :  2) Load3DObjects(): I set the viewport,clearColor,enable both cull_face and depth_test. Now I Load Shaders: 3)LoadShader():   - gl.createProgram()   - compile   - link   - fire ProgramLoaded callback function on the mesh   4) mesh.ProgramLoaded():     - Set Uniforms and Attributes: getUniformLocation, getAttribLocation     - gl.enableVertexAttribArray(program.vertexPosAttribute);      gl.enableVertexAttribArray(program.colorPosAttribute);   - Once all Materials are loaded, fire CreateGLBuffers();   5) CreateGLBuffers():          I for loop through all the Object3D and run the following code:        _mesh.vertexPosBuffer = gl.createBuffer();     gl.bindBuffer(gl.ARRAY_BUFFER, _mesh.vertexPosBuffer);     gl.bufferData(gl.ARRAY_BUFFER, _mesh.meshVertices, gl.DYNAMIC_DRAW);      _mesh.colorPosBuffer = gl.createBuffer();    gl.bindBuffer(gl.ARRAY_BUFFER,_mesh.colorPosBuffer);    gl.bufferData(gl.ARRAY_BUFFER,_mesh.colorVertices, gl.DYNAMIC_DRAW);      - I create a new Node, which has a children array that holds other nodes.These nodes      also have a Draw Function which calls its children's draw function as well.        - I create a new Geometry Node, holds a mesh object. The geometry node also has a      a Draw Function, which really callls the Meshes Draw function.     - I create yet another Node and add it to an array called sceneChildren    - and that array I add to yet another new Node I create for the scene:       var geometry = new Node([new Goemetry(_mesh)]);     geometry.name = "Geometry Node";     sceneChildren[sceneChildren.length] = new Node([geometry]);   (outside of the for loop): scene = new Node(scenChildren);   RUN_GAME_LOOP!   In render, I draw the scene.    Here's some pseudocode just in case: http://pastebin.com/prHRYxxW   Thank very much  in advance. Hopefully this wasn't too long.           
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!