mirror of
https://github.com/glest/glest-source.git
synced 2025-09-26 07:28:59 +02:00
- attempt to add "some" VBO rendering for static models (need to test if this improves performance in different environments)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -16,35 +16,63 @@
|
||||
#include "graphics_interface.h"
|
||||
#include "context_gl.h"
|
||||
#include "gl_wrap.h"
|
||||
#include <map>
|
||||
#include "util.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Platform;
|
||||
using namespace Shared::Util;
|
||||
using namespace std;
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
namespace Shared { namespace Graphics { namespace Gl {
|
||||
|
||||
std::map<string,bool> cacheExtensionCheckList;
|
||||
static int vboEnabled = 0;
|
||||
|
||||
// =====================================================
|
||||
// class Globals
|
||||
// =====================================================
|
||||
|
||||
bool isGlExtensionSupported(const char *extensionName){
|
||||
bool getVBOSupported() {
|
||||
if(vboEnabled == 0) {
|
||||
bool value = isGlExtensionSupported("GL_ARB_vertex_buffer_object");
|
||||
vboEnabled = (value == true ? 1 : -1);
|
||||
}
|
||||
return (vboEnabled == 1);
|
||||
}
|
||||
void setVBOSupported(bool value) {
|
||||
vboEnabled = (value == true ? 1 : -1);
|
||||
};
|
||||
|
||||
void overrideGlExtensionSupport(const char *extensionName,bool value) {
|
||||
cacheExtensionCheckList[extensionName]=value;
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("OpenGL Extension [%s] supported status FORCED TO = %d\n",extensionName,cacheExtensionCheckList[extensionName]);
|
||||
}
|
||||
|
||||
bool isGlExtensionSupported(const char *extensionName) {
|
||||
if(cacheExtensionCheckList.find(extensionName) != cacheExtensionCheckList.end()) {
|
||||
return cacheExtensionCheckList[extensionName];
|
||||
}
|
||||
const GLubyte *extensionStr= glGetString(GL_EXTENSIONS);
|
||||
const char *s= reinterpret_cast<const char *>(extensionStr);
|
||||
size_t len= strlen(extensionName);
|
||||
|
||||
cacheExtensionCheckList[extensionName]=false;
|
||||
if(s != NULL) {
|
||||
while ((s = strstr (s, extensionName)) != NULL) {
|
||||
s+= len;
|
||||
if((*s == ' ') || (*s == '\0')) {
|
||||
return true;
|
||||
cacheExtensionCheckList[extensionName] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("OpenGL Extension [%s] supported status = %d\n",extensionName,cacheExtensionCheckList[extensionName]);
|
||||
return cacheExtensionCheckList[extensionName];
|
||||
}
|
||||
|
||||
bool isGlVersionSupported(int major, int minor, int release){
|
||||
bool isGlVersionSupported(int major, int minor, int release) {
|
||||
|
||||
const char *strVersion= getGlVersion();
|
||||
|
||||
@@ -52,94 +80,94 @@ bool isGlVersionSupported(int major, int minor, int release){
|
||||
const char *majorTok= strVersion;
|
||||
int majorSupported= atoi(majorTok);
|
||||
|
||||
if(majorSupported<major){
|
||||
if(majorSupported<major) {
|
||||
return false;
|
||||
}
|
||||
else if(majorSupported>major){
|
||||
else if(majorSupported>major) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//minor
|
||||
int i=0;
|
||||
while(strVersion[i]!='.'){
|
||||
while(strVersion[i]!='.') {
|
||||
++i;
|
||||
}
|
||||
const char *minorTok= &strVersion[i]+1;
|
||||
int minorSupported= atoi(minorTok);
|
||||
|
||||
if(minorSupported<minor){
|
||||
if(minorSupported<minor) {
|
||||
return false;
|
||||
}
|
||||
else if(minorSupported>minor){
|
||||
else if(minorSupported>minor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//release
|
||||
++i;
|
||||
while(strVersion[i]!='.'){
|
||||
while(strVersion[i]!='.') {
|
||||
++i;
|
||||
}
|
||||
const char *releaseTok= &strVersion[i]+1;
|
||||
|
||||
if(atoi(releaseTok)<release){
|
||||
if(atoi(releaseTok) < release) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *getGlVersion(){
|
||||
const char *getGlVersion() {
|
||||
return reinterpret_cast<const char *>(glGetString(GL_VERSION));
|
||||
}
|
||||
|
||||
const char *getGlRenderer(){
|
||||
const char *getGlRenderer() {
|
||||
return reinterpret_cast<const char *>(glGetString(GL_RENDERER));
|
||||
}
|
||||
|
||||
const char *getGlVendor(){
|
||||
const char *getGlVendor() {
|
||||
return reinterpret_cast<const char *>(glGetString(GL_VENDOR));
|
||||
}
|
||||
|
||||
const char *getGlExtensions(){
|
||||
const char *getGlExtensions() {
|
||||
return reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
const char *getGlPlatformExtensions(){
|
||||
const char *getGlPlatformExtensions() {
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
return getPlatformExtensions(static_cast<ContextGl*>(c)->getPlatformContextGl());
|
||||
}
|
||||
|
||||
int getGlMaxLights(){
|
||||
int getGlMaxLights() {
|
||||
int i;
|
||||
glGetIntegerv(GL_MAX_LIGHTS, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int getGlMaxTextureSize(){
|
||||
int getGlMaxTextureSize() {
|
||||
int i;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int getGlMaxTextureUnits(){
|
||||
int getGlMaxTextureUnits() {
|
||||
int i;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int getGlModelviewMatrixStackDepth(){
|
||||
int getGlModelviewMatrixStackDepth() {
|
||||
int i;
|
||||
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int getGlProjectionMatrixStackDepth(){
|
||||
int getGlProjectionMatrixStackDepth() {
|
||||
int i;
|
||||
glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
void checkGlExtension(const char *extensionName){
|
||||
void checkGlExtension(const char *extensionName) {
|
||||
if(!isGlExtensionSupported(extensionName)){
|
||||
throw runtime_error("OpenGL extension not supported: " + string(extensionName));
|
||||
}
|
||||
|
Reference in New Issue
Block a user