Commit abdde5e7 authored by TimePath's avatar TimePath

Inject OpenGLBinding instead of using GlobalOpenGL() everywhere

parent 9dfae1c9
......@@ -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 ) {
}