mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 11:19:48 +02:00
- added the ability to toggle hardware acceleration and full screen anti-aliasing via ini settings
- added video card info screen to options menu
This commit is contained in:
60
source/shared_lib/include/graphics/context.h
Normal file
60
source/shared_lib/include/graphics/context.h
Normal file
@@ -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
|
@@ -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();
|
||||
|
@@ -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; }
|
||||
|
38
source/shared_lib/include/platform/sdl/window_gl.h
Normal file
38
source/shared_lib/include/platform/sdl/window_gl.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// 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
|
@@ -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__);
|
||||
}
|
||||
|
||||
|
@@ -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__);
|
||||
|
||||
|
@@ -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);
|
||||
|
44
source/shared_lib/sources/platform/sdl/window_gl.cpp
Normal file
44
source/shared_lib/sources/platform/sdl/window_gl.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||
//
|
||||
// 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
|
Reference in New Issue
Block a user