• Advertisement

lonewolff

Member
  • Content count

    1242
  • Joined

  • Last visited

Community Reputation

1195 Excellent

About lonewolff

  • Rank
    Contributor

Personal Information

  • Interests
    Art
    Audio
    Design
    Programming

Recent Profile Visitors

16016 profile views
  1. C++ Problems with shift left (<<)

    Thanks JoeJ, Yep, it was the signed / unsigned thing that was tripping me up in the end. Thanks to everyone for the help
  2. C++ Problems with shift left (<<)

    Oh, you are right. Turns out I was thinking backwards. I wanted to shift right. But by shifting right using the code in my OP, I am still getting FF. So I am not sure what is happening there.
  3. Hi guys, I am having problems with trying to perform a basic 'shift left' on a char. char temp[1]; temp[0] = buffer[0] << 1; // buffer[0] is 0xff After this I have temp[0] writing to a file. Instead of being the expected 0x7F it is written as 0xF8. Any guidance on what I am doing wrong would be awesome. Thanks in advance
  4. C++ std::thread question

    Ah, so simple Thanks for helping me out @DerekB
  5. Hi guys, Is there a way to setup a thread as a global, but fire off the execution of the thread elsewhere in the program? If I have something like this it throws an error - "term does not evaluate to a function taking 1 arguments" std::thread t1; t1(someFn); Any help would be greatly appreciated
  6. LOL, you make it look so easy. Can't thank you enough dude
  7. Cool, thanks for that. How would you go about re-normalising as above? From the diagram, how would you work out where the height of the red area should be?
  8. @dietrich Arggh! Turns out I was working with a screwy model. I have enabled backface culling and all is now great. A huge thanks to you though, I have learned a lot today!
  9. Oddly enough, the result is the same.
  10. Yes, I believe so. I am setting it as in identity matrix and am not applying any translations.
  11. Thanks for the replies guys. @dietrich- Right you are! I have moved the light into view space and taken away attenuation for the time being to turn it in to a directional light only. Things are looking better, but still some anomalies. The only thing I can see is that the light position is off on the z-axis. Sphere is at 0,0,0 light is at -5, 2, 5 camera is at 0, 0, -5 Going by this, the light should be behind the object, not in front. Does this give a hint at any calculation I may have missed? Here is the shader in its current form. attribute vec3 in_Position; attribute vec3 in_Normal; attribute vec4 in_Colour; varying vec3 v_Position; varying vec3 v_Normal; varying vec4 v_Colour; varying vec3 v_LightPos; uniform vec3 u_LightPos; uniform mat4 worldMatrix; uniform mat4 viewMatrix; uniform mat4 projectionMatrix; void main() { vec4 object_space_pos = vec4(in_Position, 1.0); gl_Position = worldMatrix * vec4(in_Position, 1.0); gl_Position = viewMatrix * gl_Position; gl_Position = projectionMatrix * gl_Position; mat4 WV = worldMatrix * viewMatrix; v_Position = vec3(WV * object_space_pos); v_Normal = vec3(WV * vec4(in_Normal, 0.0)); v_Colour = in_Colour; vec4 object_space_light = vec4(u_LightPos, 1.0); v_LightPos = vec3(WV * object_space_light); } and varying vec3 v_Position; varying vec3 v_Normal; varying vec4 v_Colour; varying vec3 v_LightPos; void main() { float dist = length(v_LightPos - v_Position); vec3 lightVector = normalize(v_LightPos - v_Position); float diffuse_light = max(dot(v_Normal, lightVector), 0.1); // diffuse_light = diffuse_light * (1.0 / (1.0 + (0.0000001 * dist * dist))); // gl_FragColor = v_Colour * diffuse_light; gl_FragColor = vec4(v_Colour.rgb * diffuse_light, v_Colour.a); } Thanks again, this is hugely appreciated
  12. Hi Guys, I have been struggling for a number of hours trying to make a directional (per fragment) lighting shader. I have been following this tutorial in the 'per fragment' section of the page - http://www.learnopengles.com/tag/per-vertex-lighting/ along with tutorials from other sites. This is what I have at this point. // Vertex shader varying vec3 v_Normal; varying vec4 v_Colour; varying vec3 v_LightPos; uniform vec3 u_LightPos; uniform mat4 worldMatrix; uniform mat4 viewMatrix; uniform mat4 projectionMatrix; void main() { vec4 object_space_pos = vec4(in_Position, 1.0); gl_Position = worldMatrix * vec4(in_Position, 1.0); gl_Position = viewMatrix * gl_Position; // WV gl_Position = projectionMatrix * gl_Position; mat4 WV = worldMatrix * viewMatrix; v_Position = vec3(WV * object_space_pos); v_Normal = vec3(WV * vec4(in_Normal, 0.0)); v_Colour = in_Colour; v_LightPos = u_LightPos; } And // Fragment varying vec3 v_Position; varying vec3 v_Normal; varying vec4 v_Colour; varying vec3 v_LightPos; void main() { float dist = length(v_LightPos - v_Position); vec3 lightVector = normalize(v_LightPos - v_Position); float diffuse_light = max(dot(v_Normal, lightVector), 0.1); diffuse_light = diffuse_light * (1.0 / (1.0 + (0.25 * dist * dist))); gl_FragColor = v_Colour * diffuse_light; } If I change the last line of the fragment shader to 'gl_FragColor = v_Colour;' the model (a white sphere) will render to the screen in solid white, as expected. But if I leave the shader as is above, the object is invisible. I am suspecting that it is something to do with this line in the vertex shader, but am at a loss as to what is wrong. v_Position = vec3(WV * object_space_pos); If I comment the above line out, I get some sort of shading going on which looks like it is trying to light the subject (with the normals calculating etc.) Any help would be hugely appreciated. Thanks in advance
  13. C++ Get HWND of another application

    Correct. In my case I know what the window title will be on every occasion (even if it changes). So this method works out well for me.
  14. C++ Get HWND of another application

    Anyway, worked it out. Thanks FindWindow(NULL, "Untitled - Notepad");
  15. C++ Get HWND of another application

    Yes, I did do a google search, thanks Isn't this talking about getting the window 'host' applications though? In your example, the OP is talking about an application that is using his own DLL in it. If I were to get the HWND of something like notepad.exe how would I go about that?
  • Advertisement