-
Notifications
You must be signed in to change notification settings - Fork 17
/
grguBuffer.cpp
152 lines (124 loc) · 3.53 KB
/
grguBuffer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//**************************************************************
//* OpenGLide - Glide to OpenGL Wrapper
//* http://openglide.sourceforge.net
//*
//* Buffer functions
//*
//* OpenGLide is OpenSource under LGPL license
//* Originally made by Fabio Barros
//* Modified by Paul for Glidos (http://www.glidos.net)
//* Linux version by Simon White
//**************************************************************
#include <stdio.h>
#include "GlOgl.h"
#include "GLRender.h"
#include "platform/window.h"
// extern functions
void ConvertColorF( GrColor_t GlideColor, float &R, float &G, float &B, float &A );
//*************************************************
//* Clear all the Buffers
//*************************************************
FX_ENTRY void FX_CALL
grBufferClear( GrColor_t color, GrAlpha_t alpha, FxU16 depth )
{
#if defined( OGL_PARTDONE ) || defined( OGL_COMBINE )
GlideMsg( "grBufferClear( %d, %d, %d )\n", color, alpha, depth );
#endif
static GrColor_t old_color = 0;
static float BR = 0.0f,
BG = 0.0f,
BB = 0.0f,
BA = 0.0f;
static unsigned int Bits;
Bits = 0;
RenderDrawTriangles( );
if ( OpenGL.ColorMask )
{
Bits = GL_COLOR_BUFFER_BIT;
if ( color != old_color )
{
old_color = color;
ConvertColorF( color, BR, BG, BB, BA );
}
glClearColor( BR, BG, BB, BA );
}
if ( Glide.State.DepthBufferWritting )
{
glClearDepth( depth * D1OVER65535 );
Bits |= GL_DEPTH_BUFFER_BIT;
}
if ( ! OpenGL.Clipping )
{
glClear( Bits );
}
else
{
glEnable( GL_SCISSOR_TEST );
glClear( Bits );
glDisable( GL_SCISSOR_TEST );
}
#ifdef OPENGL_DEBUG
GLErro( "grBufferClear" );
#endif
}
//*************************************************
//* Swaps Front and Back Buffers
//*************************************************
FX_ENTRY void FX_CALL
grBufferSwap( int swap_interval )
{
#if defined( OGL_PARTDONE ) || defined( OGL_COMBINE )
GlideMsg( "grBufferSwap( %d )\n", swap_interval );
#endif
RenderDrawTriangles( );
glFlush( );
#ifdef OGL_DEBUG
static float Temp = 1.0f;
if ( OGLRender.FrameTriangles > OGLRender.MaxTriangles )
{
OGLRender.MaxTriangles = OGLRender.FrameTriangles;
}
OGLRender.FrameTriangles = 0;
#endif
SwapBuffers( );
#ifdef OGL_DEBUG
RDTSC( FinalTick );
Temp = (float)(FinalTick - InitialTick);
FpsAux += Temp;
Frame++;
RDTSC( InitialTick );
#endif
#ifdef OPENGL_DEBUG
GLErro( "grBufferSwap" );
#endif
}
//*************************************************
//* Return the number of queued buffer swap requests
//* Always 0, never pending
//*************************************************
FX_ENTRY int FX_CALL
grBufferNumPending( void )
{
#ifdef OGL_DONE
GlideMsg( "grBufferNumPending( ) = 0\n" );
#endif
return 0;
}
//*************************************************
//* Defines the Buffer to Render
//*************************************************
FX_ENTRY void FX_CALL
grRenderBuffer( GrBuffer_t dwBuffer )
{
#ifdef OGL_DONE
GlideMsg( "grRenderBuffer( %d )\n", dwBuffer );
#endif
RenderDrawTriangles( );
Glide.State.RenderBuffer = dwBuffer;
// Valid parameters are only FRONT and BACK ( 0x0 and 0x1 )
OpenGL.RenderBuffer = GL_FRONT + dwBuffer;
glDrawBuffer( OpenGL.RenderBuffer );
#ifdef OPENGL_DEBUG
GLErro( "grRenderBuffer" );
#endif
}