mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-29 10:25:27 +08:00
OpenGl works now under GTK
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -31,9 +31,6 @@ class wxLog;
|
||||
|
||||
extern wxApp *wxTheApp;
|
||||
|
||||
extern GdkVisual *wxVisualSetByExternal;
|
||||
extern GdkColormap *wxColormapSetByExternal;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global functions
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -66,8 +63,7 @@ class wxApp: public wxEvtHandler
|
||||
|
||||
/* this may have to be overwritten when special, non-default visuals have
|
||||
to be set. it is also platform dependent as only X knows about displays
|
||||
and visuals. by standard, this routine looks at wxVisualSetByExternal
|
||||
which might have been set in the wxModule code of the OpenGL canvas */
|
||||
and visuals. */
|
||||
virtual bool InitVisual();
|
||||
|
||||
virtual bool OnInit();
|
||||
|
||||
@@ -31,9 +31,6 @@ class wxLog;
|
||||
|
||||
extern wxApp *wxTheApp;
|
||||
|
||||
extern GdkVisual *wxVisualSetByExternal;
|
||||
extern GdkColormap *wxColormapSetByExternal;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global functions
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -66,8 +63,7 @@ class wxApp: public wxEvtHandler
|
||||
|
||||
/* this may have to be overwritten when special, non-default visuals have
|
||||
to be set. it is also platform dependent as only X knows about displays
|
||||
and visuals. by standard, this routine looks at wxVisualSetByExternal
|
||||
which might have been set in the wxModule code of the OpenGL canvas */
|
||||
and visuals. */
|
||||
virtual bool InitVisual();
|
||||
|
||||
virtual bool OnInit();
|
||||
|
||||
+22
-42
@@ -44,9 +44,6 @@ wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
extern wxList wxPendingDelete;
|
||||
extern wxResourceCache *wxTheResourceCache;
|
||||
|
||||
GdkVisual *wxVisualSetByExternal = (GdkVisual*) NULL;
|
||||
GdkColormap *wxColormapSetByExternal = (GdkColormap*) NULL;
|
||||
|
||||
unsigned char g_palette[64*3] =
|
||||
{
|
||||
0x0, 0x0, 0x0,
|
||||
@@ -174,45 +171,28 @@ wxApp::~wxApp(void)
|
||||
|
||||
bool wxApp::InitVisual()
|
||||
{
|
||||
if (wxVisualSetByExternal)
|
||||
{
|
||||
/* this happens in the wxModule code of the OpenGl canvas.
|
||||
it chooses the best display for OpenGl and stores it
|
||||
in wxDisplaySetByExternal. we then have to make it the
|
||||
default for the system */
|
||||
|
||||
gtk_widget_set_default_visual( wxVisualSetByExternal );
|
||||
}
|
||||
|
||||
if (wxColormapSetByExternal)
|
||||
{
|
||||
/* OpenGl also gives us a colormap */
|
||||
|
||||
gtk_widget_set_default_colormap( wxColormapSetByExternal );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this initiates the standard palette as defined by GdkImlib
|
||||
in the GNOME libraries. it ensures that all GNOME applications
|
||||
use the same 64 colormap entries on 8-bit displays so you
|
||||
can use several rather graphics-heavy applications at the
|
||||
same time */
|
||||
|
||||
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
|
||||
return TRUE;
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
GdkColor col;
|
||||
col.red = g_palette[i*3 + 0] << 8;
|
||||
col.green = g_palette[i*3 + 1] << 8;
|
||||
col.blue = g_palette[i*3 + 2] << 8;
|
||||
col.pixel = 0;
|
||||
/* this initiates the standard palette as defined by GdkImlib
|
||||
in the GNOME libraries. it ensures that all GNOME applications
|
||||
use the same 64 colormap entries on 8-bit displays so you
|
||||
can use several rather graphics-heavy applications at the
|
||||
same time */
|
||||
|
||||
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
|
||||
|
||||
gdk_color_alloc( cmap, &col );
|
||||
}
|
||||
|
||||
gtk_widget_set_default_colormap( cmap );
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
GdkColor col;
|
||||
col.red = g_palette[i*3 + 0] << 8;
|
||||
col.green = g_palette[i*3 + 1] << 8;
|
||||
col.blue = g_palette[i*3 + 2] << 8;
|
||||
col.pixel = 0;
|
||||
|
||||
gdk_color_alloc( cmap, &col );
|
||||
}
|
||||
|
||||
gtk_widget_set_default_colormap( cmap );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -467,15 +447,15 @@ int wxEntry( int argc, char *argv[] )
|
||||
|
||||
gtk_init( &argc, &argv );
|
||||
|
||||
wxModule::RegisterModules();
|
||||
if (!wxModule::InitializeModules()) return FALSE;
|
||||
|
||||
if (!wxTheApp->InitVisual()) return 0;
|
||||
|
||||
wxApp::CommonInit();
|
||||
|
||||
if (!wxTheApp->OnInitGui()) return 0;
|
||||
|
||||
wxModule::RegisterModules();
|
||||
if (!wxModule::InitializeModules()) return FALSE;
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
@@ -288,6 +288,7 @@ gtk_myfixed_realize (GtkWidget *widget)
|
||||
attributes.event_mask |=
|
||||
GDK_EXPOSURE_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_BUTTON1_MOTION_MASK |
|
||||
GDK_BUTTON2_MOTION_MASK |
|
||||
|
||||
+12
-1
@@ -634,6 +634,17 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
||||
|
||||
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
|
||||
{
|
||||
if (gdk_event->is_hint)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GdkModifierType state;
|
||||
gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
|
||||
gdk_event->x = x;
|
||||
gdk_event->y = y;
|
||||
gdk_event->state = state;
|
||||
}
|
||||
|
||||
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
|
||||
|
||||
if (g_blockEventsOnDrag) return TRUE;
|
||||
@@ -646,7 +657,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
*/
|
||||
*/
|
||||
|
||||
wxMouseEvent event( wxEVT_MOTION );
|
||||
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
|
||||
|
||||
+22
-42
@@ -44,9 +44,6 @@ wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||
extern wxList wxPendingDelete;
|
||||
extern wxResourceCache *wxTheResourceCache;
|
||||
|
||||
GdkVisual *wxVisualSetByExternal = (GdkVisual*) NULL;
|
||||
GdkColormap *wxColormapSetByExternal = (GdkColormap*) NULL;
|
||||
|
||||
unsigned char g_palette[64*3] =
|
||||
{
|
||||
0x0, 0x0, 0x0,
|
||||
@@ -174,45 +171,28 @@ wxApp::~wxApp(void)
|
||||
|
||||
bool wxApp::InitVisual()
|
||||
{
|
||||
if (wxVisualSetByExternal)
|
||||
{
|
||||
/* this happens in the wxModule code of the OpenGl canvas.
|
||||
it chooses the best display for OpenGl and stores it
|
||||
in wxDisplaySetByExternal. we then have to make it the
|
||||
default for the system */
|
||||
|
||||
gtk_widget_set_default_visual( wxVisualSetByExternal );
|
||||
}
|
||||
|
||||
if (wxColormapSetByExternal)
|
||||
{
|
||||
/* OpenGl also gives us a colormap */
|
||||
|
||||
gtk_widget_set_default_colormap( wxColormapSetByExternal );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this initiates the standard palette as defined by GdkImlib
|
||||
in the GNOME libraries. it ensures that all GNOME applications
|
||||
use the same 64 colormap entries on 8-bit displays so you
|
||||
can use several rather graphics-heavy applications at the
|
||||
same time */
|
||||
|
||||
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
|
||||
return TRUE;
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
GdkColor col;
|
||||
col.red = g_palette[i*3 + 0] << 8;
|
||||
col.green = g_palette[i*3 + 1] << 8;
|
||||
col.blue = g_palette[i*3 + 2] << 8;
|
||||
col.pixel = 0;
|
||||
/* this initiates the standard palette as defined by GdkImlib
|
||||
in the GNOME libraries. it ensures that all GNOME applications
|
||||
use the same 64 colormap entries on 8-bit displays so you
|
||||
can use several rather graphics-heavy applications at the
|
||||
same time */
|
||||
|
||||
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
|
||||
|
||||
gdk_color_alloc( cmap, &col );
|
||||
}
|
||||
|
||||
gtk_widget_set_default_colormap( cmap );
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
GdkColor col;
|
||||
col.red = g_palette[i*3 + 0] << 8;
|
||||
col.green = g_palette[i*3 + 1] << 8;
|
||||
col.blue = g_palette[i*3 + 2] << 8;
|
||||
col.pixel = 0;
|
||||
|
||||
gdk_color_alloc( cmap, &col );
|
||||
}
|
||||
|
||||
gtk_widget_set_default_colormap( cmap );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -467,15 +447,15 @@ int wxEntry( int argc, char *argv[] )
|
||||
|
||||
gtk_init( &argc, &argv );
|
||||
|
||||
wxModule::RegisterModules();
|
||||
if (!wxModule::InitializeModules()) return FALSE;
|
||||
|
||||
if (!wxTheApp->InitVisual()) return 0;
|
||||
|
||||
wxApp::CommonInit();
|
||||
|
||||
if (!wxTheApp->OnInitGui()) return 0;
|
||||
|
||||
wxModule::RegisterModules();
|
||||
if (!wxModule::InitializeModules()) return FALSE;
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
@@ -288,6 +288,7 @@ gtk_myfixed_realize (GtkWidget *widget)
|
||||
attributes.event_mask |=
|
||||
GDK_EXPOSURE_MASK |
|
||||
GDK_POINTER_MOTION_MASK |
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON_MOTION_MASK |
|
||||
GDK_BUTTON1_MOTION_MASK |
|
||||
GDK_BUTTON2_MOTION_MASK |
|
||||
|
||||
+12
-1
@@ -634,6 +634,17 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
||||
|
||||
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
|
||||
{
|
||||
if (gdk_event->is_hint)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GdkModifierType state;
|
||||
gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
|
||||
gdk_event->x = x;
|
||||
gdk_event->y = y;
|
||||
gdk_event->state = state;
|
||||
}
|
||||
|
||||
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
|
||||
|
||||
if (g_blockEventsOnDrag) return TRUE;
|
||||
@@ -646,7 +657,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
*/
|
||||
*/
|
||||
|
||||
wxMouseEvent event( wxEVT_MOTION );
|
||||
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
include ../../setup/general/makedirs
|
||||
@@ -2,4 +2,4 @@ wxGLCanvas
|
||||
----------
|
||||
|
||||
No known issues, though probably palettes aren't correctly
|
||||
handled under Windows.
|
||||
handled under Windows. They are ignored under GTK.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
CC = g++
|
||||
|
||||
cube: cube.o glcanvas.o
|
||||
$(CC) -o cube \
|
||||
cube.o glcanvas.o \
|
||||
`wx-config --libs` -lMesaGL -lMesaGLU
|
||||
|
||||
cube.o: cube.cpp
|
||||
$(CC) `wx-config --cflags` -I../../src -c cube.cpp
|
||||
|
||||
glcanvas.o: ../../src/glcanvas.cpp
|
||||
$(CC) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o cube
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
#include "cube.h"
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
// `Main program' equivalent, creating windows and returning main app frame
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
@@ -54,7 +52,7 @@ bool MyApp::OnInit(void)
|
||||
|
||||
frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200));
|
||||
|
||||
InitGL();
|
||||
// InitGL();
|
||||
|
||||
// Show the frame
|
||||
frame->Show(TRUE);
|
||||
@@ -81,6 +79,8 @@ void MyApp::InitGL(void)
|
||||
glEnable(GL_LIGHT0);
|
||||
}
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(wxID_EXIT, MyFrame::OnExit)
|
||||
END_EVENT_TABLE()
|
||||
@@ -169,8 +169,11 @@ void TestGLCanvas::OnSize(wxSizeEvent& event)
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
|
||||
if ( GetContext() )
|
||||
if (GetContext())
|
||||
{
|
||||
SetCurrent();
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
CC = g++
|
||||
|
||||
isosurf: isosurf.o glcanvas.o
|
||||
$(CC) -o isosurf \
|
||||
isosurf.o glcanvas.o \
|
||||
`wx-config --libs` -lMesaGL -lMesaGLU
|
||||
|
||||
isosurf.o: isosurf.cpp
|
||||
$(CC) `wx-config --cflags` -I../../src -c isosurf.cpp
|
||||
|
||||
glcanvas.o: ../../src/glcanvas.cpp
|
||||
$(CC) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o cube
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
CPP = g++
|
||||
CC = gcc
|
||||
|
||||
Penguin: penguin.o trackball.o lw.o glcanvas.o
|
||||
$(CPP) -o Penguin \
|
||||
penguin.o trackball.o lw.o glcanvas.o \
|
||||
`wx-config --libs` -lMesaGL -lMesaGLU
|
||||
|
||||
penguin.o: penguin.cpp
|
||||
$(CPP) `wx-config --cflags` -I../../src -c penguin.cpp
|
||||
|
||||
lw.o: lw.c
|
||||
$(CC) `wx-config --cflags` -I../../src -c lw.c
|
||||
|
||||
trackball.o: trackball.c
|
||||
$(CC) `wx-config --cflags` -I../../src -c trackball.c
|
||||
|
||||
glcanvas.o: ../../src/glcanvas.cpp
|
||||
$(CPP) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o penguin
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 1998 Janne Löf <jlof@mail.student.oulu.fi>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LW_H
|
||||
#define LW_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
#define LW_MAX_POINTS 200
|
||||
#define LW_MAX_NAME_LEN 500
|
||||
|
||||
typedef struct {
|
||||
char name[LW_MAX_NAME_LEN];
|
||||
GLfloat r,g,b;
|
||||
} lwMaterial;
|
||||
|
||||
typedef struct {
|
||||
int material; /* material of this face */
|
||||
int index_cnt; /* number of vertices */
|
||||
int *index; /* index to vertex */
|
||||
float *texcoord; /* u,v texture coordinates */
|
||||
} lwFace;
|
||||
|
||||
typedef struct {
|
||||
int face_cnt;
|
||||
lwFace *face;
|
||||
|
||||
int material_cnt;
|
||||
lwMaterial *material;
|
||||
|
||||
int vertex_cnt;
|
||||
GLfloat *vertex;
|
||||
|
||||
} lwObject;
|
||||
|
||||
|
||||
int lw_is_lwobject(const char *lw_file);
|
||||
lwObject *lw_object_read(const char *lw_file);
|
||||
void lw_object_free( lwObject *lw_object);
|
||||
void lw_object_show(const lwObject *lw_object);
|
||||
|
||||
GLfloat lw_object_radius(const lwObject *lw_object);
|
||||
void lw_object_scale (lwObject *lw_object, GLfloat scale);
|
||||
|
||||
#endif /* LW_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: penguin.h
|
||||
// Purpose: wxGLCanvas demo program
|
||||
// Author: Robert Roebling
|
||||
// Modified by:
|
||||
// Created: 04/01/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Robert Roebling
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PENGUIN_H_
|
||||
#define _WX_PENGUIN_H_
|
||||
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/dcclient.h"
|
||||
|
||||
#include "glcanvas.h"
|
||||
|
||||
extern "C" {
|
||||
#include "lw.h"
|
||||
#include "trackball.h"
|
||||
}
|
||||
|
||||
/* information needed to display lightwave mesh */
|
||||
typedef struct
|
||||
{
|
||||
gint do_init; /* true if initgl not yet called */
|
||||
lwObject *lwobject; /* lightwave object mesh */
|
||||
float beginx,beginy; /* position of mouse */
|
||||
float quat[4]; /* orientation of object */
|
||||
float zoom; /* field of view in degrees */
|
||||
} mesh_info;
|
||||
|
||||
|
||||
/* Define a new application type */
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit(void);
|
||||
};
|
||||
|
||||
/* Define a new frame type */
|
||||
class TestGLCanvas;
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
long style = wxDEFAULT_FRAME_STYLE);
|
||||
|
||||
void OnExit(wxCommandEvent& event);
|
||||
bool OnClose(void);
|
||||
public:
|
||||
TestGLCanvas* m_canvas;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
class TestGLCanvas: public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
TestGLCanvas(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "TestGLCanvas");
|
||||
~TestGLCanvas(void);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void LoadLWO( const wxString &filename);
|
||||
void OnMouse( wxMouseEvent& event );
|
||||
void InitGL(void);
|
||||
|
||||
mesh_info info;
|
||||
bool block;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
|
||||
* ALL RIGHTS RESERVED
|
||||
* Permission to use, copy, modify, and distribute this software for
|
||||
* any purpose and without fee is hereby granted, provided that the above
|
||||
* copyright notice appear in all copies and that both the copyright notice
|
||||
* and this permission notice appear in supporting documentation, and that
|
||||
* the name of Silicon Graphics, Inc. not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission.
|
||||
*
|
||||
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
|
||||
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
|
||||
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
||||
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
|
||||
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
|
||||
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
|
||||
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
|
||||
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* US Government Users Restricted Rights
|
||||
* Use, duplication, or disclosure by the Government is subject to
|
||||
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
|
||||
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
|
||||
* clause at DFARS 252.227-7013 and/or in similar or successor
|
||||
* clauses in the FAR or the DOD or NASA FAR Supplement.
|
||||
* Unpublished-- rights reserved under the copyright laws of the
|
||||
* United States. Contractor/manufacturer is Silicon Graphics,
|
||||
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
|
||||
*
|
||||
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
|
||||
*/
|
||||
/*
|
||||
* trackball.h
|
||||
* A virtual trackball implementation
|
||||
* Written by Gavin Bell for Silicon Graphics, November 1988.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pass the x and y coordinates of the last and current positions of
|
||||
* the mouse, scaled so they are from (-1.0 ... 1.0).
|
||||
*
|
||||
* The resulting rotation is returned as a quaternion rotation in the
|
||||
* first paramater.
|
||||
*/
|
||||
void
|
||||
trackball(float q[4], float p1x, float p1y, float p2x, float p2y);
|
||||
|
||||
/*
|
||||
* Given two quaternions, add them together to get a third quaternion.
|
||||
* Adding quaternions to get a compound rotation is analagous to adding
|
||||
* translations to get a compound translation. When incrementally
|
||||
* adding rotations, the first argument here should be the new
|
||||
* rotation, the second and third the total rotation (which will be
|
||||
* over-written with the resulting new total rotation).
|
||||
*/
|
||||
void
|
||||
add_quats(float *q1, float *q2, float *dest);
|
||||
|
||||
/*
|
||||
* A useful function, builds a rotation matrix in Matrix based on
|
||||
* given quaternion.
|
||||
*/
|
||||
void
|
||||
build_rotmatrix(float m[4][4], float q[4]);
|
||||
|
||||
/*
|
||||
* This function computes a quaternion based on an axis (defined by
|
||||
* the given vector) and an angle about which to rotate. The angle is
|
||||
* expressed in radians. The result is put into the third argument.
|
||||
*/
|
||||
void
|
||||
axis_to_quat(float a[3], float phi, float q[4]);
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
include ../../../setup/general/makedirs
|
||||
@@ -1,67 +0,0 @@
|
||||
#
|
||||
# wxGLCanvas source makefile for Unix
|
||||
#
|
||||
# Copyright 1998, Robert Roebling
|
||||
#
|
||||
|
||||
# wxWindows base directory
|
||||
WXBASEDIR=@WXBASEDIR@
|
||||
|
||||
# set the OS type for compilation
|
||||
OS=@OS@
|
||||
|
||||
# compile a library only
|
||||
RULE=gslib
|
||||
|
||||
# needed for unactivated
|
||||
NONE=
|
||||
|
||||
# define library name
|
||||
LIB_TARGET=wx_opengl_gtk
|
||||
LIB_MAJOR=1
|
||||
LIB_MINOR=0
|
||||
|
||||
# define library sources
|
||||
|
||||
LIB_CPP_SRC= \
|
||||
\
|
||||
glcanvas.cpp
|
||||
|
||||
#define library objects
|
||||
LIB_OBJ= \
|
||||
\
|
||||
$(LIB_CPP_SRC:.cpp=.o)
|
||||
|
||||
all::
|
||||
|
||||
clean::
|
||||
|
||||
#additional things needed for compile
|
||||
ADD_COMPILE=
|
||||
|
||||
# include the definitions now
|
||||
include ../../../../template.mak
|
||||
|
||||
install::
|
||||
@echo "Installing library files and headers for libwx_opengl_gtk.."
|
||||
@echo " Creating directory.."
|
||||
@$(WXBASEDIR)/mkinstalldirs /usr/local/include/wx_opengl
|
||||
@echo " Copying headers from /include/wx"
|
||||
@cd $(WXBASEDIR)/utils/glcanvas/src ; \
|
||||
for f in *.h ; do \
|
||||
rm -f /usr/local/include/wx_opengl/$$f ; \
|
||||
$(INSTALL_DATA) $$f /usr/local/include/wx_opengl/$$f ; \
|
||||
done
|
||||
@echo " Copying static library files to /usr/local/lib"
|
||||
@cd $(WXBASEDIR)/lib/$(OS) ; \
|
||||
for f in libwx_opengl_gtk.a ; do \
|
||||
rm -f /usr/local/lib/$$f ; \
|
||||
$(INSTALL_DATA) $$f /usr/local/lib/$$f ; \
|
||||
done
|
||||
@echo " Copying shared libraries to /usr/local/lib"
|
||||
@cd $(WXBASEDIR)/lib/$(OS) ; \
|
||||
for f in libwx_opengl_gtk.so* ; do \
|
||||
rm -f /usr/local/lib/$$f ; \
|
||||
$(INSTALL_PROGRAM) $$f /usr/local/lib/$$f ; \
|
||||
done
|
||||
|
||||
+162
-49
File diff suppressed because it is too large
Load Diff
@@ -19,9 +19,11 @@
|
||||
#include "wx/defs.h"
|
||||
#include "wx/scrolwin.h"
|
||||
|
||||
extern "C" {
|
||||
#include "GL/gl.h"
|
||||
#include "GL/glx.h"
|
||||
#include "GL/glu.h"
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// classes
|
||||
@@ -75,9 +77,20 @@ class wxGLCanvas: public wxScrolledWindow
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
|
||||
public:
|
||||
wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette);
|
||||
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 );
|
||||
|
||||
bool Create( 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();
|
||||
|
||||
void SetCurrent();
|
||||
@@ -86,11 +99,19 @@ class wxGLCanvas: public wxScrolledWindow
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
inline wxGLContext* GetContext() const { return m_glContext; }
|
||||
inline wxGLContext* GetContext() const { return m_glContext; }
|
||||
|
||||
protected:
|
||||
// implementation
|
||||
|
||||
wxGLContext* m_glContext; // this is typedef-ed ptr, in fact
|
||||
virtual void SetSize( int x, int y, int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO );
|
||||
virtual void SetSize( int width, int height );
|
||||
|
||||
virtual GtkWidget *GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
|
||||
wxGLContext *m_glContext;
|
||||
GtkWidget *m_glWidget;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user