2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 #include "bufferobj.h"
38 #include "extensions.h"
42 #include "texformat.h"
46 #include "array_cache/acache.h"
47 #include "swrast/swrast.h"
48 #include "swrast_setup/swrast_setup.h"
49 #include "swrast/s_context.h"
50 #include "swrast/s_depth.h"
51 #include "swrast/s_lines.h"
52 #include "swrast/s_triangle.h"
53 #include "swrast/s_trispan.h"
55 #include "tnl/t_context.h"
56 #include "tnl/t_pipeline.h"
58 #include "drivers/common/driverfuncs.h"
62 #include <interface/Screen.h>
65 // BeOS component ordering for B_RGBA32 bitmap format
72 #define PACK_B_RGBA32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
73 (color[RCOMP] << 16) | (color[ACOMP] << 24))
75 #define PACK_B_RGB32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
76 (color[RCOMP] << 16) | 0xFF000000)
78 // Big Endian B_RGBA32 bitmap format
84 #define PACK_B_RGBA32(color) (color[ACOMP] | (color[RCOMP] << 8) | \
85 (color[GCOMP] << 16) | (color[BCOMP] << 24))
87 #define PACK_B_RGB32(color) ((color[RCOMP] << 8) | (color[GCOMP] << 16) | \
88 (color[BCOMP] << 24) | 0xFF000000)
91 #define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord) - 1)
93 const char * color_space_name(color_space space
);
96 // This object hangs off of the BGLView object. We have to use
97 // Be's BGLView class as-is to maintain binary compatibility (we
98 // can't add new members to it). Instead we just put all our data
99 // in this class and use BGLVIew::m_gc to point to it.
103 friend class BGLView
;
108 void Init(BGLView
* bglview
, GLcontext
* c
, GLvisual
* v
, GLframebuffer
* b
);
112 void SwapBuffers() const;
113 status_t
CopyPixelsOut(BPoint source
, BBitmap
*dest
);
114 status_t
CopyPixelsIn(BBitmap
*source
, BPoint dest
);
116 void CopySubBuffer(GLint x
, GLint y
, GLuint width
, GLuint height
) const;
117 void Draw(BRect updateRect
) const;
120 MesaDriver(const MesaDriver
&rhs
); // copy constructor illegal
121 MesaDriver
&operator=(const MesaDriver
&rhs
); // assignment oper. illegal
123 GLcontext
* m_glcontext
;
124 GLvisual
* m_glvisual
;
125 GLframebuffer
* m_glframebuffer
;
130 GLchan m_clear_color
[4]; // buffer clear color
131 GLuint m_clear_index
; // buffer clear color index
132 GLint m_bottom
; // used for flipping Y coords
136 // Mesa Device Driver callback functions
137 static void UpdateState(GLcontext
*ctx
, GLuint new_state
);
138 static void ClearIndex(GLcontext
*ctx
, GLuint index
);
139 static void ClearColor(GLcontext
*ctx
, const GLfloat color
[4]);
140 static void Clear(GLcontext
*ctx
, GLbitfield mask
,
141 GLboolean all
, GLint x
, GLint y
,
142 GLint width
, GLint height
);
143 static void ClearFront(GLcontext
*ctx
, GLboolean all
, GLint x
, GLint y
,
144 GLint width
, GLint height
);
145 static void ClearBack(GLcontext
*ctx
, GLboolean all
, GLint x
, GLint y
,
146 GLint width
, GLint height
);
147 static void Index(GLcontext
*ctx
, GLuint index
);
148 static void Color(GLcontext
*ctx
, GLubyte r
, GLubyte g
,
149 GLubyte b
, GLubyte a
);
150 static void SetBuffer(GLcontext
*ctx
, GLframebuffer
*colorBuffer
,
152 static void GetBufferSize(GLframebuffer
* framebuffer
, GLuint
*width
,
154 static void Error(GLcontext
*ctx
);
155 static const GLubyte
* GetString(GLcontext
*ctx
, GLenum name
);
157 // Front-buffer functions
158 static void WriteRGBASpanFront(const GLcontext
*ctx
, GLuint n
,
160 CONST GLubyte rgba
[][4],
161 const GLubyte mask
[]);
162 static void WriteRGBSpanFront(const GLcontext
*ctx
, GLuint n
,
164 CONST GLubyte rgba
[][3],
165 const GLubyte mask
[]);
166 static void WriteMonoRGBASpanFront(const GLcontext
*ctx
, GLuint n
,
168 const GLchan color
[4],
169 const GLubyte mask
[]);
170 static void WriteRGBAPixelsFront(const GLcontext
*ctx
, GLuint n
,
171 const GLint x
[], const GLint y
[],
172 CONST GLubyte rgba
[][4],
173 const GLubyte mask
[]);
174 static void WriteMonoRGBAPixelsFront(const GLcontext
*ctx
, GLuint n
,
175 const GLint x
[], const GLint y
[],
176 const GLchan color
[4],
177 const GLubyte mask
[]);
178 static void WriteCI32SpanFront(const GLcontext
*ctx
, GLuint n
,
180 const GLuint index
[], const GLubyte mask
[]);
181 static void WriteCI8SpanFront(const GLcontext
*ctx
, GLuint n
,
183 const GLubyte index
[], const GLubyte mask
[]);
184 static void WriteMonoCISpanFront(const GLcontext
*ctx
, GLuint n
,
186 GLuint colorIndex
, const GLubyte mask
[]);
187 static void WriteCI32PixelsFront(const GLcontext
*ctx
,
188 GLuint n
, const GLint x
[], const GLint y
[],
189 const GLuint index
[], const GLubyte mask
[]);
190 static void WriteMonoCIPixelsFront(const GLcontext
*ctx
, GLuint n
,
191 const GLint x
[], const GLint y
[],
192 GLuint colorIndex
, const GLubyte mask
[]);
193 static void ReadCI32SpanFront(const GLcontext
*ctx
,
194 GLuint n
, GLint x
, GLint y
, GLuint index
[]);
195 static void ReadRGBASpanFront(const GLcontext
*ctx
, GLuint n
,
198 static void ReadCI32PixelsFront(const GLcontext
*ctx
,
199 GLuint n
, const GLint x
[], const GLint y
[],
200 GLuint indx
[], const GLubyte mask
[]);
201 static void ReadRGBAPixelsFront(const GLcontext
*ctx
,
202 GLuint n
, const GLint x
[], const GLint y
[],
203 GLubyte rgba
[][4], const GLubyte mask
[]);
205 // Back buffer functions
206 static void WriteRGBASpanBack(const GLcontext
*ctx
, GLuint n
,
208 CONST GLubyte rgba
[][4],
209 const GLubyte mask
[]);
210 static void WriteRGBSpanBack(const GLcontext
*ctx
, GLuint n
,
212 CONST GLubyte rgba
[][3],
213 const GLubyte mask
[]);
214 static void WriteMonoRGBASpanBack(const GLcontext
*ctx
, GLuint n
,
216 const GLchan color
[4],
217 const GLubyte mask
[]);
218 static void WriteRGBAPixelsBack(const GLcontext
*ctx
, GLuint n
,
219 const GLint x
[], const GLint y
[],
220 CONST GLubyte rgba
[][4],
221 const GLubyte mask
[]);
222 static void WriteMonoRGBAPixelsBack(const GLcontext
*ctx
, GLuint n
,
223 const GLint x
[], const GLint y
[],
224 const GLchan color
[4],
225 const GLubyte mask
[]);
226 static void WriteCI32SpanBack(const GLcontext
*ctx
, GLuint n
,
228 const GLuint index
[], const GLubyte mask
[]);
229 static void WriteCI8SpanBack(const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
230 const GLubyte index
[], const GLubyte mask
[]);
231 static void WriteMonoCISpanBack(const GLcontext
*ctx
, GLuint n
,
232 GLint x
, GLint y
, GLuint colorIndex
,
233 const GLubyte mask
[]);
234 static void WriteCI32PixelsBack(const GLcontext
*ctx
,
235 GLuint n
, const GLint x
[], const GLint y
[],
236 const GLuint index
[], const GLubyte mask
[]);
237 static void WriteMonoCIPixelsBack(const GLcontext
*ctx
,
238 GLuint n
, const GLint x
[], const GLint y
[],
239 GLuint colorIndex
, const GLubyte mask
[]);
240 static void ReadCI32SpanBack(const GLcontext
*ctx
,
241 GLuint n
, GLint x
, GLint y
, GLuint index
[]);
242 static void ReadRGBASpanBack(const GLcontext
*ctx
, GLuint n
,
245 static void ReadCI32PixelsBack(const GLcontext
*ctx
,
246 GLuint n
, const GLint x
[], const GLint y
[],
247 GLuint indx
[], const GLubyte mask
[]);
248 static void ReadRGBAPixelsBack(const GLcontext
*ctx
,
249 GLuint n
, const GLint x
[], const GLint y
[],
250 GLubyte rgba
[][4], const GLubyte mask
[]);
254 //------------------------------------------------------------------
255 // Public interface methods
256 //------------------------------------------------------------------
260 // Input: rect - initial rectangle
261 // name - window name
262 // resizingMode - example: B_FOLLOW_NONE
263 // mode - usually 0 ?
264 // options - Bitwise-OR of BGL_* tokens
266 BGLView::BGLView(BRect rect
, char *name
,
267 ulong resizingMode
, ulong mode
,
269 : BView(rect
, name
, B_FOLLOW_ALL_SIDES
, mode
| B_WILL_DRAW
| B_FRAME_EVENTS
) // | B_FULL_UPDATE_ON_RESIZE)
271 // We don't support single buffering (yet): double buffering forced.
272 options
|= BGL_DOUBLE
;
274 const GLboolean rgbFlag
= ((options
& BGL_INDEX
) == 0);
275 const GLboolean alphaFlag
= ((options
& BGL_ALPHA
) == BGL_ALPHA
);
276 const GLboolean dblFlag
= ((options
& BGL_DOUBLE
) == BGL_DOUBLE
);
277 const GLboolean stereoFlag
= false;
278 const GLint depth
= (options
& BGL_DEPTH
) ? 16 : 0;
279 const GLint stencil
= (options
& BGL_STENCIL
) ? 8 : 0;
280 const GLint accum
= (options
& BGL_ACCUM
) ? 16 : 0;
281 const GLint index
= (options
& BGL_INDEX
) ? 32 : 0;
282 const GLint red
= rgbFlag
? 8 : 0;
283 const GLint green
= rgbFlag
? 8 : 0;
284 const GLint blue
= rgbFlag
? 8 : 0;
285 const GLint alpha
= alphaFlag
? 8 : 0;
287 m_options
= options
| BGL_INDIRECT
;
289 struct dd_function_table functions
;
292 fprintf(stderr
, "Mesa Warning: color index mode not supported\n");
295 // Allocate auxiliary data object
296 MesaDriver
* md
= new MesaDriver();
298 // examine option flags and create gl_context struct
299 GLvisual
* visual
= _mesa_create_visual( rgbFlag
,
302 red
, green
, blue
, alpha
,
306 accum
, accum
, accum
, accum
,
310 // Initialize device driver function table
311 _mesa_init_driver_functions(&functions
);
313 functions
.GetString
= md
->GetString
;
314 functions
.UpdateState
= md
->UpdateState
;
315 functions
.GetBufferSize
= md
->GetBufferSize
;
316 functions
.Clear
= md
->Clear
;
317 functions
.ClearIndex
= md
->ClearIndex
;
318 functions
.ClearColor
= md
->ClearColor
;
319 functions
.Error
= md
->Error
;
321 // create core context
322 GLcontext
*ctx
= _mesa_create_context(visual
, NULL
, &functions
, md
);
324 _mesa_destroy_visual(visual
);
328 _mesa_enable_sw_extensions(ctx
);
329 _mesa_enable_1_3_extensions(ctx
);
330 _mesa_enable_1_4_extensions(ctx
);
331 _mesa_enable_1_5_extensions(ctx
);
334 // create core framebuffer
335 GLframebuffer
* buffer
= _mesa_create_framebuffer(visual
,
336 depth
> 0 ? GL_TRUE
: GL_FALSE
,
337 stencil
> 0 ? GL_TRUE
: GL_FALSE
,
338 accum
> 0 ? GL_TRUE
: GL_FALSE
,
342 /* Initialize the software rasterizer and helper modules.
344 _swrast_CreateContext(ctx
);
345 _ac_CreateContext(ctx
);
346 _tnl_CreateContext(ctx
);
347 _swsetup_CreateContext(ctx
);
348 _swsetup_Wakeup(ctx
);
350 md
->Init(this, ctx
, visual
, buffer
);
352 // Hook aux data into BGLView object
355 // some stupid applications (Quake2) don't even think about calling LockGL()
356 // before using glGetString and friends... so make sure there is at least a
358 if (!_mesa_get_current_context()) {
360 // not needed, we don't have a looper yet: UnlockLooper();
368 // printf("BGLView destructor\n");
369 MesaDriver
* md
= (MesaDriver
*) m_gc
;
374 void BGLView::LockGL()
376 MesaDriver
* md
= (MesaDriver
*) m_gc
;
381 void BGLView::UnlockGL()
383 MesaDriver
* md
= (MesaDriver
*) m_gc
;
388 void BGLView::SwapBuffers()
393 void BGLView::SwapBuffers(bool vSync
)
395 MesaDriver
* md
= (MesaDriver
*) m_gc
;
400 BScreen
screen(Window());
401 screen
.WaitForRetrace();
407 void BGLView::CopySubBufferMESA(GLint x
, GLint y
, GLuint width
, GLuint height
)
409 MesaDriver
* md
= (MesaDriver
*) m_gc
;
411 md
->CopySubBuffer(x
, y
, width
, height
);
415 BView
* BGLView::EmbeddedView()
420 status_t
BGLView::CopyPixelsOut(BPoint source
, BBitmap
*dest
)
422 if (! dest
|| ! dest
->Bounds().IsValid())
425 MesaDriver
* md
= (MesaDriver
*) m_gc
;
427 return md
->CopyPixelsOut(source
, dest
);
430 status_t
BGLView::CopyPixelsIn(BBitmap
*source
, BPoint dest
)
432 if (! source
|| ! source
->Bounds().IsValid())
435 MesaDriver
* md
= (MesaDriver
*) m_gc
;
437 return md
->CopyPixelsIn(source
, dest
);
441 void BGLView::ErrorCallback(unsigned long errorCode
) // Mesa's GLenum is not ulong but uint!
444 sprintf(msg
, "GL: Error code $%04lx.", errorCode
);
446 fprintf(stderr
, "%s\n", msg
);
450 void BGLView::Draw(BRect updateRect
)
452 // printf("BGLView::Draw()\n");
453 MesaDriver
* md
= (MesaDriver
*) m_gc
;
455 md
->Draw(updateRect
);
458 void BGLView::AttachedToWindow()
460 BView::AttachedToWindow();
462 // don't paint window background white when resized
463 SetViewColor(B_TRANSPARENT_32_BIT
);
466 void BGLView::AllAttached()
468 BView::AllAttached();
469 // printf("BGLView AllAttached\n");
472 void BGLView::DetachedFromWindow()
474 BView::DetachedFromWindow();
477 void BGLView::AllDetached()
479 BView::AllDetached();
480 // printf("BGLView AllDetached");
483 void BGLView::FrameResized(float width
, float height
)
485 return BView::FrameResized(width
, height
);
488 status_t
BGLView::Perform(perform_code d
, void *arg
)
490 return BView::Perform(d
, arg
);
494 status_t
BGLView::Archive(BMessage
*data
, bool deep
) const
496 return BView::Archive(data
, deep
);
499 void BGLView::MessageReceived(BMessage
*msg
)
501 BView::MessageReceived(msg
);
504 void BGLView::SetResizingMode(uint32 mode
)
506 BView::SetResizingMode(mode
);
519 BHandler
*BGLView::ResolveSpecifier(BMessage
*msg
, int32 index
,
520 BMessage
*specifier
, int32 form
,
521 const char *property
)
523 return BView::ResolveSpecifier(msg
, index
, specifier
, form
, property
);
526 status_t
BGLView::GetSupportedSuites(BMessage
*data
)
528 return BView::GetSupportedSuites(data
);
531 void BGLView::DirectConnected( direct_buffer_info
*info
)
534 if (! m_direct_connected
&& m_direct_connection_disabled
)
537 direct_info_locker
->Lock();
538 switch(info
->buffer_state
& B_DIRECT_MODE_MASK
) {
540 m_direct_connected
= true;
541 case B_DIRECT_MODIFY
:
542 // Get clipping information
545 m_clip_list_count
= info
->clip_list_count
;
546 m_clip_list
= (clipping_rect
*) malloc(m_clip_list_count
*sizeof(clipping_rect
));
548 memcpy(m_clip_list
, info
->clip_list
, m_clip_list_count
*sizeof(clipping_rect
));
549 fBits
= (uint8
*) info
->bits
;
550 fRowBytes
= info
->bytes_per_row
;
551 fFormat
= info
->pixel_format
;
552 fBounds
= info
->window_bounds
;
560 direct_info_locker
->Unlock();
564 void BGLView::EnableDirectMode( bool enabled
)
570 //---- virtual reserved methods ----------
572 void BGLView::_ReservedGLView1() {}
573 void BGLView::_ReservedGLView2() {}
574 void BGLView::_ReservedGLView3() {}
575 void BGLView::_ReservedGLView4() {}
576 void BGLView::_ReservedGLView5() {}
577 void BGLView::_ReservedGLView6() {}
578 void BGLView::_ReservedGLView7() {}
579 void BGLView::_ReservedGLView8() {}
582 // Not implemented!!!
584 BGLView::BGLView(const BGLView
&v
)
587 // XXX not sure how this should work
588 printf("Warning BGLView::copy constructor not implemented\n");
591 BGLView
&BGLView::operator=(const BGLView
&v
)
593 printf("Warning BGLView::operator= not implemented\n");
598 void BGLView::dither_front()
603 bool BGLView::confirm_dither()
609 void BGLView::draw(BRect r
)
614 /* Direct Window stuff */
615 void BGLView::drawScanline( int x1
, int x2
, int y
, void *data
)
620 void BGLView::scanlineHandler(struct rasStateRec
*state
,
626 void BGLView::lock_draw()
631 void BGLView::unlock_draw()
636 bool BGLView::validateView()
644 MesaDriver::MesaDriver()
648 m_glframebuffer
= NULL
;
652 m_clear_color
[BE_RCOMP
] = 0;
653 m_clear_color
[BE_GCOMP
] = 0;
654 m_clear_color
[BE_BCOMP
] = 0;
655 m_clear_color
[BE_ACOMP
] = 0;
661 MesaDriver::~MesaDriver()
663 _mesa_destroy_visual(m_glvisual
);
664 _mesa_destroy_framebuffer(m_glframebuffer
);
665 _mesa_destroy_context(m_glcontext
);
671 void MesaDriver::Init(BGLView
* bglview
, GLcontext
* ctx
, GLvisual
* visual
, GLframebuffer
* framebuffer
)
676 m_glframebuffer
= framebuffer
;
678 MesaDriver
* md
= (MesaDriver
*) ctx
->DriverCtx
;
679 struct swrast_device_driver
* swdd
= _swrast_GetDeviceDriverReference( ctx
);
680 TNLcontext
* tnl
= TNL_CONTEXT(ctx
);
682 assert(md
->m_glcontext
== ctx
);
686 // Use default TCL pipeline
687 tnl
->Driver
.RunPipeline
= _tnl_run_pipeline
;
689 swdd
->SetBuffer
= this->SetBuffer
;
693 void MesaDriver::LockGL()
695 m_bglview
->LockLooper();
697 UpdateState(m_glcontext
, 0);
698 _mesa_make_current(m_glcontext
, m_glframebuffer
);
702 void MesaDriver::UnlockGL()
704 if (m_bglview
->Looper()->IsLocked())
705 m_bglview
->UnlockLooper();
706 // Could call _mesa_make_current(NULL, NULL) but it would just
707 // hinder performance
711 void MesaDriver::SwapBuffers() const
713 _mesa_notifySwapBuffers(m_glcontext
);
716 m_bglview
->LockLooper();
717 m_bglview
->DrawBitmap(m_bitmap
);
718 m_bglview
->UnlockLooper();
723 void MesaDriver::CopySubBuffer(GLint x
, GLint y
, GLuint width
, GLuint height
) const
726 // Source bitmap and view's bitmap are same size.
727 // Source and dest rectangle are the same.
728 // Note (x,y) = (0,0) is the lower-left corner, have to flip Y
731 srcAndDest
.right
= x
+ width
- 1;
732 srcAndDest
.bottom
= m_bottom
- y
;
733 srcAndDest
.top
= srcAndDest
.bottom
- height
+ 1;
734 m_bglview
->DrawBitmap(m_bitmap
, srcAndDest
, srcAndDest
);
738 status_t
MesaDriver::CopyPixelsOut(BPoint location
, BBitmap
*bitmap
)
740 color_space scs
= m_bitmap
->ColorSpace();
741 color_space dcs
= bitmap
->ColorSpace();
743 if (scs
!= dcs
&& (scs
!= B_RGBA32
|| dcs
!= B_RGB32
)) {
744 printf("CopyPixelsOut(): incompatible color space: %s != %s\n",
745 color_space_name(scs
),
746 color_space_name(dcs
));
750 // debugger("CopyPixelsOut()");
752 BRect sr
= m_bitmap
->Bounds();
753 BRect dr
= bitmap
->Bounds();
755 sr
= sr
& dr
.OffsetBySelf(location
);
756 dr
= sr
.OffsetByCopy(-location
.x
, -location
.y
);
758 uint8
*ps
= (uint8
*) m_bitmap
->Bits();
759 uint8
*pd
= (uint8
*) bitmap
->Bits();
762 for (y
= (uint32
) sr
.top
; y
<= (uint32
) sr
.bottom
; y
++) {
763 s
= (uint32
*) (ps
+ y
* m_bitmap
->BytesPerRow());
764 s
+= (uint32
) sr
.left
;
766 d
= (uint32
*) (pd
+ (y
+ (uint32
) (dr
.top
- sr
.top
)) * bitmap
->BytesPerRow());
767 d
+= (uint32
) dr
.left
;
769 memcpy(d
, s
, dr
.IntegerWidth() * 4);
774 status_t
MesaDriver::CopyPixelsIn(BBitmap
*bitmap
, BPoint location
)
776 color_space scs
= bitmap
->ColorSpace();
777 color_space dcs
= m_bitmap
->ColorSpace();
779 if (scs
!= dcs
&& (dcs
!= B_RGBA32
|| scs
!= B_RGB32
)) {
780 printf("CopyPixelsIn(): incompatible color space: %s != %s\n",
781 color_space_name(scs
),
782 color_space_name(dcs
));
786 // debugger("CopyPixelsIn()");
788 BRect sr
= bitmap
->Bounds();
789 BRect dr
= m_bitmap
->Bounds();
791 sr
= sr
& dr
.OffsetBySelf(location
);
792 dr
= sr
.OffsetByCopy(-location
.x
, -location
.y
);
794 uint8
*ps
= (uint8
*) bitmap
->Bits();
795 uint8
*pd
= (uint8
*) m_bitmap
->Bits();
798 for (y
= (uint32
) sr
.top
; y
<= (uint32
) sr
.bottom
; y
++) {
799 s
= (uint32
*) (ps
+ y
* bitmap
->BytesPerRow());
800 s
+= (uint32
) sr
.left
;
802 d
= (uint32
*) (pd
+ (y
+ (uint32
) (dr
.top
- sr
.top
)) * m_bitmap
->BytesPerRow());
803 d
+= (uint32
) dr
.left
;
805 memcpy(d
, s
, dr
.IntegerWidth() * 4);
811 void MesaDriver::Draw(BRect updateRect
) const
814 m_bglview
->DrawBitmap(m_bitmap
, updateRect
, updateRect
);
818 void MesaDriver::Error(GLcontext
*ctx
)
820 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
821 if (md
&& md
->m_bglview
)
822 md
->m_bglview
->ErrorCallback((unsigned long) ctx
->ErrorValue
);
825 void MesaDriver::UpdateState( GLcontext
*ctx
, GLuint new_state
)
827 struct swrast_device_driver
* swdd
= _swrast_GetDeviceDriverReference( ctx
);
829 _swrast_InvalidateState( ctx
, new_state
);
830 _swsetup_InvalidateState( ctx
, new_state
);
831 _ac_InvalidateState( ctx
, new_state
);
832 _tnl_InvalidateState( ctx
, new_state
);
834 if (ctx
->Color
.DrawBuffer
[0] == GL_FRONT
) {
835 /* read/write front buffer */
836 swdd
->WriteRGBASpan
= MesaDriver::WriteRGBASpanFront
;
837 swdd
->WriteRGBSpan
= MesaDriver::WriteRGBSpanFront
;
838 swdd
->WriteRGBAPixels
= MesaDriver::WriteRGBAPixelsFront
;
839 swdd
->WriteMonoRGBASpan
= MesaDriver::WriteMonoRGBASpanFront
;
840 swdd
->WriteMonoRGBAPixels
= MesaDriver::WriteMonoRGBAPixelsFront
;
841 swdd
->WriteCI32Span
= MesaDriver::WriteCI32SpanFront
;
842 swdd
->WriteCI8Span
= MesaDriver::WriteCI8SpanFront
;
843 swdd
->WriteMonoCISpan
= MesaDriver::WriteMonoCISpanFront
;
844 swdd
->WriteCI32Pixels
= MesaDriver::WriteCI32PixelsFront
;
845 swdd
->WriteMonoCIPixels
= MesaDriver::WriteMonoCIPixelsFront
;
846 swdd
->ReadRGBASpan
= MesaDriver::ReadRGBASpanFront
;
847 swdd
->ReadRGBAPixels
= MesaDriver::ReadRGBAPixelsFront
;
848 swdd
->ReadCI32Span
= MesaDriver::ReadCI32SpanFront
;
849 swdd
->ReadCI32Pixels
= MesaDriver::ReadCI32PixelsFront
;
852 /* read/write back buffer */
853 swdd
->WriteRGBASpan
= MesaDriver::WriteRGBASpanBack
;
854 swdd
->WriteRGBSpan
= MesaDriver::WriteRGBSpanBack
;
855 swdd
->WriteRGBAPixels
= MesaDriver::WriteRGBAPixelsBack
;
856 swdd
->WriteMonoRGBASpan
= MesaDriver::WriteMonoRGBASpanBack
;
857 swdd
->WriteMonoRGBAPixels
= MesaDriver::WriteMonoRGBAPixelsBack
;
858 swdd
->WriteCI32Span
= MesaDriver::WriteCI32SpanBack
;
859 swdd
->WriteCI8Span
= MesaDriver::WriteCI8SpanBack
;
860 swdd
->WriteMonoCISpan
= MesaDriver::WriteMonoCISpanBack
;
861 swdd
->WriteCI32Pixels
= MesaDriver::WriteCI32PixelsBack
;
862 swdd
->WriteMonoCIPixels
= MesaDriver::WriteMonoCIPixelsBack
;
863 swdd
->ReadRGBASpan
= MesaDriver::ReadRGBASpanBack
;
864 swdd
->ReadRGBAPixels
= MesaDriver::ReadRGBAPixelsBack
;
865 swdd
->ReadCI32Span
= MesaDriver::ReadCI32SpanBack
;
866 swdd
->ReadCI32Pixels
= MesaDriver::ReadCI32PixelsBack
;
871 void MesaDriver::ClearIndex(GLcontext
*ctx
, GLuint index
)
873 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
874 md
->m_clear_index
= index
;
878 void MesaDriver::ClearColor(GLcontext
*ctx
, const GLfloat color
[4])
880 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
881 CLAMPED_FLOAT_TO_CHAN(md
->m_clear_color
[BE_RCOMP
], color
[0]);
882 CLAMPED_FLOAT_TO_CHAN(md
->m_clear_color
[BE_GCOMP
], color
[1]);
883 CLAMPED_FLOAT_TO_CHAN(md
->m_clear_color
[BE_BCOMP
], color
[2]);
884 CLAMPED_FLOAT_TO_CHAN(md
->m_clear_color
[BE_ACOMP
], color
[3]);
885 assert(md
->m_bglview
);
889 void MesaDriver::Clear(GLcontext
*ctx
, GLbitfield mask
,
890 GLboolean all
, GLint x
, GLint y
,
891 GLint width
, GLint height
)
893 if (mask
& DD_FRONT_LEFT_BIT
)
894 ClearFront(ctx
, all
, x
, y
, width
, height
);
895 if (mask
& DD_BACK_LEFT_BIT
)
896 ClearBack(ctx
, all
, x
, y
, width
, height
);
898 mask
&= ~(DD_FRONT_LEFT_BIT
| DD_BACK_LEFT_BIT
);
900 _swrast_Clear( ctx
, mask
, all
, x
, y
, width
, height
);
906 void MesaDriver::ClearFront(GLcontext
*ctx
,
907 GLboolean all
, GLint x
, GLint y
,
908 GLint width
, GLint height
)
910 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
911 BGLView
*bglview
= md
->m_bglview
;
914 bglview
->SetHighColor(md
->m_clear_color
[BE_RCOMP
],
915 md
->m_clear_color
[BE_GCOMP
],
916 md
->m_clear_color
[BE_BCOMP
],
917 md
->m_clear_color
[BE_ACOMP
]);
918 bglview
->SetLowColor(md
->m_clear_color
[BE_RCOMP
],
919 md
->m_clear_color
[BE_GCOMP
],
920 md
->m_clear_color
[BE_BCOMP
],
921 md
->m_clear_color
[BE_ACOMP
]);
923 BRect b
= bglview
->Bounds();
924 bglview
->FillRect(b
);
931 b
.bottom
= md
->m_height
- y
- 1;
932 b
.top
= b
.bottom
- height
;
933 bglview
->FillRect(b
);
936 // restore drawing color
938 bglview
->SetHighColor(md
->mColor
[BE_RCOMP
],
939 md
->mColor
[BE_GCOMP
],
940 md
->mColor
[BE_BCOMP
],
941 md
->mColor
[BE_ACOMP
]);
942 bglview
->SetLowColor(md
->mColor
[BE_RCOMP
],
943 md
->mColor
[BE_GCOMP
],
944 md
->mColor
[BE_BCOMP
],
945 md
->mColor
[BE_ACOMP
]);
950 void MesaDriver::ClearBack(GLcontext
*ctx
,
951 GLboolean all
, GLint x
, GLint y
,
952 GLint width
, GLint height
)
954 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
955 BGLView
*bglview
= md
->m_bglview
;
957 BBitmap
*bitmap
= md
->m_bitmap
;
959 GLuint
*start
= (GLuint
*) bitmap
->Bits();
960 const GLuint
*clearPixelPtr
= (const GLuint
*) md
->m_clear_color
;
961 const GLuint clearPixel
= B_LENDIAN_TO_HOST_INT32(*clearPixelPtr
);
964 const int numPixels
= md
->m_width
* md
->m_height
;
965 if (clearPixel
== 0) {
966 memset(start
, 0, numPixels
* 4);
969 for (int i
= 0; i
< numPixels
; i
++) {
970 start
[i
] = clearPixel
;
976 start
+= y
* md
->m_width
+ x
;
977 for (int i
= 0; i
< height
; i
++) {
978 for (int j
= 0; j
< width
; j
++) {
979 start
[j
] = clearPixel
;
981 start
+= md
->m_width
;
987 void MesaDriver::SetBuffer(GLcontext
*ctx
, GLframebuffer
*buffer
,
996 void MesaDriver::GetBufferSize(GLframebuffer
* framebuffer
, GLuint
*width
,
999 GET_CURRENT_CONTEXT(ctx
);
1003 MesaDriver
* md
= (MesaDriver
*) ctx
->DriverCtx
;
1004 BGLView
*bglview
= md
->m_bglview
;
1007 BRect b
= bglview
->Bounds();
1008 *width
= (GLuint
) b
.IntegerWidth() + 1; // (b.right - b.left + 1);
1009 *height
= (GLuint
) b
.IntegerHeight() + 1; // (b.bottom - b.top + 1);
1010 md
->m_bottom
= (GLint
) b
.bottom
;
1012 if (ctx
->Visual
.doubleBufferMode
) {
1013 if (*width
!= md
->m_width
|| *height
!= md
->m_height
) {
1014 // allocate new size of back buffer bitmap
1016 delete md
->m_bitmap
;
1017 BRect
rect(0.0, 0.0, *width
- 1, *height
- 1);
1018 md
->m_bitmap
= new BBitmap(rect
, B_RGBA32
);
1023 md
->m_bitmap
= NULL
;
1026 md
->m_width
= *width
;
1027 md
->m_height
= *height
;
1031 const GLubyte
*MesaDriver::GetString(GLcontext
*ctx
, GLenum name
)
1035 return (const GLubyte
*) "Mesa " MESA_VERSION_STRING
" powered BGLView (software)";
1037 // Let core library handle all other cases
1043 // Plot a pixel. (0,0) is upper-left corner
1044 // This is only used when drawing to the front buffer.
1045 inline void Plot(BGLView
*bglview
, int x
, int y
)
1047 // XXX There's got to be a better way!
1048 BPoint
p(x
, y
), q(x
+1, y
);
1049 bglview
->StrokeLine(p
, q
);
1053 void MesaDriver::WriteRGBASpanFront(const GLcontext
*ctx
, GLuint n
,
1055 CONST GLubyte rgba
[][4],
1056 const GLubyte mask
[])
1058 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1059 BGLView
*bglview
= md
->m_bglview
;
1061 int flippedY
= md
->m_bottom
- y
;
1063 for (GLuint i
= 0; i
< n
; i
++) {
1065 bglview
->SetHighColor(rgba
[i
][0], rgba
[i
][1], rgba
[i
][2], rgba
[i
][3]);
1066 Plot(bglview
, x
++, flippedY
);
1071 for (GLuint i
= 0; i
< n
; i
++) {
1072 bglview
->SetHighColor(rgba
[i
][0], rgba
[i
][1], rgba
[i
][2], rgba
[i
][3]);
1073 Plot(bglview
, x
++, flippedY
);
1078 void MesaDriver::WriteRGBSpanFront(const GLcontext
*ctx
, GLuint n
,
1080 CONST GLubyte rgba
[][3],
1081 const GLubyte mask
[])
1083 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1084 BGLView
*bglview
= md
->m_bglview
;
1086 int flippedY
= md
->m_bottom
- y
;
1088 for (GLuint i
= 0; i
< n
; i
++) {
1090 bglview
->SetHighColor(rgba
[i
][0], rgba
[i
][1], rgba
[i
][2]);
1091 Plot(bglview
, x
++, flippedY
);
1096 for (GLuint i
= 0; i
< n
; i
++) {
1097 bglview
->SetHighColor(rgba
[i
][0], rgba
[i
][1], rgba
[i
][2]);
1098 Plot(bglview
, x
++, flippedY
);
1103 void MesaDriver::WriteMonoRGBASpanFront(const GLcontext
*ctx
, GLuint n
,
1105 const GLchan color
[4],
1106 const GLubyte mask
[])
1108 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1109 BGLView
*bglview
= md
->m_bglview
;
1111 int flippedY
= md
->m_bottom
- y
;
1112 bglview
->SetHighColor(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1114 for (GLuint i
= 0; i
< n
; i
++) {
1116 Plot(bglview
, x
++, flippedY
);
1121 for (GLuint i
= 0; i
< n
; i
++) {
1122 Plot(bglview
, x
++, flippedY
);
1127 void MesaDriver::WriteRGBAPixelsFront(const GLcontext
*ctx
,
1128 GLuint n
, const GLint x
[], const GLint y
[],
1129 CONST GLubyte rgba
[][4],
1130 const GLubyte mask
[] )
1132 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1133 BGLView
*bglview
= md
->m_bglview
;
1136 for (GLuint i
= 0; i
< n
; i
++) {
1138 bglview
->SetHighColor(rgba
[i
][0], rgba
[i
][1], rgba
[i
][2]);
1139 Plot(bglview
, x
[i
], md
->m_bottom
- y
[i
]);
1144 for (GLuint i
= 0; i
< n
; i
++) {
1145 bglview
->SetHighColor(rgba
[i
][0], rgba
[i
][1], rgba
[i
][2]);
1146 Plot(bglview
, x
[i
], md
->m_bottom
- y
[i
]);
1152 void MesaDriver::WriteMonoRGBAPixelsFront(const GLcontext
*ctx
, GLuint n
,
1153 const GLint x
[], const GLint y
[],
1154 const GLchan color
[4],
1155 const GLubyte mask
[])
1157 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1158 BGLView
*bglview
= md
->m_bglview
;
1160 // plot points using current color
1161 bglview
->SetHighColor(color
[RCOMP
], color
[GCOMP
], color
[BCOMP
]);
1163 for (GLuint i
= 0; i
< n
; i
++) {
1165 Plot(bglview
, x
[i
], md
->m_bottom
- y
[i
]);
1170 for (GLuint i
= 0; i
< n
; i
++) {
1171 Plot(bglview
, x
[i
], md
->m_bottom
- y
[i
]);
1177 void MesaDriver::WriteCI32SpanFront( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1178 const GLuint index
[], const GLubyte mask
[] )
1180 printf("WriteCI32SpanFront() not implemented yet!\n");
1184 void MesaDriver::WriteCI8SpanFront( const GLcontext
*ctx
, GLuint n
, GLint x
, GLint y
,
1185 const GLubyte index
[], const GLubyte mask
[] )
1187 printf("WriteCI8SpanFront() not implemented yet!\n");
1191 void MesaDriver::WriteMonoCISpanFront( const GLcontext
*ctx
, GLuint n
,
1193 GLuint colorIndex
, const GLubyte mask
[] )
1195 printf("WriteMonoCISpanFront() not implemented yet!\n");
1200 void MesaDriver::WriteCI32PixelsFront( const GLcontext
*ctx
, GLuint n
,
1201 const GLint x
[], const GLint y
[],
1202 const GLuint index
[], const GLubyte mask
[] )
1204 printf("WriteCI32PixelsFront() not implemented yet!\n");
1208 void MesaDriver::WriteMonoCIPixelsFront( const GLcontext
*ctx
, GLuint n
,
1209 const GLint x
[], const GLint y
[],
1210 GLuint colorIndex
, const GLubyte mask
[] )
1212 printf("WriteMonoCIPixelsFront() not implemented yet!\n");
1217 void MesaDriver::ReadCI32SpanFront( const GLcontext
*ctx
,
1218 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
1220 printf("ReadCI32SpanFront() not implemented yet!\n");
1225 void MesaDriver::ReadRGBASpanFront( const GLcontext
*ctx
, GLuint n
,
1226 GLint x
, GLint y
, GLubyte rgba
[][4] )
1228 printf("ReadRGBASpanFront() not implemented yet!\n");
1233 void MesaDriver::ReadCI32PixelsFront( const GLcontext
*ctx
,
1234 GLuint n
, const GLint x
[], const GLint y
[],
1235 GLuint indx
[], const GLubyte mask
[] )
1237 printf("ReadCI32PixelsFront() not implemented yet!\n");
1242 void MesaDriver::ReadRGBAPixelsFront( const GLcontext
*ctx
,
1243 GLuint n
, const GLint x
[], const GLint y
[],
1244 GLubyte rgba
[][4], const GLubyte mask
[] )
1246 printf("ReadRGBAPixelsFront() not implemented yet!\n");
1253 void MesaDriver::WriteRGBASpanBack(const GLcontext
*ctx
, GLuint n
,
1255 CONST GLubyte rgba
[][4],
1256 const GLubyte mask
[])
1258 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1259 BBitmap
*bitmap
= md
->m_bitmap
;
1263 int row
= md
->m_bottom
- y
;
1264 uint8
* ptr
= (uint8
*) bitmap
->Bits() + (row
* bitmap
->BytesPerRow()) + x
* 4;
1265 uint32
* pixel
= (uint32
*) ptr
;
1270 *pixel
= PACK_B_RGBA32(rgba
[0]);
1276 *pixel
++ = PACK_B_RGBA32(rgba
[0]);
1283 void MesaDriver::WriteRGBSpanBack(const GLcontext
*ctx
, GLuint n
,
1285 CONST GLubyte rgb
[][3],
1286 const GLubyte mask
[])
1288 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1289 BBitmap
*bitmap
= md
->m_bitmap
;
1293 int row
= md
->m_bottom
- y
;
1294 uint8
* ptr
= (uint8
*) bitmap
->Bits() + (row
* bitmap
->BytesPerRow()) + x
* 4;
1295 uint32
* pixel
= (uint32
*) ptr
;
1300 *pixel
= PACK_B_RGB32(rgb
[0]);
1306 *pixel
++ = PACK_B_RGB32(rgb
[0]);
1315 void MesaDriver::WriteMonoRGBASpanBack(const GLcontext
*ctx
, GLuint n
,
1317 const GLchan color
[4], const GLubyte mask
[])
1319 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1320 BBitmap
*bitmap
= md
->m_bitmap
;
1324 int row
= md
->m_bottom
- y
;
1325 uint8
* ptr
= (uint8
*) bitmap
->Bits() + (row
* bitmap
->BytesPerRow()) + x
* 4;
1326 uint32
* pixel
= (uint32
*) ptr
;
1327 uint32 pixel_color
= PACK_B_RGBA32(color
);
1332 *pixel
= pixel_color
;
1337 *pixel
++ = pixel_color
;
1343 void MesaDriver::WriteRGBAPixelsBack(const GLcontext
*ctx
,
1344 GLuint n
, const GLint x
[], const GLint y
[],
1345 CONST GLubyte rgba
[][4],
1346 const GLubyte mask
[] )
1348 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1349 BBitmap
*bitmap
= md
->m_bitmap
;
1355 int row
= md
->m_bottom
- *y
;
1356 uint8
* pixel
= (uint8
*) bitmap
->Bits() + (row
* bitmap
->BytesPerRow()) + *x
* 4;
1357 *((uint32
*) pixel
) = PACK_B_RGBA32(rgba
[0]);
1365 for (GLuint i
= 0; i
< n
; i
++) {
1367 GLubyte
*pixel
= (GLubyte
*) bitmap
->Bits()
1368 + ((md
->m_bottom
- y
[i
]) * bitmap
->BytesPerRow()) + x
[i
] * 4;
1369 pixel
[BE_RCOMP
] = rgba
[i
][RCOMP
];
1370 pixel
[BE_GCOMP
] = rgba
[i
][GCOMP
];
1371 pixel
[BE_BCOMP
] = rgba
[i
][BCOMP
];
1372 pixel
[BE_ACOMP
] = rgba
[i
][ACOMP
];
1377 for (GLuint i
= 0; i
< n
; i
++) {
1378 GLubyte
*pixel
= (GLubyte
*) bitmap
->Bits()
1379 + ((md
->m_bottom
- y
[i
]) * bitmap
->BytesPerRow()) + x
[i
] * 4;
1380 pixel
[BE_RCOMP
] = rgba
[i
][RCOMP
];
1381 pixel
[BE_GCOMP
] = rgba
[i
][GCOMP
];
1382 pixel
[BE_BCOMP
] = rgba
[i
][BCOMP
];
1383 pixel
[BE_ACOMP
] = rgba
[i
][ACOMP
];
1390 void MesaDriver::WriteMonoRGBAPixelsBack(const GLcontext
*ctx
, GLuint n
,
1391 const GLint x
[], const GLint y
[],
1392 const GLchan color
[4],
1393 const GLubyte mask
[])
1395 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1396 BBitmap
*bitmap
= md
->m_bitmap
;
1400 uint32 pixel_color
= PACK_B_RGBA32(color
);
1404 int row
= md
->m_bottom
- *y
;
1405 uint8
* pixel
= (uint8
*) bitmap
->Bits() + (row
* bitmap
->BytesPerRow()) + *x
* 4;
1407 *((uint32
*) pixel
) = pixel_color
;
1414 for (GLuint i
= 0; i
< n
; i
++) {
1416 GLubyte
* ptr
= (GLubyte
*) bitmap
->Bits()
1417 + ((md
->m_bottom
- y
[i
]) * bitmap
->BytesPerRow()) + x
[i
] * 4;
1418 *((uint32
*) ptr
) = pixel_color
;
1423 for (GLuint i
= 0; i
< n
; i
++) {
1424 GLubyte
* ptr
= (GLubyte
*) bitmap
->Bits()
1425 + ((md
->m_bottom
- y
[i
]) * bitmap
->BytesPerRow()) + x
[i
] * 4;
1426 *((uint32
*) ptr
) = pixel_color
;
1433 void MesaDriver::WriteCI32SpanBack( const GLcontext
*ctx
, GLuint n
,
1435 const GLuint index
[], const GLubyte mask
[] )
1437 printf("WriteCI32SpanBack() not implemented yet!\n");
1441 void MesaDriver::WriteCI8SpanBack( const GLcontext
*ctx
, GLuint n
,
1443 const GLubyte index
[], const GLubyte mask
[] )
1445 printf("WriteCI8SpanBack() not implemented yet!\n");
1449 void MesaDriver::WriteMonoCISpanBack( const GLcontext
*ctx
, GLuint n
,
1451 GLuint colorIndex
, const GLubyte mask
[] )
1453 printf("WriteMonoCISpanBack() not implemented yet!\n");
1458 void MesaDriver::WriteCI32PixelsBack( const GLcontext
*ctx
, GLuint n
,
1459 const GLint x
[], const GLint y
[],
1460 const GLuint index
[], const GLubyte mask
[] )
1462 printf("WriteCI32PixelsBack() not implemented yet!\n");
1466 void MesaDriver::WriteMonoCIPixelsBack( const GLcontext
*ctx
, GLuint n
,
1467 const GLint x
[], const GLint y
[],
1468 GLuint colorIndex
, const GLubyte mask
[] )
1470 printf("WriteMonoCIPixelsBack() not implemented yet!\n");
1475 void MesaDriver::ReadCI32SpanBack( const GLcontext
*ctx
,
1476 GLuint n
, GLint x
, GLint y
, GLuint index
[] )
1478 printf("ReadCI32SpanBack() not implemented yet!\n");
1483 void MesaDriver::ReadRGBASpanBack( const GLcontext
*ctx
, GLuint n
,
1484 GLint x
, GLint y
, GLubyte rgba
[][4] )
1486 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1487 const BBitmap
*bitmap
= md
->m_bitmap
;
1489 int row
= md
->m_bottom
- y
;
1490 const GLubyte
*pixel
= (GLubyte
*) bitmap
->Bits()
1491 + (row
* bitmap
->BytesPerRow()) + x
* 4;
1493 for (GLuint i
= 0; i
< n
; i
++) {
1494 rgba
[i
][RCOMP
] = pixel
[BE_RCOMP
];
1495 rgba
[i
][GCOMP
] = pixel
[BE_GCOMP
];
1496 rgba
[i
][BCOMP
] = pixel
[BE_BCOMP
];
1497 rgba
[i
][ACOMP
] = pixel
[BE_ACOMP
];
1503 void MesaDriver::ReadCI32PixelsBack( const GLcontext
*ctx
,
1504 GLuint n
, const GLint x
[], const GLint y
[],
1505 GLuint indx
[], const GLubyte mask
[] )
1507 printf("ReadCI32PixelsBack() not implemented yet!\n");
1512 void MesaDriver::ReadRGBAPixelsBack( const GLcontext
*ctx
,
1513 GLuint n
, const GLint x
[], const GLint y
[],
1514 GLubyte rgba
[][4], const GLubyte mask
[] )
1516 MesaDriver
*md
= (MesaDriver
*) ctx
->DriverCtx
;
1517 const BBitmap
*bitmap
= md
->m_bitmap
;
1521 for (GLuint i
= 0; i
< n
; i
++) {
1523 GLubyte
*pixel
= (GLubyte
*) bitmap
->Bits()
1524 + ((md
->m_bottom
- y
[i
]) * bitmap
->BytesPerRow()) + x
[i
] * 4;
1525 rgba
[i
][RCOMP
] = pixel
[BE_RCOMP
];
1526 rgba
[i
][GCOMP
] = pixel
[BE_GCOMP
];
1527 rgba
[i
][BCOMP
] = pixel
[BE_BCOMP
];
1528 rgba
[i
][ACOMP
] = pixel
[BE_ACOMP
];
1532 for (GLuint i
= 0; i
< n
; i
++) {
1533 GLubyte
*pixel
= (GLubyte
*) bitmap
->Bits()
1534 + ((md
->m_bottom
- y
[i
]) * bitmap
->BytesPerRow()) + x
[i
] * 4;
1535 rgba
[i
][RCOMP
] = pixel
[BE_RCOMP
];
1536 rgba
[i
][GCOMP
] = pixel
[BE_GCOMP
];
1537 rgba
[i
][BCOMP
] = pixel
[BE_BCOMP
];
1538 rgba
[i
][ACOMP
] = pixel
[BE_ACOMP
];
1543 const char * color_space_name(color_space space
)
1545 #define C2N(a) case a: return #a