Version 3.2 requires OpenGL 2.0.

Remove unnecessary dependencies between ivis library and main source.
Add link test program to detect and prevent new unnecessary dependencies.
master
per 2013-12-14 17:33:32 +01:00
parent 5057823792
commit 7b8cddf092
8 changed files with 114 additions and 111 deletions

View File

@ -33,7 +33,6 @@
#include "lib/ivis_opengl/piestate.h"
#include "lib/ivis_opengl/piepalette.h"
#include "lib/ivis_opengl/pieclip.h"
#include "lib/netplay/netplay.h"
#include "piematrix.h"
#include "screen.h"
@ -142,10 +141,9 @@ static std::vector<ShadowcastingShape> scshapes;
static std::vector<SHAPE> tshapes;
static std::vector<SHAPE> shapes;
static void pie_Draw3DButton(iIMDShape *shape)
static void pie_Draw3DButton(iIMDShape *shape, PIELIGHT teamcolour)
{
const PIELIGHT colour = WZCOL_WHITE;
const PIELIGHT teamcolour = pal_GetTeamColour(NetPlay.players[selectedPlayer].colour);
pie_SetFogStatus(false);
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
pie_ActivateShader(SHADER_BUTTON, shape, teamcolour, colour);
@ -411,13 +409,13 @@ void pie_Draw3DShape(iIMDShape *shape, int frame, int team, PIELIGHT colour, int
ASSERT(frame >= 0, "Negative frame %d", frame);
ASSERT(team >= 0, "Negative team %d", team);
const PIELIGHT teamcolour = pal_GetTeamColour(team);
if (pieFlag & pie_BUTTON)
{
pie_Draw3DButton(shape);
pie_Draw3DButton(shape, teamcolour);
}
else
{
const PIELIGHT teamcolour = pal_GetTeamColour(team);
SHAPE tshape;
tshape.shape = shape;
tshape.frame = frame;

View File

@ -71,7 +71,6 @@ static int preview_width = 0, preview_height = 0;
static Vector2i player_pos[MAX_PLAYERS];
static bool mappreview = false;
OPENGL_DATA opengl;
extern bool writeGameInfo(const char *pFileName); // Used to help debug issues when we have fatal errors.
/* Initialise the double buffered display */
bool screenInitialise()
@ -153,43 +152,35 @@ bool screenInitialise()
debug(LOG_3D, " * Total number of Texture Units (TUs) supported is %d.", (int) glMaxTUs);
debug(LOG_3D, " * GL_ARB_timer_query %s supported!", GLEW_ARB_timer_query ? "is" : "is NOT");
if (!GLEW_VERSION_2_0)
{
debug(LOG_FATAL, "OpenGL 2.0 not supported! Please upgrade your drivers.");
return false;
}
screenWidth = MAX(screenWidth, 640);
screenHeight = MAX(screenHeight, 480);
std::pair<int, int> glslVersion(0, 0);
if (GLEW_ARB_shading_language_100 && GLEW_ARB_shader_objects)
{
sscanf((char const *)glGetString(GL_SHADING_LANGUAGE_VERSION), "%d.%d", &glslVersion.first, &glslVersion.second);
sscanf((char const *)glGetString(GL_SHADING_LANGUAGE_VERSION), "%d.%d", &glslVersion.first, &glslVersion.second);
/* Dump information about OpenGL 2.0+ implementation to the console and the dump file */
GLint glMaxTIUs, glMaxTCs, glMaxTIUAs, glmaxSamples, glmaxSamplesbuf;
/* Dump information about OpenGL 2.0+ implementation to the console and the dump file */
GLint glMaxTIUs, glMaxTCs, glMaxTIUAs, glmaxSamples, glmaxSamplesbuf;
debug(LOG_3D, " * OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
ssprintf(opengl.GLSLversion, "OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
addDumpInfo(opengl.GLSLversion);
debug(LOG_3D, " * OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
ssprintf(opengl.GLSLversion, "OpenGL GLSL Version : %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
addDumpInfo(opengl.GLSLversion);
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &glMaxTIUs);
debug(LOG_3D, " * Total number of Texture Image Units (TIUs) supported is %d.", (int) glMaxTIUs);
glGetIntegerv(GL_MAX_TEXTURE_COORDS, &glMaxTCs);
debug(LOG_3D, " * Total number of Texture Coords (TCs) supported is %d.", (int) glMaxTCs);
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB,&glMaxTIUAs);
debug(LOG_3D, " * Total number of Texture Image Units ARB(TIUAs) supported is %d.", (int) glMaxTIUAs);
glGetIntegerv(GL_SAMPLE_BUFFERS, &glmaxSamplesbuf);
debug(LOG_3D, " * (current) Max Sample buffer is %d.", (int) glmaxSamplesbuf);
glGetIntegerv(GL_SAMPLES, &glmaxSamples);
debug(LOG_3D, " * (current) Max Sample level is %d.", (int) glmaxSamples);
}
bool haveARB_vertex_buffer_object = GLEW_ARB_vertex_buffer_object || GLEW_VERSION_1_5;
bool canRunShaders = GLEW_VERSION_1_2 && haveARB_vertex_buffer_object && glslVersion >= std::make_pair(1, 20); // glGetString(GL_SHADING_LANGUAGE_VERSION) >= "1.20"
screen_EnableMissingFunctions(); // We need to do this before pie_LoadShaders(), but the effect of this call will be undone later by iV_TextInit(), so we will need to call it again.
if (!canRunShaders || !pie_LoadShaders())
{
writeGameInfo("WZdebuginfo.txt");
debug(LOG_FATAL, _("OpenGL GLSL shader version 1.20 is not supported by your system. The game requires this. Please upgrade your graphics drivers/hardware, if possible."));
exit(1);
}
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &glMaxTIUs);
debug(LOG_3D, " * Total number of Texture Image Units (TIUs) supported is %d.", (int) glMaxTIUs);
glGetIntegerv(GL_MAX_TEXTURE_COORDS, &glMaxTCs);
debug(LOG_3D, " * Total number of Texture Coords (TCs) supported is %d.", (int) glMaxTCs);
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB,&glMaxTIUAs);
debug(LOG_3D, " * Total number of Texture Image Units ARB(TIUAs) supported is %d.", (int) glMaxTIUAs);
glGetIntegerv(GL_SAMPLE_BUFFERS, &glmaxSamplesbuf);
debug(LOG_3D, " * (current) Max Sample buffer is %d.", (int) glmaxSamplesbuf);
glGetIntegerv(GL_SAMPLES, &glmaxSamples);
debug(LOG_3D, " * (current) Max Sample level is %d.", (int) glmaxSamples);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@ -276,8 +267,8 @@ void wzPerfFrame()
time(&aclock); /* Get time in seconds */
t = localtime(&aclock); /* Convert time to struct */
ssprintf(screendump_filename, "screenshots/wz2100-perf-sample-%02d-%04d%02d%02d_%02d%02d%02d-%s.png", perfList.size() - 1,
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, getLevelName());
ssprintf(screendump_filename, "screenshots/wz2100-perf-sample-%02d-%04d%02d%02d_%02d%02d%02d.png", perfList.size() - 1,
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
screendump_required = true;
GL_DEBUG("Performance sample complete");
}
@ -320,66 +311,6 @@ void screenShutDown(void)
glErrors();
}
// Make OpenGL's VBO functions available under the core names for drivers that support OpenGL 1.4 only but have the VBO extension
void screen_EnableMissingFunctions()
{
if (!GLEW_VERSION_1_3 && GLEW_ARB_multitexture)
{
debug(LOG_WARNING, "Pre-OpenGL 1.3: Fixing ARB_multitexture extension function names.");
__glewActiveTexture = __glewActiveTextureARB;
__glewMultiTexCoord2fv = __glewMultiTexCoord2fvARB;
}
if (!GLEW_VERSION_1_5 && GLEW_ARB_vertex_buffer_object)
{
debug(LOG_WARNING, "Pre-OpenGL 1.5: Fixing ARB_vertex_buffer_object extension function names.");
__glewBindBuffer = __glewBindBufferARB;
__glewBufferData = __glewBufferDataARB;
__glewBufferSubData = __glewBufferSubDataARB;
__glewDeleteBuffers = __glewDeleteBuffersARB;
__glewGenBuffers = __glewGenBuffersARB;
__glewGetBufferParameteriv = __glewGetBufferParameterivARB;
__glewGetBufferPointerv = __glewGetBufferPointervARB;
__glewGetBufferSubData = __glewGetBufferSubDataARB;
__glewIsBuffer = __glewIsBufferARB;
__glewMapBuffer = __glewMapBufferARB;
__glewUnmapBuffer = __glewUnmapBufferARB;
}
if (!GLEW_VERSION_2_0 && GLEW_ARB_shader_objects)
{
debug(LOG_WARNING, "Pre-OpenGL 2.0: Fixing ARB_shader_objects extension function names.");
__glewGetUniformLocation = __glewGetUniformLocationARB;
__glewAttachShader = __glewAttachObjectARB;
__glewCompileShader = __glewCompileShaderARB;
__glewCreateProgram = __glewCreateProgramObjectARB;
__glewCreateShader = __glewCreateShaderObjectARB;
__glewGetProgramInfoLog = __glewGetInfoLogARB;
__glewGetShaderInfoLog = __glewGetInfoLogARB; // Same as previous.
__glewGetProgramiv = __glewGetObjectParameterivARB;
__glewUseProgram = __glewUseProgramObjectARB;
__glewGetShaderiv = __glewGetObjectParameterivARB;
__glewLinkProgram = __glewLinkProgramARB;
__glewShaderSource = __glewShaderSourceARB;
__glewUniform1f = __glewUniform1fARB;
__glewUniform1i = __glewUniform1iARB;
__glewUniform4fv = __glewUniform4fvARB;
}
if ((GLEW_ARB_imaging || GLEW_EXT_blend_color) && __glewBlendColor == NULL)
{
__glewBlendColor = __glewBlendColorEXT; // Shouldn't be needed if GLEW_ARB_imaging is true, but apparently is needed even in that case, with some drivers..?
if (__glewBlendColor == NULL)
{
debug(LOG_ERROR, "Your graphics driver is broken, and claims to support ARB_imaging or EXT_blend_color without exporting glBlendColor[EXT].");
__GLEW_ARB_imaging = __GLEW_EXT_blend_color = 0;
}
}
}
void screen_SetBackDropFromFile(const char* filename)
{
backdropGfx->loadTexture(filename);
@ -558,7 +489,7 @@ void screenDoDumpToDiskIfRequired(void)
*
* \param path The directory path to save the screenshot in.
*/
void screenDumpToDisk(const char* path)
void screenDumpToDisk(const char* path, const char *level)
{
unsigned int screendump_num = 0;
time_t aclock;
@ -567,11 +498,11 @@ void screenDumpToDisk(const char* path)
time(&aclock); /* Get time in seconds */
t = localtime(&aclock); /* Convert time to struct */
ssprintf(screendump_filename, "%s/wz2100-%04d%02d%02d_%02d%02d%02d-%s.png", path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, getLevelName());
ssprintf(screendump_filename, "%s/wz2100-%04d%02d%02d_%02d%02d%02d-%s.png", path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, level);
while (PHYSFS_exists(screendump_filename))
{
ssprintf(screendump_filename, "%s/wz2100-%04d%02d%02d_%02d%02d%02d-%s-%d.png", path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, getLevelName(), ++screendump_num);
ssprintf(screendump_filename, "%s/wz2100-%04d%02d%02d_%02d%02d%02d-%s-%d.png", path, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, level, ++screendump_num);
}
screendump_required = true;
}

View File

@ -50,7 +50,7 @@ extern void screen_Upload(const char *newBackDropBmp);
void screen_Display();
/* screendump */
extern void screenDumpToDisk(const char* path);
void screenDumpToDisk(const char *path, const char *level);
extern int wz_texture_compression;
@ -58,7 +58,6 @@ extern void screenDoDumpToDiskIfRequired(void);
void screen_enableMapPreview(int width, int height, Vector2i *playerpositions);
void screen_disableMapPreview(void);
void screen_EnableMissingFunctions();
/// gaphics performance measurement points
enum PERF_POINT

View File

@ -687,9 +687,6 @@ bool systemInitialise(void)
// Initialize the iVis text rendering module
iV_TextInit();
// Fix badly named OpenGL functions. Must be done after iV_TextInit, to avoid the renames being clobbered by an extra glewInit() call.
screen_EnableMissingFunctions();
pie_InitRadar();
return true;

View File

@ -680,8 +680,7 @@ void kf_RecalcLighting( void )
/* Sends the screen buffer to disk */
void kf_ScreenDump( void )
{
//CONPRINTF(ConsoleString,(ConsoleString,"Screen dump written to working directory : %s", screenDumpToDisk()));
screenDumpToDisk(ScreenDumpPath);
screenDumpToDisk(ScreenDumpPath, getLevelName());
}
// --------------------------------------------------------------------------

View File

@ -1265,6 +1265,10 @@ int realmain(int argc, char *argv[])
{
return EXIT_FAILURE;
}
if (!pie_LoadShaders())
{
return EXIT_FAILURE;
}
war_SetWidth(pie_GetVideoBufferWidth());
war_SetHeight(pie_GetVideoBufferHeight());

View File

@ -1,5 +1,5 @@
AM_CPPFLAGS = $(SDL_CFLAGS) $(PHYSFS_CFLAGS) $(PNG_CFLAGS) $(OPENGL_CFLAGS) $(WZ_CPPFLAGS) -I$(top_srcdir)/tools \
-I. -I$(top_srcdir)/lib/framework $(QT4_CFLAGS) $(LIBCRYPTO_CFLAGS)
-I. -I$(top_srcdir)/lib/framework $(QT4_CFLAGS) $(LIBCRYPTO_CFLAGS) $(OPENGLC_CFLAGS) $(GLEW_CFLAGS)
AM_CFLAGS = $(WZ_CFLAGS)
AM_CXXFLAGS = $(WZ_CXXFLAGS)
@ -11,13 +11,20 @@ qslint_SOURCES = qslint.cpp lint.cpp
qslint_LDADD = $(PHYSFS_LIBS) $(QT4_LIBS)
endif
check_PROGRAMS = maptest modeltest qtscripttest framework_linktest
check_PROGRAMS = maptest modeltest qtscripttest framework_linktest ivis_linktest
qtscripttest_SOURCES = qtscripttest.cpp lint.cpp
qtscripttest_LDADD = $(PHYSFS_LIBS) $(QT4_LIBS)
framework_linktest_SOURCES = framework_linktest.cpp
framework_linktest_LDADD = $(top_builddir)/lib/framework/libframework.a $(PHYSFS_LIBS) $(LIBCRYPTO_LIBS) $(LDFLAGS)
ivis_linktest_SOURCES = ivis_linktest.cpp
ivis_linktest_LDADD = $(PHYSFS_LIBS) $(LIBCRYPTO_LIBS) $(QT4_LIBS) $(SDL_LIBS) $(OPENGL_LIBS) \
$(OPENGLC_LIBS) $(GLEW_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(LDFLAGS) $(PHYSFS_LIBS) \
$(PNG_LIBS) $(top_builddir)/lib/framework/libframework.a $(top_builddir)/lib/ivis_opengl/libivis_opengl.a \
$(top_builddir)/3rdparty/quesoglc/libquesoglc.a $(top_builddir)/lib/sdl/libsdl.a
modeltest_SOURCES = modeltest.c
maptest_SOURCES = ../tools/map/mapload.cpp maptest.cpp
@ -33,7 +40,7 @@ EXTRA_DIST = \
Tests.xcodeproj
# qtscripttest commented out for 3.1
TESTS = maptest modeltest
TESTS = maptest modeltest framework_linktest
maplist.txt:
(cd $(abs_top_srcdir)/data ; find base mp -name game.map > $(abs_top_builddir)/tests/maplist.txt )

68
tests/ivis_linktest.cpp Normal file
View File

@ -0,0 +1,68 @@
#include "lib/framework/wzglobal.h"
#include "lib/framework/types.h"
#include "lib/framework/frame.h"
#include "lib/framework/wzapp.h"
#include "lib/framework/input.h"
#include "lib/ivis_opengl/screen.h"
#include "lib/ivis_opengl/piemode.h"
#include "lib/ivis_opengl/pieclip.h"
#include "src/console.h" // HACK
// --- console dummy implementations ---
// this should be implemented within ivis/gfxqueue
#define MAX_CONSOLE_TMP_STRING_LENGTH (255)
char ConsoleString[MAX_CONSOLE_TMP_STRING_LENGTH];
bool addConsoleMessage(const char *Text, CONSOLE_TEXT_JUSTIFICATION jusType, SDWORD player)
{
return true;
}
// --- misc dummy implementations ---
UDWORD realTime; // from gtime
bool bMultiPlayer; // FIXME, really should not access this from ivis lib
void addDumpInfo(const char *inbuffer)
{
}
// --- end linking hacks ---
void mainLoop(void)
{
pie_ScreenFlip(CLEAR_BLACK);
frameUpdate(); // General housekeeping
if (keyPressed(KEY_ESC))
{
inputLoseFocus(); // remove it from input stream
exit(1); // FIXME, insert SDL_QUIT event instead
}
}
int realmain(int argc, char **argv)
{
wzMain(argc, argv);
debug_init();
debug_register_callback(debug_callback_stderr, NULL, NULL, NULL);
pie_SetVideoBufferWidth(800);
pie_SetVideoBufferHeight(600);
if (!wzMain2(0, false, true))
{
fprintf(stderr, "Failed to initialize graphics\n");
return EXIT_FAILURE;
}
frameInitialise();
screenInitialise();
wzMain3(); // enter main loop
frameShutDown();
screenShutDown();
wzShutdown();
return EXIT_SUCCESS;
}