10
« on: August 02, 2011, 05:53:10 am »
I hate to bump a thread like this, but I seem to still be having this trouble. I created a smaller sample for you which may help, as it only uses SFML and OpenGL, removing wxWidgets from it entirely. It is a truly minimal sample. This is it:
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;
bool initialised = false;
sf::RenderWindow App;
void setup() {
cout << "Setting up rendering context." << endl;
cout << "OpenGL vendor: " << glGetString(GL_VENDOR) << endl;
cout << "OpenGL renderer: " << glGetString(GL_RENDERER) << endl;
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
App.PreserveOpenGLStates(true);
GLfloat ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
App.SetActive(true);
initialised = true;
}
void changeSize(GLfloat w, GLfloat h) {
if (initialised) {
GLfloat fAspect;
// Prevent a divide by zero, when window is too short
// (you cant make a window of zero width).
if(h == 0)
h = 1;
glViewport(0, 0, w, h);
fAspect = (GLfloat)w / (GLfloat)h;
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the clipping volume
gluPerspective(35.0f, fAspect, 1.0f, 50.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
}
void render() {
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -200.0f);
glBegin(GL_QUADS);
glColor3f(0.1f, 1.0f, 0.1f);
glVertex3f(100.0f, -100.0f, 100.0f);
glNormal3f(100.0f, -101.0f, 100.0f);
glVertex3f(100.0f, -100.0f, -100.0f);
glNormal3f(100.0f, -101.0f, -100.0f);
glVertex3f(-100.0f, -100.0f, -100.0f);
glNormal3f(-100.0f, -101.0f, -100.0f);
glVertex3f(-100.0f, -100.0f, 100.0f);
glNormal3f(-100.0f, -101.0f, 100.0f);
glVertex3f(-100.0f, 100.0f, 100.0f);
glNormal3f(-100.0f, 101.0f, 100.0f);
glVertex3f(-100.0f, 100.0f, -100.0f);
glNormal3f(-100.0f, 101.0f, -100.0f);
glVertex3f(100.0f, 100.0f, -100.0f);
glNormal3f(100.0f, 101.0f, -100.0f);
glVertex3f(100.0f, 100.0f, 100.0f);
glNormal3f(100.0f, 101.0f, 100.0f);
glEnd();
glFlush();
}
int main()
{
// Create the main window
App.Create(sf::VideoMode(800, 600), "SFML window");
setup();
// Start the game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
if (Event.Type == sf::Event::Resized)
changeSize(Event.Size.Width, Event.Size.Height);
}
// Clear screen
App.Clear();
render();
// Update the window
App.Display();
}
return EXIT_SUCCESS;
}
It still displays no more than a blank screen, and I cannot determine why. Please, any explanation is greatly appreciated, let alone help. I just want to get this working.