PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 8ms 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
 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
27#include "linden_common.h"
28#include "indra_constants.h"
29
30#include "llwindowmesaheadless.h"
31#include "llgl.h"
32
33#define MESA_CHANNEL_TYPE GL_UNSIGNED_SHORT
34#define MESA_CHANNEL_SIZE 2
35
36U16 *gMesaBuffer = NULL;
37
38//
39// LLWindowMesaHeadless
40//
41LLWindowMesaHeadless::LLWindowMesaHeadless(LLWindowCallbacks* callbacks,
42                                           const std::string& title, const std::string& name, S32 x, S32 y, S32 width, S32 height,
43							 U32 flags,  BOOL fullscreen, BOOL clearBg,
44							 BOOL disable_vsync, BOOL use_gl, BOOL ignore_pixel_depth)
45	: LLWindow(callbacks, fullscreen, flags)
46{
47	if (use_gl)
48	{
49		llinfos << "MESA Init" << llendl;
50		mMesaContext = OSMesaCreateContextExt( GL_RGBA, 32, 0, 0, NULL );
51
52		/* Allocate the image buffer */
53		mMesaBuffer = new unsigned char [width * height * 4 * MESA_CHANNEL_SIZE];
54		llassert(mMesaBuffer);
55
56		gMesaBuffer = (U16*)mMesaBuffer;
57
58		/* Bind the buffer to the context and make it current */
59		if (!OSMesaMakeCurrent( mMesaContext, mMesaBuffer, MESA_CHANNEL_TYPE, width, height ))
60		{
61			llerrs << "MESA: OSMesaMakeCurrent failed!" << llendl;
62		}
63
64		llverify(gGLManager.initGL());
65	}
66}
67
68
69LLWindowMesaHeadless::~LLWindowMesaHeadless()
70{
71	delete mMesaBuffer;
72	OSMesaDestroyContext( mMesaContext );
73}
74
75void LLWindowMesaHeadless::swapBuffers()
76{
77	glFinish();
78}