GLView.cpp revision af69d88d
1af69d88dSmrg/*
2af69d88dSmrg * Copyright 2006-2012, Haiku. All rights reserved.
3af69d88dSmrg * Distributed under the terms of the MIT License.
4af69d88dSmrg *
5af69d88dSmrg * Authors:
6af69d88dSmrg *		Jérôme Duval, korli@users.berlios.de
7af69d88dSmrg *		Philippe Houdoin, philippe.houdoin@free.fr
8af69d88dSmrg *		Stefano Ceccherini, burton666@libero.it
9af69d88dSmrg */
10af69d88dSmrg
11af69d88dSmrg#include <kernel/image.h>
12af69d88dSmrg
13af69d88dSmrg#include <GLView.h>
14af69d88dSmrg
15af69d88dSmrg#include <assert.h>
16af69d88dSmrg#include <stdio.h>
17af69d88dSmrg#include <stdlib.h>
18af69d88dSmrg#include <string.h>
19af69d88dSmrg
20af69d88dSmrg#include <DirectWindow.h>
21af69d88dSmrg#include <GLRenderer.h>
22af69d88dSmrg
23af69d88dSmrg#include "interface/DirectWindowPrivate.h"
24af69d88dSmrg#include "GLDispatcher.h"
25af69d88dSmrg#include "GLRendererRoster.h"
26af69d88dSmrg
27af69d88dSmrg
28af69d88dSmrgstruct glview_direct_info {
29af69d88dSmrg	direct_buffer_info* direct_info;
30af69d88dSmrg	bool direct_connected;
31af69d88dSmrg	bool enable_direct_mode;
32af69d88dSmrg
33af69d88dSmrg	glview_direct_info();
34af69d88dSmrg	~glview_direct_info();
35af69d88dSmrg};
36af69d88dSmrg
37af69d88dSmrg
38af69d88dSmrgBGLView::BGLView(BRect rect, const char* name, ulong resizingMode, ulong mode,
39af69d88dSmrg	ulong options)
40af69d88dSmrg	:
41af69d88dSmrg	BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS),
42af69d88dSmrg		//  | B_FULL_UPDATE_ON_RESIZE)
43af69d88dSmrg	fGc(NULL),
44af69d88dSmrg	fOptions(options),
45af69d88dSmrg	fDitherCount(0),
46af69d88dSmrg	fDrawLock("BGLView draw lock"),
47af69d88dSmrg	fDisplayLock("BGLView display lock"),
48af69d88dSmrg	fClipInfo(NULL),
49af69d88dSmrg	fRenderer(NULL),
50af69d88dSmrg	fRoster(NULL),
51af69d88dSmrg	fDitherMap(NULL)
52af69d88dSmrg{
53af69d88dSmrg	fRoster = new GLRendererRoster(this, options);
54af69d88dSmrg}
55af69d88dSmrg
56af69d88dSmrg
57af69d88dSmrgBGLView::~BGLView()
58af69d88dSmrg{
59af69d88dSmrg	delete fClipInfo;
60af69d88dSmrg	if (fRenderer)
61af69d88dSmrg		fRenderer->Release();
62af69d88dSmrg}
63af69d88dSmrg
64af69d88dSmrg
65af69d88dSmrgvoid
66af69d88dSmrgBGLView::LockGL()
67af69d88dSmrg{
68af69d88dSmrg	// TODO: acquire the OpenGL API lock it on this glview
69af69d88dSmrg
70af69d88dSmrg	fDisplayLock.Lock();
71af69d88dSmrg	if (fRenderer)
72af69d88dSmrg		fRenderer->LockGL();
73af69d88dSmrg}
74af69d88dSmrg
75af69d88dSmrg
76af69d88dSmrgvoid
77af69d88dSmrgBGLView::UnlockGL()
78af69d88dSmrg{
79af69d88dSmrg	if (fRenderer)
80af69d88dSmrg		fRenderer->UnlockGL();
81af69d88dSmrg	fDisplayLock.Unlock();
82af69d88dSmrg
83af69d88dSmrg	// TODO: release the GL API lock to others glviews
84af69d88dSmrg}
85af69d88dSmrg
86af69d88dSmrg
87af69d88dSmrgvoid
88af69d88dSmrgBGLView::SwapBuffers()
89af69d88dSmrg{
90af69d88dSmrg	SwapBuffers(false);
91af69d88dSmrg}
92af69d88dSmrg
93af69d88dSmrg
94af69d88dSmrgvoid
95af69d88dSmrgBGLView::SwapBuffers(bool vSync)
96af69d88dSmrg{
97af69d88dSmrg	if (fRenderer) {
98af69d88dSmrg		_LockDraw();
99af69d88dSmrg		fRenderer->SwapBuffers(vSync);
100af69d88dSmrg		_UnlockDraw();
101af69d88dSmrg	}
102af69d88dSmrg}
103af69d88dSmrg
104af69d88dSmrg
105af69d88dSmrgBView*
106af69d88dSmrgBGLView::EmbeddedView()
107af69d88dSmrg{
108af69d88dSmrg	return NULL;
109af69d88dSmrg}
110af69d88dSmrg
111af69d88dSmrg
112af69d88dSmrgvoid*
113af69d88dSmrgBGLView::GetGLProcAddress(const char* procName)
114af69d88dSmrg{
115af69d88dSmrg	BGLDispatcher* glDispatcher = NULL;
116af69d88dSmrg
117af69d88dSmrg	if (fRenderer)
118af69d88dSmrg		glDispatcher = fRenderer->GLDispatcher();
119af69d88dSmrg
120af69d88dSmrg	if (glDispatcher)
121af69d88dSmrg		return (void*)glDispatcher->AddressOf(procName);
122af69d88dSmrg
123af69d88dSmrg	return NULL;
124af69d88dSmrg}
125af69d88dSmrg
126af69d88dSmrg
127af69d88dSmrgstatus_t
128af69d88dSmrgBGLView::CopyPixelsOut(BPoint source, BBitmap* dest)
129af69d88dSmrg{
130af69d88dSmrg	if (!fRenderer)
131af69d88dSmrg		return B_ERROR;
132af69d88dSmrg
133af69d88dSmrg	if (!dest || !dest->Bounds().IsValid())
134af69d88dSmrg		return B_BAD_VALUE;
135af69d88dSmrg
136af69d88dSmrg	return fRenderer->CopyPixelsOut(source, dest);
137af69d88dSmrg}
138af69d88dSmrg
139af69d88dSmrg
140af69d88dSmrgstatus_t
141af69d88dSmrgBGLView::CopyPixelsIn(BBitmap* source, BPoint dest)
142af69d88dSmrg{
143af69d88dSmrg	if (!fRenderer)
144af69d88dSmrg		return B_ERROR;
145af69d88dSmrg
146af69d88dSmrg	if (!source || !source->Bounds().IsValid())
147af69d88dSmrg		return B_BAD_VALUE;
148af69d88dSmrg
149af69d88dSmrg	return fRenderer->CopyPixelsIn(source, dest);
150af69d88dSmrg}
151af69d88dSmrg
152af69d88dSmrg
153af69d88dSmrg/*!	Mesa's GLenum is not ulong but uint, so we can't use GLenum
154af69d88dSmrg	without breaking this method signature.
155af69d88dSmrg	Instead, we have to use the effective BeOS's SGI OpenGL GLenum type:
156af69d88dSmrg	unsigned long.
157af69d88dSmrg */
158af69d88dSmrgvoid
159af69d88dSmrgBGLView::ErrorCallback(unsigned long errorCode)
160af69d88dSmrg{
161af69d88dSmrg	char msg[32];
162af69d88dSmrg	sprintf(msg, "GL: Error code $%04lx.", errorCode);
163af69d88dSmrg	// TODO: under BeOS R5, it call debugger(msg);
164af69d88dSmrg	fprintf(stderr, "%s\n", msg);
165af69d88dSmrg}
166af69d88dSmrg
167af69d88dSmrg
168af69d88dSmrgvoid
169af69d88dSmrgBGLView::Draw(BRect updateRect)
170af69d88dSmrg{
171af69d88dSmrg	if (fRenderer) {
172af69d88dSmrg		_LockDraw();
173af69d88dSmrg		fRenderer->Draw(updateRect);
174af69d88dSmrg		_UnlockDraw();
175af69d88dSmrg		return;
176af69d88dSmrg	}
177af69d88dSmrg	// TODO: auto-size and center the string
178af69d88dSmrg	MovePenTo(8, 32);
179af69d88dSmrg	DrawString("No OpenGL renderer available!");
180af69d88dSmrg}
181af69d88dSmrg
182af69d88dSmrg
183af69d88dSmrgvoid
184af69d88dSmrgBGLView::AttachedToWindow()
185af69d88dSmrg{
186af69d88dSmrg	BView::AttachedToWindow();
187af69d88dSmrg
188af69d88dSmrg	fBounds = Bounds();
189af69d88dSmrg	for (BView* view = this; view != NULL; view = view->Parent())
190af69d88dSmrg		view->ConvertToParent(&fBounds);
191af69d88dSmrg
192af69d88dSmrg	fRenderer = fRoster->GetRenderer();
193af69d88dSmrg	if (fRenderer != NULL) {
194af69d88dSmrg		// Jackburton: The following code was commented because it doesn't look
195af69d88dSmrg		// good in "direct" mode:
196af69d88dSmrg		// when the window is moved, the app_server doesn't paint the view's
197af69d88dSmrg		// background, and the stuff behind the window itself shows up.
198af69d88dSmrg		// Setting the view color to black, instead, looks a bit more elegant.
199af69d88dSmrg#if 0
200af69d88dSmrg		// Don't paint white window background when resized
201af69d88dSmrg		SetViewColor(B_TRANSPARENT_32_BIT);
202af69d88dSmrg#else
203af69d88dSmrg		SetViewColor(0, 0, 0);
204af69d88dSmrg#endif
205af69d88dSmrg
206af69d88dSmrg		// Set default OpenGL viewport:
207af69d88dSmrg		LockGL();
208af69d88dSmrg		glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight());
209af69d88dSmrg		UnlockGL();
210af69d88dSmrg		fRenderer->FrameResized(Bounds().IntegerWidth(),
211af69d88dSmrg			Bounds().IntegerHeight());
212af69d88dSmrg
213af69d88dSmrg		if (fClipInfo) {
214af69d88dSmrg			fRenderer->DirectConnected(fClipInfo->direct_info);
215af69d88dSmrg			fRenderer->EnableDirectMode(fClipInfo->enable_direct_mode);
216af69d88dSmrg		}
217af69d88dSmrg
218af69d88dSmrg		return;
219af69d88dSmrg	}
220af69d88dSmrg
221af69d88dSmrg	fprintf(stderr, "no renderer found! \n");
222af69d88dSmrg
223af69d88dSmrg	// No Renderer, no rendering. Setup a minimal "No Renderer" string drawing
224af69d88dSmrg	// context
225af69d88dSmrg	SetFont(be_bold_font);
226af69d88dSmrg	// SetFontSize(16);
227af69d88dSmrg}
228af69d88dSmrg
229af69d88dSmrg
230af69d88dSmrgvoid
231af69d88dSmrgBGLView::AllAttached()
232af69d88dSmrg{
233af69d88dSmrg	BView::AllAttached();
234af69d88dSmrg}
235af69d88dSmrg
236af69d88dSmrg
237af69d88dSmrgvoid
238af69d88dSmrgBGLView::DetachedFromWindow()
239af69d88dSmrg{
240af69d88dSmrg	if (fRenderer)
241af69d88dSmrg		fRenderer->Release();
242af69d88dSmrg	fRenderer = NULL;
243af69d88dSmrg
244af69d88dSmrg	BView::DetachedFromWindow();
245af69d88dSmrg}
246af69d88dSmrg
247af69d88dSmrg
248af69d88dSmrgvoid
249af69d88dSmrgBGLView::AllDetached()
250af69d88dSmrg{
251af69d88dSmrg	BView::AllDetached();
252af69d88dSmrg}
253af69d88dSmrg
254af69d88dSmrg
255af69d88dSmrgvoid
256af69d88dSmrgBGLView::FrameResized(float width, float height)
257af69d88dSmrg{
258af69d88dSmrg	fBounds = Bounds();
259af69d88dSmrg	for (BView* v = this; v; v = v->Parent())
260af69d88dSmrg		v->ConvertToParent(&fBounds);
261af69d88dSmrg
262af69d88dSmrg	if (fRenderer) {
263af69d88dSmrg		LockGL();
264af69d88dSmrg		_LockDraw();
265af69d88dSmrg		_CallDirectConnected();
266af69d88dSmrg		fRenderer->FrameResized(width, height);
267af69d88dSmrg		_UnlockDraw();
268af69d88dSmrg		UnlockGL();
269af69d88dSmrg	}
270af69d88dSmrg
271af69d88dSmrg	BView::FrameResized(width, height);
272af69d88dSmrg}
273af69d88dSmrg
274af69d88dSmrg
275af69d88dSmrgstatus_t
276af69d88dSmrgBGLView::Perform(perform_code d, void* arg)
277af69d88dSmrg{
278af69d88dSmrg	return BView::Perform(d, arg);
279af69d88dSmrg}
280af69d88dSmrg
281af69d88dSmrg
282af69d88dSmrgstatus_t
283af69d88dSmrgBGLView::Archive(BMessage* data, bool deep) const
284af69d88dSmrg{
285af69d88dSmrg	return BView::Archive(data, deep);
286af69d88dSmrg}
287af69d88dSmrg
288af69d88dSmrg
289af69d88dSmrgvoid
290af69d88dSmrgBGLView::MessageReceived(BMessage* msg)
291af69d88dSmrg{
292af69d88dSmrg	BView::MessageReceived(msg);
293af69d88dSmrg}
294af69d88dSmrg
295af69d88dSmrg
296af69d88dSmrgvoid
297af69d88dSmrgBGLView::SetResizingMode(uint32 mode)
298af69d88dSmrg{
299af69d88dSmrg	BView::SetResizingMode(mode);
300af69d88dSmrg}
301af69d88dSmrg
302af69d88dSmrg
303af69d88dSmrgvoid
304af69d88dSmrgBGLView::GetPreferredSize(float* _width, float* _height)
305af69d88dSmrg{
306af69d88dSmrg	if (_width)
307af69d88dSmrg		*_width = 0;
308af69d88dSmrg	if (_height)
309af69d88dSmrg		*_height = 0;
310af69d88dSmrg}
311af69d88dSmrg
312af69d88dSmrg
313af69d88dSmrgvoid
314af69d88dSmrgBGLView::Show()
315af69d88dSmrg{
316af69d88dSmrg	BView::Show();
317af69d88dSmrg}
318af69d88dSmrg
319af69d88dSmrg
320af69d88dSmrgvoid
321af69d88dSmrgBGLView::Hide()
322af69d88dSmrg{
323af69d88dSmrg	BView::Hide();
324af69d88dSmrg}
325af69d88dSmrg
326af69d88dSmrg
327af69d88dSmrgBHandler*
328af69d88dSmrgBGLView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier,
329af69d88dSmrg	int32 form, const char* property)
330af69d88dSmrg{
331af69d88dSmrg	return BView::ResolveSpecifier(msg, index, specifier, form, property);
332af69d88dSmrg}
333af69d88dSmrg
334af69d88dSmrg
335af69d88dSmrgstatus_t
336af69d88dSmrgBGLView::GetSupportedSuites(BMessage* data)
337af69d88dSmrg{
338af69d88dSmrg	return BView::GetSupportedSuites(data);
339af69d88dSmrg}
340af69d88dSmrg
341af69d88dSmrg
342af69d88dSmrgvoid
343af69d88dSmrgBGLView::DirectConnected(direct_buffer_info* info)
344af69d88dSmrg{
345af69d88dSmrg	if (fClipInfo == NULL) {
346af69d88dSmrg		fClipInfo = new (std::nothrow) glview_direct_info();
347af69d88dSmrg		if (fClipInfo == NULL)
348af69d88dSmrg			return;
349af69d88dSmrg	}
350af69d88dSmrg
351af69d88dSmrg	direct_buffer_info* localInfo = fClipInfo->direct_info;
352af69d88dSmrg
353af69d88dSmrg	switch (info->buffer_state & B_DIRECT_MODE_MASK) {
354af69d88dSmrg		case B_DIRECT_START:
355af69d88dSmrg			fClipInfo->direct_connected = true;
356af69d88dSmrg			memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE);
357af69d88dSmrg			_UnlockDraw();
358af69d88dSmrg			break;
359af69d88dSmrg
360af69d88dSmrg		case B_DIRECT_MODIFY:
361af69d88dSmrg			_LockDraw();
362af69d88dSmrg			memcpy(localInfo, info, DIRECT_BUFFER_INFO_AREA_SIZE);
363af69d88dSmrg			_UnlockDraw();
364af69d88dSmrg			break;
365af69d88dSmrg
366af69d88dSmrg		case B_DIRECT_STOP:
367af69d88dSmrg			fClipInfo->direct_connected = false;
368af69d88dSmrg			_LockDraw();
369af69d88dSmrg			break;
370af69d88dSmrg	}
371af69d88dSmrg
372af69d88dSmrg	if (fRenderer)
373af69d88dSmrg		_CallDirectConnected();
374af69d88dSmrg}
375af69d88dSmrg
376af69d88dSmrg
377af69d88dSmrgvoid
378af69d88dSmrgBGLView::EnableDirectMode(bool enabled)
379af69d88dSmrg{
380af69d88dSmrg	if (fRenderer)
381af69d88dSmrg		fRenderer->EnableDirectMode(enabled);
382af69d88dSmrg	if (fClipInfo == NULL) {
383af69d88dSmrg		fClipInfo = new (std::nothrow) glview_direct_info();
384af69d88dSmrg		if (fClipInfo == NULL)
385af69d88dSmrg			return;
386af69d88dSmrg	}
387af69d88dSmrg
388af69d88dSmrg	fClipInfo->enable_direct_mode = enabled;
389af69d88dSmrg}
390af69d88dSmrg
391af69d88dSmrg
392af69d88dSmrgvoid
393af69d88dSmrgBGLView::_LockDraw()
394af69d88dSmrg{
395af69d88dSmrg	if (!fClipInfo || !fClipInfo->enable_direct_mode)
396af69d88dSmrg		return;
397af69d88dSmrg
398af69d88dSmrg	fDrawLock.Lock();
399af69d88dSmrg}
400af69d88dSmrg
401af69d88dSmrg
402af69d88dSmrgvoid
403af69d88dSmrgBGLView::_UnlockDraw()
404af69d88dSmrg{
405af69d88dSmrg	if (!fClipInfo || !fClipInfo->enable_direct_mode)
406af69d88dSmrg		return;
407af69d88dSmrg
408af69d88dSmrg	fDrawLock.Unlock();
409af69d88dSmrg}
410af69d88dSmrg
411af69d88dSmrg
412af69d88dSmrgvoid
413af69d88dSmrgBGLView::_CallDirectConnected()
414af69d88dSmrg{
415af69d88dSmrg	if (!fClipInfo)
416af69d88dSmrg		return;
417af69d88dSmrg
418af69d88dSmrg	direct_buffer_info* localInfo = fClipInfo->direct_info;
419af69d88dSmrg	direct_buffer_info* info = (direct_buffer_info*)malloc(
420af69d88dSmrg		DIRECT_BUFFER_INFO_AREA_SIZE);
421af69d88dSmrg	if (info == NULL)
422af69d88dSmrg		return;
423af69d88dSmrg
424af69d88dSmrg	memcpy(info, localInfo, DIRECT_BUFFER_INFO_AREA_SIZE);
425af69d88dSmrg
426af69d88dSmrg	// Collect the rects into a BRegion, then clip to the view's bounds
427af69d88dSmrg	BRegion region;
428af69d88dSmrg	for (uint32 c = 0; c < localInfo->clip_list_count; c++)
429af69d88dSmrg		region.Include(localInfo->clip_list[c]);
430af69d88dSmrg	BRegion boundsRegion = fBounds.OffsetByCopy(localInfo->window_bounds.left,
431af69d88dSmrg		localInfo->window_bounds.top);
432af69d88dSmrg	info->window_bounds = boundsRegion.RectAtInt(0);
433af69d88dSmrg		// window_bounds are now view bounds
434af69d88dSmrg	region.IntersectWith(&boundsRegion);
435af69d88dSmrg
436af69d88dSmrg	info->clip_list_count = region.CountRects();
437af69d88dSmrg	info->clip_bounds = region.FrameInt();
438af69d88dSmrg
439af69d88dSmrg	for (uint32 c = 0; c < info->clip_list_count; c++)
440af69d88dSmrg		info->clip_list[c] = region.RectAtInt(c);
441af69d88dSmrg	fRenderer->DirectConnected(info);
442af69d88dSmrg	free(info);
443af69d88dSmrg}
444af69d88dSmrg
445af69d88dSmrg
446af69d88dSmrg//---- virtual reserved methods ----------
447af69d88dSmrg
448af69d88dSmrg
449af69d88dSmrgvoid BGLView::_ReservedGLView1() {}
450af69d88dSmrgvoid BGLView::_ReservedGLView2() {}
451af69d88dSmrgvoid BGLView::_ReservedGLView3() {}
452af69d88dSmrgvoid BGLView::_ReservedGLView4() {}
453af69d88dSmrgvoid BGLView::_ReservedGLView5() {}
454af69d88dSmrgvoid BGLView::_ReservedGLView6() {}
455af69d88dSmrgvoid BGLView::_ReservedGLView7() {}
456af69d88dSmrgvoid BGLView::_ReservedGLView8() {}
457af69d88dSmrg
458af69d88dSmrg
459af69d88dSmrg// #pragma mark -
460af69d88dSmrg
461af69d88dSmrg
462af69d88dSmrg// BeOS compatibility: contrary to others BView's contructors,
463af69d88dSmrg// BGLView one wants a non-const name argument.
464af69d88dSmrgBGLView::BGLView(BRect rect, char* name, ulong resizingMode, ulong mode,
465af69d88dSmrg	ulong options)
466af69d88dSmrg	:
467af69d88dSmrg	BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS),
468af69d88dSmrg	fGc(NULL),
469af69d88dSmrg	fOptions(options),
470af69d88dSmrg	fDitherCount(0),
471af69d88dSmrg	fDrawLock("BGLView draw lock"),
472af69d88dSmrg	fDisplayLock("BGLView display lock"),
473af69d88dSmrg	fClipInfo(NULL),
474af69d88dSmrg	fRenderer(NULL),
475af69d88dSmrg	fRoster(NULL),
476af69d88dSmrg	fDitherMap(NULL)
477af69d88dSmrg{
478af69d88dSmrg	fRoster = new GLRendererRoster(this, options);
479af69d88dSmrg}
480af69d88dSmrg
481af69d88dSmrg
482af69d88dSmrg#if 0
483af69d88dSmrg// TODO: implement BGLScreen class...
484af69d88dSmrg
485af69d88dSmrg
486af69d88dSmrgBGLScreen::BGLScreen(char* name, ulong screenMode, ulong options,
487af69d88dSmrg		status_t* error, bool debug)
488af69d88dSmrg	:
489af69d88dSmrg	BWindowScreen(name, screenMode, error, debug)
490af69d88dSmrg{
491af69d88dSmrg}
492af69d88dSmrg
493af69d88dSmrg
494af69d88dSmrgBGLScreen::~BGLScreen()
495af69d88dSmrg{
496af69d88dSmrg}
497af69d88dSmrg
498af69d88dSmrg
499af69d88dSmrgvoid
500af69d88dSmrgBGLScreen::LockGL()
501af69d88dSmrg{
502af69d88dSmrg}
503af69d88dSmrg
504af69d88dSmrg
505af69d88dSmrgvoid
506af69d88dSmrgBGLScreen::UnlockGL()
507af69d88dSmrg{
508af69d88dSmrg}
509af69d88dSmrg
510af69d88dSmrg
511af69d88dSmrgvoid
512af69d88dSmrgBGLScreen::SwapBuffers()
513af69d88dSmrg{
514af69d88dSmrg}
515af69d88dSmrg
516af69d88dSmrg
517af69d88dSmrgvoid
518af69d88dSmrgBGLScreen::ErrorCallback(unsigned long errorCode)
519af69d88dSmrg{
520af69d88dSmrg	// Mesa's GLenum is not ulong but uint!
521af69d88dSmrg	char msg[32];
522af69d88dSmrg	sprintf(msg, "GL: Error code $%04lx.", errorCode);
523af69d88dSmrg	// debugger(msg);
524af69d88dSmrg	fprintf(stderr, "%s\n", msg);
525af69d88dSmrg	return;
526af69d88dSmrg}
527af69d88dSmrg
528af69d88dSmrg
529af69d88dSmrgvoid
530af69d88dSmrgBGLScreen::ScreenConnected(bool enabled)
531af69d88dSmrg{
532af69d88dSmrg}
533af69d88dSmrg
534af69d88dSmrg
535af69d88dSmrgvoid
536af69d88dSmrgBGLScreen::FrameResized(float width, float height)
537af69d88dSmrg{
538af69d88dSmrg	return BWindowScreen::FrameResized(width, height);
539af69d88dSmrg}
540af69d88dSmrg
541af69d88dSmrg
542af69d88dSmrgstatus_t
543af69d88dSmrgBGLScreen::Perform(perform_code d, void* arg)
544af69d88dSmrg{
545af69d88dSmrg	return BWindowScreen::Perform(d, arg);
546af69d88dSmrg}
547af69d88dSmrg
548af69d88dSmrg
549af69d88dSmrgstatus_t
550af69d88dSmrgBGLScreen::Archive(BMessage* data, bool deep) const
551af69d88dSmrg{
552af69d88dSmrg	return BWindowScreen::Archive(data, deep);
553af69d88dSmrg}
554af69d88dSmrg
555af69d88dSmrg
556af69d88dSmrgvoid
557af69d88dSmrgBGLScreen::MessageReceived(BMessage* msg)
558af69d88dSmrg{
559af69d88dSmrg	BWindowScreen::MessageReceived(msg);
560af69d88dSmrg}
561af69d88dSmrg
562af69d88dSmrg
563af69d88dSmrgvoid
564af69d88dSmrgBGLScreen::Show()
565af69d88dSmrg{
566af69d88dSmrg	BWindowScreen::Show();
567af69d88dSmrg}
568af69d88dSmrg
569af69d88dSmrg
570af69d88dSmrgvoid
571af69d88dSmrgBGLScreen::Hide()
572af69d88dSmrg{
573af69d88dSmrg	BWindowScreen::Hide();
574af69d88dSmrg}
575af69d88dSmrg
576af69d88dSmrg
577af69d88dSmrgBHandler*
578af69d88dSmrgBGLScreen::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier,
579af69d88dSmrg	int32 form, const char* property)
580af69d88dSmrg{
581af69d88dSmrg	return BWindowScreen::ResolveSpecifier(msg, index, specifier,
582af69d88dSmrg		form, property);
583af69d88dSmrg}
584af69d88dSmrg
585af69d88dSmrg
586af69d88dSmrgstatus_t
587af69d88dSmrgBGLScreen::GetSupportedSuites(BMessage* data)
588af69d88dSmrg{
589af69d88dSmrg	return BWindowScreen::GetSupportedSuites(data);
590af69d88dSmrg}
591af69d88dSmrg
592af69d88dSmrg
593af69d88dSmrg//---- virtual reserved methods ----------
594af69d88dSmrg
595af69d88dSmrgvoid BGLScreen::_ReservedGLScreen1() {}
596af69d88dSmrgvoid BGLScreen::_ReservedGLScreen2() {}
597af69d88dSmrgvoid BGLScreen::_ReservedGLScreen3() {}
598af69d88dSmrgvoid BGLScreen::_ReservedGLScreen4() {}
599af69d88dSmrgvoid BGLScreen::_ReservedGLScreen5() {}
600af69d88dSmrgvoid BGLScreen::_ReservedGLScreen6() {}
601af69d88dSmrgvoid BGLScreen::_ReservedGLScreen7() {}
602af69d88dSmrgvoid BGLScreen::_ReservedGLScreen8() {}
603af69d88dSmrg#endif
604af69d88dSmrg
605af69d88dSmrg
606af69d88dSmrgconst char* color_space_name(color_space space)
607af69d88dSmrg{
608af69d88dSmrg#define C2N(a)	case a:	return #a
609af69d88dSmrg
610af69d88dSmrg	switch (space) {
611af69d88dSmrg	C2N(B_RGB24);
612af69d88dSmrg	C2N(B_RGB32);
613af69d88dSmrg	C2N(B_RGBA32);
614af69d88dSmrg	C2N(B_RGB32_BIG);
615af69d88dSmrg	C2N(B_RGBA32_BIG);
616af69d88dSmrg	C2N(B_GRAY8);
617af69d88dSmrg	C2N(B_GRAY1);
618af69d88dSmrg	C2N(B_RGB16);
619af69d88dSmrg	C2N(B_RGB15);
620af69d88dSmrg	C2N(B_RGBA15);
621af69d88dSmrg	C2N(B_CMAP8);
622af69d88dSmrg	default:
623af69d88dSmrg		return "Unknown!";
624af69d88dSmrg	};
625af69d88dSmrg
626af69d88dSmrg#undef C2N
627af69d88dSmrg};
628af69d88dSmrg
629af69d88dSmrg
630af69d88dSmrgglview_direct_info::glview_direct_info()
631af69d88dSmrg{
632af69d88dSmrg	// TODO: See direct_window_data() in app_server's ServerWindow.cpp
633af69d88dSmrg	direct_info = (direct_buffer_info*)calloc(1, DIRECT_BUFFER_INFO_AREA_SIZE);
634af69d88dSmrg	direct_connected = false;
635af69d88dSmrg	enable_direct_mode = false;
636af69d88dSmrg}
637af69d88dSmrg
638af69d88dSmrg
639af69d88dSmrgglview_direct_info::~glview_direct_info()
640af69d88dSmrg{
641af69d88dSmrg	free(direct_info);
642af69d88dSmrg}
643af69d88dSmrg
644