• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By racarate
      Hey everybody!
      I am trying to replicate all these cool on-screen debug visuals I see in all the SIGGRAPH and GDC talks, but I really don't know where to start.  The only resource I know of is almost 16 years old:
      http://number-none.com/product/Interactive Profiling, Part 1/index.html
      Does anybody have a more up-to-date reference?  Do people use minimal UI libraries like Dear ImgGui?  Also, If I am profiling OpenGL ES 3.0 (which doesn't have timer queries) is there really anything I can do to measure performance GPU-wise?  Or should I just chart CPU-side frame time?  I feel like this is something people re-invent for every game there has gotta be a tutorial out there... right?
       
       
    • By Achivai
      Hey, I am semi-new to 3d-programming and I've hit a snag. I have one object, let's call it Object A. This object has a long int array of 3d xyz-positions stored in it's vbo as an instanced attribute. I am using these numbers to instance object A a couple of thousand times. So far so good. 
      Now I've hit a point where I want to remove one of these instances of object A while the game is running, but I'm not quite sure how to go about it. At first my thought was to update the instanced attribute of Object A and change the positions to some dummy number that I could catch in the vertex shader and then decide there whether to draw the instance of Object A or not, but I think that would be expensive to do while the game is running, considering that it might have to be done several times every frame in some cases. 
      I'm not sure how to proceed, anyone have any tips?
    • By fleissi
      Hey guys!

      I'm new here and I recently started developing my own rendering engine. It's open source, based on OpenGL/DirectX and C++.
      The full source code is hosted on github:
      https://github.com/fleissna/flyEngine

      I would appreciate if people with experience in game development / engine desgin could take a look at my source code. I'm looking for honest, constructive criticism on how to improve the engine.
      I'm currently writing my master's thesis in computer science and in the recent year I've gone through all the basics about graphics programming, learned DirectX and OpenGL, read some articles on Nvidia GPU Gems, read books and integrated some of this stuff step by step into the engine.

      I know about the basics, but I feel like there is some missing link that I didn't get yet to merge all those little pieces together.

      Features I have so far:
      - Dynamic shader generation based on material properties
      - Dynamic sorting of meshes to be renderd based on shader and material
      - Rendering large amounts of static meshes
      - Hierarchical culling (detail + view frustum)
      - Limited support for dynamic (i.e. moving) meshes
      - Normal, Parallax and Relief Mapping implementations
      - Wind animations based on vertex displacement
      - A very basic integration of the Bullet physics engine
      - Procedural Grass generation
      - Some post processing effects (Depth of Field, Light Volumes, Screen Space Reflections, God Rays)
      - Caching mechanisms for textures, shaders, materials and meshes

      Features I would like to have:
      - Global illumination methods
      - Scalable physics
      - Occlusion culling
      - A nice procedural terrain generator
      - Scripting
      - Level Editing
      - Sound system
      - Optimization techniques

      Books I have so far:
      - Real-Time Rendering Third Edition
      - 3D Game Programming with DirectX 11
      - Vulkan Cookbook (not started yet)

      I hope you guys can take a look at my source code and if you're really motivated, feel free to contribute :-)
      There are some videos on youtube that demonstrate some of the features:
      Procedural grass on the GPU
      Procedural Terrain Engine
      Quadtree detail and view frustum culling

      The long term goal is to turn this into a commercial game engine. I'm aware that this is a very ambitious goal, but I'm sure it's possible if you work hard for it.

      Bye,

      Phil
    • By tj8146
      I have attached my project in a .zip file if you wish to run it for yourself.
      I am making a simple 2d top-down game and I am trying to run my code to see if my window creation is working and to see if my timer is also working with it. Every time I run it though I get errors. And when I fix those errors, more come, then the same errors keep appearing. I end up just going round in circles.  Is there anyone who could help with this? 
       
      Errors when I build my code:
      1>Renderer.cpp 1>c:\users\documents\opengl\game\game\renderer.h(15): error C2039: 'string': is not a member of 'std' 1>c:\program files (x86)\windows kits\10\include\10.0.16299.0\ucrt\stddef.h(18): note: see declaration of 'std' 1>c:\users\documents\opengl\game\game\renderer.h(15): error C2061: syntax error: identifier 'string' 1>c:\users\documents\opengl\game\game\renderer.cpp(28): error C2511: 'bool Game::Rendering::initialize(int,int,bool,std::string)': overloaded member function not found in 'Game::Rendering' 1>c:\users\documents\opengl\game\game\renderer.h(9): note: see declaration of 'Game::Rendering' 1>c:\users\documents\opengl\game\game\renderer.cpp(35): error C2597: illegal reference to non-static member 'Game::Rendering::window' 1>c:\users\documents\opengl\game\game\renderer.cpp(36): error C2597: illegal reference to non-static member 'Game::Rendering::window' 1>c:\users\documents\opengl\game\game\renderer.cpp(43): error C2597: illegal reference to non-static member 'Game::Rendering::window' 1>Done building project "Game.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========  
       
      Renderer.cpp
      #include <GL/glew.h> #include <GLFW/glfw3.h> #include "Renderer.h" #include "Timer.h" #include <iostream> namespace Game { GLFWwindow* window; /* Initialize the library */ Rendering::Rendering() { mClock = new Clock; } Rendering::~Rendering() { shutdown(); } bool Rendering::initialize(uint width, uint height, bool fullscreen, std::string window_title) { if (!glfwInit()) { return -1; } /* Create a windowed mode window and its OpenGL context */ window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); if (!window) { glfwTerminate(); return -1; } /* Make the window's context current */ glfwMakeContextCurrent(window); glViewport(0, 0, (GLsizei)width, (GLsizei)height); glOrtho(0, (GLsizei)width, (GLsizei)height, 0, 1, -1); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glfwSwapInterval(1); glEnable(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_TEXTURE_2D); glLoadIdentity(); return true; } bool Rendering::render() { /* Loop until the user closes the window */ if (!glfwWindowShouldClose(window)) return false; /* Render here */ mClock->reset(); glfwPollEvents(); if (mClock->step()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glfwSwapBuffers(window); mClock->update(); } return true; } void Rendering::shutdown() { glfwDestroyWindow(window); glfwTerminate(); } GLFWwindow* Rendering::getCurrentWindow() { return window; } } Renderer.h
      #pragma once namespace Game { class Clock; class Rendering { public: Rendering(); ~Rendering(); bool initialize(uint width, uint height, bool fullscreen, std::string window_title = "Rendering window"); void shutdown(); bool render(); GLFWwindow* getCurrentWindow(); private: GLFWwindow * window; Clock* mClock; }; } Timer.cpp
      #include <GL/glew.h> #include <GLFW/glfw3.h> #include <time.h> #include "Timer.h" namespace Game { Clock::Clock() : mTicksPerSecond(50), mSkipTics(1000 / mTicksPerSecond), mMaxFrameSkip(10), mLoops(0) { mLastTick = tick(); } Clock::~Clock() { } bool Clock::step() { if (tick() > mLastTick && mLoops < mMaxFrameSkip) return true; return false; } void Clock::reset() { mLoops = 0; } void Clock::update() { mLastTick += mSkipTics; mLoops++; } clock_t Clock::tick() { return clock(); } } TImer.h
      #pragma once #include "Common.h" namespace Game { class Clock { public: Clock(); ~Clock(); void update(); bool step(); void reset(); clock_t tick(); private: uint mTicksPerSecond; ufloat mSkipTics; uint mMaxFrameSkip; uint mLoops; uint mLastTick; }; } Common.h
      #pragma once #include <cstdio> #include <cstdlib> #include <ctime> #include <cstring> #include <cmath> #include <iostream> namespace Game { typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; typedef float ufloat; }  
      Game.zip
    • By lxjk
      Hi guys,
      There are many ways to do light culling in tile-based shading. I've been playing with this idea for a while, and just want to throw it out there.
      Because tile frustums are general small compared to light radius, I tried using cone test to reduce false positives introduced by commonly used sphere-frustum test.
      On top of that, I use distance to camera rather than depth for near/far test (aka. sliced by spheres).
      This method can be naturally extended to clustered light culling as well.
      The following image shows the general ideas

       
      Performance-wise I get around 15% improvement over sphere-frustum test. You can also see how a single light performs as the following: from left to right (1) standard rendering of a point light; then tiles passed the test of (2) sphere-frustum test; (3) cone test; (4) spherical-sliced cone test
       

       
      I put the details in my blog post (https://lxjk.github.io/2018/03/25/Improve-Tile-based-Light-Culling-with-Spherical-sliced-Cone.html), GLSL source code included!
       
      Eric
  • Advertisement
  • Advertisement
Sign in to follow this  

OpenGL [SDL] Super slow framerate on Windows 7, GLEW shaders unavailable

This topic is 2224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

I've been working on a project off and on in SDL for a number of months now, and I've had an issue from the start that I recently had some time to try and debug. I've been developing on Windows XP until this past week, so it was not really an issue until now.

Basically, my SDL bases game works perfectly fine on any Windows XP machine (ie. normal frame rate, shaders work no problem), but I initially noticed that if I ran the executable on Windows 7, the frame rate would only be 10-15 for no reason (on super high-end machines, ie. Phenom II X6 / 5970) but this was strictly a Windows 7 issue as indicated by testing on several different machines. Upon further investigation I realized that if I run the game from within Visual Studio 2008 on a Windows 7 machine it works perfectly (ie. 7000+ FPS w/o vsync), but as soon as I ran it from the executable instead, the frame rate would once again be between 10 and 15, and if shaders were being used via GLEW, the program would simply exit because GLEW 2.0 was unavailable.

tldr; SDL OpenGL game, works fine on XP, on Win7 works fine in VS2008 but EXE limited to 10 fps and shaders wont work

Honestly not sure what the issue could possibly be and has been baffling me for some time. If anyone has any suggestions or input, it would be greatly appreciated. It almost seems like SDL is somehow switching to software mode or some limited version of OpenGL. Also worth mentioning that the only things being rendered is some text (generated and rendered via lists) and a very simple skybox with 1024x1024 textures for each side.

My game is using SDLmain and a number of libraries, including:
SDL
SDL_ttf
GLEW
FreeImage
Qt
FMOD Ex
FBX SDK
Bullet Physics

Thanks for reading. Some code, if it helps any:

Main.cpp:

#include "Game.h"
int main(int argc, char * argv[]) {
Game * game = new Game();
if(!game->init()) { return -1; }
game->run();
delete game;
return 0;
}


OpenGL Setup:

bool Game::init() {
if(m_initialized) { return false; }
settings->load();
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) == -1) { return false; }
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, settings->verticalSync ? 1 : 0);
m_graphics = SDL_SetVideoMode(settings->windowWidth, settings->windowHeight, 0, SDL_OPENGL | (settings->fullScreen ? SDL_FULLSCREEN : 0));
SDL_WM_SetCaption("Game", NULL);
QString iconPath;
iconPath.append(QString("%1/Icons/Block.bmp").arg(settings->dataDirectoryName));
QByteArray iconPathBytes = iconPath.toLocal8Bit();
m_icon = SDL_LoadBMP(iconPathBytes.data());
SDL_WM_SetIcon(m_icon, NULL);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, settings->windowWidth, settings->windowHeight);
if(glewInit() != GLEW_OK) { return false; }
if(!GLEW_VERSION_2_0) { return false; }

