• Content count

  • Joined

  • Last visited

Community Reputation

137 Neutral

About punkcoders

  • Rank
  1. That's true, thanks for the doc...   But i've tried with D3D11_MAP_WRITE flag, i still returns an error 0x80070057 ...
  2. I've programmed a streaming texture with the Map method. It works ok with mapFlags set to 0.   Now i'm trying to optimize it with D3D11_MAP_FLAG_DO_NOT_WAIT   But cannot make it work, the map() method returns error code E_INVALIDARG = 0x80070057   Here is how i call map function: // update texture D3D11_MAPPED_SUBRESOURCE sub; HRESULT hr = pImmediateContext->Map(s_pTexture, 0, D3D11_MAP_WRITE_DISCARD, /*D3D11_MAP_FLAG_DO_NOT_WAIT*/ 0 , &sub); if ( SUCCEEDED( hr ) ) { memcpy(sub.pData,screen,512*512*4); pImmediateContext->Unmap(s_pTexture,0); } else { if ( hr == D3DERR_WASSTILLDRAWING ) OutputDebugString("D3DERR_WASSTILLDRAWING"); char c[256]; wsprintf(c,"error 0x%x ", hr); OutputDebugString(c); } And the texture creation : // Create the texture D3D11_TEXTURE2D_DESC desc; ZeroMemory(&desc,sizeof(desc)); desc.Width = 512; desc.Height = 512; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_B8G8R8X8_UNORM; desc.SampleDesc.Count = 1; desc.Usage = D3D11_USAGE_DYNAMIC; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; desc.MiscFlags = 0; pd3dDevice->CreateTexture2D( &desc, NULL, &s_pTexture );
  3. DX11 stretched software renderer

    Thank you :)
  4. Hi,   I'm working on oldschool dos-like games with my own cpu-rendrer, this works like emulators: the only direct3d stuff i need is update a pixel-table and stretch it so it fits window & screen.   In directx 9 i used a dynamic texture with lockrect, and stretched in a dxsprite, so it fits any backbuffer size.   What tool is required in dx11 ? Is "WARP" the good one ? Or "direct2d" ?   Or just use the same way, so, a dynamic texture... where are dynamic texture & lockrect in dx11 ?
  5. ok i found it...   i made this instead: IDirect3DSwapChain9 * chain; pd3dDevice->GetSwapChain(0,&chain); D3DPRESENT_PARAMETERS pp; chain->GetPresentParameters(&pp); chain->Release(); return ( pp.PresentationInterval != D3DPRESENT_INTERVAL_IMMEDIATE );
  6. I have a strange result:   - when vsync is ON,   DXUTIsVsyncEnabled() returns FALSE - when vsync is OFF, DXUTIsVsyncEnabled() returns TRUE   I read the source: bool WINAPI DXUTIsVsyncEnabled() { DXUTDeviceSettings* pDS = GetDXUTState().GetCurrentDeviceSettings(); if( pDS ) { if( DXUTIsD3D9( pDS ) ) return ( pDS->d3d9.pp.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE ); else return ( pDS->d3d10.SyncInterval == 0 ); } else { return true; } }; Microsoft developers seem to have made a big error   They should have called it DXUTIsVsyncDisabled()   ( or they should have returned a != test ... )   I hope this error has been fixed in later versions...     Is there a more direct way to get the presentation interval of a d3d9 device ?
  7. The ancestors of game engine scripts were just parameter files used to create bonus or characters class without recompiling the engine.   Stuff like: skin_id=645 energy=78 speed=11 weapon_id=47 fly=true etc... Can be stored in XML files or other ascii encoding method.
  8. You cannot synchronize a circular audio buffer with screen vsync, each chipset has its own rythm. When vsync flip occurs, you cannot read the byte position played by audio chip, and when audiobuffer swap occurs, you cannot read the index of currently drawn screen scanline.   That's why old machines emulators have problems of sound latency and cleaness... have a look at their sources, audio and video sync is based on complex workarounds in intermediate elastic buffer.
  9. If you want a game mechanism entierely based on scripting, like unity does... you need a very powerful virtual machine, like mono c#   If you just want to make a very basic "ia" actions on a few variables (select a target, impulse vector, increase/decrease energy variable, change animation index...) well... i think the easiest syntax to compile would be a very specific asm-like, and for each class make separate scripts for each events (maybe ia event is enough, i'd not add a collide event, just a distance test in the ia event)   let's say it's the script of the "ia" routine of a "zombi" class, stupidly following slowly the player, and going into close-attack behavior when near: start: readObjectPosition 0, %v1 ;let's say player has index 0, copy its position vector in a vector register readObjectPosition C_ME, %v2 ;local object index is stored in constant C_ME, copy position in other vector register subtractVectors %v1, %v2 ;vector substraction stored in the second register getVectorMagnitude %v2, %f1 ;get distance and store in a float register Cmp %f1,5 ;jump to label 2 if distance to player is greater than 5 JG label_2 label_1: setBehavior 1 ;request behavior 1, the zombi stands up and attacks JMP label_end label_2: setBehavior 0 ;request behavior 0, the zombi walks with an impulse speed normalizeVector %v2, 0.1 ;set vector magnitude to 0.1 unit/second impulse %v3 ;update the impulsion vector label_end: the idea is to make something easy to compile and easy to read   if you keep very simple behaviors i'ts ok, so all complex stuff like pathfinder, physics, bone animation, state machines, object generation and culling, will be natively managed by your engine. Scripting is just used for behavior appointments.
  10. P.S.2 :   If you're not comfortable with OOP, you can do exactly the same with a procedural approach. I suspect the first pop-like were developed in C so were fully procedural.   So, each character and state methods are replaced by global functions (  walking_start(), walking_routine(), etc  ), with an argument "object" (or a small table) replacing "this". For each state, just make a small table with global function references.   I personnaly prefer the procedural approach, it makes shorter code, but wrapped in a static class to avoid name conflicts.
  11. To program behaviors of games like princeofpersia-flashback-abe-etc you need a state machine. Each character is managed like a mini-application with a small sub-program for each action.   First have a look to the design pattern state (google is your friend). For characters you can make simple states with at least 2 events: start(), routine(). (i think it does not need stop, pause, resume, etc)   Create a CharacterStateManager motherclass ( with its events routine() and changestate() ). It needs a "frame-timer" variable to control the end of states. On every changeState call the frame-timer must be reset to 0. The routine call only one state routine at once. Each character is an instance of CharacterStateManager.   Then, for each action (most will be shared by all characters) make an abstract motherclass CharacterState with empty functions to make sure there won't be any call of undefined function. Then, each character will use one instance of each state class.   Examples:   - standing up state. on start() event set the frame of character standing up. on routine() event, wait for an action input (keypress for player, ia for non-player, or hit), and when key pressed, call changeState( TheNextState );   - crouching state. on start() event change height of hitBox .on routine() event, display the frames or crouching animation. When finished, call a changeState to te crouched state   - crouched state. on routine() event, wait the input for standing up (release key "down" for player, ia for non player)   - standing state. on start() event change height of hitBox. on routine() event, play in reverse the crouching animation frames and change height of hitbox, when finished, call a changeState to the standing up state.   - walking state. on routine() event, play animation. Each time character reach a new tile, chek the input (ia or keyboard or hit), if no change state then carry on walking.   - etc...     I developed a game like this a long time ago, was really more simple than flashback or abe, the states i used for all characters were: standing, walking on floor, walking on stairs up, walking stairs down, jumping, falling, knocked, speaking.   good work !     P.S. do not forget to manage your characters with an object pool, because javascript garbage collector is a pure crap you cannot trust on. So, do not subclass the CharacterStateManager, use a "behavior" index instead, and use it to reference global or static functions.
  12. free wrapper api for xaudio 2 ?

    microsoft made one called xAct   but it's not as "user-friendly" as the interface you'd like, cos you first need to create wavebank files     if you look for a very very user friendly api, SDL 2.0 now uses directx on windows
  13. Hello,   I'm working on procedural surfaces and textures (software rendering)   I've tested several ways to do it ( texture with DYNAMIC_USAGE, backbuffer with DONOTWAIT in LockRect() function, updateTexture() / updateSurface()... )   Whatever approach i use, i have cpu-cycles-spoiling, seems that the cpu is looping waiting gpu has finished copying the pixels.   I found in openGL a tool made to avoid this cpu-spoil (Pixel Buffer Object) based on a double-buffer, so cpu doesn't need to wait the end of copy... i'd like to do the equivalent in directx.