[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz gfx/jni/GzzGL-jni.cxx gfx/libos/Os-GLX.cxx ...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz gfx/jni/GzzGL-jni.cxx gfx/libos/Os-GLX.cxx ... |
Date: |
Thu, 05 Dec 2002 03:08:12 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/12/05 03:08:11
Modified files:
gfx/jni : GzzGL-jni.cxx
gfx/libos : Os-GLX.cxx Os.hxx
gzz/gfx/gl : GL.java
Log message:
More motion towards off-screen buffers. Not quite there yet, but
refactoring going ok
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.66&tr2=1.67&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libos/Os-GLX.cxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libos/Os.hxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.25&tr2=1.26&r1=text&r2=text
Patches:
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.66 gzz/gfx/jni/GzzGL-jni.cxx:1.67
--- gzz/gfx/jni/GzzGL-jni.cxx:1.66 Wed Dec 4 05:54:22 2002
+++ gzz/gfx/jni/GzzGL-jni.cxx Thu Dec 5 03:08:11 2002
@@ -44,7 +44,7 @@
typedef std::vector<GLubyte> ByteVector;
-ObjectStorer<Os::Window> windows;
+ObjectStorer<Os::RenderingSurface> windows;
ObjectStorer<Image> images;
ObjectStorer<Mosaic::MosaicTile> imagetiles;
ObjectStorer<RealFont> fonts;
@@ -104,12 +104,12 @@
return env->NewStringUTF(stdstr.c_str());
}
-Os::Window *getWindowByWID(int wid) {
+Os::RenderingSurface *getWindowByWID(int wid) {
return (wid<0 ? defaultWindow : windows.get(wid));
}
void setWindow(int wid = -1) {
- Os::Window *win = getWindowByWID(wid);
+ Os::RenderingSurface *win = getWindowByWID(wid);
if(!win->setCurrent()) {
cerr << "Couldn't set window to current -> returning\n";
return;
@@ -125,7 +125,7 @@
}
int wid = contextStack[contextStack.size()-1];
contextStack.pop_back();
- Os::Window *win = getWindowByWID(wid);
+ Os::RenderingSurface *win = getWindowByWID(wid);
if(!win->releaseCurrent()) {
cerr << "Couldn't release window current!!!";
exit(17);
@@ -301,13 +301,13 @@
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_repaintWindow
(JNIEnv *env, jclass, jint id) {
DBG(dbg_event) << "RepaintWindow called\n";
- Os::Window *w = windows.get(id);
+ Os::Window *w = (Os::Window *)windows.get(id);
w->repaint();
}
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_getWindowSize
(JNIEnv *env, jclass, jint id, jobject rect) {
- Os::Window *win = windows.get(id);
+ Os::RenderingSurface *win = windows.get(id);
int xywh[4];
win->getSize(xywh);
@@ -327,7 +327,7 @@
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_addTimeoutWindow
(JNIEnv *env, jclass, jint id, jint ms, jint tid) {
- Os::Window *w = windows.get(id);
+ Os::Window *w = (Os::Window *)windows.get(id);
w->addTimeout(ms, tid);
}
@@ -343,12 +343,14 @@
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Window_1move
(JNIEnv *env, jclass, jint id, jint x, jint y) {
- windows.get(id)->move(x,y);
+ Os::Window *w = (Os::Window *)windows.get(id);
+ w->move(x,y);
}
JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_impl_1Window_1resize
- (JNIEnv *env, jclass, jint id, jint w, jint h) {
- windows.get(id)->resize(w,h);
+ (JNIEnv *env, jclass, jint id, jint wid, jint h) {
+ Os::Window *w = (Os::Window *)windows.get(id);
+ w->resize(wid,h);
}
Index: gzz/gfx/libos/Os-GLX.cxx
diff -u gzz/gfx/libos/Os-GLX.cxx:1.13 gzz/gfx/libos/Os-GLX.cxx:1.14
--- gzz/gfx/libos/Os-GLX.cxx:1.13 Wed Dec 4 10:29:14 2002
+++ gzz/gfx/libos/Os-GLX.cxx Thu Dec 5 03:08:11 2002
@@ -144,15 +144,18 @@
int swaMask;
int numReturned;
- GLXFBConfig *vinfo;
+ GLXFBConfig *dbFbConfig;
XVisualInfo *dbVinfo;
+ GLXContext dbContext;
+
+ GLXFBConfig *pbFbConfig;
+ GLXContext pbContext;
vector<Timeout> timeouts;
vector<LXWindow *> windows;
// vector<IdleTasks *> idletasks;
- GLXContext context;
std::map<Win, LXWindow *> windowsByX;
LXWindowSystem() {
@@ -160,16 +163,16 @@
int nel;
- vinfo = glXChooseFBConfig(dpy, DefaultScreen(dpy),
+ dbFbConfig = glXChooseFBConfig(dpy, DefaultScreen(dpy),
doubleBufferAttributes, &nel);
- if(!vinfo) BARF("Can't get dblbuf visual");
+ if(!dbFbConfig) BARF("Can't get dblbuf visual");
- context = glXCreateNewContext(dpy, vinfo[0], GLX_RGBA_TYPE,
+ dbContext = glXCreateNewContext(dpy, dbFbConfig[0], GLX_RGBA_TYPE,
0, GL_TRUE);
- dbVinfo = glXGetVisualFromFBConfig(dpy, vinfo[0]);
+ dbVinfo = glXGetVisualFromFBConfig(dpy, dbFbConfig[0]);
swa.border_pixel = 0;
swa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy),
@@ -196,6 +199,14 @@
CWBackPixmap
);
+
+ pbFbConfig = glXChooseFBConfig(dpy, DefaultScreen(dpy),
+ pbufferAttributes, &nel);
+ if(!pbFbConfig) BARF("Can't get dblbuf visual");
+
+ pbContext = glXCreateNewContext(dpy, pbFbConfig[0], GLX_RGBA_TYPE,
+ 0, GL_TRUE);
+
}
@@ -233,7 +244,19 @@
//
struct LXPBuffer : public Os::RenderingSurface {
LXWindowSystem *ws;
+
GLXPbuffer pbuf;
+
+ LXPBuffer(LXWindowSystem *ws, int w, int h) : ws(ws) {
+ int attrs[] = {
+ GLX_PBUFFER_WIDTH, w,
+ GLX_PBUFFER_HEIGHT, h,
+ GLX_PRESERVED_CONTENTS, 1,
+ GLX_LARGEST_PBUFFER, 1,
+ 0
+ };
+ pbuf = glXCreatePbuffer(ws->dpy, ws->pbFbConfig[0], attrs);
+ }
};
struct LXWindow : public Os::Window {
@@ -291,7 +314,7 @@
DBG(dbg) << "setcurrent "<<xw<<"\n";
// Can't check for GL errors; we might not have a current context!
// GLERR
- bool ret = glXMakeCurrent(ws->dpy, xw, ws->context);
+ bool ret = glXMakeCurrent(ws->dpy, xw, ws->dbContext);
// GLERR
DBG(dbg) << "setcurrent : "<<ret<<"\n";
return ret;
Index: gzz/gfx/libos/Os.hxx
diff -u gzz/gfx/libos/Os.hxx:1.13 gzz/gfx/libos/Os.hxx:1.14
--- gzz/gfx/libos/Os.hxx:1.13 Wed Dec 4 10:29:14 2002
+++ gzz/gfx/libos/Os.hxx Thu Dec 5 03:08:11 2002
@@ -84,6 +84,10 @@
virtual bool releaseCurrent() = 0;
virtual void getSize(int *xywh) = 0;
+
+ /** Swap buffers; may be no-op.
+ */
+ virtual void swapBuffers() = 0;
};
/** An OpenGL rendering surface in a physical
@@ -106,7 +110,6 @@
// virtual pair<int, int> getSize() = 0;
- virtual void swapBuffers() = 0;
virtual void resize(int w, int h) = 0;
virtual void move(int x, int y) = 0;
Index: gzz/gzz/gfx/gl/GL.java
diff -u gzz/gzz/gfx/gl/GL.java:1.25 gzz/gzz/gfx/gl/GL.java:1.26
--- gzz/gzz/gfx/gl/GL.java:1.25 Wed Dec 4 05:54:22 2002
+++ gzz/gzz/gfx/gl/GL.java Thu Dec 5 03:08:11 2002
@@ -300,26 +300,14 @@
}
static private native void deleteRenderable3(int id);
-//--------- Window
- /** An on-screen GLX window into which graphics can be drawn.
- */
- final static public class Window extends NonRenderableJavaObject {
-
- private Window(int id) { super(id); }
-
+//--------- Renderable surface
+ static public class RenderingSurface extends NonRenderableJavaObject {
+ private RenderingSurface(int id) { super(id); }
protected void deleteObj() { deleteWindow(getId()); }
- // XXX ???
- public void repaint() { GL.repaintWindow(getId()); }
-
- /** Call the EventHandler.timeout(id) with the given id,
- * after at least ms milliseconds have passed.
- */
- public void addTimeout(int ms, int id) {
- addTimeoutWindow(getId(), ms, id);
- }
-
/** Get the current bounds of the window on screen.
+ * For off-screen surfaces, only width and height are
+ * significant.
*/
public Rectangle getBounds() {
Rectangle rect = new Rectangle();
@@ -333,6 +321,23 @@
/** Release this window from being the current OpenGL context.
*/
public void release() { impl_Window_release(getId()); }
+ }
+//--------- Window
+ /** An on-screen GLX window into which graphics can be drawn.
+ */
+ final static public class Window extends RenderingSurface {
+
+ private Window(int id) { super(id); }
+
+ // XXX ???
+ public void repaint() { GL.repaintWindow(getId()); }
+
+ /** Call the EventHandler.timeout(id) with the given id,
+ * after at least ms milliseconds have passed.
+ */
+ public void addTimeout(int ms, int id) {
+ addTimeoutWindow(getId(), ms, id);
+ }
/** Move the upper left corner of the window to the given coordinates.
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz gfx/jni/GzzGL-jni.cxx gfx/libos/Os-GLX.cxx ...,
Tuomas J. Lukka <=