etc.


Game Loop:

void Game::run() {
if(!m_initialized) { return; }
m_running = true;
SDL_Event event;
static unsigned int lastTime = SDL_GetTicks();
unsigned int currentTime = SDL_GetTicks();
do {
if(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_KEYDOWN:
if(!console->isActive()) {
menu->handleInput(event);
}
if(!menu->isActive()) {
console->handleInput(event);
}
break;
case SDL_MOUSEMOTION:
if(!console->isActive() &&
!menu->isActive() &&
SDL_GetAppState() & SDL_APPMOUSEFOCUS &&
SDL_GetAppState() & SDL_APPINPUTFOCUS &&
SDL_GetAppState() & SDL_APPACTIVE) {
camera->handleInput(event);
}
break;
case SDL_QUIT:
m_running = false;
break;
default:
break;
}
}
if(m_running) {
currentTime = SDL_GetTicks();
update(currentTime - lastTime);
draw();
lastTime = currentTime;
}
} while(m_running);
}

Share this post


Link to post
Share on other sites
Advertisement
if(SDL_PollEvent(&event))

Should be:

while ( SDL_PollEvent( &event ) )

It's likely that your event queue accumulates more and and more windows events until your game slows down to a crawl -- you need to process all of the window messages between each frame, not just one per frame. (Not sure if this will fix your problem, but it will certainly help...)

