diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 3beef596..ddd0ef8f 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1876,8 +1876,9 @@ void Renderer::renderMinimap(){ glEnable(GL_BLEND); - glBegin(GL_TRIANGLES); glColor4f(1.f, 1.f, 1.f, 1.f); + glBegin(GL_TRIANGLES); + glVertex2i(mx+x, my+mh-y); glColor4f(1.f, 1.f, 1.f, 0.0f); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 8a5ce55f..33bc3098 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -535,6 +535,9 @@ int glestMain(int argc, char** argv){ //string test = lang.get("ExitGameServer?"); //printf("[%s]",test.c_str()); + Renderer &renderer= Renderer::getInstance(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] OpenGL Info:\n%s\n",__FILE__,__FUNCTION__,__LINE__,renderer.getGlInfo().c_str()); + //main loop while(Window::handleEvent()){ program->loop(); diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 43d424c1..c1c16ae7 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -454,7 +454,7 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - window->initGl(config.getInt("ColorBits"), config.getInt("DepthBits"), config.getInt("StencilBits")); + window->initGl(config.getInt("ColorBits"), config.getInt("DepthBits"), config.getInt("StencilBits"),config.getBool("HardwareAcceleration","false"),config.getBool("FullScreenAntiAliasing","false")); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 232cfbc4..511a050d 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -17,6 +17,7 @@ #include "config.h" #include "menu_state_root.h" #include "util.h" +#include "menu_state_graphic_info.h" #include "leak_dumper.h" @@ -226,6 +227,9 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): buttonAutoConfig.setText(lang.get("AutoConfig")); buttonAutoConfig.init(450, buttonRowPos, 125); + buttonVideoInfo.setText(lang.get("VideoInfo")); + buttonVideoInfo.init(620, buttonRowPos, 100); + } void MenuStateOptions::showMessageBox(const string &text, const string &header, bool toggle){ @@ -311,6 +315,10 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ saveConfig(); mainMenu->setState(new MenuStateOptions(program, mainMenu)); } + else if(buttonVideoInfo.mouseClick(x, y)){ + soundRenderer.playFx(coreData.getClickSoundA()); + mainMenu->setState(new MenuStateGraphicInfo(program, mainMenu)); + } else if(labelPlayerName.mouseClick(x, y) && ( activeInputLabel != &labelPlayerName )){ setActiveInputLable(&labelPlayerName); } @@ -338,6 +346,7 @@ void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){ buttonOk.mouseMove(x, y); buttonAbort.mouseMove(x, y); buttonAutoConfig.mouseMove(x, y); + buttonVideoInfo.mouseMove(x, y); listBoxLang.mouseMove(x, y); listBoxVolumeFx.mouseMove(x, y); listBoxVolumeAmbient.mouseMove(x, y); @@ -393,6 +402,7 @@ void MenuStateOptions::render(){ renderer.renderButton(&buttonOk); renderer.renderButton(&buttonAbort); renderer.renderButton(&buttonAutoConfig); + renderer.renderButton(&buttonVideoInfo); renderer.renderListBox(&listBoxLang); renderer.renderListBox(&listBoxShadows); renderer.renderListBox(&listBoxTextures3D); diff --git a/source/glest_game/menu/menu_state_options.h b/source/glest_game/menu/menu_state_options.h index 96ce9049..159035e4 100644 --- a/source/glest_game/menu/menu_state_options.h +++ b/source/glest_game/menu/menu_state_options.h @@ -25,6 +25,7 @@ private: GraphicButton buttonOk; GraphicButton buttonAbort; GraphicButton buttonAutoConfig; + GraphicButton buttonVideoInfo; GraphicLabel labelLang; GraphicLabel labelShadows; diff --git a/source/shared_lib/include/graphics/context.h b/source/shared_lib/include/graphics/context.h new file mode 100644 index 00000000..eab0f7eb --- /dev/null +++ b/source/shared_lib/include/graphics/context.h @@ -0,0 +1,60 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2001-2008 Martio Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_GRAPHICS_CONTEXT_H_ +#define _SHARED_GRAPHICS_CONTEXT_H_ + +#include "types.h" + +namespace Shared{ namespace Graphics{ + +using Platform::uint32; +using Platform::int8; + +// ===================================================== +// class Context +// ===================================================== + +class Context{ +protected: + uint32 colorBits; + uint32 depthBits; + uint32 stencilBits; + int8 hardware_acceleration; + int8 fullscreen_anti_aliasing; + +public: + Context(); + virtual ~Context(){} + + uint32 getColorBits() const {return colorBits;} + uint32 getDepthBits() const {return depthBits;} + uint32 getStencilBits() const {return stencilBits;} + int8 getHardware_acceleration() const { return hardware_acceleration; } + int8 getFullscreen_anti_aliasing() const { return fullscreen_anti_aliasing; } + + void setColorBits(uint32 colorBits) {this->colorBits= colorBits;} + void setDepthBits(uint32 depthBits) {this->depthBits= depthBits;} + void setStencilBits(uint32 stencilBits) {this->stencilBits= stencilBits;} + void setHardware_acceleration(int8 value) { hardware_acceleration = value; } + void setFullscreen_anti_aliasing(int8 value) { fullscreen_anti_aliasing = value; } + + virtual void init()= 0; + virtual void end()= 0; + virtual void reset()= 0; + + virtual void makeCurrent()= 0; + virtual void swapBuffers()= 0; +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/include/platform/sdl/gl_wrap.h b/source/shared_lib/include/platform/sdl/gl_wrap.h index 79f43e5a..20044c1d 100644 --- a/source/shared_lib/include/platform/sdl/gl_wrap.h +++ b/source/shared_lib/include/platform/sdl/gl_wrap.h @@ -48,7 +48,7 @@ class PlatformContextGl { public: virtual ~PlatformContextGl() {} - virtual void init(int colorBits, int depthBits, int stencilBits); + virtual void init(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing); virtual void end(); virtual void makeCurrent(); diff --git a/source/shared_lib/include/platform/sdl/window.h b/source/shared_lib/include/platform/sdl/window.h index a0b95838..0ecf38f8 100644 --- a/source/shared_lib/include/platform/sdl/window.h +++ b/source/shared_lib/include/platform/sdl/window.h @@ -141,7 +141,7 @@ public: static bool handleEvent(); static void revertMousePos(); static bool isKeyDown() { return isKeyPressedDown; } - static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1); + static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1, bool hardware_acceleration=false, bool fullscreen_anti_aliasing=false); static const bool getIsFullScreen() { return isFullScreen; } static void setIsFullScreen(bool value) { isFullScreen = value; } static SDL_keysym getKeystate() { return keystate; } diff --git a/source/shared_lib/include/platform/sdl/window_gl.h b/source/shared_lib/include/platform/sdl/window_gl.h new file mode 100644 index 00000000..5065c9dd --- /dev/null +++ b/source/shared_lib/include/platform/sdl/window_gl.h @@ -0,0 +1,38 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2005 Matthias Braun +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _SHARED_PLATFORM_WINDOWGL_H_ +#define _SHARED_PLATFORM_WINDOWGL_H_ + +#include "context_gl.h" +#include "window.h" + +using Shared::Graphics::Gl::ContextGl; + +namespace Shared{ namespace Platform{ + +// ===================================================== +// class WindowGl +// ===================================================== + +class WindowGl: public Window{ +private: + ContextGl context; + +public: + void initGl(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing); + void makeCurrentGl(); + void swapBuffersGl(); +}; + +}}//end namespace + +#endif diff --git a/source/shared_lib/sources/graphics/gl/context_gl.cpp b/source/shared_lib/sources/graphics/gl/context_gl.cpp index 0d4e8193..b6dfeb00 100644 --- a/source/shared_lib/sources/graphics/gl/context_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/context_gl.cpp @@ -29,7 +29,7 @@ namespace Shared{ namespace Graphics{ namespace Gl{ void ContextGl::init(){ //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - pcgl.init(colorBits, depthBits, stencilBits); + pcgl.init(colorBits, depthBits, stencilBits, hardware_acceleration, fullscreen_anti_aliasing); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index b9a23c42..c8cce720 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -35,11 +35,11 @@ namespace Shared{ namespace Platform{ // class PlatformContextGl // ====================================== -void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits) { +void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - Window::setupGraphicsScreen(depthBits, stencilBits); + Window::setupGraphicsScreen(depthBits, stencilBits, hardware_acceleration, fullscreen_anti_aliasing); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 13bca152..c027a3c6 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -345,7 +345,7 @@ void Window::destroy() { SDL_PushEvent(&event); } -void Window::setupGraphicsScreen(int depthBits, int stencilBits) { +void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_acceleration, bool fullscreen_anti_aliasing) { static int newDepthBits = depthBits; static int newStencilBits = stencilBits; if(depthBits >= 0) @@ -353,7 +353,13 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits) { if(stencilBits >= 0) newStencilBits = stencilBits; - //SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); + if(fullscreen_anti_aliasing == true) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16); + } + if(hardware_acceleration == true) { + SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); + } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1); diff --git a/source/shared_lib/sources/platform/sdl/window_gl.cpp b/source/shared_lib/sources/platform/sdl/window_gl.cpp new file mode 100644 index 00000000..6b0acd66 --- /dev/null +++ b/source/shared_lib/sources/platform/sdl/window_gl.cpp @@ -0,0 +1,44 @@ +// ============================================================== +// This file is part of Glest Shared Library (www.glest.org) +// +// Copyright (C) 2005 Matthias Braun +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== +#include "window_gl.h" + +#include "gl_wrap.h" +#include "graphics_interface.h" +#include "leak_dumper.h" + +using namespace Shared::Graphics; + +namespace Shared{ namespace Platform{ + +// ===================================================== +// class WindowGl +// ===================================================== + +void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,bool hardware_acceleration, bool fullscreen_anti_aliasing){ + context.setColorBits(colorBits); + context.setDepthBits(depthBits); + context.setStencilBits(stencilBits); + context.setHardware_acceleration(hardware_acceleration); + context.setFullscreen_anti_aliasing(fullscreen_anti_aliasing); + + context.init(); +} + +void WindowGl::makeCurrentGl() { + GraphicsInterface::getInstance().setCurrentContext(&context); + context.makeCurrent(); +} + +void WindowGl::swapBuffersGl(){ + context.swapBuffers(); +} + +}}//end namespace