PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llwindow/llwindowmesaheadless.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 78 lines | 36 code | 12 blank | 30 comment | 2 complexity | 73bfc56caa890fcf7ccf70b47a337547 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llwindowmesaheadless.cpp
  3. * @brief Platform-dependent implementation of llwindow
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "linden_common.h"
  27. #include "indra_constants.h"
  28. #include "llwindowmesaheadless.h"
  29. #include "llgl.h"
  30. #define MESA_CHANNEL_TYPE GL_UNSIGNED_SHORT
  31. #define MESA_CHANNEL_SIZE 2
  32. U16 *gMesaBuffer = NULL;
  33. //
  34. // LLWindowMesaHeadless
  35. //
  36. LLWindowMesaHeadless::LLWindowMesaHeadless(LLWindowCallbacks* callbacks,
  37. const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height,
  38. U32 flags, BOOL fullscreen, BOOL clearBg,
  39. BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth)
  40. : LLWindow(callbacks, fullscreen, flags)
  41. {
  42. if (use_gl)
  43. {
  44. llinfos << "MESA Init" << llendl;
  45. mMesaContext = OSMesaCreateContextExt( GL_RGBA, 32, 0, 0, NULL );
  46. /* Allocate the image buffer */
  47. mMesaBuffer = new unsigned char [width * height * 4 * MESA_CHANNEL_SIZE];
  48. llassert(mMesaBuffer);
  49. gMesaBuffer = (U16*)mMesaBuffer;
  50. /* Bind the buffer to the context and make it current */
  51. if (!OSMesaMakeCurrent( mMesaContext, mMesaBuffer, MESA_CHANNEL_TYPE, width, height ))
  52. {
  53. llerrs << "MESA: OSMesaMakeCurrent failed!" << llendl;
  54. }
  55. llverify(gGLManager.initGL());
  56. }
  57. }
  58. LLWindowMesaHeadless::~LLWindowMesaHeadless()
  59. {
  60. delete mMesaBuffer;
  61. OSMesaDestroyContext( mMesaContext );
  62. }
  63. void LLWindowMesaHeadless::swapBuffers()
  64. {
  65. glFinish();
  66. }