void Keyboard::Update(void) { Device::Update(); //poll HRESULT hr = m_pDevice->GetDeviceState(N_KEYS*sizeof(unsigned char), (void*) currentState()); switch(hr){ case DI_OK: break; //everything is fine case DIERR_INPUTLOST: case DIERR_NOTACQUIRED: m_pDevice->Acquire(); //get the device back return; case E_PENDING: //not ready yet, maybe next frame return; default: assert(hr != DIERR_NOTINITIALIZED); assert(hr != DIERR_INVALIDPARAM); } /* emit events */ for (unsigned int i=0; i<N_KEYS; i++) { if (Up(currentState(), i) && Down(oldState(), i)) EVENT(KeyReleasedEvent(i)); else if (Down(currentState(), i) && Up(oldState(), i)) EVENT(KeyPressedEvent(i)); } flipBuffers(); }
void EnvReadInsert(FILE_NUM fnum, int offset, OBJECT env) { int pos; OBJECT x, loser; debug3(DET, DD, "EnvReadInsert(%s, %d, env %d)", FileName(fnum), offset, (int) env); /* to limit the cache size, remove least recently used entry if full */ if( cache_count >= MAX_CACHE ) { Child(loser, Down(env_cache)); DeleteLink(Up(loser)); DisposeChild(Up(loser)); cache_count--; } /* insert the new entry */ hash2(pos, fnum, offset); if( tab[pos] == nilobj ) New(tab[pos], ACAT); New(x, ACAT); env_fnum(x) = fnum; env_offset(x) = offset; env_read(x) = TRUE; Link(tab[pos], x); Link(env_cache, x); Link(x, env); cache_count++; debug1(DET, DD, "EnvReadInsert returning (cache_count = %d)", cache_count); } /* end EnvReadInsert */
// insert a written block. int proc_insertBuff(int index,int pathIndex,struct block *buff,loff_t pos, size_t count,context *ct) { loff_t* f_pos,spos; size_t left = count, wrt; int ret; if(RELEASE(index)) return count; if(pathIndex==INDEX_PATH_NUM) { spos = ((pipes[index].ct)[CONTEXT]).bpos + pos; } else { spos=pos; } f_pos=(loff_t *)&spos; while(1) { Down(index); wrt = left; ret = dev_insertBuff(&((pipes[index]).device), f_pos,buff, &left, ct); if(pathIndex==INDEX_PATH_NUM) POS(ct)=*f_pos-((pipes[index].ct)[CONTEXT]).bpos; else POS(ct)=*f_pos; if(ret == DEV_FAULT) {Up(index); return -EFAULT;} if(wrt && !R_ABLE(ct)) { R_ABLE(ct) = 1; if(ret == DEV_SEEK) { wake_up_interruptible_sync(&(RQ(index))); } else { wake_up_interruptible(&(RQ(index))); } } if(ret == DEV_SEEK) {Up(index); return -P_ESEEK;} if(ret == DEV_FULL) { W_ABLE(ct) = 0; Up(index); PDEBUG("<%d>: device full, sleep, left %d\n", current->pid, (int)left); Wait_Event(WQ(index), RELEASE(index)||W_ABLE(ct)); if(RELEASE(index)) return count; continue; } Up(index); if(left <= 0) break; } return count; }
void DetachGalley(OBJECT hd) { OBJECT prnt, index; assert( type(hd) == HEAD && Up(hd) != hd, "DetachGalley: precondition!" ); debug1(DGA, D, "DetachGalley( %s )", SymName(actual(hd))); Parent(prnt, Up(hd)); assert( Up(prnt) != prnt, "DetachGalley: parent!" ); New(index, UNATTACHED); pinpoint(index) = nilobj; MoveLink(Up(hd), index, PARENT); Link(NextDown(Up(prnt)), index); debug0(DGA, D, "DetachGalley returning."); } /* end DetachGalley */
void myMovingWallVelocityFvPatchVectorField::updateCoeffs() { if ( updated() ) { return; } // Info << "void myMovingWallVelocityFvPatchVectorField::updateCoeffs()" <<endl; const fvMesh & mesh = dimensionedInternalField().mesh(); const fvPatch & p = patch(); const polyPatch & pp = p.patch(); if ( myTimeIndex_ < mesh.time().timeIndex() ) { oldoldFc_ = oldFc_; oldFc_ = Fc_; Fc_ = pp.faceCentres(); myTimeIndex_ = mesh.time().timeIndex(); } // const pointField& oldPoints = mesh.oldPoints(); const volVectorField & U = mesh.lookupObject<volVectorField>( dimensionedInternalField().name() ); scalar deltaT = mesh.time().deltaT().value(); scalar deltaT0 = mesh.time().deltaT0().value(); if ( U.oldTime().timeIndex() == U.oldTime().oldTime().timeIndex() || U.oldTime().oldTime().timeIndex() < 0 ) { deltaT0 = GREAT; } // Set coefficients based on deltaT and deltaT0 scalar coefft = 1 + deltaT / (deltaT + deltaT0); scalar coefft00 = deltaT * deltaT / ( deltaT0 * (deltaT + deltaT0) ); scalar coefft0 = coefft + coefft00; tmp<vectorField> Up = (coefft * Fc_ - coefft0 * oldFc_ + coefft00 * oldoldFc_) / mesh.time().deltaT().value(); scalarField phip = p.patchField<surfaceScalarField, scalar>( fvc::meshPhi( U ) ); tmp<vectorField> n = p.nf(); const scalarField & magSf = p.magSf(); tmp<scalarField> Un = phip / (magSf + VSMALL); vectorField::operator=( Up() + n() *( Un() - ( n() & Up() ) ) ); fixedValueFvPatchVectorField::updateCoeffs(); }
int main() { COORD pos; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); int i, leftB, rightB, upB, downB; leftB = 11; rightB = 67; upB = 11; downB = 13; pos.Y = 12; pos.X = 66; for (i = 0; i < 12; i++) { pos = Left (pos, leftB); leftB--; pos = Up (pos, upB); upB--; pos = Right (pos, rightB); rightB++; pos = Down (pos, downB); downB++; } pos = Left (pos, leftB); leftB--; if (leftB == 0) { printf("*"); } pos.X = 0; pos.Y = 25; SetConsoleCursorPosition(hConsole, pos); SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); return 0; }
FULL_CHAR *SymName(OBJECT s) { OBJECT p; if( s == nilobj ) return AsciiToFull("<nilobj>"); Parent(p, Up(s)); assert( is_word(type(p)), "SymName: !is_word(type(p))!" ); return string(p); } /* end SymName */
void Camera :: move(double value) { Point3 Eye(eye.x, eye.y+value, eye.z); Point3 Look = lookAt; Vector3 Up(0.0, 1.0, 0.0); set(Eye, Look, Up); }
bool Init() { Vector3f Pos(-10.0f, 0.0f, -10.0f); Vector3f Target(1.0f, 0.0f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); unsigned int Indices[] = { 0, 2, 1, 0, 3, 2}; CreateIndexBuffer(Indices, sizeof(Indices)); CreateVertexBuffer(Indices, ARRAY_SIZE_IN_ELEMENTS(Indices)); m_pEffect = new LightingTechnique(); if (!m_pEffect->Init()) { printf("Error initializing the lighting technique\n"); return false; } m_pEffect->Enable(); m_pEffect->SetTextureUnit(0); m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png"); if (!m_pTexture->Load()) { return false; } return true; }
bool Init() { Vector3f Pos(5.0f, 1.0f, -3.0f); Vector3f Target(0.0f, 0.0f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); CreateVertexBuffer(); m_pEffect = new LightingTechnique(); if (!m_pEffect->Init()) { printf("Error initializing the lighting technique\n"); return false; } m_pEffect->Enable(); m_pEffect->SetTextureUnit(0); m_pTexture = new Texture(GL_TEXTURE_2D, "../Content/test.png"); if (!m_pTexture->Load()) { return false; } return true; }
void DrawDebugDirectionalArrow(const UWorld* InWorld, FVector const& LineStart, FVector const& LineEnd, float ArrowSize, FColor const& Color, bool bPersistentLines, float LifeTime, uint8 DepthPriority) { // no debug line drawing on dedicated server if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer) { if (ArrowSize <= 0) { ArrowSize = 10.f; } DrawDebugLine(InWorld, LineStart, LineEnd, Color, bPersistentLines, LifeTime); FVector Dir = (LineEnd-LineStart); Dir.Normalize(); FVector Up(0, 0, 1); FVector Right = Dir ^ Up; if (!Right.IsNormalized()) { Dir.FindBestAxisVectors(Up, Right); } FVector Origin = FVector::ZeroVector; FMatrix TM; // get matrix with dir/right/up TM.SetAxes(&Dir, &Right, &Up, &Origin); // since dir is x direction, my arrow will be pointing +y, -x and -y, -x float ArrowSqrt = FMath::Sqrt(ArrowSize); FVector ArrowPos; DrawDebugLine(InWorld, LineEnd, LineEnd + TM.TransformPosition(FVector(-ArrowSqrt, ArrowSqrt, 0)), Color, bPersistentLines, LifeTime, DepthPriority); DrawDebugLine(InWorld, LineEnd, LineEnd + TM.TransformPosition(FVector(-ArrowSqrt, -ArrowSqrt, 0)), Color, bPersistentLines, LifeTime, DepthPriority); } }
int main() { while (~scanf("%d %d", &n, &m)) { init(n); for (int i = 1; i <= n; ++i) { scanf("%I64d", s + i); s[i] += s[i - 1]; } dp[1] = s[1] * s[1] + m; q.push_back(0); for (int i = 1; i <= n; ++i) { while (q.size() >= 2 && Up(q[1], q.front()) <= s[i] * Down(q[1], q.front())) { // printf(" %d\n", q[1]); // printf("--- %I64d %d\n", dp[i], q.size()); q.pop_front(); } if (!q.empty()) Dp(i, q.front()); // printf("%I64d %d\n", dp[i], q.size()); while (q.size() >= 2 /*&& 1, printf("--- %I64d %d\n *** %I64d %I64d\n", dp[i], q.back(), Up(i, q.back()) * Down(q.back(), q[q.size() - 2]), Up(q.back(), q[q.size() - 2]) * Down(i, q.back())) */&& Up(i, q.back()) * Down(q.back(), q[q.size() - 2]) <= Up(q.back(), q[q.size() - 2]) * Down(i, q.back())) { // ; // printf(" %d\n", q[1]); q.pop_back(); } q.push_back(i); // printf(" %d\n", q.size()); } printf("%I64d\n", dp[n]); } }
void Keyboard::Deinit() { qDebug() << "Killing keyboard\n"; // Release all keys ModifierUp(ModCtrlL); ModifierUp(ModCtrlR); ModifierUp(ModCtrl); ModifierUp(ModAltL); ModifierUp(ModAltR); ModifierUp(ModAlt); ModifierUp(ModShiftL); ModifierUp(ModShiftR); ModifierUp(ModShift); ModifierUp(ModMetaL); ModifierUp(ModMetaR); ModifierUp(ModMeta); /* for (Keycode i = 0; i < std::numeric_limits<Keycode>::max(); ++i) { Up(i); } Up(std::numeric_limits<Keycode>::max()); */ // Just unpress ASCII printing characters for (Keycode i = 32; i < 127; ++i) { Up(i); } }
void CASWEnvSpark::CreateSpark( void ) { CUtlReference<CNewParticleEffect> pEffect = CNewParticleEffect::CreateOrAggregate( NULL, "asw_env_sparks", GetAbsOrigin(), NULL ); if ( pEffect ) { pEffect->SetControlPoint( 0, GetAbsOrigin() ); pEffect->SetControlPointOrientation( 0, Forward(), -Left(), Up() ); pEffect->SetControlPoint( 2, Vector( GetRenderColorR(), GetRenderColorG(), GetRenderColorB() ) ); float flMagnitude = m_flMagnitude/100; float flElecReduction = 1.0f; float flCollide = (m_flPercentCollide/100); float flAmtElectrical = 0; if ( m_bElectrical ) { flAmtElectrical = flMagnitude; flElecReduction = 0.6; } pEffect->SetControlPoint( 3, Vector( ((1.0f-flCollide)* flMagnitude)*flElecReduction, (flCollide*flMagnitude)*flElecReduction, flMagnitude ) ); pEffect->SetControlPoint( 4, Vector( flAmtElectrical, 0, 0 ) ); //Msg( "Spark - Magnitude = %f\n", flMagnitude ); } if ( m_bPlaySound ) { EmitSound( "DoSpark" ); } }
ssize_t p_sock_read(int index, struct file *filp, char *buf, size_t count, loff_t *f_pos) { // context *ct=getct(index,*f_pos); pipe_file *pp=&(pipes[index]); kpipe_setup *pipeSetup=&(pipeManage.threads[index].pipeSetup[0]); size_t len; int type; loff_t tmp_pos=*f_pos; sock_pos_t *sockPos=filp->private_data; if(!filp->private_data) { HDEBUG("first read,malloc sock_pos_t\n"); sockPos=kmalloc(sizeof(sock_pos_t),GFP_KERNEL); memset(sockPos,0,sizeof(sock_pos_t)); sockPos->magic = SOCK_POS_MAGIC; filp->private_data = sockPos; } Down(index); if(tmp_pos >= ((pp->ct)[CONTEXT]).bpos) { HDEBUG("read idx\n"); if(pipeSetup->pathIndex!=INDEX_PATH_NUM) pipeSetup++; tmp_pos -=((pp->ct)[CONTEXT]).bpos; } type=pipeSetup->type; Up(index); len = p_close_createAndRead(sockPos,pipeSetup,buf,count,&tmp_pos); if(len>=0) { *f_pos +=len; sockPos->pos = tmp_pos+len; } return len; }
bool Init() { Vector3f Pos(0.0f, 5.0f, -22.0f); Vector3f Target(0.0f, -0.2f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); if (!m_lightingEffect.Init()) { printf("Error initializing the lighting technique\n"); return false; } m_lightingEffect.Enable(); m_lightingEffect.SetTextureUnit(0); m_lightingEffect.SetDirectionalLight(m_directionalLight); if (!m_pickingTexture.Init(WINDOW_WIDTH, WINDOW_HEIGHT)) { return false; } if (!m_pickingEffect.Init()) { return false; } if (!m_simpleColorEffect.Init()) { return false; } m_pMesh = new Mesh(); return m_pMesh->LoadMesh("../Content/spider.obj"); }
// Drops all rings with additional 1 second wait time void DropAll() { Down(); while(GetRingCount() > 0); wait1Msec(1000); Up(); }
// // Constructor // CSample03::CSample03( HINSTANCE Instance, UINT Width, UINT Height, const WCHAR *Caption ): CDemo_GL( Instance, Width, Height, Caption ) { Vec3<float> Eye( 0.0f, 0.0f, 5.0f ); Vec3<float> At( 0.0f, 0.0f, 0.0f ); Vec3<float> Up( 0.0f, 1.0f, 0.0f ); m_View.LookAtRH( Eye, At, Up ); // // OpenGL objects // CreateShaders(); CreateVertexBuffers(); CreateIndexBuffers(); m_OcclusionQuery = new GL::CQuery(); // // App // m_TrackBall = new UI::CTrackBall( Vec2<float>( m_Width / 2.0f, m_Height / 2.0f ), 250.0f, UI::CTrackBall::RT_TRACKBALL ); }
TBool CPage::KeyEvent(int aKeyCode) { ASSERT(iLayout); TBool result = ETrue; switch(aKeyCode) { case EKeyDevice3: Execute(); break; case EKeyLeftArrow: Left(); break; case EKeyRightArrow: Right(); break; case EKeyUpArrow: Up(); break; case EKeyDownArrow: Down(); break; default: result = EFalse; break; } return result; }
bool Init() { Vector3f Pos(0.0f, 1.5f, -6.5f); Vector3f Target(0.0f, -0.2f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); if (!m_lightingEffect.Init()) { printf("Error initializing the lighting technique\n"); return false; } GLint MaxPatchVertices = 0; glGetIntegerv(GL_MAX_PATCH_VERTICES, &MaxPatchVertices); printf("Max supported patch vertices %d\n", MaxPatchVertices); glPatchParameteri(GL_PATCH_VERTICES, 3); m_lightingEffect.Enable(); m_lightingEffect.SetColorTextureUnit(COLOR_TEXTURE_UNIT_INDEX); m_lightingEffect.SetDirectionalLight(m_directionalLight); m_pMesh = new Mesh(); return m_pMesh->LoadMesh("../Content/monkey.obj"); }
//PORT: LRESULT return (was UINT) LRESULT CEditSpinSlider::OnNcHitTest(CPoint point) { // TODO: Add your message handler code here and/or call default UINT ret = CEdit::OnNcHitTest(point); if(ret == HTNOWHERE) { ScreenToClient(&point); CRect Client; GetClientRect(&Client); CRect BG(Client.right,Client.top,Client.right+23,Client.bottom); CRect Up(Client.right,Client.top+1,Client.right+10,Client.top+(Client.Height()/2)-1); CRect Down = Up; Down.top = Up.bottom+1; Down.bottom = Client.bottom-1; CRect Right = Up; Right.bottom = Down.bottom; Right.left = Up.right+1; Right.right = Client.right+22; if(Up.PtInRect(point)) return 30; if(Down.PtInRect(point)) return 31; if(Right.PtInRect(point)) return 32; } return ret; }
void ToStruct(JOYSTICK_FEATURE& feature) const { feature.name = new char[m_name.length() + 1]; feature.type = m_type; switch (m_type) { case JOYSTICK_FEATURE_TYPE_SCALAR: Primitive().ToStruct(feature.scalar.primitive); break; case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: Up().ToStruct(feature.analog_stick.up); Down().ToStruct(feature.analog_stick.down); Right().ToStruct(feature.analog_stick.right); Left().ToStruct(feature.analog_stick.left); break; case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: PositiveX().ToStruct(feature.accelerometer.positive_x); PositiveY().ToStruct(feature.accelerometer.positive_y); PositiveZ().ToStruct(feature.accelerometer.positive_z); break; case JOYSTICK_FEATURE_TYPE_MOTOR: Primitive().ToStruct(feature.motor.primitive); break; default: break; } std::strcpy(feature.name, m_name.c_str()); }
void cLogger::PreScan(int src, int tr) { Lock(); source=src; transponder=tr; prescan=pmStart; Up(); Unlock(); }
void CommanderWindow::PulseReceived( Pulse *pulse ) { switch ( (*pulse)[0] ) { case PULSE_BACK: case PULSE_UP: if ( Up() ) Refresh(); break; case PULSE_REFRESH: case PULSE_LOAD: Refresh(); break; case PULSE_SELECT: if ( Select() ) Refresh(); break; default: Window::PulseReceived( pulse ); break; } }
VOID InitWorldViewProjMatrix(HWND hwnd) { // Initialize world matrix D3DXMatrixIdentity(&g_mWorld); // Initialize view matrix D3DXVECTOR3 eyePoint(0.0f, 0.0f, -5.0f); g_EyePos = eyePoint; D3DXVECTOR3 lookAt(0.0f, 0.0f, 0.0f); D3DXVECTOR3 Up(0.0f, 1.0f, 0.0f); D3DXMatrixLookAtLH(&g_mView, &eyePoint, &lookAt, &Up); // Initialize projection matrix float fov = (float)(D3DX_PI / 4); // Calculate aspect ratio RECT rc; GetClientRect(hwnd, &rc); UINT width = rc.right - rc.left; UINT height = rc.bottom - rc.top; float aspectRatio = width / (float)height; D3DXMatrixPerspectiveFovLH(&g_mProj, fov, aspectRatio, 1.0f, 1000.0f); g_mWorldViewPorj = g_mWorld * g_mView * g_mProj; }
void find(int rank) { int i,flag; for(i=0,flag=0;i<27;i++) { if(!visit[i]&&Yes(i)) { level[rank][0]++; level[rank][level[rank][0]]='A'+i; visit[i]=1; flag=1; } } if(flag==0) { return; } for(i=1;i<=level[rank][0];i++) { Up(level[rank][i]-'A'); } for(i=1;i<=level[rank][0];i++) { Updata(level[rank][i]-'A'); } find(rank+1); }
/** * <param name="gameTime"></param> * <param name="horizontalAxis_"> value between -1.0 and 1.0 </param> * <param name="verticalAxis_"> value between -1.0 and 1.0 </param> * <param name="rollAxis_"> value between -1.0 and 1.0 </param> * <param name="zoom"> zoom value </param> */ void ArcBallCameraController::HandleControls(const GameTime& gameTime_, float rightAxis_, float upAxis_, float forwardAxis_, float horizontalOrbit_, float verticalOrbit_, float /*rollOrbit_*/, float zoom_) { float r = rightAxis_ * gameTime_.FrameTime() * m_fInputDisplacementRate; float u = upAxis_ * gameTime_.FrameTime() * m_fInputDisplacementRate; float f = forwardAxis_ * gameTime_.FrameTime() * m_fInputDisplacementRate; float dH = horizontalOrbit_ * gameTime_.FrameTime() * m_fInputTurnRate; float dV = verticalOrbit_ * gameTime_.FrameTime() * m_fInputTurnRate; //float dR = rollOrbit_ * gameTime_.FrameTime() * m_fInputTurnRate; if ( dH != 0.0f ) RotateTargetRight(dH);//OrbitUp( dH ); if ( dV != 0.0f ) RotateTargetUp(dV); //OrbitRight( dV ); //if ( dR != 0.0f ) RotateClockwise( dR ); //decrease distance to target m_fDistance += zoom_ * gameTime_.FrameTime() * m_fInputDistanceRate; if ( m_fDistance < 0.001f ) m_fDistance = 0.001f; if ( r != 0.0f || u != 0.0f || f != 0.0f ) { Vector3F pos = Target() + (Right() * r) + (Up() * u) + (Direction() * f); Target(pos); /*Vector3F target = pos; target.Normalize(); target *= m_fDistance; target += pos; SetCamera(pos, target, Up());*/ } }
void Movement(unsigned char key, int x, int y) { //Obrót zrealizowany jest jako rotacja wektora od oczu obserwatora do punktu na który patrzy wokó³ wektora wskazuj¹cego 'w górê' od obserwatora, //a nastêpnie wyliczenie nowego punktu skupienia wzroku obserwatora jako przesuniêcie punktu oczu o zrotowany wczeœniej wektor. //Przesuniêcie to translacja punktu po³o¿enia obserwatora i punktu skupienia jego wzroku o znormalizowany wektor od oczu do obserwowanego punktu //(w taki sposób modu³ tego wektora nie ulega zmianie). glm::vec4 vrot; glm::vec3 move; int i = 1, j = 1; if (key == 'a' || key == 'd' ) { vrot = glm::rotate(glm::mat4(1.0f), key == 'a' ? 3.0f : -3.0f, m_up)*glm::vec4(m_center - m_eye, 0); m_center = m_eye + glm::vec3(vrot); } else if ((key == 'w' || key == 's') && direction == 0) { move = glm::normalize(m_center - m_eye); move *= 0.2; if (key == 's')move *= -1; if (fly || !CollisionX(move, i)) { m_eye.x += move.x; m_center.x += move.x; p_i = i; } if (fly || !CollisionZ(move, j)) { m_eye.z += move.z; m_center.z += move.z; p_j = j; } if (fly) { m_eye.y += move.y; m_center.y += move.y; } } else if (key == 'c') { if (M[p_i][p_j] == 'u')Up(); else if (M[p_i][p_j] == 'd')Down(); } else if (key == 'm') { M.Show(cur_layer); printf("%d %d\n", p_i, p_j); } else if (key == 'f')fly = !fly; }
HRESULT D3DEngine::OnCreateDevice(ID3D10Device* d3d_device) { HRESULT hr; // Find the D3DX effect file WCHAR str[MAX_PATH]; V_RETURN(DXUTFindDXSDKMediaFileCch(str, MAX_PATH, kFileTutFX)); DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS; #if defined( DEBUG ) || defined( _DEBUG ) // Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders. // Setting this flag improves the shader debugging experience, but still allows // the shaders to be optimized and to run exactly the way they will run in // the release configuration of this program. dwShaderFlags |= D3D10_SHADER_DEBUG; #endif V_RETURN( D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, d3d_device, NULL, NULL, &effect_, NULL, NULL ) ); // techniqueを入手 technique_ = effect_->GetTechniqueByName( "Render" ); diffuse_variable_ = effect_->GetVariableByName( "g_txDiffuse" )->AsShaderResource(); world_variable_ = effect_->GetVariableByName( "World" )->AsMatrix(); view_variable_ = effect_->GetVariableByName( "View" )->AsMatrix(); projection_variable_ = effect_->GetVariableByName( "Projection" )->AsMatrix(); // Define the input layout const D3D10_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 }, }; UINT numElements = sizeof( layout ) / sizeof( layout[0] ); // Create the input layout D3D10_PASS_DESC PassDesc; technique_->GetPassByIndex( 0 )->GetDesc( &PassDesc ); V_RETURN( d3d_device->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &vertex_layout_ ) ); // Set the input layout d3d_device->IASetInputLayout( vertex_layout_ ); // Load the mesh V_RETURN(mesh_.Create(d3d_device, kFileTinyMesh, true)); // Initialize the world matrices D3DXMatrixIdentity( &world_ ); // Initialize the view matrix D3DXVECTOR3 Eye( 0.0f, 3.0f, -500.0f ); D3DXVECTOR3 At( 0.0f, 1.0f, 0.0f ); D3DXVECTOR3 Up( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtLH( &view_, &Eye, &At, &Up ); // Update Variables that never change view_variable_->SetMatrix( ( float* )&view_ ); return S_OK; }
//return a free block. int proc_freeBuff(int index,int pathIndex, struct block *buff) { Down(index); dev_freeBuff(&(pipes[index].device),buff); Up(index); return 0; }