Share this post


Link to post
Share on other sites
Oh dear, I feel ashamed for implementing that wrong. Thanks for the reply! Although this did not fix my previous issues (slow framerate, shaders unsupported), it did fix my input handling and bizarre behaviours I was experiencing with my camera which I had yet to solve, so thanks!

Still looking for a solution, though. I just can't figure what's so different with the execution of the game between being run from Visual Studio 2008 vs. from the compiled release executable.

Share this post


Link to post
Share on other sites
Are you mixing any regular SDL drawing (i.e. not OpenGL stuff) with your OpenGL drawing? That could be a possible cause on WDDM drivers.

Share this post


Link to post
Share on other sites
Not as far as I know, I'm using glLists for my SkyBox, and standard OpenGL stuff for the rest, see code below. The only strange thing I'm doing is using SDL_ttf which uses SDL_Surface to blit text which I convert to an OpenGL texture. Irregardless, I don't think any of this should be an issue if it works perfectly fine from Visual Studio 2008, right?

Edit: Furthermore, there are no problems on Windows XP when running from either VS2008 or EXE. So why is it such a problem on Windows 7? I'm using platform independent libraries (ie. no STL), so I'm still completely baffled.

SkyBox Load:

bool SkyBox::load() {
if(m_loaded) { return true; }

for(int i=0;i<6;i++) {
m_textures = Game::resources->getTexture(m_textureNames);
if(m_textures == NULL) { return false; }
if(!m_textures->load()) { return false; }
}

m_skyBoxList = glGenLists(6);

float width = (float) (m_textures[0]->getWidth() - 1) / (float) m_textures[0]->getWidth();

// left side
glNewList(m_skyBoxList, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2d(1 - width, width);
glVertex3d(-0.5, 0.5, 0.5);
glTexCoord2d(1 - width, 1 - width);
glVertex3d(-0.5, -0.5, 0.5);
glTexCoord2d(width, 1 - width);
glVertex3d(-0.5, -0.5, -0.5);
glTexCoord2d(width, width);
glVertex3d(-0.5, 0.5, -0.5);
glEnd();
glEndList();

// right side
glNewList(m_skyBoxList + 1, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2d(1 - width, width);
glVertex3d(0.5, 0.5, -0.5);
glTexCoord2d(1 - width, 1 - width);
glVertex3d(0.5, -0.5, -0.5);
glTexCoord2d(width, 1 - width);
glVertex3d(0.5, -0.5, 0.5);
glTexCoord2d(width, width);
glVertex3d(0.5, 0.5, 0.5);
glEnd();
glEndList();

// front side
glNewList(m_skyBoxList + 2, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2d(1 - width, width);
glVertex3d(-0.5, 0.5, -0.5);
glTexCoord2d(1 - width, 1 - width);
glVertex3d(-0.5, -0.5, -0.5);
glTexCoord2d(width, 1 - width);
glVertex3d(0.5, -0.5, -0.5);
glTexCoord2d(width, width);
glVertex3d(0.5, 0.5, -0.5);
glEnd();
glEndList();

// back side
glNewList(m_skyBoxList + 3, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2d(1 - width, width);
glVertex3d(0.5, 0.5, 0.5);
glTexCoord2d(1 - width, 1 - width);
glVertex3d(0.5, -0.5, 0.5);
glTexCoord2d(width, 1 - width);
glVertex3d(-0.5, -0.5, 0.5);
glTexCoord2d(width, width);
glVertex3d(-0.5, 0.5, 0.5);
glEnd();
glEndList();

// top side
glNewList(m_skyBoxList + 4, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2d(width, 1 - width);
glVertex3d(-0.5, 0.5, 0.5);
glTexCoord2d(width, width);
glVertex3d(-0.5, 0.5, -0.5);
glTexCoord2d(1 - width, width);
glVertex3d(0.5, 0.5, -0.5);
glTexCoord2d(1 - width, 1 - width);
glVertex3d(0.5, 0.5, 0.5);
glEnd();
glEndList();

// bottom side
glNewList(m_skyBoxList + 5, GL_COMPILE);
glBegin(GL_POLYGON);
glTexCoord2d(width, 1 - width);
glVertex3d(-0.5, -0.5, -0.5);
glTexCoord2d(width, width);
glVertex3d(-0.5, -0.5, 0.5);
glTexCoord2d(1 - width, width);
glVertex3d(0.5, -0.5, 0.5);
glTexCoord2d(1 - width, 1 - width);
glVertex3d(0.5, -0.5, -0.5);
glEnd();
glEndList();

m_loaded = true;

return true;
}


SkyBox Draw:

void SkyBox::draw() {
if(!m_loaded) { return; }

glDisable(GL_DEPTH_TEST);

glLoadIdentity();

glRotated(Game::camera->getRotation().x, 1, 0, 0);
glRotated(Game::camera->getRotation().y, 0, 1, 0);

for(int i=0;i<6;i++) {
m_textures->activate();
glCallList(m_skyBoxList + i);
}

glEnable(GL_DEPTH_TEST);
}


Game Draw:

void Game::draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// set up 3d rendering
glEnable(GL_TEXTURE_2D);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70.0f, (GLfloat) settings->windowWidth / (GLfloat) settings->windowHeight, 0.1f, 10000.0f);
glMatrixMode(GL_MODELVIEW);

// render skybox
if(skyBox != NULL) {
skyBox->draw();
}

// render world
if(mainShader != NULL) { mainShader->activate(); }

glPushMatrix();
camera->setup();

glScalef(100, 100, 100);

glBegin(GL_POLYGON);

// left
glVertex3f(-1.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, 0.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);

// right
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, -1.0f, 0.0f);
glVertex3f(0.0f, -1.0f, -1.0f);
glVertex3f(0.0f, 0.0f, -1.0f);

// front
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f(0.0f, -1.0f, 0.0f);

// back
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, 0.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(0.0f, -1.0f, -1.0f);

// top
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, -1.0f);
glVertex3f(-1.0f, 0.0f, -1.0f);
glVertex3f(-1.0f, 0.0f, 0.0f);

// bottom
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);

glEnd();
glPopMatrix();

if(mainShader != NULL) { mainShader->deactivate(); }

// set up 2d rendering
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, settings->windowWidth, settings->windowHeight, 0);

