I'm learning C++, and I'm writing my first OpenGL program. Unfortunately, it seems to be defaulting to Software Rendering (CPU uses bounces, GPU uses stays at 1%). I'm using SDL as the Windowing system. I've got no idea why, but when there is significant scaling, the program grinds to a halt. My PC should be able to handle it - I'm using an 8800GTX. My texture is 1024x1024, 32 bit RGBA and loaded with DevIL, and glGetString(GL_VENDOR) is returning "NVidia Corporation". Any ideas?
I'm sorry to be dumping all the code, but I've got absolutely no idea at all what is doing it. I'm very new to OpenGL.
#pragma once
#include "SDL.h"
#include "SDL_opengl.h"7
#include "IL/il.h"
#include "IL/ilut.h"
#include <math.h>
const int SCREEN_WIDTH = 1024;
const int SCREEN_HEIGHT = 768;
const int SCREEN_BPP = 32;
const int FPS = 60;
const int XSIZE = 1024;
const int YSIZE = 768;
int main( int argc, char *argv[] )
{
bool quit = false;
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_HWSURFACE | SDL_OPENGL);
glEnable(GL_TEXTURE_2D);
const GLubyte * Vendor = glGetString(GL_VENDOR);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our window to red
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho(0, XSIZE, YSIZE, 0, 0, 1);
glMatrixMode (GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
GLuint image;
ilInit();
ilutRenderer(ILUT_OPENGL);
ILuint texid;
ILboolean success;
ilGenImages(1, &texid);
ilBindImage(texid);
success = ilLoadImage("Textures.png");
if (success)
{
success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
if (!success)
{
SDL_Quit();
return -1;
}
glGenTextures(1, &image);
glBindTexture(GL_TEXTURE_2D, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData());
ilDeleteImages(1, &texid);
}
else
{
SDL_Quit();
return -2;
}
SDL_Event event;
float x = 0.0f;
while (!quit)
{
while ( SDL_PollEvent(&event) )
{
switch (event.type)
{
case SDL_QUIT:
quit = true;
break;
}
}
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(200.0f, 200.0f, 0.0f);
glRotatef(x,0.0f,0.0f, 1.0f);
glScalef(1.0f+x, 1.0f+x, 1.0f+x);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-100, -100);
glTexCoord2f(0.0f, 0.119140f);
glVertex2f(-100, 100);
glTexCoord2f(0.091797f, 0.119140f);
glVertex2f(100, 100);
glTexCoord2f(0.091797f, 0.0f);
glVertex2f(100, -100);
glEnd();
x += 0.1f;
SDL_GL_SwapBuffers();
glFlush;
}
return 0;
}
Edit : (24/04/2011 9.22 PM AEST) When run on an ancient card, on an ancient computer, it maintains ~60FPS.