• Content count

  • Joined

  • Last visited

Community Reputation

130 Neutral

About sjf

  • Rank
  1. Quote:Original post by Anonymous Poster Is this going to be speed bowling? The sound should last like 1/10th of a second for something like that, if another ball can hit the same pin, WOW! Who said anything 'bout another ball??? The ball could rebound and hit the same pin etc... And that was just a bad example! However, the question REMAINS.
  2. Hi guys, Hopefully a quick question, after I start playing a sound effect with OpenAL via a buffered source, how can I check if the sound is still playing? I am NOT wanting to LOOP the sound effect! For example, when a bowling ball hits a ten pin, I want to trigger a sound effect (easy and done), but if the ball hits to SAME pin again while the sound effect is still playing, I want to check the status of the source. How? TIA [Edited by - sjf on August 21, 2006 11:08:36 PM]
  3. I agree, try clamping the edge of the textures just by using the extension GL_CLAMP_EDGE_EXT or somesuch...
  4. True, but I'm asking here. More active community et al. Get an answer faster etc... [Edited by - sjf on June 17, 2006 9:04:14 PM]
  5. Hi guys, I’d like to implement soft shadowing for spheres in real-time. After going through the maths of Humus’ sample ( I finally understand his shadow shader and would now like to implement it – cut ‘n’ paste or by other means I don’t mind. However I’m having a very hard time trying to extract the key opengl ingredients/api-calls, and in their correct order, from his rather neat framework (2). Here are Humus’ functions of interest RE: the sphere shadows: bool MainApp::drawFrame() { renderer->changeMask(ALL); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // added GL_COLOR_BUFFER_BIT ... // Pass 0, ambient lighting + depth drawRoom(0); // Pass 1, shadows vec4 spherePos[SPHERE_COUNT]; for (unsigned int j = 0; j < SPHERE_COUNT; j++){ spherePos[j] = vec4(spheres[j].pos, spheres[j].size * spheres[j].size); } renderer->setShader(shadow); renderer->setMask(ALPHA); renderer->apply(); renderer->changeShaderConstant3f("lightPos", spheres[SPHERE_COUNT].pos); renderer->changeShaderConstantArray4f("spherePos", spherePos, SPHERE_COUNT); drawRoom(1); // Pass 2, lighting drawRoom(2); return true; } void MainApp::drawRoom(int pass){ ... glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vertexArray); if (pass != 1){ glEnableVertexAttribArrayARB(1); glVertexAttribPointerARB(1, 2, GL_FLOAT, GL_FALSE, 0, texCoordArray); if (pass != 0){ glEnableVertexAttribArrayARB(2); glEnableVertexAttribArrayARB(3); glEnableVertexAttribArrayARB(4); glVertexAttribPointerARB(2, 3, GL_FLOAT, GL_FALSE, 0, tangentArray); glVertexAttribPointerARB(3, 3, GL_FLOAT, GL_FALSE, 0, binormalArray); glVertexAttribPointerARB(4, 3, GL_FLOAT, GL_FALSE, 0, normalArray); } } if (pass == 1){ glDrawArrays(GL_QUADS, 0, 24); } else { static int n[] = { 2, 1, 0, 0, 0, 0 }; for (int i = 0; i < 1; i++){ // changed from “< 6" if (pass == 0){ renderer->setShader(roomAmbient); renderer->setTexture("Base", base[n[i]]); renderer->apply(); } else { renderer->setShader(room); renderer->setTexture("Base", base[n[i]]); renderer->setTexture("Bump", bump[n[i]]); renderer->setBlending(DST_ALPHA, ONE); renderer->setMask(COLOR); renderer->apply(); renderer->changeShaderConstant3f("lightPos", spheres[SPHERE_COUNT].pos); renderer->changeShaderConstant3f("camPos", position); } glDrawArrays(GL_QUADS, 4 * i, 4); } } if (pass != 1){ if (pass != 0){ glDisableVertexAttribArrayARB(4); glDisableVertexAttribArrayARB(3); glDisableVertexAttribArrayARB(2); } glDisableVertexAttribArrayARB(1); } glDisableClientState(GL_VERTEX_ARRAY); } In an effort at keeping it simple, the following is my humble attempt. And all I get to see is a RED quad for all my effort. :) void RenderFloor(const light& point_source) { static vertex quad1[4] = { // x y z { -15.0f, 0.0f, -15.0f }, { -15.0f, 0.0f, 15.0f }, { 15.0f, 0.0f, -15.0f }, { 15.0f, 0.0f, 15.0f } }; static texture_normal_vertex quad2[4] = { // tu tv nx ny nz x y z { 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -15.0f, 0.0f, -15.0f }, { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, -15.0f, 0.0f, 15.0f }, { 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 15.0f, 0.0f, -15.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 15.0f, 0.0f, 15.0f } }; glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // Test color glInterleavedArrays(GL_V3F, 0, quad1); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); float sphere_position[MAX_SPHERES][4]; for (int i = 0; i < MAX_SPHERES; ++i) { sphere_position[i][x] = spheres[i].position[x]; sphere_position[i][y] = spheres[i].position[y]; sphere_position[i][z] = spheres[i].position[z]; sphere_position[i][w] = spheres[i].size * spheres[i].size; char str[32]; sprintf(str, "sphere_position[%d]", i); shadows.Bind(str, sphere_position[i], 4); } shadows.Bind("light_position", point_source.position, 3); // “shadows" is my shader object. glDepthMask(GL_FALSE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); glInterleavedArrays(GL_V3F, 0, quad1); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); shadows.Disable(); glEnable(GL_BLEND); glBlendFunc(GL_DST_ALPHA, GL_ONE); glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // Test color glInterleavedArrays(GL_V3F, 0, quad1); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisable(GL_BLEND); glDepthMask(GL_TRUE); return; } Anyone have any tips, comments or suggestions relating to where I’ve screwed up or how to better debug? I normally prefer to implement my shadows in a 2 pass system instead of the above 3. I just don’t want to see Humus’ sample go to waste! Thanks anyone. PS: I’m not quite up to the stage of pulling my hair out (yet).
  6. Where can I download GLUT?

    Try here at That's the one I use. And have always. You using windows or something else?
  7. OpenGL OpenGL 2 SDK

    Or try GLEW, HTH
  8. Thanks heaps everyone! Wudan, your snippet worked like a gem. A huge Thanks to you (++rating).
  9. So then how can I track the camera position when the mouse is moved?
  10. How do I determine the camera position when my scene is drawn from the following Point-of-view?: glLoadIdentity(); glTranslatef(0.0f, 0.0f, -20.0f); glRotatef(+g_mouse_z, 0.0f, 0.0f, 1.0f ); glRotatef(-g_mouse_y, 1.0f, 0.0f, 0.0f ); glRotatef(-g_mouse_x, 0.0f, 1.0f, 0.0f ); Th8ks peeps!
  11. Hey all, I’m trying to “turn off” active textures 0 and 1. I do the following to load them into a shader of mine: /* Load the cloud texture. */ glActiveTexture(GL_TEXTURE0 + 0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); glActiveTexture(GL_TEXTURE0 + 1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); But when I do the following later on, all hell breaks lose: glColor4f(0.0f, 1.0f, 0.0f, 1.0f); // This colour has no effect! /* Render the foreground. */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_floor); // This texture has no effect! RenderStuff(); glDisable(GL_TEXTURE_2D); I’ve traced the problem to not “turning off” my first set the textures “id_cloud”! ‘cos’ if I comment out enabling my cloud textures, everything works fine. So, in short, how do I disable what I have enabled?: /* Load the cloud texture. */ glActiveTexture(GL_TEXTURE0 + 0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); glActiveTexture(GL_TEXTURE0 + 1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); If further explanation is required, just ask. Thanks in advance!
  12. ASM - GLSL

    Paul, yours is also the same as:, which is based on the standard ACM cel/toon shader paper - I forget the author. Cheers
  13. ASM - GLSL

    Hey, Paul, "long time no see". And I think I copied it from someone who copied it from someone who copied it from a friend and so on... leading to you (I hope). Thanks anyway. Nice Demo too.
  14. Hi all, I’m trying to convert a few assembly vertex shaders to GLSL vertex shaders. And I am having a bit of a hard time doing so – but maybe it’s just late at night. Anyway, the following is one assembly vertex shader: !!ARBvp1.0 # Vertex Program for Cel shading # Constant Parameters PARAM mvp[4] = { state.matrix.mvp }; # modelview projection matrix PARAM lightPosition = program.env[0]; # Object space light position # Per-vertex inputs ATTRIB inPosition = vertex.position; # Position ATTRIB inColor = vertex.color; # Color ATTRIB inNormal = vertex.normal; # Normal # Temporaries TEMP lightVector; # Light vector TEMP normLightVector; # Normalized light vector # Outputs OUTPUT outPosition = result.position; # Position OUTPUT outColor = result.color; # Primary color OUTPUT outTexture = result.texcoord[0]; # Texture coordinate set 0 # Output position DP4 outPosition.x, mvp[0], inPosition; DP4 outPosition.y, mvp[1], inPosition; DP4 outPosition.z, mvp[2], inPosition; DP4 outPosition.w, mvp[3], inPosition; MOV outColor, inColor; # Output color SUB lightVector, lightPosition, inPosition; # Calculate light vector # Normalize light vector DP3 normLightVector.w, lightVector, lightVector; RSQ normLightVector.w, normLightVector.w; MUL, normLightVector.w, lightVector; DP3 outTexture.x, normLightVector, inNormal; # Dot light vector with normal END And here was my attempt to convert it to GLSL: uniform vec4 light_position; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; vec4 light_vector = light_position - gl_Position; vec4 normal_light_vector; normal_light_vector.w = dot(light_vector, light_vector); normal_light_vector.w = inversesqrt(normal_light_vector.w); = normal_light_vector.w *; gl_TexCoord[0].x = dot(, gl_Normal); } While it compiles without error, all I see is a completely BLACK model/rendering. What have I missed? Thanks everyone! EDIT: fixed source tags. [Edited by - sjf on April 8, 2006 6:22:38 AM]