// render hud / gui elements
displayFPS();
menu->draw();
console->draw();

SDL_GL_SwapBuffers();
}


Font Draw / Load:

void Font::drawTextHelper(int x, int y, const char * text) const {
if(!m_loaded) { return; }

glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

glBindTexture(GL_TEXTURE_2D, m_texture);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();

glLoadIdentity();

glTranslated(x, y, 0);
glListBase(m_font - 32);
glCallLists(strlen(text), GL_BYTE, text);

glPopMatrix();
}

bool Font::load() {
if(m_loaded) { return true; }

QString fontPath = QString("%1/Fonts/%2").arg(Game::settings->dataDirectoryName).arg(m_fileName);

QFileInfo fontFile(fontPath);
if(!fontFile.exists()) { return false; }

QByteArray bytes = fontPath.toLocal8Bit();

TTF_Font * fontData;
if(!(fontData = TTF_OpenFont(bytes.data(), m_size))) {
return false;
}

SDL_Color colour = {255, 255, 255, 255};

SDL_Surface * character;
QVector characters;
int maxWidth = -1;
int maxHeight = -1;
char data[2];
data[1] = '\0';
for(int i=0;i<128;i++ ) {
data[0] = (char) (i + 32);
character = TTF_RenderText_Blended(fontData, data, colour);
characters.push_back(character);
if(maxWidth < 0 || maxWidth < character->w) { maxWidth = character->w; }
if(maxHeight < 0 || maxHeight < character->h) { maxHeight = character->h; }
}

m_horizontalSpacing = maxWidth;
m_verticalSpacing = maxHeight;

int width = 1, tempWidth = maxWidth * 16;
int height = 1, tempHeight = maxHeight * 8;
while(width < tempWidth) { width *= 2; }
while(height < tempHeight) { height *= 2; }

SDL_Surface * temp = SDL_CreateRGBSurface(0, width, height, 32,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
#else
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
#endif
);

SDL_Rect sourceArea, destArea;
int x = 0;
int y = 0;
for(int i=0;i<128;i++) {
sourceArea.x = 0;
sourceArea.y = 0;
sourceArea.w = characters->w;
sourceArea.h = characters->h;

destArea.x = maxWidth * x;
destArea.y = maxHeight * y;
destArea.w = characters->w;
destArea.h = characters->h;

SDL_SetAlpha(characters, 0, 0);
SDL_BlitSurface(characters, &sourceArea, temp, &destArea);

x++;
if(x == 16) {
x = 0;
y++;
}
}

glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_2D, m_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, temp->w, temp->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

m_font = glGenLists(128);

x = 0;
y = 0;
float w = (float) maxWidth / (float) (temp->w);
float h = (float) maxHeight / (float) (temp->h);
for(int i=0;i<128;i++) {

glNewList(m_font + i, GL_COMPILE);

glBegin(GL_QUADS);
glTexCoord2f((w * x), ((h * y))); glVertex2i(0, 0);
glTexCoord2f((w * x) + w, ((h * y))); glVertex2i(maxWidth, 0);
glTexCoord2f((w * x) + w, ((h * y) + h)); glVertex2i(maxWidth, maxHeight);
glTexCoord2f((w * x), ((h * y) + h)); glVertex2i(0, maxHeight);
glEnd();

glTranslated(maxWidth, 0, 0);

glEndList();

x++;
if(x == 16) {
x = 0;
y++;
}
}

for(int i=0;i<128;i++) {
SDL_FreeSurface(characters);
}
SDL_FreeSurface(temp);

m_loaded = true;

return true;
}

Share this post


Link to post
Share on other sites
Found the solution to all my issues finally, after consulting some friends. Turns out Visual Studio 2008 on Windows 7 would use the operating system's version of OpenGL, and when I ran it from the EXE it used the local OpenGL32.dll which was either out of date, or built for the wrong platform. So, removing this DLL fixed all framerate issues, and now runs no problem after defaulting to the operating system's OpenGL32.dll. Hopefully this helps anyone else who runs into this issue!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement