Jump to content
  • Advertisement

foursticksj

Member
  • Content Count

    18
  • Joined

  • Last visited

Community Reputation

100 Neutral

About foursticksj

  • Rank
    Member
  1. [font="arial, verdana, tahoma, sans-serif"] I've been developing a GUI system for a while now using Direct X and C++. I started out using DXUT's GUI, but I wanted to implement my own images and sound effects, and I thought it would be good programming experience. So far, I've made a button, slider, and check-box control, and an animated cursor. The last control I want to add for now is the text-box. I haven't even started the implementation yet since I see a few problems that I want to sort out first. [/font] [font="arial, verdana, tahoma, sans-serif"] The first problem is determining the position of the caret when a user is typing or has clicked in front or behind a character in the text-box. Since I would like to work with fonts that have a variety of character widths, I am not sure how to go about setting the caret position. I am using the LPD3DXFONT interface for creating and drawing text. I have been able to find the average and greatest width of a character from any font using the TEXTMETRICA structure, but this does not really help me since I would need to know the width of every character the user enters. I don't have a problem with using a font which contains characters of equal width if all other options are too complicated, so this way I could do something like (text.size ()*charWidth+textbox.x), but even with Lucida Console, which I was pretty sure has equal character widths, reports to having very slight differences in average and largest character width. [/font] The second problem is in actually gathering the input from the keyboard and transferring it to the text-box. I can find out if any key is down using DirectInput, but this means of course I would have to poll every key twice, once with shift and once without. Is this necessary or is there an easier way of doing this? Making the text-box should be pretty straightforward if I can first get a solution to these problems. Any ideas?
  2. foursticksj

    Decompilers

    Thanks for the information. I just downloaded PE (portable executable) Explorer, which converts exe,dll,etc into assembly. Unfortunately, I have no clue how to read this. Is it at all possible to edit a specific line of code (such as assigning a string name) in the assembly code and recompile the exe? Is there a relatively easy method to finding a particular section of code?
  3. foursticksj

    Decompilers

    Quick question. I was wondering if there are any decompiler programs that could convert exe files into c++ code (for programs written with c++)? I know you can do this with dll files, but I am not sure about executables.
  4. foursticksj

    Need Very Small Random Numbers

    There's nothing wrong with your formula, the resulting numbers are correct on an even distribution. The reason you do not see numbers below 10^-3 is because the probability of those numbers being chosen is very low. For example, if you choose a number between 1 and 10^4, only 10% of numbers are below 10^3, 1% below 10^2, and .1% below 10^1. This means that in your example, there is only a 1% chance of getting a random number lower than 10^-3. If you want random numbers with each x in 10^x to have an equal probability of being chosen, try something like this, int exp = GET_RANDOM_INT (-67,-1); double prob = GET_RANDOM_DOUBLE (pow(10.0,exp-1),pow(10.0,exp)); //... // random number generators int GET_RANDOM_INT (int low, int high) { int r=0; int range=0; range = (high - low) + 1; r = low + (rand() % range); return r; } double GET_RANDOM_DOUBLE (double low, double high) { double r=0.0; double range=0.0; double deci=0.0; range = high - low; deci = (double)(rand ()) / (double)(RAND_MAX); r = low + (deci*range); return r; }
  5. foursticksj

    Primitive drawing

    The index is static, It is definitely increasing. The point I was trying to make was that if I put the z values of the triangle in between front and far view plane, nothing shows up on the screen. If I run the code as shown above, I get the screenshot as a result. I'm a bit confused on the exact values I should use for my settings. Which values should I use (for vertices, view, and projection) that I would know without a doubt that isn't the problem?
  6. foursticksj

    Primitive drawing

    I am trying to draw a rotating triangle using Direct X in the DXUT framework. I posted a question recently on this same subject drawing a 2D triangle, which would not show up on the screen. Now, using the untransformed vertices method, the 3D triangle again, will not get drawn to the screen. I did some troubleshooting, every function here gets called. Also, when I set the near view plane to the same value as the camera's Z coordinate, a wavering line appears in the middle of the screen (see screenshot). Other than that, the triangle never shows up. // FVF and vertex struct #define JGDK_BASICFVF (D3DFVF_XYZ | D3DFVF_DIFFUSE) struct JGDK_BASICVERTEX // USE JGDK_BASICFVF { FLOAT x, y, z; DWORD color; }; /* ........... */ // Init function bool GameApp::init (const WCHAR* title, HINSTANCE hInstance, bool isWindowed, int suggestedWidth, int suggestedHeight) { /* initialize app ................ */ // create vertices and vertex Buffer, and store the vertices in the buffer JGDK_BASICVERTEX vertices[] = { { 2.5f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 0.0f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), }, { -2.5f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; DXUTGetD3D9Device ()->CreateVertexBuffer(3*sizeof(JGDK_BASICVERTEX), 0, JGDK_BASICFVF, D3DPOOL_MANAGED, &m_vertexBuffer, NULL); VOID* pVoid; m_vertexBuffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); m_vertexBuffer->Unlock(); DXUTGetD3D9Device ()->SetRenderState(D3DRS_LIGHTING, FALSE); return true; } void GameApp::vOnFrameRender (void) { DXUTGetD3D9Device ()->BeginScene (); static float index = 0.0f; index+=0.05; // an ever-increasing float value DXUTGetD3D9Device ()->SetFVF(JGDK_BASICFVF); D3DXMATRIX matRotateY; D3DXMatrixRotationY(&matRotateY, index); DXUTGetD3D9Device ()->SetTransform(D3DTS_WORLD, &matRotateY); D3DXMATRIX matView; D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3 (0, 0.0f, 10.0f), &D3DXVECTOR3 (0.0f, 0.0f, 0.0f), &D3DXVECTOR3 (0.0f, 1.0f, 0.0f)); DXUTGetD3D9Device ()->SetTransform(D3DTS_VIEW, &matView); D3DXMATRIX matProjection; D3DXMatrixPerspectiveFovLH(&matProjection, D3DXToRadian(45), (FLOAT) 800 / (FLOAT)600, 10.0f, 100.0f); DXUTGetD3D9Device ()->SetTransform(D3DTS_PROJECTION, &matProjection); DXUTGetD3D9Device ()->SetStreamSource(0, m_vertexBuffer, 0, sizeof(JGDK_BASICVERTEX)); DXUTGetD3D9Device ()->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); g_HUD.OnRender( m_timer.getDelta ()); DXUTGetD3D9Device ()->EndScene (); // DXUT calls the device's Present () function after this callback is returned } I have tried moving the near view plane to 1.0f, as well as moving the camera closer. Nothing shows up unless the near view plane is set to the same value as the camera's Z coordinate, in which case I get a random flashing line like this:
  7. foursticksj

    Drawing Primitives with DXUT

    Hmm, nevermind. I forgot to remove the RHW
  8. foursticksj

    Drawing Primitives with DXUT

    Just out of curiosity, why would the triangle disapear when I add the z coordinate? I'm planning on just doing 2D stuff, but I might need to do some rotation. Is there some Z buffer function I need to call?
  9. foursticksj

    Drawing Primitives with DXUT

    Cool, I got it up. All I really had to do was change the z coordinated to 0s and you can see the triangle. Of course, this probably has to do with the way the camera was set up. Thanks for all the help
  10. foursticksj

    Drawing Primitives with DXUT

    DXUT does this automatically in its Render function after it calls the Callback function, which in this case is GameApp::vOnFrameRender().
  11. foursticksj

    Drawing Primitives with DXUT

    I don't think that is the problem. I set up the view and projection matrices and get the same result. I think I did it right, but here is the new code: void GameApp::vOnFrameRender (void) // render callback { DXUTGetD3D9Device ()->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); DXUTGetD3D9Device ()->BeginScene (); CUSTOMVERTEX vertices[] = { { 400.0f, 62.5f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 650.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), }, { 150.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; DXUTGetD3D9Device ()->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); DXUTGetD3D9Device ()->SetFVF(CUSTOMFVF); D3DXMATRIX matView; D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3 (0.0f, 0.0f, 10.0f), &D3DXVECTOR3 (0.0f, 0.0f, 0.0f), &D3DXVECTOR3 (0.0f, 1.0f, 0.0f)); DXUTGetD3D9Device ()->SetTransform(D3DTS_VIEW, &matView); D3DXMATRIX matProjection; D3DXMatrixPerspectiveFovLH(&matProjection, 0, (FLOAT) 800 / (FLOAT)600, 1.0f, 100.0f); DXUTGetD3D9Device ()->SetTransform(D3DTS_PROJECTION, &matProjection); DXUTGetD3D9Device ()->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); DXUTGetD3D9Device ()->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); DXUTGetD3D9Device ()->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); DXUTGetD3D9Device ()->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); g_HUD.OnRender( m_timer.getDelta ()); DXUTGetD3D9Device ()->EndScene(); // Release the vertex Buffer!! SAFE_RELEASE (v_buffer); } What should I try next?
  12. foursticksj

    Drawing Primitives with DXUT

    I know that each function gets called every frame. I can also draw sprites and lines (LPD3DXLINE) with no problems using DXUT. As for cleaning up the code and releasing pointers, I was going to do this after I got everything working. What other type of trouble-shooting should I try? I have not messed with the world, view and projection matrices. Does DXUT initialize the camera or screen somehow that I would not see the triangle?
  13. Has anyone had any problems drawing primitives using the DXUT framework? I have two programs that do exactly the same thing, drawing a triangle to the screen. One uses DXUT and the other does not. The program that does not use DXUT renders the triangle fine, while using DXUT nothing gets drawn. Not using DXUT: ------------------------------------------------------------------------------ void render() { d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); d3ddev->BeginScene(); // create the vertices using the CUSTOMVERTEX struct CUSTOMVERTEX vertices[] = { { 400.0f, 62.5f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 650.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), }, { 150.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; d3ddev->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); d3ddev->SetFVF(CUSTOMFVF); d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL); } ------------------------------------------------------------------------------ Using DXUT ------------------------------------------------------------------------------ void GameApp::vOnFrameRender (void) // render callback { DXUTGetD3D9Device ()->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); DXUTGetD3D9Device ()->BeginScene (); CUSTOMVERTEX vertices[] = { { 400.0f, 62.5f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), }, { 650.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), }, { 150.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), }, }; LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; DXUTGetD3D9Device ()->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &v_buffer, NULL); VOID* pVoid; v_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, vertices, sizeof(vertices)); v_buffer->Unlock(); DXUTGetD3D9Device ()->SetFVF(CUSTOMFVF); DXUTGetD3D9Device ()->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); DXUTGetD3D9Device ()->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); g_HUD.OnRender( m_timer.getDelta ()); DXUTGetD3D9Device ()->EndScene(); } ------------------------------------------------------------------------------ I know the verticies should be declared in a initialization function, Im just simplifying the code for now. Help with this would be greatly appreciated.
  14. I've been working on an interface for game controllers using Direct Input. I was just wondering if it is possible to get the x and y positions of both movement sticks for a 2 stick controller. Since im using the DIJOYSTATE2 format for controller data, I see that it only supports 1 stick. I've looked at the directx documentation, but cant find anything about using both sticks. How can I get this information from the controller?
  15. foursticksj

    Pixel level collision with DirectX textures

    Thanks for the help. I set up the engine to store the collision mask array at loadtime. I have not yet started on comparing the two arrays for the collision method because I want to take into account sprite rotation. Every sprite will be rotated about the center of the image. I have no idea where to start since the overlapped region could be a wide variety of shapes. Is there a somewhat efficient way to detect pixel level collision between rotated sprites?
  • 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!