What is shareable between OpenGL contexts and how to enable sharing

I’m making a CAD software that will create different OpenGL contexts for similar view (if they aren’t showing the same thing).

I would like to share much data as possible between them OpenGL contexts, especially VBOs and shaders.

I want to know what I can share and how I share them, in a cross-platform way and possibly with plain OpenGL 3.2 (no engine).

1

The only things OpenGL contexts can share is objects. And even then, “container” objects cannot be shared. Container objects are objects whose primary purpose is to have other objects attached to them. Specifically, the following are container objects:

  • Framebuffer objects
  • Vertex array objects
  • Transform feedback objects
  • Program pipeline objects

All other objects can be shared.

Sharing objects is a context-based task, usually done either as part of the creation of the context or immediately afterwards. However, since this is done on the context itself, it cannot be a cross-platform operation. OpenGL only defines the behavior of the context, not how to manipulate the context object. The platform-specific APIs responsible for creating and managing contexts handle that: GLX, WGL, EGL, etc.

There are generally two ways this gets handled. One way is for the context creation function to take another context as a parameter; the newly created context will share all sharable objects with the given context. wglCreateContextAttribsARB is the WGL context creation function that takes a context to share with the new one.

The other ways is to use a function immediately after creating the context. This function takes two contexts and shares objects between them. However, you should use such a function immediately after creating the context; you don’t want to create objects in the destination context which might conflict with those already in the source. WGL has an older function, wglShareLists, that shares objects between contexts. I know it only talks about display lists, but it shares all sharable objects.

I’m making a CAD software that will create different OpenGL contexts for similar view (if they aren’t showing the same thing).

You don’t need different contexts for that. OpenGL contexts are not tied to a specific window or drawable. You can bind a OpenGL context to any window/drawable that is pixel format compatible.

I want to know what I can share and how I share them, in a cross-platform way

In general all objects the hold data (textures, vertex/pixel/element objects, renderbuffer objects) are shared, objects that hold state (vertex array object, framebuffer object) are not.

Sharing is setup in Windows either through calling wglShareLists to connect a newly created context to previously existing ones. Or by passing a handle to the context to share with to wglCreateContextAttribsARB; however to obtain a function pointer to that function you first have to create a proxy context (which requires jumping a few hoops, which I’ve implemented in https://git.datenwolf.net/wglarb/ so you can simply call wglarb_CreateContextAttribsARB without having to care about the rest).

In a X11/GLX environment context sharing has always been set up at context creation time, practically identical to the wglCreateContextAttribsARB way using the glXCreateContext

2

According to official information, Query objects cannot be shared either:

Most OpenGL objects are sharable, including Sync Objects and GLSL Objects. Container Objects are not sharable, nor are Query Objects.

So to complete the other answers: you cannot share the following objects:

  • Framebuffer objects
  • Vertex array objects
  • Transform feedback objects
  • Program pipeline objects
  • Query objects

All other OpenGL objects can be shared. You are the most welcome!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật