wxMotif now uses wxGLCanvas implementation from wxX11,

removed unused files.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24167 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-10-13 17:28:15 +00:00
parent f15b55cee0
commit fe8d146972
2 changed files with 0 additions and 561 deletions

View File

@@ -1,161 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: glcanvas.h
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
// Uses the GLX extension.
// Author: Julian Smart and Wolfram Gloger
// Modified by:
// Created: 1995, 1999
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Wolfram Gloger
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "glcanvas.h"
#endif
#ifndef _WX_GLCANVAS_H_
#define _WX_GLCANVAS_H_
#include "wx/setup.h"
#if wxUSE_GLCANVAS
#include "wx/gdicmn.h"
#include "wx/palette.h"
#include "wx/scrolwin.h"
#include <GL/glx.h>
enum
{
WX_GL_RGBA=1, /* use true color palette */
WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
WX_GL_DOUBLEBUFFER, /* use doublebuffer */
WX_GL_STEREO, /* use stereoscopic display */
WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
};
//---------------------------------------------------------------------------
// classes
//---------------------------------------------------------------------------
class WXDLLEXPORT wxGLContext: public wxObject
{
public:
wxGLContext( bool isRGB, wxWindow *win,
const wxPalette& palette = wxNullPalette );
wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette),
const wxGLContext *other /* for sharing display lists */
);
~wxGLContext();
void SetCurrent();
void SetColour(const char *colour);
void SwapBuffers();
void SetupPixelFormat();
void SetupPalette(const wxPalette& palette);
wxPalette CreateDefaultPalette();
inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
inline wxWindow* GetWindow() const { return m_window; }
// inline GtkWidget* GetWidget() const { return m_widget; }
inline GLXContext GetContext() const { return m_glContext; }
public:
GLXContext m_glContext;
// GtkWidget *m_widget;
wxPalette m_palette;
wxWindow* m_window;
DECLARE_CLASS(wxGLContext)
};
class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
{
public:
inline wxGLCanvas() {
m_glContext = (wxGLContext*) NULL;
m_sharedContext = (wxGLContext*) NULL;
// m_glWidget = (GtkWidget*) NULL;
m_vi = (void*) NULL;
// m_exposed = FALSE;
}
wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
bool Create( wxWindow *parent,
const wxGLContext *shared = (wxGLContext*)NULL,
const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
~wxGLCanvas();
void SetCurrent();
void SetColour(const char *colour);
void SwapBuffers();
// void OnSize(wxSizeEvent& event);
// void OnInternalIdle();
inline wxGLContext* GetContext() const { return m_glContext; }
// implementation
wxGLContext *m_glContext,
*m_sharedContext;
wxGLCanvas *m_sharedContextOf;
void *m_vi;
// GtkWidget *m_glWidget;
// bool m_exposed;
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxGLCanvas)
};
#endif
// wxUSE_GLCANVAS
#endif
// _WX_GLCANVAS_H_

View File

@@ -1,400 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: glcanvas.cpp
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
// Uses the GLX extension.
// Author: Julian Smart and Wolfram Gloger
// Modified by:
// Created: 1995, 1999
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Wolfram Gloger
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "glcanvas.h"
#endif
#include "wx/setup.h"
#if wxUSE_GLCANVAS
#include "wx/glcanvas.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/log.h"
#ifdef __VMS
# pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS
# pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
// DLL options compatibility check:
#include "wx/build.h"
WX_CHECK_BUILD_OPTIONS("wxGL")
#ifdef OLD_MESA
// workaround for bug in Mesa's glx.c
static int bitcount( unsigned long n )
{
int bits;
for (bits=0; n>0;) {
if(n & 1) bits++;
n = n >> 1;
}
return bits;
}
#endif
/*
* GLContext implementation
*/
IMPLEMENT_CLASS(wxGLContext,wxObject)
wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette) )
{
m_window = win;
// m_widget = win->m_wxwindow;
wxGLCanvas *gc = (wxGLCanvas*) win;
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
wxCHECK_RET( vi, "invalid visual for OpenGl" );
m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi,
None, GL_TRUE);
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
}
wxGLContext::wxGLContext(
bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette),
const wxGLContext *other /* for sharing display lists */
)
{
m_window = win;
// m_widget = win->m_wxwindow;
wxGLCanvas *gc = (wxGLCanvas*) win;
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
wxCHECK_RET( vi, "invalid visual for OpenGl" );
if( other != 0 )
m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi,
other->m_glContext, GL_TRUE );
else
m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi,
None, GL_TRUE );
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
}
wxGLContext::~wxGLContext()
{
if (!m_glContext) return;
if (m_glContext == glXGetCurrentContext())
{
glXMakeCurrent( (Display*) m_window->GetXDisplay(), None, NULL);
}
glXDestroyContext( (Display*) m_window->GetXDisplay(), m_glContext );
}
void wxGLContext::SwapBuffers()
{
if (m_glContext)
{
Display* display = (Display*) m_window->GetXDisplay();
glXSwapBuffers(display, (Window) m_window->GetXWindow());
}
}
void wxGLContext::SetCurrent()
{
if (m_glContext)
{
Display* display = (Display*) m_window->GetXDisplay();
glXMakeCurrent(display, (Window) m_window->GetXWindow(),
m_glContext );;
}
}
void wxGLContext::SetColour(const char *colour)
{
wxColour *the_colour = wxTheColourDatabase->FindColour(colour);
if(the_colour) {
GLboolean b;
glGetBooleanv(GL_RGBA_MODE, &b);
if(b) {
glColor3ub(the_colour->Red(),
the_colour->Green(),
the_colour->Blue());
} else {
GLint pix = (GLint)the_colour->m_pixel;
if(pix == -1) {
XColor exact_def;
exact_def.red = (unsigned short)the_colour->Red() << 8;
exact_def.green = (unsigned short)the_colour->Green() << 8;
exact_def.blue = (unsigned short)the_colour->Blue() << 8;
exact_def.flags = DoRed | DoGreen | DoBlue;
if(!XAllocColor((Display*) m_window->GetXDisplay(),
(Colormap) wxTheApp->GetMainColormap(m_window->GetXDisplay()),
&exact_def)) {
wxLogError("wxGLCanvas: cannot allocate color\n");
return;
}
pix = the_colour->m_pixel = exact_def.pixel;
}
glIndexi(pix);
}
}
}
void wxGLContext::SetupPixelFormat()
{
}
void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
{
}
wxPalette wxGLContext::CreateDefaultPalette()
{
return wxNullPalette;
}
/*
* GLCanvas implementation
*/
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow)
// EVT_SIZE(wxGLCanvas::OnSize)
END_EVENT_TABLE()
wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
: wxScrolledWindow(parent, id, pos, size, style, name)
{
Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette );
}
wxGLCanvas::wxGLCanvas( wxWindow *parent,
const wxGLContext *shared,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
: wxScrolledWindow(parent, id, pos, size, style, name)
{
Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette );
}
wxGLCanvas::wxGLCanvas( wxWindow *parent,
const wxGLCanvas *shared,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
: wxScrolledWindow(parent, id, pos, size, style, name)
{
Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette );
}
/*
bool wxGLCanvas::Create(wxWindow *parent,
const wxGLContext *shared, const wxGLCanvas *shared_context_of,
wxWindowID id = -1, const wxPoint& pos,
const wxSize& size, long style,
const wxString& name, int *attribList, const wxPalette& palette):
wxScrolledWindow(parent, id, pos, size, style, name)
*/
bool wxGLCanvas::Create( wxWindow *parent,
const wxGLContext *shared,
const wxGLCanvas *shared_context_of,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette)
{
XVisualInfo *vi, vi_templ;
XWindowAttributes xwa;
int val, n;
m_sharedContext = (wxGLContext*)shared; // const_cast
m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast
m_glContext = (wxGLContext*) NULL;
Display* display = (Display*) GetXDisplay();
// Check for the presence of the GLX extension
if(!glXQueryExtension(display, NULL, NULL)) {
wxLogError("wxGLCanvas: GLX extension is missing\n");
return false;
}
if(attribList) {
int data[512], arg=0, p=0;
while( (attribList[arg]!=0) && (p<512) )
{
switch( attribList[arg++] )
{
case WX_GL_RGBA: data[p++] = GLX_RGBA; break;
case WX_GL_BUFFER_SIZE:
data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_LEVEL:
data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break;
case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break;
case WX_GL_STEREO: data[p++] = GLX_STEREO; break;
case WX_GL_AUX_BUFFERS:
data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_RED:
data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_GREEN:
data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_BLUE:
data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ALPHA:
data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_DEPTH_SIZE:
data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_STENCIL_SIZE:
data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_RED:
data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_GREEN:
data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_BLUE:
data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_ALPHA:
data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
default:
break;
}
}
data[p] = 0;
attribList = (int*) data;
// Get an appropriate visual
vi = glXChooseVisual(display, DefaultScreen(display), attribList);
if(!vi) return false;
// Here we should make sure that vi is the same visual as the
// one used by the xwindow drawable in wxCanvas. However,
// there is currently no mechanism for this in wx_canvs.cc.
} else {
// By default, we use the visual of xwindow
// NI: is this really senseful ? opengl in e.g. color index mode ?
XGetWindowAttributes(display, (Window) GetXWindow(), &xwa);
vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
if(!vi) return false;
glXGetConfig(display, vi, GLX_USE_GL, &val);
if(!val) return false;
// Basically, this is it. It should be possible to use vi
// in glXCreateContext() below. But this fails with Mesa.
// I notified the Mesa author about it; there may be a fix.
#ifdef OLD_MESA
// Construct an attribute list matching the visual
int a_list[32];
n = 0;
if(vi->c_class==TrueColor || vi->c_class==DirectColor) { // RGBA visual
a_list[n++] = GLX_RGBA;
a_list[n++] = GLX_RED_SIZE;
a_list[n++] = bitcount(vi->red_mask);
a_list[n++] = GLX_GREEN_SIZE;
a_list[n++] = bitcount(vi->green_mask);
a_list[n++] = GLX_BLUE_SIZE;
a_list[n++] = bitcount(vi->blue_mask);
glXGetConfig(display, vi, GLX_ALPHA_SIZE, &val);
a_list[n++] = GLX_ALPHA_SIZE;
a_list[n++] = val;
} else { // Color index visual
glXGetConfig(display, vi, GLX_BUFFER_SIZE, &val);
a_list[n++] = GLX_BUFFER_SIZE;
a_list[n++] = val;
}
a_list[n] = None;
// XFree(vi);
vi = glXChooseVisual(display, DefaultScreen(display), a_list);
if(!vi) return false;
#endif /* OLD_MESA */
}
m_vi = vi; // safe for later use
wxCHECK_MSG( m_vi, FALSE, "required visual couldn't be found" );
// Create the GLX context and make it current
wxGLContext *share= m_sharedContext;
if (share==NULL && m_sharedContextOf)
share = m_sharedContextOf->GetContext();
m_glContext = new wxGLContext( TRUE, this, wxNullPalette, share );
#ifndef OLD_MESA
// XFree(vi);
#endif
SetCurrent();
return true;
}
wxGLCanvas::~wxGLCanvas(void)
{
XVisualInfo *vi = (XVisualInfo *) m_vi;
if (vi) XFree( vi );
if (m_glContext) delete m_glContext;
// Display* display = (Display*) GetXDisplay();
// if(glx_cx) glXDestroyContext(display, glx_cx);
}
void wxGLCanvas::SwapBuffers()
{
if( m_glContext ) m_glContext->SwapBuffers();
// Display* display = (Display*) GetXDisplay();
// if(glx_cx) glXSwapBuffers(display, (Window) GetXWindow());
}
void wxGLCanvas::SetCurrent()
{
if( m_glContext ) m_glContext->SetCurrent();
// Display* display = (Display*) GetXDisplay();
// if(glx_cx) glXMakeCurrent(display, (Window) GetXWindow(), glx_cx);
}
void wxGLCanvas::SetColour(const char *col)
{
if( m_glContext ) m_glContext->SetColour(col);
}
#endif
// wxUSE_GLCANVAS