-
Notifications
You must be signed in to change notification settings - Fork 17
/
Glide.cpp
140 lines (111 loc) · 4.78 KB
/
Glide.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
//**************************************************************
//* OpenGLide - Glide to OpenGL Wrapper
//* http://openglide.sourceforge.net
//*
//* Main File
//*
//* 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 "Glextensions.h"
#include "PGTexture.h"
#include "PGUTexture.h"
#include "platform/error.h"
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Version ///////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
const char * OpenGLideVersion = "0.09rc9";
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
// Main Structs
GlideStruct Glide;
OpenGLStruct OpenGL;
// Classes
PGTexture *Textures;
PGUTexture UTextures;
#ifdef OGL_DEBUG
// Profiling variables
FxI64 InitialTick;
FxI64 FinalTick;
FxU32 Frame;
double Fps;
double FpsAux;
#endif
double ClockFreq;
// Error Function variable
GLIDEERRORFUNCTION ExternErrorFunction;
// Number of Errors
unsigned long NumberOfErrors;
// Support DLL functions
void InitMainVariables( void )
{
OpenGL.WinOpen = false;
OpenGL.GlideInit = false;
NumberOfErrors = 0;
GetOptions( );
}
bool InitWindow( FxU hWnd )
{
if ( !InitialiseOpenGLWindow( hWnd, 0, 0, OpenGL.WindowWidth, OpenGL.WindowHeight ) ) {
Error( "Failed to Initialise OpenGL Window!\n" );
return false;
}
if ( !strcmp( (char*)glGetString( GL_RENDERER ), "GDI Generic" ) )
ReportWarning("You are running in a Non-Accelerated OpenGL!!!\nThings can become really slow");
ValidateUserConfig( );
GlideMsg( OGL_LOG_SEPARATE );
GlideMsg( " Setting in Use: \n" );
GlideMsg( OGL_LOG_SEPARATE );
GlideMsg( "Init Full Screen = %s\n", InternalConfig.InitFullScreen ? "true" : "false" );
GlideMsg( "Fog = %s\n", InternalConfig.FogEnable ? "true" : "false" );
GlideMsg( "Precision Fix = %s\n", InternalConfig.PrecisionFix ? "true" : "false" );
GlideMsg( "Wrap 565 to 5551 = %s\n", InternalConfig.Wrap565to5551 ? "true" : "false" );
GlideMsg( "Texture Memory Size = %d Mb\n", InternalConfig.TextureMemorySize );
GlideMsg( "Frame Buffer Memory Size = %d Mb\n", InternalConfig.FrameBufferMemorySize );
GlideMsg( "MMX is %s\n", InternalConfig.MMXEnable ? "present" : "not present" );
GlideMsg( OGL_LOG_SEPARATE );
#ifdef OGL_DEBUG
GlideMsg( OGL_LOG_SEPARATE );
GlideMsg( "GlideState size = %d\n", sizeof( GlideState ) );
GlideMsg( "GrState size = %d\n", sizeof( GrState ) );
GlideMsg( OGL_LOG_SEPARATE );
#endif
GlideMsg( OGL_LOG_SEPARATE );
GlideMsg( "** Glide Calls **\n" );
GlideMsg( OGL_LOG_SEPARATE );
return true;
}
//*************************************************
//* Initializes OpenGL
//*************************************************
void InitOpenGL( void )
{
glShadeModel( GL_SMOOTH );
OpenGL.ZNear = ZBUFFERNEAR;
OpenGL.ZFar = ZBUFFERFAR;
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glOrtho( 0, Glide.WindowWidth, 0, Glide.WindowHeight, OpenGL.ZNear, OpenGL.ZFar );
glViewport( 0, 0, OpenGL.WindowWidth, OpenGL.WindowHeight );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
// glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
// glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND );
// glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
// glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glPixelStorei( GL_PACK_ALIGNMENT, 2);
glPixelStorei( GL_UNPACK_ALIGNMENT, 2);
}