begin_frame refactor
This commit is contained in:
parent
042626a373
commit
cee838c08e
|
|
@ -549,20 +549,24 @@ get_screenshot(PNMImage &image) {
|
|||
GraphicsStateGuardian *gsg = window->get_gsg();
|
||||
nassertr(gsg != (GraphicsStateGuardian *)NULL, false);
|
||||
|
||||
window->make_current();
|
||||
if (!window->begin_frame(GraphicsOutput::FM_refresh)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a temporary texture to receive the framebuffer image.
|
||||
PT(Texture) tex = new Texture;
|
||||
|
||||
|
||||
RenderBuffer buffer = gsg->get_render_buffer(get_screenshot_buffer_type());
|
||||
if (!gsg->framebuffer_copy_to_ram(tex, -1, this, buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
window->end_frame(GraphicsOutput::FM_refresh);
|
||||
|
||||
if (!tex->store(image)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -790,7 +790,7 @@ cull_and_draw_together(const GraphicsEngine::Windows &wlist) {
|
|||
for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
|
||||
GraphicsOutput *win = (*wi);
|
||||
if (win->is_active() && win->get_gsg()->is_active()) {
|
||||
if (win->begin_frame()) {
|
||||
if (win->begin_frame(GraphicsOutput::FM_render)) {
|
||||
win->clear();
|
||||
|
||||
int num_display_regions = win->get_num_active_display_regions();
|
||||
|
|
@ -800,7 +800,7 @@ cull_and_draw_together(const GraphicsEngine::Windows &wlist) {
|
|||
cull_and_draw_together(win, dr);
|
||||
}
|
||||
}
|
||||
win->end_frame();
|
||||
win->end_frame(GraphicsOutput::FM_render);
|
||||
|
||||
if (_auto_flip) {
|
||||
if (win->flip_ready()) {
|
||||
|
|
@ -864,7 +864,7 @@ cull_bin_draw(const GraphicsEngine::Windows &wlist) {
|
|||
GraphicsOutput *win = (*wi);
|
||||
if (win->is_active() && win->get_gsg()->is_active()) {
|
||||
// This should be done in the draw thread, not here.
|
||||
if (win->begin_frame()) {
|
||||
if (win->begin_frame(GraphicsOutput::FM_render)) {
|
||||
win->clear();
|
||||
|
||||
int num_display_regions = win->get_num_active_display_regions();
|
||||
|
|
@ -874,7 +874,7 @@ cull_bin_draw(const GraphicsEngine::Windows &wlist) {
|
|||
cull_bin_draw(win, dr);
|
||||
}
|
||||
}
|
||||
win->end_frame();
|
||||
win->end_frame(GraphicsOutput::FM_render);
|
||||
|
||||
if (_auto_flip) {
|
||||
if (win->flip_ready()) {
|
||||
|
|
@ -940,8 +940,8 @@ make_contexts(const GraphicsEngine::Windows &wlist) {
|
|||
Windows::const_iterator wi;
|
||||
for (wi = wlist.begin(); wi != wlist.end(); ++wi) {
|
||||
GraphicsOutput *win = (*wi);
|
||||
if (win->needs_context()) {
|
||||
win->make_context();
|
||||
if (win->begin_frame(GraphicsOutput::FM_refresh)) {
|
||||
win->end_frame(GraphicsOutput::FM_refresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,17 +372,6 @@ flip_ready() const {
|
|||
return _flip_ready;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::needs_context
|
||||
// Access: Public
|
||||
// Description: Returns true if make_context() still needs to be
|
||||
// called, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool GraphicsOutput::
|
||||
needs_context() const {
|
||||
return _needs_context;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::operator <
|
||||
// Access: Public
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ GraphicsOutput(GraphicsPipe *pipe, GraphicsStateGuardian *gsg,
|
|||
_has_size = false;
|
||||
_is_valid = false;
|
||||
_flip_ready = false;
|
||||
_needs_context = true;
|
||||
_cube_map_index = -1;
|
||||
_cube_map_dr = NULL;
|
||||
_sort = 0;
|
||||
|
|
@ -961,7 +960,7 @@ reset_window(bool swapchain) {
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GraphicsOutput::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -973,7 +972,7 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsOutput::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1090,37 +1089,6 @@ copy_to_textures() {
|
|||
_trigger_copy = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::begin_render_texture
|
||||
// Access: Public, Virtual
|
||||
// Description: If the GraphicsOutput supports direct render-to-texture,
|
||||
// and if any setup needs to be done during begin_frame,
|
||||
// then the setup code should go here. Any textures that
|
||||
// can not be rendered to directly should be reflagged
|
||||
// as RTM_copy_texture.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsOutput::
|
||||
begin_render_texture() {
|
||||
for (int i=0; i<count_textures(); i++) {
|
||||
if (get_rtm_mode(i) == RTM_bind_or_copy) {
|
||||
_textures[i]._rtm_mode = RTM_copy_texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::end_render_texture
|
||||
// Access: Public, Virtual
|
||||
// Description: If the GraphicsOutput supports direct render-to-texture,
|
||||
// and if any setup needs to be done during end_frame,
|
||||
// then the setup code should go here. Any textures that
|
||||
// could not be rendered to directly should be reflagged
|
||||
// as RTM_copy_texture.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsOutput::
|
||||
end_render_texture() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::change_scenes
|
||||
// Access: Public
|
||||
|
|
@ -1188,33 +1156,6 @@ void GraphicsOutput::
|
|||
select_cube_map(int) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::make_context
|
||||
// Access: Public, Virtual
|
||||
// Description: If _needs_context is true, this will be called
|
||||
// in the draw thread prior to rendering into the
|
||||
// window. It should attempt to create a graphics
|
||||
// context, and return true if successful, false
|
||||
// otherwise. If it returns false the window will be
|
||||
// considered failed.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GraphicsOutput::
|
||||
make_context() {
|
||||
_needs_context = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsOutput::
|
||||
make_current() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::release_gsg
|
||||
// Access: Public
|
||||
|
|
@ -1230,17 +1171,6 @@ release_gsg() {
|
|||
_active = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::auto_resize
|
||||
// Access: Public, Virtual
|
||||
// Description: Certain graphics outputs can automatically resize
|
||||
// themselves to automatically stay the same size as
|
||||
// some other graphics output.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void GraphicsOutput::
|
||||
auto_resize() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::begin_flip
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ PUBLISHED:
|
|||
RTM_triggered_copy_ram,
|
||||
};
|
||||
|
||||
// There are many reasons to call begin_frame/end_frame.
|
||||
enum FrameMode {
|
||||
FM_render, // We are rendering a frame.
|
||||
FM_parasite, // We are rendering a frame of a parasite.
|
||||
FM_refresh, // We are just refreshing the display or exposing the window.
|
||||
};
|
||||
|
||||
virtual ~GraphicsOutput();
|
||||
|
||||
INLINE GraphicsStateGuardian *get_gsg() const;
|
||||
|
|
@ -142,7 +149,6 @@ PUBLISHED:
|
|||
|
||||
public:
|
||||
// These are not intended to be called directly by the user.
|
||||
INLINE bool needs_context() const;
|
||||
INLINE bool flip_ready() const;
|
||||
|
||||
INLINE bool operator < (const GraphicsOutput &other) const;
|
||||
|
|
@ -161,21 +167,22 @@ public:
|
|||
// thread other than the draw thread. These methods are normally
|
||||
// called by the GraphicsEngine.
|
||||
void clear();
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
|
||||
virtual void begin_render_texture();
|
||||
virtual void end_render_texture();
|
||||
// These entry points have been removed. Use begin_frame/end_frame instead.
|
||||
// virtual void begin_render_texture();
|
||||
// virtual void end_render_texture();
|
||||
// INLINE bool needs_context() const;
|
||||
// bool _needs_context;
|
||||
// virtual bool make_context();
|
||||
// virtual void make_current();
|
||||
// virtual void auto_resize();
|
||||
|
||||
void change_scenes(DisplayRegion *new_dr);
|
||||
virtual void select_cube_map(int cube_map_index);
|
||||
|
||||
// This method is called in the draw thread prior to issuing any
|
||||
// drawing commands for the window.
|
||||
virtual bool make_context();
|
||||
virtual void make_current();
|
||||
virtual void release_gsg();
|
||||
virtual void auto_resize();
|
||||
|
||||
// These methods will be called within the app (main) thread.
|
||||
virtual void begin_flip();
|
||||
|
|
@ -208,7 +215,6 @@ protected:
|
|||
string _name;
|
||||
pvector<RenderTexture> _textures;
|
||||
bool _flip_ready;
|
||||
bool _needs_context;
|
||||
int _cube_map_index;
|
||||
DisplayRegion *_cube_map_dr;
|
||||
PT(Geom) _texture_card;
|
||||
|
|
|
|||
|
|
@ -106,21 +106,23 @@ get_host() {
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool ParasiteBuffer::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
|
||||
if (!_host->begin_frame(FM_parasite)) {
|
||||
return false;
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
|
||||
if (_track_host_size) {
|
||||
if ((_host->get_x_size() != _x_size)||
|
||||
(_host->get_y_size() != _y_size)) {
|
||||
set_size_and_recalc(_host->get_x_size(),
|
||||
_host->get_y_size());
|
||||
}
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
|
||||
clear_cube_map_selection();
|
||||
return _gsg->begin_frame();
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -131,46 +133,23 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ParasiteBuffer::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
end_frame_spam();
|
||||
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
|
||||
if (mode == FM_refresh) {
|
||||
return;
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ParasiteBuffer::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ParasiteBuffer::
|
||||
make_current() {
|
||||
_host->make_current();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ParasiteBuffer::auto_resize
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// to make sure this buffer is the right size. If not,
|
||||
// it will be resized.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ParasiteBuffer::
|
||||
auto_resize() {
|
||||
if (_track_host_size) {
|
||||
_host->auto_resize();
|
||||
if ((_host->get_x_size() != _x_size)||
|
||||
(_host->get_y_size() != _y_size)) {
|
||||
set_size_and_recalc(_host->get_x_size(),
|
||||
_host->get_y_size());
|
||||
_host->end_frame(FM_parasite);
|
||||
|
||||
if (mode == FM_render) {
|
||||
copy_to_textures();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,11 +63,9 @@ PUBLISHED:
|
|||
virtual bool is_active() const;
|
||||
|
||||
public:
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
virtual GraphicsOutput *get_host();
|
||||
virtual void make_current();
|
||||
virtual void auto_resize();
|
||||
|
||||
private:
|
||||
PT(GraphicsOutput) _host;
|
||||
|
|
|
|||
|
|
@ -80,20 +80,18 @@ wdxGraphicsBuffer8::
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsBuffer8::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode == FM_render) {
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
|
||||
return _gsg->begin_frame();
|
||||
}
|
||||
|
||||
|
|
@ -105,22 +103,30 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsBuffer8::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
|
||||
if (mode == FM_render) {
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
}
|
||||
|
||||
_gsg->end_frame();
|
||||
|
||||
if (mode == FM_render) {
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::begin_render_texture
|
||||
// Access: Public, Virtual
|
||||
// Access: Public
|
||||
// Description: If the GraphicsOutput supports direct render-to-texture,
|
||||
// and if any setup needs to be done during begin_frame,
|
||||
// then the setup code should go here. Any textures that
|
||||
|
|
@ -208,7 +214,7 @@ begin_render_texture() {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::end_render_texture
|
||||
// Access: Public, Virtual
|
||||
// Access: Public
|
||||
// Description: If the GraphicsOutput supports direct render-to-texture,
|
||||
// and if any setup needs to be done during end_frame,
|
||||
// then the setup code should go here. Any textures that
|
||||
|
|
@ -319,23 +325,6 @@ select_cube_map(int cube_map_index) {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsBuffer8::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsBuffer8::
|
||||
make_current() {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
DXGraphicsStateGuardian8 *dxgsg;
|
||||
DCAST_INTO_V(dxgsg, _gsg);
|
||||
|
||||
// do nothing here
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsBuffer8::release_gsg
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -41,16 +41,12 @@ public:
|
|||
int x_size, int y_size);
|
||||
virtual ~wdxGraphicsBuffer8();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
|
||||
virtual void select_cube_map(int cube_map_index);
|
||||
|
||||
virtual void make_current();
|
||||
virtual void release_gsg();
|
||||
|
||||
virtual void begin_render_texture();
|
||||
virtual void end_render_texture();
|
||||
|
||||
virtual void process_events();
|
||||
|
||||
protected:
|
||||
|
|
@ -58,6 +54,8 @@ protected:
|
|||
virtual bool open_buffer();
|
||||
|
||||
private:
|
||||
void begin_render_texture();
|
||||
void end_render_texture();
|
||||
static void process_1_event();
|
||||
|
||||
int _cube_map_index;
|
||||
|
|
|
|||
|
|
@ -64,9 +64,74 @@ wdxGraphicsWindow8::
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow8::make_current
|
||||
// Function: wdxGraphicsWindow8::begin_frame
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
// Description: This function will be called within the draw thread
|
||||
// before beginning rendering for a given frame. It
|
||||
// should do whatever setup is required, and return true
|
||||
// if the frame should be rendered, or false if it
|
||||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsWindow8::
|
||||
begin_frame(FrameMode mode) {
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_awaiting_restore) {
|
||||
// The fullscreen window was recently restored; we can't continue
|
||||
// until the GSG says we can.
|
||||
if (!_dxgsg->check_cooperative_level()) {
|
||||
// Keep waiting.
|
||||
return false;
|
||||
}
|
||||
_awaiting_restore = false;
|
||||
init_resized_window();
|
||||
}
|
||||
|
||||
make_current();
|
||||
|
||||
if (mode == FM_render) {
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
bool return_val = _gsg->begin_frame();
|
||||
_dxgsg->set_render_target();
|
||||
return return_val;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow8::end_frame
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// after rendering is completed for a given frame. It
|
||||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsWindow8::
|
||||
end_frame(FrameMode mode) {
|
||||
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
|
||||
if (mode == FM_render) {
|
||||
copy_to_textures();
|
||||
}
|
||||
|
||||
_gsg->end_frame();
|
||||
|
||||
if (mode == FM_render) {
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow8::make_current
|
||||
// Access: Private
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsWindow8::
|
||||
make_current() {
|
||||
|
|
@ -89,67 +154,6 @@ make_current() {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow8::begin_frame
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// before beginning rendering for a given frame. It
|
||||
// should do whatever setup is required, and return true
|
||||
// if the frame should be rendered, or false if it
|
||||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsWindow8::
|
||||
begin_frame() {
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
if (_awaiting_restore) {
|
||||
// The fullscreen window was recently restored; we can't continue
|
||||
// until the GSG says we can.
|
||||
if (!_dxgsg->check_cooperative_level()) {
|
||||
// Keep waiting.
|
||||
return false;
|
||||
}
|
||||
_awaiting_restore = false;
|
||||
|
||||
init_resized_window();
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
bool return_val = _gsg->begin_frame();
|
||||
_dxgsg->set_render_target();
|
||||
return return_val;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow8::end_frame
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// after rendering is completed for a given frame. It
|
||||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsWindow8::
|
||||
end_frame() {
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsWindow8::end_flip
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -38,9 +38,8 @@ public:
|
|||
const string &name);
|
||||
virtual ~wdxGraphicsWindow8();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual void make_current();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
virtual void end_flip();
|
||||
|
||||
virtual int verify_window_sizes(int numsizes, int *dimen);
|
||||
|
|
@ -73,6 +72,7 @@ private:
|
|||
|
||||
bool reset_device_resize_window(UINT new_xsize, UINT new_ysize);
|
||||
void init_resized_window();
|
||||
void make_current();
|
||||
static int D3DFMT_to_DepthBits(D3DFORMAT fmt);
|
||||
static bool is_badvidmem_card(D3DADAPTER_IDENTIFIER8 *pDevID);
|
||||
|
||||
|
|
|
|||
|
|
@ -77,21 +77,19 @@ wdxGraphicsBuffer9::
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsBuffer9::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
DBG_S dxgsg9_cat.debug ( ) << "wdxGraphicsBuffer9::begin_frame\n"; DBG_E
|
||||
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mode == FM_render) {
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
|
||||
return _gsg->begin_frame();
|
||||
}
|
||||
|
||||
|
|
@ -103,22 +101,30 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsBuffer9::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
|
||||
if (mode == FM_render) {
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
}
|
||||
|
||||
_gsg->end_frame();
|
||||
|
||||
if (mode == FM_render) {
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::begin_render_texture
|
||||
// Access: Public, Virtual
|
||||
// Access: Public
|
||||
// Description: If the GraphicsOutput supports direct render-to-texture,
|
||||
// and if any setup needs to be done during begin_frame,
|
||||
// then the setup code should go here. Any textures that
|
||||
|
|
@ -221,7 +227,7 @@ begin_render_texture() {
|
|||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsOutput::end_render_texture
|
||||
// Access: Public, Virtual
|
||||
// Access: Public
|
||||
// Description: If the GraphicsOutput supports direct render-to-texture,
|
||||
// and if any setup needs to be done during end_frame,
|
||||
// then the setup code should go here. Any textures that
|
||||
|
|
@ -355,25 +361,6 @@ select_cube_map(int cube_map_index) {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsBuffer9::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsBuffer9::
|
||||
make_current() {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
DXGraphicsStateGuardian9 *dxgsg;
|
||||
DCAST_INTO_V(dxgsg, _gsg);
|
||||
|
||||
// do nothing here
|
||||
DBG_S dxgsg9_cat.debug ( ) << "wdxGraphicsBuffer9::make_current\n"; DBG_E
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wdxGraphicsBuffer9::release_gsg
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -41,16 +41,12 @@ public:
|
|||
int x_size, int y_size);
|
||||
virtual ~wdxGraphicsBuffer9();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
|
||||
virtual void select_cube_map(int cube_map_index);
|
||||
|
||||
virtual void make_current();
|
||||
virtual void release_gsg();
|
||||
|
||||
virtual void begin_render_texture();
|
||||
virtual void end_render_texture();
|
||||
|
||||
virtual void process_events();
|
||||
|
||||
protected:
|
||||
|
|
@ -58,6 +54,8 @@ protected:
|
|||
virtual bool open_buffer();
|
||||
|
||||
private:
|
||||
void begin_render_texture();
|
||||
void end_render_texture();
|
||||
static void process_1_event();
|
||||
|
||||
int _cube_map_index;
|
||||
|
|
|
|||
|
|
@ -99,11 +99,12 @@ make_current() {
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wdxGraphicsWindow9::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_awaiting_restore) {
|
||||
// The fullscreen window was recently restored; we can't continue
|
||||
// until the GSG says we can.
|
||||
|
|
@ -112,18 +113,15 @@ begin_frame() {
|
|||
return false;
|
||||
}
|
||||
_awaiting_restore = false;
|
||||
|
||||
init_resized_window();
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
|
||||
if (mode == FM_render) {
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
bool return_val = _gsg->begin_frame();
|
||||
_dxgsg->set_render_target();
|
||||
return return_val;
|
||||
|
|
@ -137,17 +135,24 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wdxGraphicsWindow9::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
|
||||
if (mode == FM_render) {
|
||||
copy_to_textures();
|
||||
}
|
||||
|
||||
_gsg->end_frame();
|
||||
|
||||
if (mode == FM_render) {
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -38,10 +38,8 @@ public:
|
|||
const string &name);
|
||||
virtual ~wdxGraphicsWindow9();
|
||||
|
||||
virtual void make_current();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
virtual void end_flip();
|
||||
|
||||
virtual int verify_window_sizes(int numsizes, int *dimen);
|
||||
|
|
@ -74,6 +72,7 @@ private:
|
|||
|
||||
bool reset_device_resize_window(UINT new_xsize, UINT new_ysize);
|
||||
void init_resized_window();
|
||||
void make_current();
|
||||
static int D3DFMT_to_DepthBits(D3DFORMAT fmt);
|
||||
static bool is_badvidmem_card(D3DADAPTER_IDENTIFIER9 *pDevID);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ public:
|
|||
virtual ~CLP(GraphicsBuffer)();
|
||||
|
||||
virtual void select_cube_map(int cube_map_index);
|
||||
virtual void auto_resize();
|
||||
virtual void make_current();
|
||||
virtual void begin_render_texture();
|
||||
virtual void end_render_texture();
|
||||
|
||||
|
||||
private:
|
||||
void make_current();
|
||||
void begin_render_texture();
|
||||
void end_render_texture();
|
||||
|
||||
// HPBUFFERARB _pbuffer;
|
||||
// HDC _pbuffer_dc;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,19 +72,25 @@ glxGraphicsBuffer::
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool glxGraphicsBuffer::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
|
||||
glxGraphicsStateGuardian *glxgsg;
|
||||
DCAST_INTO_V(glxgsg, _gsg);
|
||||
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
|
||||
|
||||
// Now that we have made the context current to a window, we can
|
||||
// reset the GSG state if this is the first time it has been used.
|
||||
// (We can't just call reset() when we construct the GSG, because
|
||||
// reset() requires having a current context.)
|
||||
glxgsg->reset_if_new();
|
||||
|
||||
// begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
return _gsg->begin_frame();
|
||||
}
|
||||
|
|
@ -97,11 +103,11 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void glxGraphicsBuffer::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
// end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
|
|
@ -119,17 +125,6 @@ end_frame() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void glxGraphicsBuffer::
|
||||
make_current() {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
glxGraphicsStateGuardian *glxgsg;
|
||||
DCAST_INTO_V(glxgsg, _gsg);
|
||||
glXMakeCurrent(_display, _pbuffer, glxgsg->_context);
|
||||
|
||||
// Now that we have made the context current to a window, we can
|
||||
// reset the GSG state if this is the first time it has been used.
|
||||
// (We can't just call reset() when we construct the GSG, because
|
||||
// reset() requires having a current context.)
|
||||
glxgsg->reset_if_new();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@ public:
|
|||
|
||||
virtual ~glxGraphicsBuffer();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual void make_current();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
virtual void release_gsg();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ release_gsg() {
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool glxGraphicsWindow::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
|
|
@ -200,7 +200,7 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void glxGraphicsWindow::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
|
|
|
|||
|
|
@ -37,13 +37,10 @@ public:
|
|||
virtual ~glxGraphicsWindow();
|
||||
|
||||
virtual bool move_pointer(int device, int x, int y);
|
||||
|
||||
virtual bool make_context();
|
||||
virtual void make_current();
|
||||
virtual void release_gsg();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
virtual void begin_flip();
|
||||
|
||||
virtual void process_events();
|
||||
|
|
|
|||
|
|
@ -61,14 +61,15 @@ begin_frame() {
|
|||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
|
||||
OSMesaGraphicsStateGuardian *mesagsg;
|
||||
DCAST_INTO_V(mesagsg, _gsg);
|
||||
OSMesaMakeCurrent(mesagsg->_context, _image.p(), _type,
|
||||
_x_size, _y_size);
|
||||
|
||||
mesagsg->reset_if_new();
|
||||
|
||||
// begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
return _gsg->begin_frame();
|
||||
}
|
||||
|
|
@ -85,7 +86,7 @@ end_frame() {
|
|||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
// end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
|
|
@ -94,23 +95,6 @@ end_frame() {
|
|||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: OsMesaGraphicsBuffer::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void OsMesaGraphicsBuffer::
|
||||
make_current() {
|
||||
OSMesaGraphicsStateGuardian *mesagsg;
|
||||
DCAST_INTO_V(mesagsg, _gsg);
|
||||
OSMesaMakeCurrent(mesagsg->_context, _image.p(), _type,
|
||||
_x_size, _y_size);
|
||||
|
||||
mesagsg->reset_if_new();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: OsMesaGraphicsBuffer::close_buffer
|
||||
// Access: Protected, Virtual
|
||||
|
|
|
|||
|
|
@ -38,9 +38,8 @@ public:
|
|||
|
||||
virtual ~OsMesaGraphicsBuffer();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual void make_current();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
|
||||
protected:
|
||||
virtual void close_buffer();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,9 @@ wglGraphicsBuffer::
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wglGraphicsBuffer::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
|
|
@ -87,15 +89,12 @@ begin_frame() {
|
|||
}
|
||||
}
|
||||
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
wglMakeCurrent(_pbuffer_dc, wglgsg->get_context(_pbuffer_dc));
|
||||
|
||||
if (mode == FM_render) {
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
return _gsg->begin_frame();
|
||||
}
|
||||
|
||||
|
|
@ -107,17 +106,24 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsBuffer::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
end_frame_spam();
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
|
||||
if (mode == FM_render) {
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
}
|
||||
|
||||
_gsg->end_frame();
|
||||
|
||||
if (mode == FM_render) {
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -219,23 +225,6 @@ select_cube_map(int cube_map_index) {
|
|||
wglgsg->_wglSetPbufferAttribARB(_pbuffer, iattrib_list);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsBuffer::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsBuffer::
|
||||
make_current() {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
wglGraphicsStateGuardian *wglgsg;
|
||||
DCAST_INTO_V(wglgsg, _gsg);
|
||||
|
||||
wglMakeCurrent(_pbuffer_dc, wglgsg->get_context(_pbuffer_dc));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsBuffer::release_gsg
|
||||
// Access: Public, Virtual
|
||||
|
|
@ -319,7 +308,6 @@ open_buffer() {
|
|||
|
||||
wglMakeCurrent(twindow_dc, wglgsg->get_context(twindow_dc));
|
||||
wglgsg->reset_if_new();
|
||||
_needs_context = false;
|
||||
|
||||
// Now that we have fully made a window and used that window to
|
||||
// create a rendering context, we can attempt to create a pbuffer.
|
||||
|
|
|
|||
|
|
@ -46,11 +46,10 @@ public:
|
|||
int x_size, int y_size);
|
||||
virtual ~wglGraphicsBuffer();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual void select_cube_map(int cube_map_index);
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
|
||||
virtual void make_current();
|
||||
virtual void select_cube_map(int cube_map_index);
|
||||
virtual void release_gsg();
|
||||
|
||||
virtual void begin_render_texture();
|
||||
|
|
|
|||
|
|
@ -157,20 +157,26 @@ wglGraphicsWindow::
|
|||
// should be skipped.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wglGraphicsWindow::
|
||||
begin_frame() {
|
||||
begin_frame(FrameMode mode) {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
begin_frame_spam();
|
||||
if (_gsg == (GraphicsStateGuardian *)NULL) {
|
||||
return false;
|
||||
}
|
||||
auto_resize();
|
||||
if (needs_context()) {
|
||||
if (!make_context()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wglGraphicsStateGuardian *wglgsg;
|
||||
DCAST_INTO_R(wglgsg, _gsg, false);
|
||||
|
||||
HGLRC context = wglgsg->get_context(_hdc);
|
||||
nassertr(context, false);
|
||||
wglMakeCurrent(_hdc, context);
|
||||
wglgsg->reset_if_new();
|
||||
|
||||
if (mode == FM_render) {
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
make_current();
|
||||
begin_render_texture();
|
||||
clear_cube_map_selection();
|
||||
|
||||
return _gsg->begin_frame();
|
||||
}
|
||||
|
||||
|
|
@ -182,62 +188,25 @@ begin_frame() {
|
|||
// should do whatever finalization is required.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsWindow::
|
||||
end_frame() {
|
||||
end_frame(FrameMode mode) {
|
||||
|
||||
end_frame_spam();
|
||||
|
||||
nassertv(_gsg != (GraphicsStateGuardian *)NULL);
|
||||
|
||||
if (mode == FM_render) {
|
||||
copy_to_textures();
|
||||
}
|
||||
|
||||
_gsg->end_frame();
|
||||
end_render_texture();
|
||||
copy_to_textures();
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
|
||||
if (mode == FM_render) {
|
||||
trigger_flip();
|
||||
if (_one_shot) {
|
||||
prepare_for_deletion();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
clear_cube_map_selection();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsWindow::make_context
|
||||
// Access: Public, Virtual
|
||||
// Description: If _needs_context is true, this will be called
|
||||
// in the draw thread prior to rendering into the
|
||||
// window. It should attempt to create a graphics
|
||||
// context, and return true if successful, false
|
||||
// otherwise. If it returns false the window will be
|
||||
// considered failed.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool wglGraphicsWindow::
|
||||
make_context() {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
wglGraphicsStateGuardian *wglgsg;
|
||||
DCAST_INTO_R(wglgsg, _gsg, false);
|
||||
|
||||
HGLRC context = wglgsg->get_context(_hdc);
|
||||
if (context) {
|
||||
wglMakeCurrent(_hdc, context);
|
||||
wglgsg->reset_if_new();
|
||||
_needs_context = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsWindow::make_current
|
||||
// Access: Public, Virtual
|
||||
// Description: This function will be called within the draw thread
|
||||
// during begin_frame() to ensure the graphics context
|
||||
// is ready for drawing.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsWindow::
|
||||
make_current() {
|
||||
PStatTimer timer(_make_current_pcollector);
|
||||
|
||||
wglGraphicsStateGuardian *wglgsg;
|
||||
DCAST_INTO_V(wglgsg, _gsg);
|
||||
HGLRC context = wglgsg->get_context(_hdc);
|
||||
nassertv(context);
|
||||
wglMakeCurrent(_hdc, context);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -277,8 +246,12 @@ begin_flip() {
|
|||
// called. Empirically, it appears that it is not necessary in
|
||||
// many cases, but it definitely is necessary at least in the case
|
||||
// of Mesa on Windows.
|
||||
make_current();
|
||||
|
||||
wglGraphicsStateGuardian *wglgsg;
|
||||
DCAST_INTO_V(wglgsg, _gsg);
|
||||
HGLRC context = wglgsg->get_context(_hdc);
|
||||
nassertv(context);
|
||||
wglMakeCurrent(_hdc, context);
|
||||
|
||||
SwapBuffers(_hdc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,9 @@ public:
|
|||
const string &name);
|
||||
virtual ~wglGraphicsWindow();
|
||||
|
||||
virtual bool begin_frame();
|
||||
virtual void end_frame();
|
||||
virtual bool make_context();
|
||||
virtual void make_current();
|
||||
virtual bool begin_frame(FrameMode mode);
|
||||
virtual void end_frame(FrameMode mode);
|
||||
|
||||
virtual void release_gsg();
|
||||
virtual void begin_flip();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue