GPUObject.cpp 947 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #include "../Precompiled.h"
  4. #include "../GraphicsAPI/GPUObject.h"
  5. #include "../Graphics/Graphics.h"
  6. #include "../DebugNew.h"
  7. namespace Urho3D
  8. {
  9. GPUObject::GPUObject(Graphics* graphics) :
  10. graphics_(graphics)
  11. {
  12. if (Graphics::GetGAPI() == GAPI_OPENGL)
  13. object_.name_ = 0;
  14. else
  15. object_.ptr_ = nullptr;
  16. if (graphics_)
  17. graphics->AddGPUObject(this);
  18. }
  19. GPUObject::~GPUObject()
  20. {
  21. if (graphics_)
  22. graphics_->RemoveGPUObject(this);
  23. }
  24. void GPUObject::OnDeviceLost()
  25. {
  26. if (Graphics::GetGAPI() == GAPI_OPENGL)
  27. {
  28. // On OpenGL the object has already been lost at this point; reset object name
  29. object_.name_ = 0;
  30. }
  31. }
  32. void GPUObject::OnDeviceReset()
  33. {
  34. }
  35. void GPUObject::Release()
  36. {
  37. }
  38. void GPUObject::ClearDataLost()
  39. {
  40. dataLost_ = false;
  41. }
  42. Graphics* GPUObject::GetGraphics() const
  43. {
  44. return graphics_;
  45. }
  46. }