...
 
Commits (1)
......@@ -69,7 +69,7 @@ DBobView::~DBobView()
// Implementation
//////////////////////////////////////////////////////////////////////
void DBobView::render(RenderStateFlags state) const
void DBobView::render(OpenGLBinding &GL, RenderStateFlags state) const
{
glBegin(GL_LINE_STRIP);
......
......@@ -72,7 +72,7 @@ public:
void SetPath(vec3_t *pPath);
void render(RenderStateFlags state) const;
void render(OpenGLBinding &GL, RenderStateFlags state) const;
void renderSolid(Renderer &renderer, const VolumeTest &volume) const;
......
......@@ -104,7 +104,7 @@ void CalculateSpline_r(vec3_t *v, int count, vec3_t out, float tension)
delete[] v2;
}
void DTrainDrawer::render(RenderStateFlags state) const
void DTrainDrawer::render(OpenGLBinding &GL, RenderStateFlags state) const
{
for (std::list<splinePoint_t *>::const_iterator sp = m_splineList.begin(); sp != m_splineList.end(); sp++) {
splinePoint_t *pSP = (*sp);
......
......@@ -71,7 +71,7 @@ public:
virtual ~DTrainDrawer(void);
void render(RenderStateFlags state) const;
void render(OpenGLBinding &GL, RenderStateFlags state) const;
void renderSolid(Renderer &renderer, const VolumeTest &volume) const;
......
......@@ -88,7 +88,7 @@ void DVisDrawer::destroyShaders()
GlobalOpenGLStateLibrary().erase(g_state_wireframe);
}
void DVisDrawer::render(RenderStateFlags state) const
void DVisDrawer::render(OpenGLBinding &GL, RenderStateFlags state) const
{
//bleh
std::list<DWinding *>::const_iterator l = m_list->begin();
......
......@@ -51,7 +51,7 @@ public:
void SetList(std::list<DWinding *> *pointList);
void render(RenderStateFlags state) const;
void render(OpenGLBinding &GL, RenderStateFlags state) const;
void renderSolid(Renderer &renderer, const VolumeTest &volume) const;
......
......@@ -452,7 +452,7 @@ void CPortalsRender::renderWireframe(Renderer &renderer, const VolumeTest &volum
renderer.addRenderable(m_drawWireframe, g_matrix4_identity);
}
void CPortalsDrawWireframe::render(RenderStateFlags state) const
void CPortalsDrawWireframe::render(OpenGLBinding &GL, RenderStateFlags state) const
{
unsigned int n, p;
......@@ -510,7 +510,7 @@ void CPortalsRender::renderSolid(Renderer &renderer, const VolumeTest &volume) c
}
}
void CPortalsDrawSolid::render(RenderStateFlags state) const
void CPortalsDrawSolid::render(OpenGLBinding &GL, RenderStateFlags state) const
{
float trans = (100.0f - portals.trans_3d) / 100.0f;
......@@ -601,7 +601,7 @@ void CPortalsDrawSolid::render(RenderStateFlags state) const
}
}
void CPortalsDrawSolidOutline::render(RenderStateFlags state) const
void CPortalsDrawSolidOutline::render(OpenGLBinding &GL, RenderStateFlags state) const
{
for (unsigned int n = 0; n < portals.portal_count; n++) {
if (portals.lines == 2 && !portals.portal[n].hint) {
......
......@@ -123,19 +123,19 @@ class CPortalsDrawSolid : public OpenGLRenderable {
public:
mutable CubicClipVolume clip;
void render(RenderStateFlags state) const;
void render(OpenGLBinding &GL, RenderStateFlags state) const;
};
class CPortalsDrawSolidOutline : public OpenGLRenderable {
public:
mutable CubicClipVolume clip;
void render(RenderStateFlags state) const;
void render(OpenGLBinding &GL, RenderStateFlags state) const;
};
class CPortalsDrawWireframe : public OpenGLRenderable {
public:
void render(RenderStateFlags state) const;
void render(OpenGLBinding &GL, RenderStateFlags state) const;
};
class CPortalsRender : public Renderable {
......
This diff is collapsed.
......@@ -31,9 +31,9 @@ class Matrix4;
class GLProgram
{
public:
virtual void enable() = 0;
virtual void disable() = 0;
virtual void setParameters( const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light ) = 0;
virtual void enable(OpenGLBinding &GL) = 0;
virtual void disable(OpenGLBinding &GL) = 0;
virtual void setParameters( OpenGLBinding &GL, const Vector3& viewer, const Matrix4& localToWorld, const Vector3& origin, const Vector3& colour, const Matrix4& world2light ) = 0;
};
class OpenGLFogState
......
......@@ -25,6 +25,8 @@
#include <uilib/uilib.h>
#include "generic/constant.h"
struct OpenGLBinding;
template<class T>
using func = T *;
......@@ -32,7 +34,7 @@ struct _QERGtkGLTable {
STRING_CONSTANT(Name, "gtkgl");
INTEGER_CONSTANT(Version, 1);
func<ui::GLArea(bool zbufffer)> glwidget_new;
func<ui::GLArea(OpenGLBinding &GL, bool zbufffer)> glwidget_new;
func<void(ui::GLArea self)> glwidget_swap_buffers;
func<bool(ui::GLArea self)> glwidget_make_current;
func<void(ui::GLArea self)> glwidget_destroy_context;
......
......@@ -104,11 +104,13 @@ const int c_attr_TexCoord0 = 1;
const int c_attr_Tangent = 3;
const int c_attr_Binormal = 4;
struct OpenGLBinding;
class OpenGLRenderable
{
public:
virtual ~OpenGLRenderable() = default;
virtual void render( RenderStateFlags state ) const = 0;
virtual void render( OpenGLBinding &GL, RenderStateFlags state ) const = 0;
};
class Matrix4;
......@@ -139,7 +141,7 @@ STRING_CONSTANT( Name, "renderstate" );
virtual Shader* capture( const char* name ) = 0;
virtual void release( const char* name ) = 0;
/*! Render all Shader objects. */
virtual void render( RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection, const Vector3& viewer = Vector3( 0, 0, 0 ) ) = 0;
virtual void render( OpenGLBinding &GL, RenderStateFlags globalstate, const Matrix4& modelview, const Matrix4& projection, const Vector3& viewer = Vector3( 0, 0, 0 ) ) = 0;
virtual void realise() = 0;
virtual void unrealise() = 0;
......
......@@ -43,7 +43,7 @@
#include <list>
#include <set>
inline void arrow_draw( const Vector3& origin, const Vector3& direction_forward, const Vector3& direction_left, const Vector3& direction_up ){
inline void arrow_draw( OpenGLBinding &GL, const Vector3& origin, const Vector3& direction_forward, const Vector3& direction_left, const Vector3& direction_up ){
Vector3 endpoint( vector3_added( origin, vector3_scaled( direction_forward, 32.0 ) ) );
Vector3 tip1( vector3_added( vector3_added( endpoint, vector3_scaled( direction_forward, -8.0 ) ), vector3_scaled( direction_up, -4.0 ) ) );
......@@ -100,7 +100,7 @@ inline void aabb_testselect( const AABB& aabb, SelectionTest& test, SelectionInt
test.TestQuads( VertexPointer( reinterpret_cast<VertexPointer::pointer>( points ), sizeof( Vector3 ) ), IndexPointer( indices, 24 ), best );
}
inline void aabb_draw_wire( const Vector3 points[8] ){
inline void aabb_draw_wire( OpenGLBinding &GL, const Vector3 points[8] ){
unsigned int indices[26] = {
0, 1, 1, 2, 2, 3, 3, 0,
4, 5, 5, 6, 6, 7, 7, 4,
......@@ -121,7 +121,7 @@ inline void aabb_draw_wire( const Vector3 points[8] ){
#endif
}
inline void aabb_draw_flatshade( const Vector3 points[8] ){
inline void aabb_draw_flatshade( OpenGLBinding &GL, const Vector3 points[8] ){
glBegin( GL_QUADS );
glNormal3fv( vector3_to_array( aabb_normals[0] ) );
......@@ -163,19 +163,19 @@ inline void aabb_draw_flatshade( const Vector3 points[8] ){
glEnd();
}
inline void aabb_draw_wire( const AABB& aabb ){
inline void aabb_draw_wire( OpenGLBinding &GL, const AABB& aabb ){
Vector3 points[8];
aabb_corners( aabb, points );
aabb_draw_wire( points );
aabb_draw_wire( GL, points );
}
inline void aabb_draw_flatshade( const AABB& aabb ){
inline void aabb_draw_flatshade( OpenGLBinding &GL, const AABB& aabb ){
Vector3 points[8];
aabb_corners( aabb, points );
aabb_draw_flatshade( points );
aabb_draw_flatshade( GL, points );
}
inline void aabb_draw_textured( const AABB& aabb ){
inline void aabb_draw_textured( OpenGLBinding &GL, const AABB& aabb ){
Vector3 points[8];
aabb_corners( aabb, points );
......@@ -244,23 +244,23 @@ inline void aabb_draw_textured( const AABB& aabb ){
glEnd();
}
inline void aabb_draw_solid( const AABB& aabb, RenderStateFlags state ){
inline void aabb_draw_solid( OpenGLBinding &GL, const AABB& aabb, RenderStateFlags state ){
if ( state & RENDER_TEXTURE ) {
aabb_draw_textured( aabb );
aabb_draw_textured( GL, aabb );
}
else
{
aabb_draw_flatshade( aabb );
aabb_draw_flatshade( GL, aabb );
}
}
inline void aabb_draw( const AABB& aabb, RenderStateFlags state ){
inline void aabb_draw( OpenGLBinding &GL, const AABB& aabb, RenderStateFlags state ){
if ( state & RENDER_FILL ) {
aabb_draw_solid( aabb, state );
aabb_draw_solid( GL, aabb, state );
}
else
{
aabb_draw_wire( aabb );
aabb_draw_wire( GL, aabb );
}
}
......@@ -270,8 +270,8 @@ const AABB& m_aabb;
public:
RenderableSolidAABB( const AABB& aabb ) : m_aabb( aabb ){
}
void render( RenderStateFlags state ) const {
aabb_draw_solid( m_aabb, state );
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
aabb_draw_solid( GL, m_aabb, state );
}
};
......@@ -281,8 +281,8 @@ const AABB& m_aabb;
public:
RenderableWireframeAABB( const AABB& aabb ) : m_aabb( aabb ){
}
void render( RenderStateFlags state ) const {
aabb_draw_wire( m_aabb );
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
aabb_draw_wire( GL, m_aabb );
}
};
......
......@@ -346,4 +346,26 @@ inline Callback<R(Ts...)> makeCallbackF(R(*func)(Ts...)) {
return BindFirstOpaque<detail::FreeCallerWrapper<R(Ts...)>>(pVoid);
}
template<typename Lambda>
inline Callback<get_func<Lambda>> makeCallbackL(const Lambda &lambda) {
static_assert(sizeof(Lambda) == 1, "lambda must not capture");
return makeCallbackF(+lambda);
}
template<typename Lambda>
inline Callback<detail::ArgShift<get_func<Lambda>>> makeCallbackL(get_argument<Lambda, 0> env, const Lambda &lambda) {
static_assert(sizeof(Lambda) == 1, "lambda must not capture");
using R = get_result_type<Lambda>;
using Env = get_argument<Lambda, 0>;
struct Caller {
using func = R(Env);
static R call(Env env) {
(void) (func *) nullptr;
const Lambda &x = *(const Lambda *) nullptr;
x(env);
}
};
return makeCallback<Caller>(Caller(), env);
}
#endif
......@@ -25,14 +25,18 @@
// generic string printing with call lists
class GLFontCallList : public GLFont {
OpenGLBinding &GL;
GLuint m_displayList;
int m_pixelHeight;
int m_pixelAscent;
int m_pixelDescent;
public:
GLFontCallList(GLuint displayList, int asc, int desc, int pixelHeight) : m_displayList(displayList),
m_pixelHeight(pixelHeight),
m_pixelAscent(asc), m_pixelDescent(desc)
GLFontCallList(OpenGLBinding &GL, GLuint displayList, int asc, int desc, int pixelHeight)
: GL(GL),
m_displayList(displayList),
m_pixelHeight(pixelHeight),
m_pixelAscent(asc),
m_pixelDescent(desc)
{
}
......@@ -43,8 +47,8 @@ public:
void printString(const char *s)
{
GlobalOpenGL().m_glListBase(m_displayList);
GlobalOpenGL().m_glCallLists(GLsizei(strlen(s)), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte *>( s ));
GL.m_glListBase(m_displayList);
GL.m_glCallLists(GLsizei(strlen(s)), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte *>( s ));
}
virtual int getPixelAscent() const
......@@ -264,7 +268,7 @@ public:
// just a hair outside of the viewport (meaning the current raster position is invalid),
// then no text will be rendered. The solution to this is a very hacky one. You can search
// Google for "glDrawPixels clipping".
virtual void printString(const char *s)
virtual void printString(OpenGLBinding &GL, const char *s)
{
// The idea for this code initially came from the font-pangoft2.c example that comes with GtkGLExt.
......@@ -298,41 +302,41 @@ public:
bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
pango_ft2_render_layout_subpixel(&bitmap, layout, -log_rect.x,
y_offset_bitmap_render_pango_units);
GlobalOpenGL().m_glGetFloatv(GL_CURRENT_COLOR, color);
GL.m_glGetFloatv(GL_CURRENT_COLOR, color);
// Save state. I didn't see any OpenGL push/pop operations for these.
// Question: Is saving/restoring this state necessary? Being safe.
GlobalOpenGL().m_glGetIntegerv(GL_UNPACK_ALIGNMENT, &previous_unpack_alignment);
previous_blend_enabled = GlobalOpenGL().m_glIsEnabled(GL_BLEND);
GlobalOpenGL().m_glGetIntegerv(GL_BLEND_SRC, &previous_blend_func_src);
GlobalOpenGL().m_glGetIntegerv(GL_BLEND_DST, &previous_blend_func_dst);
GlobalOpenGL().m_glGetFloatv(GL_RED_BIAS, &previous_red_bias);
GlobalOpenGL().m_glGetFloatv(GL_GREEN_BIAS, &previous_green_bias);
GlobalOpenGL().m_glGetFloatv(GL_BLUE_BIAS, &previous_blue_bias);
GlobalOpenGL().m_glGetFloatv(GL_ALPHA_SCALE, &previous_alpha_scale);
GlobalOpenGL().m_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GlobalOpenGL().m_glEnable(GL_BLEND);
GlobalOpenGL().m_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GlobalOpenGL().m_glPixelTransferf(GL_RED_BIAS, color[0]);
GlobalOpenGL().m_glPixelTransferf(GL_GREEN_BIAS, color[1]);
GlobalOpenGL().m_glPixelTransferf(GL_BLUE_BIAS, color[2]);
GlobalOpenGL().m_glPixelTransferf(GL_ALPHA_SCALE, color[3]);
GlobalOpenGL().m_glDrawPixels(bitmap.width, bitmap.rows,
GL.m_glGetIntegerv(GL_UNPACK_ALIGNMENT, &previous_unpack_alignment);
previous_blend_enabled = GL.m_glIsEnabled(GL_BLEND);
GL.m_glGetIntegerv(GL_BLEND_SRC, &previous_blend_func_src);
GL.m_glGetIntegerv(GL_BLEND_DST, &previous_blend_func_dst);
GL.m_glGetFloatv(GL_RED_BIAS, &previous_red_bias);
GL.m_glGetFloatv(GL_GREEN_BIAS, &previous_green_bias);
GL.m_glGetFloatv(GL_BLUE_BIAS, &previous_blue_bias);
GL.m_glGetFloatv(GL_ALPHA_SCALE, &previous_alpha_scale);
GL.m_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GL.m_glEnable(GL_BLEND);
GL.m_glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL.m_glPixelTransferf(GL_RED_BIAS, color[0]);
GL.m_glPixelTransferf(GL_GREEN_BIAS, color[1]);
GL.m_glPixelTransferf(GL_BLUE_BIAS, color[2]);
GL.m_glPixelTransferf(GL_ALPHA_SCALE, color[3]);
GL.m_glDrawPixels(bitmap.width, bitmap.rows,
GL_ALPHA, GL_UNSIGNED_BYTE, begin_bitmap_buffer);
g_free(begin_bitmap_buffer);
// Restore state in reverse order of how we set it.
GlobalOpenGL().m_glPixelTransferf(GL_ALPHA_SCALE, previous_alpha_scale);
GlobalOpenGL().m_glPixelTransferf(GL_BLUE_BIAS, previous_blue_bias);
GlobalOpenGL().m_glPixelTransferf(GL_GREEN_BIAS, previous_green_bias);
GlobalOpenGL().m_glPixelTransferf(GL_RED_BIAS, previous_red_bias);
GlobalOpenGL().m_glBlendFunc(previous_blend_func_src, previous_blend_func_dst);
GL.m_glPixelTransferf(GL_ALPHA_SCALE, previous_alpha_scale);
GL.m_glPixelTransferf(GL_BLUE_BIAS, previous_blue_bias);
GL.m_glPixelTransferf(GL_GREEN_BIAS, previous_green_bias);
GL.m_glPixelTransferf(GL_RED_BIAS, previous_red_bias);
GL.m_glBlendFunc(previous_blend_func_src, previous_blend_func_dst);
if (!previous_blend_enabled) {
GlobalOpenGL().m_glDisable(GL_BLEND);
GL.m_glDisable(GL_BLEND);
}
GlobalOpenGL().m_glPixelStorei(GL_UNPACK_ALIGNMENT, previous_unpack_alignment);
GL.m_glPixelStorei(GL_UNPACK_ALIGNMENT, previous_unpack_alignment);
}
g_object_unref(G_OBJECT(layout));
......
......@@ -24,6 +24,8 @@
typedef unsigned int GLuint;
struct OpenGLBinding;
class GLFont {
public:
virtual int getPixelHeight() const = 0;
......@@ -32,7 +34,7 @@ public:
virtual int getPixelDescent() const = 0;
virtual void printString(const char *s) = 0;
virtual void printString(OpenGLBinding &GL, const char *s) = 0;
virtual ~GLFont()
{
......
......@@ -25,33 +25,33 @@
#include "igl.h"
void (*GLWidget_sharedContextCreated)() = 0;
void (*GLWidget_sharedContextCreated)(OpenGLBinding &GL) = 0;
void (*GLWidget_sharedContextDestroyed)() = 0;
void (*GLWidget_sharedContextDestroyed)(OpenGLBinding &GL) = 0;
unsigned int g_context_count = 0;
ui::GLArea g_shared{ui::null};
void _glwidget_context_created(ui::GLArea self, void *data)
void _glwidget_context_created(OpenGLBinding &GL, ui::GLArea self)
{
if (++g_context_count == 1) {
g_shared = self;
g_object_ref(g_shared._handle);
glwidget_make_current(g_shared);
GlobalOpenGL().contextValid = true;
GL.contextValid = true;
GLWidget_sharedContextCreated();
GLWidget_sharedContextCreated(GL);
}
}
void _glwidget_context_destroyed(ui::GLArea self, void *data)
void _glwidget_context_destroyed(OpenGLBinding &GL, ui::GLArea self)
{
if (--g_context_count == 0) {
GlobalOpenGL().contextValid = false;
GL.contextValid = false;
GLWidget_sharedContextDestroyed();
GLWidget_sharedContextDestroyed(GL);
g_shared.unref();
g_shared = ui::GLArea(ui::null);
......@@ -92,7 +92,7 @@ bool glwidget_make_current(ui::GLArea self)
// glwidget_context_created(self);
// }
gtk_gl_area_make_current(self);
auto valid = GlobalOpenGL().contextValid;
auto valid = GL.contextValid;
return true;
}
......@@ -243,15 +243,15 @@ GdkGLConfig *glconfig_new_with_depth()
return gdk_gl_config_new_by_mode((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH));
}
int glwidget_context_created(ui::GLArea self, void *data)
int glwidget_context_created(ui::GLArea self, OpenGLBinding *data)
{
_glwidget_context_created(self, data);
_glwidget_context_created(*data, self);
return false;
}
int glwidget_context_destroyed(ui::GLArea self, void *data)
int glwidget_context_destroyed(ui::GLArea self, OpenGLBinding *data)
{
_glwidget_context_destroyed(self, data);
_glwidget_context_destroyed(*data, self);
return false;
}
......@@ -274,7 +274,7 @@ bool glwidget_enable_gl(ui::GLArea self, ui::Widget root, gpointer data)
return false;
}
ui::GLArea glwidget_new(bool zbuffer)
ui::GLArea glwidget_new(OpenGLBinding &GL, bool zbuffer)
{
auto self = ui::GLArea::from(gtk_drawing_area_new());
......@@ -282,8 +282,8 @@ ui::GLArea glwidget_new(bool zbuffer)
self.connect("hierarchy-changed", G_CALLBACK(glwidget_enable_gl), 0);
self.connect("realize", G_CALLBACK(glwidget_context_created), 0);
self.connect("unrealize", G_CALLBACK(glwidget_context_destroyed), 0);
self.connect("realize", G_CALLBACK(glwidget_context_created), &GL);
self.connect("unrealize", G_CALLBACK(glwidget_context_destroyed), &GL);
return self;
}
......
......@@ -24,11 +24,13 @@
#if !defined( INCLUDED_GTKUTIL_GLWIDGET_H )
#define INCLUDED_GTKUTIL_GLWIDGET_H
extern void (*GLWidget_sharedContextCreated)();
struct OpenGLBinding;
extern void (*GLWidget_sharedContextDestroyed)();
extern void (*GLWidget_sharedContextCreated)(OpenGLBinding &GL);
ui::GLArea glwidget_new(bool zbuffer);
extern void (*GLWidget_sharedContextDestroyed)(OpenGLBinding &GL);
ui::GLArea glwidget_new(OpenGLBinding &GL, bool zbuffer);
void glwidget_create_context(ui::GLArea self);
......
......@@ -253,7 +253,7 @@ RenderablePivot(){
m_vertices.push_back( PointVertex( Vertex3f( 0, 0, 16 ), g_colour_z ) );
}
void render( RenderStateFlags state ) const {
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
if ( m_vertices.size() == 0 ) {
return;
}
......
......@@ -821,7 +821,7 @@ inline ArbitraryMeshVertex arbitrarymeshvertex_quantised( const ArbitraryMeshVer
/// \brief Sets up the OpenGL colour and vertex arrays for \p array.
inline void pointvertex_gl_array( const PointVertex* array ){
inline void pointvertex_gl_array( OpenGLBinding &GL, const PointVertex* array ){
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( PointVertex ), &array->colour );
glVertexPointer( 3, GL_FLOAT, sizeof( PointVertex ), &array->vertex );
}
......@@ -834,14 +834,14 @@ public:
RenderablePointArray( const Array<PointVertex>& array, GLenum mode )
: m_array( array ), m_mode( mode ){
}
void render( RenderStateFlags state ) const {
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
#define NV_DRIVER_BUG 1
#if NV_DRIVER_BUG
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, 0 );
glVertexPointer( 3, GL_FLOAT, 0, 0 );
glDrawArrays( GL_TRIANGLE_FAN, 0, 0 );
#endif
pointvertex_gl_array( m_array.data() );
pointvertex_gl_array( GL, m_array.data() );
glDrawArrays( m_mode, 0, GLsizei( m_array.size() ) );
}
};
......@@ -855,8 +855,8 @@ RenderablePointVector( GLenum mode )
: m_mode( mode ){
}
void render( RenderStateFlags state ) const {
pointvertex_gl_array( &m_vector.front() );
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
pointvertex_gl_array( GL, &m_vector.front() );
glDrawArrays( m_mode, 0, GLsizei( m_vector.size() ) );
}
......@@ -887,8 +887,8 @@ RenderableVertexBuffer( GLenum mode, const VertexBuffer<PointVertex>& vertices )
: m_mode( mode ), m_vertices( vertices ){
}
void render( RenderStateFlags state ) const {
pointvertex_gl_array( m_vertices.data() );
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
pointvertex_gl_array( GL, m_vertices.data() );
glDrawArrays( m_mode, 0, m_vertices.size() );
}
};
......@@ -903,9 +903,9 @@ RenderableIndexBuffer( GLenum mode, const IndexBuffer& indices, const VertexBuff
: m_mode( mode ), m_indices( indices ), m_vertices( vertices ){
}
void render( RenderStateFlags state ) const {
void render( OpenGLBinding &GL, RenderStateFlags state ) const {
#if 1
pointvertex_gl_array( m_vertices.data() );
pointvertex_gl_array( GL, m_vertices.data() );
glDrawElements( m_mode, GLsizei( m_indices.size() ), RenderIndexTypeID, m_indices.data() );
#else
glBegin( m_mode );
......
......@@ -95,7 +95,7 @@ idCameraDef *g_splineList = &splineList;
idVec3 idSplineList::zero( 0,0,0 );
void glLabeledPoint( idVec3 &color, idVec3 &point, float size, const char *label ) {
void glLabeledPoint( OpenGLBinding &GL, idVec3 &color, idVec3 &point, float size, const char *label ) {
glColor3fv( color );
glPointSize( size );
glBegin( GL_POINTS );
......@@ -110,7 +110,7 @@ void glLabeledPoint( idVec3 &color, idVec3 &point, float size, const char *label
}
void glBox( idVec3 &color, idVec3 &point, float size ) {
void glBox( OpenGLBinding &GL, idVec3 &color, idVec3 &point, float size ) {
idVec3 mins( point );
idVec3 maxs( point );
mins[0] -= size;
......@@ -243,7 +243,7 @@ void idSplineList::buildSpline() {
}
void idSplineList::draw( bool editMode ) {
void idSplineList::draw( OpenGLBinding &GL, bool editMode ) {
int i;
idVec4 yellow( 1, 1, 0, 1 );
......@@ -267,7 +267,7 @@ void idSplineList::draw( bool editMode ) {
if ( editMode ) {
for ( i = 0; i < controlPoints.Num(); i++ ) {
glBox( activeColor, *controlPoints[i], 4 );
glBox( GL, activeColor, *controlPoints[i], 4 );
}
}
......@@ -292,8 +292,8 @@ void idSplineList::draw( bool editMode ) {
if ( count > 0 ) {
//assert(activeSegment >=0 && activeSegment < count);
if ( activeSegment >= 0 && activeSegment < count ) {
glBox( activeColor, *splinePoints[activeSegment], 6 );
glBox( yellow, *splinePoints[activeSegment], 8 );
glBox( GL, activeColor, *splinePoints[activeSegment], 6 );
glBox( GL, yellow, *splinePoints[activeSegment], 8 );
}
}
......
......@@ -34,8 +34,8 @@
typedef int fileHandle_t;
extern void glBox( idVec3 &color, idVec3 &point, float size );
extern void glLabeledPoint( idVec3 &color, idVec3 &point, float size, const char *label );
extern void glBox( OpenGLBinding &GL, idVec3 &color, idVec3 &point, float size );
extern void glLabeledPoint( OpenGLBinding &GL, idVec3 &color, idVec3 &point, float size, const char *label );
static idVec4 blue( 0, 0, 1, 1 );
static idVec4 red( 1, 0, 0, 1 );
......@@ -148,10 +148,10 @@ virtual void updateSelection( const idVec3 &move ) {
}
}
void drawSelection() {
void drawSelection(OpenGLBinding &GL) {
int count = selectedPoints.Num();
for ( int i = 0; i < count; i++ ) {
glBox( red, *getPoint( selectedPoints[i] ), 4 );
glBox( GL, red, *getPoint( selectedPoints[i] ), 4 );
}
}
......@@ -213,7 +213,7 @@ void initPosition( long startTime, long totalTime );
const idVec3 *getPosition( long time );
void draw( bool editMode );
void draw( OpenGLBinding &GL, bool editMode );
void addToRenderer();
void setSelectedPoint( idVec3 *p );
......@@ -441,7 +441,7 @@ virtual const idVec3 *getPosition( long t ) {
return NULL;
}
virtual void draw( bool editMode ) {};
virtual void draw( OpenGLBinding &GL, bool editMode ) {};
virtual void parse( const char *( *text ) ) {};
virtual void write( fileHandle_t file, const char *name );
......@@ -533,8 +533,8 @@ virtual idVec3 *getPoint( int index ) {
return &pos;
}
virtual void draw( bool editMode ) {
glLabeledPoint( blue, pos, ( editMode ) ? 5 : 3, "Fixed point" );
virtual void draw( OpenGLBinding &GL, bool editMode ) {
glLabeledPoint( GL, blue, pos, ( editMode ) ? 5 : 3, "Fixed point" );
}
protected:
......@@ -603,9 +603,9 @@ virtual void addPoint( const idVec3 &v ) {
}
}
virtual void draw( bool editMode ) {
glLabeledPoint( blue, startPos, ( editMode ) ? 5 : 3, "Start interpolated" );
glLabeledPoint( blue, endPos, ( editMode ) ? 5 : 3, "End interpolated" );
virtual void draw( OpenGLBinding &GL, bool editMode ) {
glLabeledPoint( GL, blue, startPos, ( editMode ) ? 5 : 3, "Start interpolated" );
glLabeledPoint( GL, blue, endPos, ( editMode ) ? 5 : 3, "End interpolated" );
glBegin( GL_LINES );
glVertex3fv( startPos );
glVertex3fv( endPos );
......@@ -686,8 +686,8 @@ virtual void addPoint( const float x, const float y, const float z ) {
target.addPoint( x, y, z );
}
virtual void draw( bool editMode ) {
target.draw( editMode );
virtual void draw( OpenGLBinding &GL, bool editMode ) {
target.draw( GL, editMode );
}
virtual void updateSelection( const idVec3 &move ) {
......@@ -1012,14 +1012,14 @@ bool getCameraInfo( long time, float *origin, float *direction, float *fv ) {
return b;
}
void draw( bool editMode ) {
void draw( OpenGLBinding &GL, bool editMode ) {
// gcc doesn't allow casting away from bools
// why? I've no idea...
if ( cameraPosition ) {
cameraPosition->draw( (bool)( ( editMode || cameraRunning ) && cameraEdit ) );
cameraPosition->draw( GL, (bool)( ( editMode || cameraRunning ) && cameraEdit ) );
int count = targetPositions.Num();
for ( int i = 0; i < count; i++ ) {
targetPositions[i]->draw( (bool)( ( editMode || cameraRunning ) && i == activeTarget && !cameraEdit ) );
targetPositions[i]->draw( GL, (bool)( ( editMode || cameraRunning ) && i == activeTarget && !cameraEdit ) );
}
}
}
......
......@@ -39,9 +39,9 @@ class RenderableCurve : public OpenGLRenderable {
public:
std::vector<PointVertex> m_vertices;
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
pointvertex_gl_array(&m_vertices.front());
pointvertex_gl_array(GL, &m_vertices.front());
glDrawArrays(GL_LINE_STRIP, 0, GLsizei(m_vertices.size()));
}
};
......
......@@ -61,10 +61,10 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
Matrix4 mat = matrix4_rotation_for_euler_xyz_degrees(m_angles);
arrow_draw(m_origin, matrix4_transformed_direction(mat, Vector3(1, 0, 0)),
arrow_draw(GL, m_origin, matrix4_transformed_direction(mat, Vector3(1, 0, 0)),
matrix4_transformed_direction(mat, Vector3(0, 1, 0)),
matrix4_transformed_direction(mat, Vector3(0, 0, 1)));
}
......
......@@ -68,7 +68,7 @@
extern bool g_newLightDraw;
void sphere_draw_fill(const Vector3 &origin, float radius, int sides)
void sphere_draw_fill(OpenGLBinding &GL, const Vector3 &origin, float radius, int sides)
{
if (radius <= 0) {
return;
......@@ -139,7 +139,7 @@ void sphere_draw_fill(const Vector3 &origin, float radius, int sides)
glEnd();
}
void sphere_draw_wire(const Vector3 &origin, float radius, int sides)
void sphere_draw_wire(OpenGLBinding &GL, const Vector3 &origin, float radius, int sides)
{
{
glBegin(GL_LINE_LOOP);
......@@ -193,7 +193,7 @@ void sphere_draw_wire(const Vector3 &origin, float radius, int sides)
}
}
void light_draw_box_lines(const Vector3 &origin, const Vector3 points[8])
void light_draw_box_lines(OpenGLBinding &GL, const Vector3 &origin, const Vector3 points[8])
{
//draw lines from the center of the bbox to the corners
glBegin(GL_LINES);
......@@ -225,29 +225,29 @@ void light_draw_box_lines(const Vector3 &origin, const Vector3 points[8])
glEnd();
}
void light_draw_radius_wire(const Vector3 &origin, const float envelope[3])
void light_draw_radius_wire(OpenGLBinding &GL, const Vector3 &origin, const float envelope[3])
{
if (envelope[0] > 0) {
sphere_draw_wire(origin, envelope[0], 24);
sphere_draw_wire(GL, origin, envelope[0], 24);
}
if (envelope[1] > 0) {
sphere_draw_wire(origin, envelope[1], 24);
sphere_draw_wire(GL, origin, envelope[1], 24);
}
if (envelope[2] > 0) {
sphere_draw_wire(origin, envelope[2], 24);
sphere_draw_wire(GL, origin, envelope[2], 24);
}
}
void light_draw_radius_fill(const Vector3 &origin, const float envelope[3])
void light_draw_radius_fill(OpenGLBinding &GL, const Vector3 &origin, const float envelope[3])
{
if (envelope[0] > 0) {
sphere_draw_fill(origin, envelope[0], 16);
sphere_draw_fill(GL, origin, envelope[0], 16);
}
if (envelope[1] > 0) {
sphere_draw_fill(origin, envelope[1], 16);
sphere_draw_fill(GL, origin, envelope[1], 16);
}
if (envelope[2] > 0) {
sphere_draw_fill(origin, envelope[2], 16);
sphere_draw_fill(GL, origin, envelope[2], 16);
}
}
......@@ -266,7 +266,7 @@ void light_vertices(const AABB &aabb_light, Vector3 points[6])
points[5] = Vector3(min[0], mid[1], mid[2]);
}
void light_draw(const AABB &aabb_light, RenderStateFlags state)
void light_draw(OpenGLBinding &GL, const AABB &aabb_light, RenderStateFlags state)
{
Vector3 points[6];
light_vertices(aabb_light, points);
......@@ -587,9 +587,9 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
light_draw_radius_wire(m_origin, m_radii.m_radii);
light_draw_radius_wire(GL, m_origin, m_radii.m_radii);
}
};
......@@ -603,9 +603,9 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
light_draw_radius_fill(m_origin, m_radii.m_radii);
light_draw_radius_fill(GL, m_origin, m_radii.m_radii);
}
};
......@@ -619,17 +619,17 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
//draw the bounding box of light based on light_radius key
if ((state & RENDER_FILL) != 0) {
aabb_draw_flatshade(m_points);
aabb_draw_flatshade(GL, m_points);
} else {
aabb_draw_wire(m_points);
aabb_draw_wire(GL, m_points);
}
#if 1 //disable if you dont want lines going from the center of the light bbox to the corners
light_draw_box_lines(m_origin, m_points);
light_draw_box_lines(GL, m_origin, m_points);
#endif
}
};
......@@ -646,7 +646,7 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
glBegin(GL_POINTS);
glColor3fv(vector3_to_array(m_eclass.color));
......@@ -665,7 +665,7 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
Matrix4 unproject(matrix4_full_inverse(m_projection));
Vector3 points[8];
......@@ -680,7 +680,7 @@ public:
points[7] = vector4_projected(matrix4_transformed_vector4(unproject, Vector4(points[7], 1)));
// Vector4 test1 = matrix4_transformed_vector4( unproject, Vector4( 0.5f, 0.5f, 0.5f, 1 ) );
// Vector3 test2 = vector4_projected( test1 );
aabb_draw_wire(points);
aabb_draw_wire(GL, points);
}
};
......@@ -1179,12 +1179,12 @@ public:
m_traverseObservers.detach(*observer);
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
if (!g_newLightDraw) {
aabb_draw(m_aabb_light, state);
aabb_draw(GL, m_aabb_light, state);
} else {
light_draw(m_aabb_light, state);
light_draw(GL, m_aabb_light, state);
}
}
......
......@@ -100,10 +100,10 @@ public:
{
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
glRasterPos3fv(vector3_to_array(m_position));
GlobalOpenGL().drawString(m_named.name());
GL.drawString(m_named.name());
}
};
......
......@@ -52,7 +52,7 @@ public:
Vector3 start;
Vector3 end;
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
float s1[2], s2[2];
Vector3 dir(vector3_subtracted(end, start));
......
......@@ -168,7 +168,7 @@ public:
}
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
#if 1
if ((state & RENDER_BUMP) != 0) {
......
......@@ -101,7 +101,7 @@ public:
ReleaseShader();
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
if ((state & RENDER_BUMP) != 0) {
if (GlobalShaderCache().useShaderLanguage()) {
......
......@@ -110,13 +110,13 @@ inline bool texdef_sane(const texdef_t &texdef)
&& fabs(texdef.shift[1]) < (1 << 16);
}
inline void Winding_DrawWireframe(const Winding &winding)
inline void Winding_DrawWireframe(OpenGLBinding &GL, const Winding &winding)
{
glVertexPointer(3, GL_FLOAT, sizeof(WindingVertex), &winding.points.data()->vertex);
glDrawArrays(GL_LINE_LOOP, 0, GLsizei(winding.numpoints));
}
inline void Winding_Draw(const Winding &winding, const Vector3 &normal, RenderStateFlags state)
inline void Winding_Draw(OpenGLBinding &GL, const Winding &winding, const Vector3 &normal, RenderStateFlags state)
{
glVertexPointer(3, GL_FLOAT, sizeof(WindingVertex), &winding.points.data()->vertex);
......@@ -1070,9 +1070,9 @@ public:
m_shader.instanceDetach();
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
Winding_Draw(m_winding, m_planeTransformed.plane3().normal(), state);
Winding_Draw(GL, m_winding, m_planeTransformed.plane3().normal(), state);
}
void updateFiltered()
......@@ -1468,7 +1468,7 @@ struct EdgeFaces {
class RenderableWireframe : public OpenGLRenderable {
public:
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
#if 1
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(PointVertex), &m_vertices->colour);
......@@ -3128,12 +3128,12 @@ public:
}
}
void render(RenderStateFlags state) const
void render(OpenGLBinding &GL, RenderStateFlags state) const
{
if ((state & RENDER_FILL) != 0) {
Winding_Draw(m_winding, m_plane.normal(), state);
Winding_Draw(GL, m_winding, m_plane.normal(), state);
} else {
Winding_DrawWireframe(m_winding);
Winding_DrawWireframe(GL, m_winding);
// also draw a line indicating the direction of the cut
Vector3 lineverts[2];
......
......@@ -722,6 +722,7 @@ void Camera_motionDelta(int x, int y, unsigned int state, void *data)
}
class CamWnd {
OpenGLBinding &GL;
View m_view;
camera_t m_Camera;
RadiantCameraView m_cameraview;
......@@ -756,7 +757,7 @@ public:
guint m_sizeHandler;
guint m_exposeHandler;
CamWnd();
CamWnd(OpenGLBinding &GL);
~CamWnd();
......@@ -815,9 +816,9 @@ typedef MemberCaller<CamWnd, void(), &CamWnd::queue_draw> CamWndQueueDraw;
Shader *CamWnd::m_state_select1 = 0;
Shader *CamWnd::m_state_select2 = 0;
CamWnd *NewCamWnd()
CamWnd *NewCamWnd(OpenGLBinding &GL)
{
return new CamWnd;
return new CamWnd(GL);
}
void DeleteCamWnd(CamWnd *camwnd)
......@@ -1293,11 +1294,12 @@ void CamWnd_Remove_Handlers_FreeMove(CamWnd &camwnd)
g_signal_handler_disconnect(G_OBJECT(camwnd.m_gl_widget), camwnd.m_freelook_button_press_handler);
}
CamWnd::CamWnd() :
CamWnd::CamWnd(OpenGLBinding &GL) :
GL(GL),
m_view(true),
m_Camera(&m_view, CamWndQueueDraw(*this)),
m_cameraview(m_Camera, &m_view, ReferenceCaller<CamWnd, void(), CamWnd_Update>(*this)),
m_gl_widget(glwidget_new(TRUE)),
m_gl_widget(glwidget_new(GL, TRUE)),
m_window_observer(NewWindowObserver()),
m_XORRectangle(m_gl_widget),
m_deferredDraw(WidgetQueueDrawCaller(m_gl_widget)),
......@@ -1562,9 +1564,9 @@ public:
m_state_stack.back().m_state->addRenderable(renderable, world, m_state_stack.back().m_lights);
}
void render(const Matrix4 &modelview, const Matrix4 &projection)
void render(OpenGLBinding &GL, const Matrix4 &modelview, const Matrix4 &projection)
{
GlobalShaderCache().render(m_globalstate, modelview, projection, m_viewer);
GlobalShaderCache().render(GL, m_globalstate, modelview, projection, m_viewer);
}
};
......@@ -1689,7 +1691,7 @@ void CamWnd::Cam_Draw()
Scene_Render(renderer, m_view);
renderer.render(m_Camera.modelview, m_Camera.projection);
renderer.render(GL, m_Camera.modelview, m_Camera.projection);
}
// prepare for 2d stuff
......@@ -1703,7 +1705,7 @@ void CamWnd::Cam_Draw()
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if (GlobalOpenGL().GL_1_3()) {
if (GL.GL_1_3()) {
glClientActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0);
}
......@@ -1734,14 +1736,14 @@ void CamWnd::Cam_Draw()
}
if (g_camwindow_globals_private.m_showStats) {
glRasterPos3f(1.0f, static_cast<float>( m_Camera.height ) - GlobalOpenGL().m_font->getPixelDescent(), 0.0f);
glRasterPos3f(1.0f, static_cast<float>( m_Camera.height ) - GL.m_font->getPixelDescent(), 0.0f);
extern const char *Renderer_GetStats();
GlobalOpenGL().drawString(Renderer_GetStats());
GL.drawString(Renderer_GetStats());
glRasterPos3f(1.0f, static_cast<float>( m_Camera.height ) - GlobalOpenGL().m_font->getPixelDescent() -
GlobalOpenGL().m_font->getPixelHeight(), 0.0f);
glRasterPos3f(1.0f, static_cast<float>( m_Camera.height ) - GL.m_font->getPixelDescent() -
GL.m_font->getPixelHeight(), 0.0f);
extern const char *Cull_GetStats();
GlobalOpenGL().drawString(Cull_GetStats());
GL.drawString(Cull_GetStats());
}
// bind back to the default texture so that we don't have problems
......
......@@ -28,7 +28,9 @@
class CamWnd;
CamWnd *NewCamWnd();
struct OpenGLBinding;
CamWnd *NewCamWnd(OpenGLBinding &GL);
void DeleteCamWnd(CamWnd *camwnd);
......
......@@ -41,9 +41,9 @@
CDbgDlg g_DbgDlg;
void Feedback_draw2D(VIEWTYPE viewType)
void Feedback_draw2D(OpenGLBinding &GL, VIEWTYPE viewType)
{
g_DbgDlg.draw2D(viewType);
g_DbgDlg.draw2D(GL, viewType);
}
void CSelectMsg::saxStartElement(message_info_t *ctx, const xmlChar *name, const xmlChar **attrs)
......@@ -127,7 +127,7 @@ void CPointMsg::DropHighlight()
{
}
void CPointMsg::Draw2D(VIEWTYPE vt)
void CPointMsg::Draw2D(OpenGLBinding &GL, VIEWTYPE vt)
{
int nDim1 = (vt == YZ) ? 1 : 0;
int nDim2 = (vt == XY) ? 1 : 2;
......@@ -197,7 +197,7 @@ void CWindingMsg::DropHighlight()
{
}
void CWindingMsg::Draw2D(VIEWTYPE vt)
void CWindingMsg::Draw2D(OpenGLBinding &GL, VIEWTYPE vt)
{
int i;
......
......@@ -34,6 +34,8 @@
#include "dialog.h"
#include "xywindow.h"
struct OpenGLBinding;
// we use these classes to let plugins draw inside the Radiant windows
// 2D window like YZ XZ XY
class IGL2DWindow {
......@@ -46,7 +48,7 @@ public:
// Decrement the reference count
virtual void DecRef() = 0;
virtual void Draw2D(VIEWTYPE vt) = 0;
virtual void Draw2D(OpenGLBinding &GL, VIEWTYPE vt) = 0;
};
// 3D window
......@@ -134,7 +136,7 @@ public:
}
}
void Draw2D(VIEWTYPE vt);
void Draw2D(OpenGLBinding &GL, VIEWTYPE vt);
};
class CWindingMsg : public ISAXHandler, public IGL2DWindow {
......@@ -186,7 +188,7 @@ public:
}
}
void Draw2D(VIEWTYPE vt);
void Draw2D(OpenGLBinding &GL, VIEWTYPE vt);
};
......@@ -216,10 +218,10 @@ public:
void DropHighlight();
void draw2D(VIEWTYPE viewType)
void draw2D(OpenGLBinding &GL, VIEWTYPE viewType)
{
if (m_pDraw2D != 0) {
m_pDraw2D->Draw2D(viewType);
m_pDraw2D->Draw2D(GL, viewType);
}
}
......@@ -236,6 +238,6 @@ protected:
extern CDbgDlg g_DbgDlg;
void Feedback_draw2D(VIEWTYPE viewType);
void Feedback_draw2D(OpenGLBinding &GL, VIEWTYPE viewType);
#endif
......@@ -430,7 +430,7 @@ void about_button_issues(ui::Widget widget, gpointer data)
OpenURL(cred.c_str());
}
void DoAbout()
void DoAbout(OpenGLBinding &GL)
{
ModalDialog dialog;
ModalDialogButton ok_button(dialog, eIDOK);
......
......@@ -51,7 +51,8 @@ void DoFind();
void DoSides(int type, int axis);
void DoAbout();
struct OpenGLBinding;
void DoAbout(OpenGLBinding &GL);
#if GDEF_OS_WINDOWS
......
......@@ -61,6 +61,7 @@
*/
#include <igl.h>
#include "main.h"
#include "globaldefs.h"
......@@ -650,8 +651,8 @@ int main(int argc, char *argv[])
user_shortcuts_init();
g_pParentWnd = 0;
g_pParentWnd = new MainFrame();
OpenGLBinding &GL = GlobalOpenGLModule::getTable();
g_pParentWnd = new MainFrame(GL);
hide_splash();
......
......@@ -2449,7 +2449,7 @@ ui::MenuItem create_patch_menu()
return patch_menu_item;
}
ui::MenuItem create_help_menu()
ui::MenuItem create_help_menu(OpenGLBinding &GL)
{
// Help menu
auto help_menu_item = new_sub_menu_item_with_mnemonic("_Help");
......@@ -2466,12 +2466,14 @@ ui::MenuItem create_help_menu()
create_menu_item_with_mnemonic(menu, "Bug report", makeCallbackF(OpenBugReportURL));
create_menu_item_with_mnemonic(menu, "Shortcuts list", makeCallbackF(DoCommandListDlg));
create_menu_item_with_mnemonic(menu, "_About", makeCallbackF(DoAbout));
create_menu_item_with_mnemonic(menu, "_About", makeCallbackL(GL, [](OpenGLBinding &GL) {
DoAbout(GL);
}));
return help_menu_item;
}
ui::MenuBar create_main_menu(MainFrame::EViewStyle style)
ui::MenuBar create_main_menu(MainFrame::EViewStyle style, OpenGLBinding &GL)
{
auto menu_bar = ui::MenuBar::from(gtk_menu_bar_new());
menu_bar.show();
......@@ -2487,7 +2489,7 @@ ui::MenuBar create_main_menu(MainFrame::EViewStyle style)
menu_bar.add(create_brush_menu());
menu_bar.add(create_patch_menu());
menu_bar.add(create_plugins_menu());
menu_bar.add(create_help_menu());
menu_bar.add(create_help_menu(GL));
return menu_bar;
}
......@@ -2846,7 +2848,7 @@ ui::Window MainFrame_getWindow()
std::vector<ui::Widget> g_floating_windows;
MainFrame::MainFrame() : m_idleRedrawStatusText(RedrawStatusTextCaller(*this))
MainFrame::MainFrame(OpenGLBinding &GL) : m_idleRedrawStatusText(RedrawStatusTextCaller(*this))
{
m_pXYWnd = 0;
m_pCamWnd = 0;
......@@ -2861,7 +2863,7 @@ MainFrame::MainFrame() : m_idleRedrawStatusText(RedrawStatusTextCaller(*this))
m_bSleeping = false;
Create();
Create(GL);
}
MainFrame::~MainFrame()
......@@ -3048,7 +3050,7 @@ static gint mainframe_delete(ui::Widget widget, GdkEvent *event, gpointer data)
return TRUE;
}
void MainFrame::Create()
void MainFrame::Create(OpenGLBinding &GL)
{
ui::Window window = ui::Window(ui::window_type::TOP);
......@@ -3090,7 +3092,7 @@ void MainFrame::Create()
register_shortcuts();
auto main_menu = create_main_menu(CurrentStyle());
auto main_menu = create_main_menu(CurrentStyle(), GL);
vbox.pack_start(main_menu, FALSE, FALSE, 0);
auto main_toolbar = create_main_toolbar(CurrentStyle());
......@@ -3151,7 +3153,7 @@ void MainFrame::Create()
gtk_paned_add1(GTK_PANED(vsplit), hsplit);
// xy
m_pXYWnd = new XYWnd();
m_pXYWnd = new XYWnd(GL);
m_pXYWnd->SetViewType(XY);
ui::Widget xy_window = ui::Widget(create_framed_widget(m_pXYWnd->GetWidget()));
......@@ -3170,7 +3172,7 @@ void MainFrame::Create()
// camera
m_pCamWnd = NewCamWnd();
m_pCamWnd = NewCamWnd(GL);
GlobalCamera_setCamWnd(*m_pCamWnd);
CamWnd_setParent(*m_pCamWnd, window);
auto camera_window = create_framed_widget(CamWnd_getWidget(*m_pCamWnd));
......@@ -3178,7 +3180,7 @@ void MainFrame::Create()
gtk_paned_add1(GTK_PANED(vsplit2), camera_window);
// textures
auto texture_window = create_framed_widget(TextureBrowser_constructWindow(window));
auto texture_window = create_framed_widget(TextureBrowser_constructWindow(window, GL));
gtk_paned_add2(GTK_PANED(vsplit2), texture_window);
}
......@@ -3202,7 +3204,7 @@ void MainFrame::Create()
window.show();
m_pCamWnd = NewCamWnd();
m_pCamWnd = NewCamWnd(GL);
GlobalCamera_setCamWnd(*m_pCamWnd);
{
......@@ -3219,7 +3221,7 @@ void MainFrame::Create()
global_accel_connect_window(window);
g_posXYWnd.connect(window);
m_pXYWnd = new XYWnd();
m_pXYWnd = new XYWnd(GL);
m_pXYWnd->m_parent = window;
m_pXYWnd->SetViewType(XY);
......@@ -3238,7 +3240,7 @@ void MainFrame::Create()
global_accel_connect_window(window);
g_posXZWnd.connect(window);
m_pXZWnd = new XYWnd();
m_pXZWnd = new XYWnd(GL);
m_pXZWnd->m_parent = window;
m_pXZWnd->SetViewType(XZ);
......@@ -3257,7 +3259,7 @@ void MainFrame::Create()
global_accel_connect_window(window);
g_posYZWnd.connect(window);
m_pYZWnd = new XYWnd();
m_pYZWnd = new XYWnd(GL);
m_pYZWnd->m_parent = window;
m_pYZWnd->SetViewType(YZ);
......@@ -3272,30 +3274,30 @@ void MainFrame::Create()
}
{
auto frame = create_framed_widget(TextureBrowser_constructWindow(GroupDialog_getWindow()));
auto frame = create_framed_widget(TextureBrowser_constructWindow(GroupDialog_getWindow(), GL));
g_page_textures = GroupDialog_addPage("Textures", frame, TextureBrowserExportTitleCaller());
}
GroupDialog_show();
} else // 4 way
{
m_pCamWnd = NewCamWnd();
m_pCamWnd = NewCamWnd(GL);
GlobalCamera_setCamWnd(*m_pCamWnd);
CamWnd_setParent(*m_pCamWnd, window);
ui::Widget camera = CamWnd_getWidget(*m_pCamWnd);
m_pYZWnd = new XYWnd();
m_pYZWnd = new XYWnd(GL);
m_pYZWnd->SetViewType(YZ);
ui::Widget yz = m_pYZWnd->GetWidget();
m_pXYWnd = new XYWnd();
m_pXYWnd = new XYWnd(GL);