⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glview.cpp

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 CPP
📖 第 1 页 / 共 4 页
字号:
void BGLView::SwapBuffers(bool vSync){	MesaDriver * md = (MesaDriver *) m_gc;	assert(md);	md->SwapBuffers();	if (vSync) {		BScreen screen(Window());		screen.WaitForRetrace();	}}#if 0void BGLView::CopySubBufferMESA(GLint x, GLint y, GLuint width, GLuint height){   MesaDriver * md = (MesaDriver *) m_gc;   assert(md);   md->CopySubBuffer(x, y, width, height);}#endifBView *	BGLView::EmbeddedView(){	return NULL;}status_t BGLView::CopyPixelsOut(BPoint source, BBitmap *dest){	if (! dest || ! dest->Bounds().IsValid())		return B_BAD_VALUE;	MesaDriver * md = (MesaDriver *) m_gc;	assert(md);	return md->CopyPixelsOut(source, dest);}status_t BGLView::CopyPixelsIn(BBitmap *source, BPoint dest){	if (! source || ! source->Bounds().IsValid())		return B_BAD_VALUE;	MesaDriver * md = (MesaDriver *) m_gc;	assert(md);	return md->CopyPixelsIn(source, dest);}void BGLView::ErrorCallback(unsigned long errorCode) // Mesa's GLenum is not ulong but uint!{	char msg[32];	sprintf(msg, "GL: Error code $%04lx.", errorCode);	// debugger(msg);	fprintf(stderr, "%s\n", msg);	return;}void BGLView::Draw(BRect updateRect){   // printf("BGLView::Draw()\n");   MesaDriver * md = (MesaDriver *) m_gc;   assert(md);   md->Draw(updateRect);}void BGLView::AttachedToWindow(){   BView::AttachedToWindow();   // don't paint window background white when resized   SetViewColor(B_TRANSPARENT_32_BIT);}void BGLView::AllAttached(){   BView::AllAttached();//   printf("BGLView AllAttached\n");}void BGLView::DetachedFromWindow(){   BView::DetachedFromWindow();}void BGLView::AllDetached(){   BView::AllDetached();//   printf("BGLView AllDetached");}void BGLView::FrameResized(float width, float height){   return BView::FrameResized(width, height);}status_t BGLView::Perform(perform_code d, void *arg){   return BView::Perform(d, arg);}status_t BGLView::Archive(BMessage *data, bool deep) const{   return BView::Archive(data, deep);}void BGLView::MessageReceived(BMessage *msg){   BView::MessageReceived(msg);}void BGLView::SetResizingMode(uint32 mode){   BView::SetResizingMode(mode);}void BGLView::Show(){   BView::Show();}void BGLView::Hide(){   BView::Hide();}BHandler *BGLView::ResolveSpecifier(BMessage *msg, int32 index,                                    BMessage *specifier, int32 form,                                    const char *property){   return BView::ResolveSpecifier(msg, index, specifier, form, property);}status_t BGLView::GetSupportedSuites(BMessage *data){   return BView::GetSupportedSuites(data);}void BGLView::DirectConnected( direct_buffer_info *info ){#if 0	if (! m_direct_connected && m_direct_connection_disabled) 		return; 	direct_info_locker->Lock(); 	switch(info->buffer_state & B_DIRECT_MODE_MASK) { 	case B_DIRECT_START: 		m_direct_connected = true;	case B_DIRECT_MODIFY: 		// Get clipping information 		if (m_clip_list)			free(m_clip_list); 		m_clip_list_count = info->clip_list_count; 		m_clip_list = (clipping_rect *) malloc(m_clip_list_count*sizeof(clipping_rect)); 		if (m_clip_list) { 			memcpy(m_clip_list, info->clip_list, m_clip_list_count*sizeof(clipping_rect));			fBits = (uint8 *) info->bits; 			fRowBytes = info->bytes_per_row; 			fFormat = info->pixel_format; 			fBounds = info->window_bounds; 			fDirty = true; 		} 		break; 	case B_DIRECT_STOP: 		fConnected = false; 		break; 	} 	direct_info_locker->Unlock(); #endif}void BGLView::EnableDirectMode( bool enabled ){   // TODO}//---- virtual reserved methods ----------void BGLView::_ReservedGLView1() {}void BGLView::_ReservedGLView2() {}void BGLView::_ReservedGLView3() {}void BGLView::_ReservedGLView4() {}void BGLView::_ReservedGLView5() {}void BGLView::_ReservedGLView6() {}void BGLView::_ReservedGLView7() {}void BGLView::_ReservedGLView8() {}#if 0// Not implemented!!!BGLView::BGLView(const BGLView &v)	: BView(v){   // XXX not sure how this should work   printf("Warning BGLView::copy constructor not implemented\n");}BGLView &BGLView::operator=(const BGLView &v){   printf("Warning BGLView::operator= not implemented\n");	return *this;}#endifvoid BGLView::dither_front(){   // no-op}bool BGLView::confirm_dither(){   // no-op   return false;}void BGLView::draw(BRect r){   // XXX no-op ???}/* Direct Window stuff */void BGLView::drawScanline( int x1, int x2, int y, void *data ){   // no-op}void BGLView::scanlineHandler(struct rasStateRec *state,                              GLint x1, GLint x2){   // no-op}void BGLView::lock_draw(){   // no-op}void BGLView::unlock_draw(){   // no-op}bool BGLView::validateView(){   // no-op   return true;}// #pragma mark -MesaDriver::MesaDriver(){   m_glcontext 		= NULL;   m_glvisual		= NULL;   m_glframebuffer 	= NULL;   m_bglview 		= NULL;   m_bitmap 		= NULL;   m_clear_color[BE_RCOMP] = 0;   m_clear_color[BE_GCOMP] = 0;   m_clear_color[BE_BCOMP] = 0;   m_clear_color[BE_ACOMP] = 0;   m_clear_index = 0;}MesaDriver::~MesaDriver(){   _mesa_destroy_visual(m_glvisual);   _mesa_destroy_framebuffer(m_glframebuffer);   _mesa_destroy_context(m_glcontext);      delete m_bitmap;}void MesaDriver::Init(BGLView * bglview, GLcontext * ctx, GLvisual * visual, GLframebuffer * framebuffer){	m_bglview 		= bglview;	m_glcontext 	= ctx;	m_glvisual 		= visual;	m_glframebuffer = framebuffer;	MesaDriver * md = (MesaDriver *) ctx->DriverCtx;	struct swrast_device_driver * swdd = _swrast_GetDeviceDriverReference( ctx );	TNLcontext * tnl = TNL_CONTEXT(ctx);	assert(md->m_glcontext == ctx );	assert(tnl);	assert(swdd);	// Use default TCL pipeline	tnl->Driver.RunPipeline = _tnl_run_pipeline; 	swdd->SetBuffer = this->SetBuffer;}void MesaDriver::LockGL(){	m_bglview->LockLooper();   UpdateState(m_glcontext, 0);   _mesa_make_current(m_glcontext, m_glframebuffer);}void MesaDriver::UnlockGL(){	if (m_bglview->Looper()->IsLocked())		m_bglview->UnlockLooper();   // Could call _mesa_make_current(NULL, NULL) but it would just   // hinder performance}void MesaDriver::SwapBuffers() const{    _mesa_notifySwapBuffers(m_glcontext);	if (m_bitmap) {		m_bglview->LockLooper();		m_bglview->DrawBitmap(m_bitmap);		m_bglview->UnlockLooper();	};}void MesaDriver::CopySubBuffer(GLint x, GLint y, GLuint width, GLuint height) const{   if (m_bitmap) {      // Source bitmap and view's bitmap are same size.      // Source and dest rectangle are the same.      // Note (x,y) = (0,0) is the lower-left corner, have to flip Y      BRect srcAndDest;      srcAndDest.left = x;      srcAndDest.right = x + width - 1;      srcAndDest.bottom = m_bottom - y;      srcAndDest.top = srcAndDest.bottom - height + 1;      m_bglview->DrawBitmap(m_bitmap, srcAndDest, srcAndDest);   }}status_t MesaDriver::CopyPixelsOut(BPoint location, BBitmap *bitmap){	color_space scs = m_bitmap->ColorSpace();	color_space dcs = bitmap->ColorSpace();	if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) {		printf("CopyPixelsOut(): incompatible color space: %s != %s\n",			color_space_name(scs),			color_space_name(dcs));		return B_BAD_TYPE;	}		// debugger("CopyPixelsOut()");		BRect sr = m_bitmap->Bounds();	BRect dr = bitmap->Bounds();	sr = sr & dr.OffsetBySelf(location);	dr = sr.OffsetByCopy(-location.x, -location.y); 		uint8 *ps = (uint8 *) m_bitmap->Bits();	uint8 *pd = (uint8 *) bitmap->Bits();	uint32 *s, *d;	uint32 y;	for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {		s = (uint32 *) (ps + y * m_bitmap->BytesPerRow());		s += (uint32) sr.left;				d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * bitmap->BytesPerRow());		d += (uint32) dr.left;				memcpy(d, s, dr.IntegerWidth() * 4);	}	return B_OK;}status_t MesaDriver::CopyPixelsIn(BBitmap *bitmap, BPoint location){	color_space scs = bitmap->ColorSpace();	color_space dcs = m_bitmap->ColorSpace();	if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {		printf("CopyPixelsIn(): incompatible color space: %s != %s\n",			color_space_name(scs),			color_space_name(dcs));		return B_BAD_TYPE;	}		// debugger("CopyPixelsIn()");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -