mirror of https://github.com/fltk/fltk
New context_changed() function for OpenGL windows allowing efficient texture loading (str #1372)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5322 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
ef48f007a1
commit
51d67574ec
2
CHANGES
2
CHANGES
|
@ -1,5 +1,7 @@
|
|||
CHANGES IN FLTK 1.1.8
|
||||
|
||||
- Added "context_changed()" function for OpenGL windows
|
||||
which allows efficent texture loading (STR #1372)
|
||||
- Added missing "const" to GLUT call (STR #1371)
|
||||
- Fixed stray FL_RELEASE events after clicking system
|
||||
areas on OS X (STR #1376)
|
||||
|
|
|
@ -41,7 +41,7 @@ class FL_EXPORT Fl_Gl_Window : public Fl_Window {
|
|||
const int *alist;
|
||||
Fl_Gl_Choice *g;
|
||||
GLContext context_;
|
||||
char valid_;
|
||||
char valid_f_;
|
||||
char damage1_; // damage() of back buffer
|
||||
virtual void draw_overlay();
|
||||
void init();
|
||||
|
@ -61,10 +61,13 @@ public:
|
|||
void hide();
|
||||
void resize(int,int,int,int);
|
||||
|
||||
char valid() const {return valid_;}
|
||||
void valid(char v) {valid_ = v;}
|
||||
char valid() const {return valid_f_ & 1;}
|
||||
void valid(char v) {if (v) valid_f_ |= 1; else valid_f_ &= 0xfe;}
|
||||
void invalidate();
|
||||
|
||||
char context_valid() const {return valid_f_ & 2;}
|
||||
void context_valid(char v) {if (v) valid_f_ |= 2; else valid_f_ &= 0xfd;}
|
||||
|
||||
static int can_do(int m) {return can_do(m,0);}
|
||||
static int can_do(const int *m) {return can_do(0, m);}
|
||||
int can_do() {return can_do(mode_,alist);}
|
||||
|
|
|
@ -58,6 +58,7 @@ unless those Widgets are modified to draw using OpenGL calls.</P>
|
|||
</TD><TD align=left valign=top>
|
||||
<UL>
|
||||
<LI><A href=#Fl_Gl_Window.context>context</A></LI>
|
||||
<LI><A href=#Fl_Gl_Window.context_valid>context_valid</A></LI>
|
||||
<LI><A href=#Fl_Gl_Window.draw>draw</A></LI>
|
||||
<LI><A href=#Fl_Gl_Window.draw_overlay>draw_overlay</A></LI>
|
||||
</UL>
|
||||
|
@ -164,9 +165,11 @@ void mywindow::draw() {
|
|||
if (!valid()) {
|
||||
glViewport(0,0,w(),h());
|
||||
glFrustum(...);
|
||||
glLight(...);
|
||||
...other initialization...
|
||||
}
|
||||
if (!context_valid()) {
|
||||
...load textures, etc. ...
|
||||
}
|
||||
... draw your geometry here ...
|
||||
}
|
||||
</PRE></UL>
|
||||
|
@ -178,6 +181,14 @@ draw()</TT> returns.
|
|||
<H4><A name=Fl_Gl_Window.invalidate>void Fl_Gl_Window::invalidate()</A></H4>
|
||||
The <TT>invalidate()</TT> method turns off <TT>valid()</TT> and is
|
||||
equivalent to calling <TT>value(0)</TT>.
|
||||
|
||||
<H4><A name=Fl_Gl_Window.context_valid>char Fl_Gl_Window::context_valid() const
|
||||
<BR> void Fl_Gl_Window::context_valid(char i)</A></H4>
|
||||
<TT>Fl_Gl_Window::context_valid()</TT> will only be set if the
|
||||
OpenGL context is created or recreated. It differs from
|
||||
<TT>Fl_Gl_Window::valid()</TT> which is also set whenever the context
|
||||
changes size.
|
||||
|
||||
<H4><A name=Fl_Gl_Window.ortho>void Fl_Gl_Window::ortho()</A></H4>
|
||||
Set the projection so 0,0 is in the lower left of the window and each
|
||||
pixel is 1 unit wide/tall. If you are drawing 2D images, your <TT>
|
||||
|
|
|
@ -88,8 +88,12 @@ void Fl_Gl_Window::show() {
|
|||
|
||||
void Fl_Gl_Window::invalidate() {
|
||||
valid(0);
|
||||
context_valid(0);
|
||||
#ifndef WIN32
|
||||
if (overlay) ((Fl_Gl_Window*)overlay)->valid(0);
|
||||
if (overlay) {
|
||||
((Fl_Gl_Window*)overlay)->valid(0);
|
||||
((Fl_Gl_Window*)overlay)->context_valid(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -137,6 +141,7 @@ void Fl_Gl_Window::make_current() {
|
|||
mode_ &= ~NON_LOCAL_CONTEXT;
|
||||
context_ = fl_create_gl_context(this, g);
|
||||
valid(0);
|
||||
context_valid(0);
|
||||
}
|
||||
fl_set_gl_context(this, context_);
|
||||
|
||||
|
@ -215,7 +220,10 @@ int fl_overlay_depth = 0;
|
|||
#endif
|
||||
|
||||
void Fl_Gl_Window::flush() {
|
||||
uchar save_valid = valid_;
|
||||
uchar save_valid = valid_f_ & 1;
|
||||
#if HAVE_GL_OVERLAY && defined(WIN32)
|
||||
uchar save_valid_f = valid_f_;
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE_QD__
|
||||
//: clear previous clipping in this shared port
|
||||
|
@ -256,7 +264,7 @@ void Fl_Gl_Window::flush() {
|
|||
fl_overlay = 1;
|
||||
draw_overlay();
|
||||
fl_overlay = 0;
|
||||
valid(save_valid);
|
||||
valid_f_ = save_valid_f;
|
||||
wglSwapLayerBuffers(Fl_X::i(this)->private_dc, WGL_SWAP_OVERLAY1);
|
||||
// if only the overlay was damaged we are done, leave main layer alone:
|
||||
if (damage() == FL_DAMAGE_OVERLAY) {
|
||||
|
@ -357,6 +365,7 @@ void Fl_Gl_Window::flush() {
|
|||
if (fixcursor) SetCursor(Fl_X::i(this)->cursor);
|
||||
#endif
|
||||
valid(1);
|
||||
context_valid(1);
|
||||
}
|
||||
|
||||
void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
|
||||
|
@ -408,7 +417,7 @@ void Fl_Gl_Window::init() {
|
|||
context_ = 0;
|
||||
g = 0;
|
||||
overlay = 0;
|
||||
valid_ = 0;
|
||||
valid_f_ = 0;
|
||||
damage1_ = 0;
|
||||
|
||||
#if 0 // This breaks resizing on Linux/X11
|
||||
|
|
|
@ -40,8 +40,8 @@ CubeView::CubeView(int x,int y,int w,int h,const char *l)
|
|||
vAng = 0.0;
|
||||
hAng=0.0;
|
||||
size=10.0;
|
||||
xshift=0.0;
|
||||
yshift=0.0;
|
||||
xshift=0.0;
|
||||
yshift=0.0;
|
||||
|
||||
/* The cube definition. These are the vertices of a unit cube
|
||||
* centered on the origin.*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0100
|
||||
version 1.0108
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
class CubeViewUI {open
|
||||
|
@ -7,7 +7,7 @@ class CubeViewUI {open
|
|||
Function {CubeViewUI()} {open
|
||||
} {
|
||||
Fl_Window mainWindow {
|
||||
label CubeView open selected
|
||||
label CubeView open
|
||||
private xywh {428 124 415 405} type Double box UP_BOX labelsize 12 resizable visible
|
||||
} {
|
||||
Fl_Group {} {open
|
||||
|
@ -47,14 +47,14 @@ cube->redraw();}
|
|||
}
|
||||
}
|
||||
Fl_Group MainView {open
|
||||
xywh {46 27 333 333}
|
||||
xywh {46 27 333 333} resizable
|
||||
} {
|
||||
Fl_Box cframe {
|
||||
xywh {46 27 333 333} box DOWN_FRAME color 4 selection_color 69
|
||||
}
|
||||
Fl_Box cube {
|
||||
label {This is the cube_view}
|
||||
xywh {48 29 329 329} align 16
|
||||
label {This is the cube_view} selected
|
||||
xywh {48 29 329 329} align 16 resizable
|
||||
code0 {\#include "CubeView.h"}
|
||||
class CubeView
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue