#include "functions.h"
#include "glwrap.h"
#include "opengl.h"
+#include "packet.h"
-int in_begin_block = 0;
-GLenum cur_error = GL_NO_ERROR;
+static int in_begin_block = 0;
+static GLenum cur_error = GL_NO_ERROR;
static void check_error()
{
- GLenum (*orig_glGetError)() = 0;
+ static GLenum (*orig_glGetError)() = NULL;
GLenum code;
if(in_begin_block)
code = orig_glGetError();
if(code!=GL_NO_ERROR)
{
- begin_packet(FUNC_GLDERROR);
- write_int(code);
- send_packet();
+ GlPacket *pkt;
+
+ pkt = packet_begin(FUNC_GLDERROR);
+ packet_write_int(pkt, code);
+ packet_send(pkt, get_out_fd());
if(cur_error==GL_NO_ERROR)
cur_error = code;
void APIENTRY glBegin(GLenum mode)
{
- static void (*orig)(GLenum);
+ static void (*orig)(GLenum) = NULL;
+ GlPacket *pkt;
+
if(!orig)
orig = glsym("glBegin");
orig(mode);
- begin_packet(FUNC_GLBEGIN);
- write_int(mode);
- send_packet();
+ pkt = packet_begin(FUNC_GLBEGIN);
+ packet_write_int(pkt, mode);
+ packet_send(pkt, get_out_fd());
in_begin_block = 1;
}
void APIENTRY glEnd()
{
- static void (*orig)();
+ static void (*orig)() = NULL;
+ GlPacket *pkt;
+
if(!orig)
orig = glsym("glEnd");
orig();
- begin_packet(FUNC_GLEND);
- send_packet();
+ pkt = packet_begin(FUNC_GLEND);
+ packet_send(pkt, get_out_fd());
in_begin_block = 0;
check_error();
GLenum APIENTRY glGetError()
{
GLenum ret = GL_NO_ERROR;
+ GlPacket *pkt;
if(in_begin_block)
{
cur_error = GL_NO_ERROR;
}
- begin_packet(FUNC_GLGETERROR);
- write_int(ret);
- send_packet();
+ pkt = packet_begin(FUNC_GLGETERROR);
+ packet_write_int(pkt, ret);
+ packet_send(pkt, get_out_fd());
return ret;
}
{
void *handle = 0;
void (*ret)() = 0;
+ GlPacket *pkt;
if(glsym((const char *)procname))
{
ret = dlsym(handle, (const char *)procname);
}
- begin_packet(FUNC_GLXGETPROCADDRESS);
- write_string((const char *)procname);
- write_pointer(ret);
- send_packet();
+ pkt = packet_begin(FUNC_GLXGETPROCADDRESS);
+ packet_write_string(pkt, (const char *)procname);
+ packet_write_pointer(pkt, ret);
+ packet_send(pkt, get_out_fd());
return ret;
}