• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

162 Neutral

About dachande

  • Rank
  1. Thanks for the suggestion, Doesn't seem to have cured the problem though... Any other possibilities? Thanks, Dach.
  2. Thanks, I should probably mention that these symptoms are occuring on a local network, as well as on localhost! Any suggestions? Dachande
  3. Hi all, I've come accross a problem that I can't seem to find any real logical explanation for... I have a client server application. The client sends a command to the server over a TCP connection, and the server sends back a 1 byte code to indicate success or failure. Both client and server are Select based and non blocking. The client performs this request 50-100 times, and for each, it waits for a response from the server before going on to the next. This is obvisouly not the most efficient method, however it is sometimes practical to do it this way, and it must therefore be workable, if less efficient. The problem I encounter is that this process works very quickly on some computers, and very slowly (up to ten times...) on others! I can't see any reason for the problem! All machines are running the same version of XP. Any ideas would be great, Thanks, Dachande
  4. Hi all, I have been working on shaders recently, and am trying to get normal mapping to work in a DX app. I've got a pretty basic shader that I've been using to implement the effect, but without much luck - so to see if it is the shader, or my app causing the problem, I have ported it in to nVidia's FX Composer, where I've got it working fine. I can only assume therefore, that the problem is down to what I'm inputting in to the vertex shader, and the most likely problem therefore is my Tangent generating code (of which I have two versions, that produce different results, put together using resources from different websites, including the infamous Terathon). My app is simply putting a single Triangle on to the screen, pointing at a forward facing camera (so the triangle normal is (0,0,-1)). My Tangent code is as follows (the Terathon version): /*Function takes triangle as 3 vertices, and the UV tex coords for each vertex (A,B,C)*/ D3DXVECTOR3 Tangent(D3DXVECTOR3 Tri[], float AU, float AV, float BU, float BV, float CU, float CV) { D3DXVECTOR3 Tangent; D3DXVECTOR3 SideA = Tri[1] - Tri[0]; D3DXVECTOR3 SideB = Tri[2] - Tri[0]; float s1 = BU - AU; float s2 = CU - AU; float t1 = BV - AV; float t2 = CV - AV; float r = 1.0F / (s1 * t2 - s2 * t1); D3DXVECTOR3 sdir((t2 * SideA.x - t1 * SideB.x) * r, (t2 * SideA.y - t1 * SideB.y) * r, (t2 * SideA.z - t1 * SideB.z) * r); D3DXVECTOR3 tdir((s1 * SideB.x - s2 * SideA.x) * r, (s1 * SideB.y - s2 * SideA.y) * r, (s1 * SideB.z - s2 * SideA.z) * r); const D3DXVECTOR3& n = Normal(Tri); const D3DXVECTOR3& t = sdir; // Gram-Schmidt orthogonalize Tangent = Normalize( (t - n * Dot(n, t)) ); return Tangent; } I would be extraordinarily grateful if someone could confirm that this is correct :) It generates a Tangent of (1,0,0) for a normal of (0,0,-1), with "standard" tex coords, 0,0 at top left, 1,1 at bottom right. Thanks in advance, Dach
  5. Yup, that looks good, standard C 'n everything. Shame about the two different methods on the two platforms though, but I can code around it ;) Thanks all that participated! Dach.
  6. Thanks Bakery21 / Evil Steve! I'll look up the fileno() function... You edited your post before I got to say anything ;) Dach.
  7. Thanks for the suggestion - only I've already done substantial development with file streams, chosen over low-level I/O mainly for their portability accross platforms! Bakery21: The information you have provided is totally correct (there are two levels of buffers, application buffers, and system/kernel buffers, fflush is for the application buffer as standard). Using FlushFileBuffers() is the same as using the "c" option in fopen(), however, these are Windows functions, and are not portable to Linux! I will suffice with the fflush / "c" option under Windows if I must, however, I'm now looking for a solution for Linux. fsync() will in theory acheive this, however, it works on file descriptors, not file streams, and I've not yet come accross a standard method for getting a descriptor from a stream (and some platforms may not provide such an option). Any ideas for ensuring a commit-to-disk under Linux?! Thanks! Dach.
  8. Hi, Aplogies if I'm wrong, but I still do not believe that fflush() by itself is enough to provide security in this matter ;) Unfortunately opening a file in notepad is no guarentee, it is however quite miss-leading in its conviction! Also from MSSN: Quote: If a program terminates abnormally, output buffers may not be flushed, resulting in loss of data. Use fflush or _flushall to ensure that the buffer associated with a specified file or all open buffers are flushed to the operating system, which can cache data before writing it to disk. The commit-to-disk feature ensures that the flushed buffer contents are not lost in the event of a system failure. There are two ways to commit buffer contents to disk: Link with the file COMMODE.OBJ to set a global commit flag. The default setting of the global flag is n, for "no-commit." Set the mode flag to c with fopen or _fdopen. Basically.. using the "c" flag with fopen() will ensure that fflsuh() works as desired in a Windows environment - but this is not a standard flag available on Linux! I'm hoping to find an ideal solution that will write to disk after an fwrite(), without having to use fflush(). Thanks again! Dach.
  9. Hi, Thanks for your reply... I'm not certain fflush will work though... fflush will flush the system buffer in to a "kernel based" buffer under Window's / Linux's control - I'm not convinced that it will give absolute security that data has been committed to disk? Thanks! Dach.
  10. Hi, I'm looking to make sure that data I write to a file (using fwrite()) is committed to the disk immediately, so that I can be sure, so long as the call returns, that the data I have written will exist on the disk after a system crash... This is with c++, and in regards to both Windows and Linux... I'm using "setvbuf(pFile, NULL, _IONBF, 0)" to set the IO mode to unbuffered, but I'm not convinced this will do the trick! I've also looked at the MSDN docs for FlushFileBuffers(), and the Linux docs for fsync(), but still can not be totally certain by the vague descriptions, that no buffering will take place within the kernel or similar... I'm looking for reassurance, or for the appropriate methods to achieve this non buffered, guarenteed IO! Any assistance would be much appreciated, thanks, Dach.
  11. Shader Tuts

    Thanks again ;) I've got it going now. I checked out the asm code my HLSL was producing, and I think I was prolly optimising out a texture or something ;) Not sure about this still though: sampler TextureSampler = sampler_state { texture = <diffuseTexture>; AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = LINEAR; MINFILTER = LINEAR; MAGFILTER = LINEAR; }; How does "texture = <diffuseTexture>;" relate to the rest of the world? The samplers map to the texture stages in the order they are decalered, as far as I am aware... Any more info? :D Thank you, Dachande
  12. Shader Tuts

    Thanks all for your helpful replies :) I've been through all the links, I've used RenderMonkey and FXComposer, and downloaded all sorts of example code... but I still have found no clear explanation of using multiple textures (this is not my only hangup, but it is a big one!). Sampler objects and texture objects are often declared, but not referenced again until a call to tex2d(sampler, coords) etc... There is no clear link between the sampler, and which texture it connects to - as far as I can see. basically (pseudoish!): sampler ASampler; sampler BSampler; float4 PSmain(float2 tex : TEXCOORD0, float2 tex2 : TEXCOORD1) : COLOR { float2 ACol = tex2d(ASampler, tex); float2 BCol = tex2d(BSampler, tex2); } I see no link between samplers and textures! I'm totally open to the possibility that I'm being dumb... BUT I know that this stuff simply isn't documented to a satisfactory mannor in the docs! Generally I'm not too bad at this stuff, but I get hung up on details that I don't understand :D Can anyone shed some light? Thanks, Dachande
  13. Shader Tuts

    Evenin' all, I've been searching for some good HLSL material for a while now, and I'm coming up with nothing... Very surprising how the Internet seems to have so little information on the subject!! The book shader X2 seems to be quite popular, but I'd like to learn more with some free tutorials before I go splashing out on books...! In particular, I'm looking at multitexturing. I have both a vertex and a pixel shader working fine... only they are as simple as they get... but my attempt at multitexturing is failing... Much to my dissapointment, the texture object and sampler object is VERY poorly documented! I haven't yet figured them our properly. Any help with my troubles would be much appreciated! Some advice, or leeds on where to get some info would be great. Thanks in advance, Dachande
  14. HLSL Texturing? (Simple)

    Thank you kindly :) The texture now displays. I guess the default diffuse colour is black, which makes sense. Can I set a colour outside of the shader, or is it a requirement to specify this when wanting to use textures? I'm pretty sure this is a stupid question... but I'm new to shaders, so I'll bask in my naivety! Thanks, Dachande
  15. Hey, I'm using HLSL to create a verrrry simple vertex shader, simply to replace the FFP when drawing a simple triangle... I have position data and texture coord data... the position data is working fine... but my triangles appear black! The FFP version is texturing fine, the the shader fails to do so... The code is as follows: float4x4 matWorldViewProj : WORLDVIEWPROJECTION; struct CIn { float4 Position : POSITION; float2 Texcoord : TEXCOORD0; }; struct COut { float4 Position : POSITION; float2 Texcoord : TEXCOORD0; }; COut main( CIn IN) { COut OUT; OUT.Position = mul(IN.Position, matWorldViewProj); OUT.Texcoord = IN.Texcoord; return OUT; } Any ideas as to why the texture won't show would be much appreaciated! Thanks in advance, Dachande
  • Advertisement