GOSImage.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. #include "MLRHeaders.hpp"
  5. //#############################################################################
  6. //############################ GOSImage ###############################
  7. //#############################################################################
  8. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. //
  10. GOSImage::GOSImage( const char* iName ) : Plug (DefaultData)
  11. {
  12. imageName = iName;
  13. flags = 0;
  14. instance = 0;
  15. mcTextureNodeIndex = 0xffffffff;
  16. ptr.pTexture = NULL;
  17. }
  18. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. //
  20. GOSImage::GOSImage( DWORD iHandle ) : Plug (DefaultData)
  21. {
  22. char str[20];
  23. sprintf(str, "image%03d", iHandle);
  24. imageName = str;
  25. flags = Loaded;
  26. instance = 0;
  27. mcTextureNodeIndex = iHandle;
  28. ptr.pTexture = NULL;
  29. }
  30. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. //
  32. GOSImage::GOSImage(const char *name, gos_TextureHints hints) : Plug (DefaultData)
  33. {
  34. imageName = name;
  35. flags = Loaded;
  36. instance = 0;
  37. ipHints = hints;
  38. mcTextureNodeIndex = mcTextureManager->loadTexture(name,gos_Texture_Detect,ipHints);
  39. ptr.pTexture = NULL;
  40. }
  41. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. //
  43. GOSImage::~GOSImage()
  44. {
  45. imageName = "";
  46. if((flags & Locked) != 0)
  47. {
  48. // gos_UnLockTexture(imageHandle);
  49. }
  50. if((flags & Loaded) != 0)
  51. {
  52. if (mcTextureManager)
  53. {
  54. mcTextureManager->removeTexture(mcTextureNodeIndex);
  55. mcTextureNodeIndex = 0xffffffff;
  56. }
  57. }
  58. flags = 0;
  59. }
  60. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. //
  62. int
  63. GOSImage::GetWidth()
  64. {
  65. return 0;
  66. }
  67. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. //
  69. int
  70. GOSImage::GetHeight()
  71. {
  72. return 0;
  73. }
  74. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75. //
  76. void
  77. GOSImage::LockImage()
  78. {
  79. if(!(flags & Locked))
  80. {
  81. flags |= Locked;
  82. DWORD imageHandle = mcTextureManager->get_gosTextureHandle(mcTextureNodeIndex);
  83. if (imageHandle != 0xffffffff)
  84. gos_LockTexture(imageHandle, 0, false, &ptr);
  85. }
  86. }
  87. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. //
  89. void
  90. GOSImage::UnlockImage()
  91. {
  92. if(flags & Locked)
  93. {
  94. flags &= ~Locked;
  95. Start_Timer(Unlock_Texture_Time);
  96. DWORD imageHandle = mcTextureManager->get_gosTextureHandle(mcTextureNodeIndex);
  97. if (imageHandle != 0xffffffff)
  98. gos_UnLockTexture(imageHandle);
  99. Stop_Timer(Unlock_Texture_Time);
  100. ptr.pTexture = NULL;
  101. }
  102. }
  103. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104. //
  105. unsigned char*
  106. GOSImage::GetImagePtr()
  107. {
  108. return (unsigned char *)ptr.pTexture;
  109. }