Jump to content
  • Advertisement

FatalCatharsis

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

100 Neutral

About FatalCatharsis

  • Rank
    Newbie
  1. FatalCatharsis

    direct input - precisely, how does it work?

    k, i omitted the boolean at the end involving the caps lock, so now it's: if( (m_Keypresses[ m_KeypressBuffer.Keypress ] & 0x80) && (!m_KeypressBuffer.wasPressed) && (shiftdown == m_KeypressBuffer.needShift)) and that works, so i guess i'll work with the caps lock later to see what's up. but now i'm faced with a new problem. so far, i've trusted that when all the keys are pressed, there state remains changed constantly until released, but apparently the space bar likes to flicker, which wholly screws up my method. this is run just below that for loop every frame: if((m_Keypresses[DIK_SPACE] & 0x80) && !(m_KeypressBuffer.SpaceWasPressed)) { m_intext[len] = ' '; m_intext[len +1] = '\0'; m_KeypressBuffer.SpaceWasPressed = true; } else if ( !(m_Keypresses[DIK_SPACE] & 0x80) && (m_KeypressBuffer.SpaceWasPressed)) { m_KeypressBuffer.SpaceWasPressed = false; } this does indeed add a space when the space bar is pressed, but it'll add a bunch of spaces, and continuously add them while it's held down. I have the backspace setup very similar and i have no problems with it whatsoever. It looks like this: if( (m_Keypresses[DIK_BACK] & 0x80) && !(m_KeypressBuffer.backWasPressed)) { m_intext[strlen(m_intext) - 1] = '\0'; m_intext[strlen(m_intext)] = 0; m_KeypressBuffer.backWasPressed = true; } else if ( !(m_Keypresses[DIK_BACK] & 0x80) && (m_KeypressBuffer.backWasPressed) ) { m_KeypressBuffer.backWasPressed = false; } can anyone think of a better solution to this? on pressing the space bar, i wish to add one and only one space to the end of a string until it is released and pressed again.
  2. FatalCatharsis

    direct input - precisely, how does it work?

    k i added a statement and a variable above the for loop like so: if( (m_Keypresses[DIK_RSHIFT] &0x80) || (m_Keypresses[DIK_LSHIFT] & 0x80)) { strcpy_s(m_outtext, "down"); shiftdown = true; } else if( !(m_Keypresses[DIK_RSHIFT] &0x80) && !(m_Keypresses[DIK_LSHIFT] & 0x80)) { strcpy_s(m_outtext, "up"); shiftdown = false; } and then replaced the whole part involving shift in that if statement with: (shiftdown == m_KeypressBuffer.needShift) which fixed the warnings. now it looks like this: if( (m_Keypresses[ m_KeypressBuffer.Keypress ] & 0x80) && (!m_KeypressBuffer.wasPressed) && ((shiftdown == m_KeypressBuffer.needShift) || (m_KeypressBuffer.CapsToggle == m_KeypressBuffer.needShift) ) ) that strcpy there is just to print on the screen whether it shows that it's pressed or not, and it does indeed toggle, but the capital letters still don't work :\ . any other ideas?
  3. k, it's kind of a vague subject, but i think i need a better grasp of what direct input is actually doing at the knuts and bolts level to troubleshoot my issues. What i'm doing is trying to translate keypresses into asci characters like any normal keyboard should do, and i came up with this elaborate (another word for disorganized) solution. I have a structure like so: struct KeypressBuffer { unsigned long Keypress[94]; bool needShift[94]; bool wasPressed[94]; bool SpaceWasPressed; bool CapsToggle; bool capsWasPressed; bool backWasPressed; }; the keypresses and need shift are defined when it is initilized, and never change, like so: int index = 1; m_KeypressBuffer.Keypress[index] = DIK_1; // 33 ! m_KeypressBuffer.needShift[index] = true; index++; m_KeypressBuffer.Keypress[index] = DIK_APOSTROPHE; // 34 " m_KeypressBuffer.needShift[index] = true; index++; m_KeypressBuffer.Keypress[index] = DIK_3; // 35 # m_KeypressBuffer.needShift[index] = true; index++; m_KeypressBuffer.Keypress[index] = DIK_4; //36 $ m_KeypressBuffer.needShift[index] = true; index++; m_KeypressBuffer.Keypress[index] = DIK_5; //37 % m_KeypressBuffer.needShift[index] = true; index++; m_KeypressBuffer.Keypress[index] = DIK_7; // 38 & m_KeypressBuffer.needShift[index] = true; index++; m_KeypressBuffer.Keypress[index] = DIK_APOSTROPHE; // 39 ' m_KeypressBuffer.needShift[index] = false; index++; ..... And so on in order of their respective ascii character values. then i have a for loop that checks every frame like so: for(int i = 1; i < 95; i++) { if( (m_Keypresses[ m_KeypressBuffer.Keypress ] & 0x80) && (!m_KeypressBuffer.wasPressed) && ( ( ( (m_Keypresses[DIK_LSHIFT] & 0x80) == m_KeypressBuffer.needShift) || ((m_Keypresses[DIK_RSHIFT] & 0x80) == m_KeypressBuffer.needShift) ) || (m_KeypressBuffer.CapsToggle == m_KeypressBuffer.needShift))) { m_intext[len] = i+32; m_intext[len + 1] = '\0'; m_KeypressBuffer.wasPressed = true; } if( !(m_Keypresses[m_KeypressBuffer.Keypress] & 0x80) && (m_KeypressBuffer.wasPressed)) { m_KeypressBuffer.wasPressed = false; } } which checks if it's pressed currently, if it wasn't pressed last frame, if the left or right shift is pressed and whether that character requires or doesn't require a shift key, and whether the caps lock is currently toggled. m_intext is a string, and what happens here is, it concatenates the letter onto the end of string if it meets all the conditions. then it says, for the next frame, that it was pressed. then on the next frame, if it's still held down, that if fails, and the next if fails and nothing happens. then the moment it's let go, the 'was pressed' marker for that respective key is still on so it fails the first check, but the second check succeeds, resetting it's 'was pressed' value, ready to take the input again. now, this works almost without a hitch, except that it is entirely ignoring the shift keys. i get these errors, warning C4805: '==' : unsafe mix of type 'int' and type 'bool' in operation which leads me to believe that i'm missing something. when direct input checks for the state of a key, does it not resolve to a boolean, and is the comparison faulty because of it? because when i initialize the array of constants at the beggining , you see that each individual character has a needshift value as a boolean, so in that massive if statement in the for loop there, it checks to see whether the keypress relates to whether that character needs shift. if it needs shift and it's not pressed, the character is ignored and not concatted and vice versa. if it doesn't need shift and it IS pressed, the character is ignored and vice versa. however, i don't think comparing the state of the shift key against a boolean is working here. does anyone have a better suggestion, or possibly a more foolproof way of doing what i wish to accomplish here? for the record, it does successfully concatenate the correct characters that you press to the screen, it just doesn't add the upper case version when your pressing shift, it still just adds the lowercase.
  4. FatalCatharsis

    dynamic vertex buffers in d3d11

    meh, just for making a growable buffer that holds quads for displaying characters from a texture file on, it's not like a rediculous number of vertices, just trying to find the most efficient method.
  5. FatalCatharsis

    dynamic vertex buffers in d3d11

    hmm, does it still allocate just as much memory though even though it's unused?
  6. hi, i have a simple question. I know how to setup a dynamic vertex buffer, and how to update the data for the vertices, but i'm curious, how do you add new vertices altogether, in d3d11? this confuses me, because it seems that when you set up the buffer description, you explicitly give it the total amount of vertices before you create the buffer. so am i supposed to ditch the current buffer entirely, and remake a brand new buffer every time you need to increase the vertices in you model? that just sounds nasty...
  7. FatalCatharsis

    Orthographic matrices in D3D

    hmm, now this is interesting. I did some further experimenting, and whatnot, and for awhile, when they said default, i figured they just wanted an identity matrix for the view matrix, but that was silly and didn't work. I honestly had no theory behind me to figure out what was wrong, so i was just pluggin' stuff in and eventually, i tried saving a copy of the view matrix at it's origin and original orientation when the scene is first rendered, and then sending that unchanging matrix into the shader along with the world and orthographic matrices, and that did it, works like a charm . Now, if someone might be so kind as to explain what the heck is happening there, i would be eternally grateful :\.
  8. FatalCatharsis

    Orthographic matrices in D3D

    so how does direct3d determine when a vertex is transformed? As the tutorial did, i am setting it up so that there are quads on the screen where the vertices have 3 dimensions, with the z values set to 0.0f and the x and y values are screen coordinates, and then just feeding the vertices into the shader with the world matrix and view matrix, replacing the projection matrix with the ortho matrix. when i created a shader that didn't take a view matrix at all that took just the world and ortho matrices and multiplied the vertices by them, the polygon was simply not rendered. same without the world matrix and just the ortho matrix. i assume this is because d3d thinks they are untransformed vertices that need to be transformed. Funny, i read the tutorial a little more closely, and there was a little note next to where they send the 3 matrices to the shader saying, [font="Arial"] Due note also that if your view matrix is changing you will need to create a default one for 2D rendering and use it instead of the regular view matrix. In this tutorial using the regular view matrix is fine as the camera in this tutorial is stationary. [/font]problem is, i don't know what the default view matrix should be :| . (btw, if you havn't noticed, i'm still fairly new to d3d, so pardon my ignorance )
  9. Hi, i'm using direct3D 11 and i'm having the worst time getting a 2d image onto the screen correctly. I'm following the 11th rastertek.com d3d11 tutorial on 2d rendering, and for the most part,I set it up the same way they have done. However, i'm not getting the same results. When i move the camera, the 2d image rendered onto the screen kinda.... tilts and gets clipped. here, this is a fraps video showing it. http://www.youtube.c...h?v=XGgpMTSZniw I've been following the tutorials fairly closely up to this point, except for taking a small departure with the camera class. I instead made my own inheriting class that takes keyboard and mouse input and moves the camera in a first person fashion, which is where i think this gets ginked up :/ . up till now, they haven't implemented any objects in the tutorials that change the view matrix. i have a direct 3d object, like in the tutorials that manages most things related to setting up and initializing direct 3d, and it's during this startup that i create the default world, projection, and orthographic matrices. I technically never use this world matrix cause each instance of my model class has it's own world matrix, and i don't know much about the uses of the projection matrix so I've wholly left it alone, but now that i'm using the orthographic matrix, it only just occurs to me, is the projection or orthographic matrix supposed to be updated each frame or something? the 2d polygon and texture render perfectly fine when not moving the camera, but then it seems to be stuck in the worlds xy plane, when moving the camera around. So, my question, do you think this has to do with the orthographic matrix or is it something else entirely?
  • 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!