Reputation: 8587
I started making this super simple game engine with SDL and OpenGL on windows. The Engine is in a static lib and the so far all it does is display a blue window, with all the ground work for an engine.
It ran fine on Windows but then I ported it to Linux and nothing. The program runs fine and is shown in the system monitor but no window is appearing. I installed a couple of mesa and gl libs to check that wasn't it. Now it wont run and says process terminated with status -1.
This is the initialization code in the engine. Please ask for anything else.
#include "Scales.h"
#include "SDL/SDL.h"
#include "gl.h"
#include "glu.h"
Engine *scalesEngine;
bool OnInit(int WindowHeight, int WindowWidth){
SDL_Surface* Surf_Display;
if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
return false;
}
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_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
if((Surf_Display = SDL_SetVideoMode(WindowWidth, WindowHeight, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) = NULL){
return false;
}
glClearColor(0.422f,0.576f,1.0f,1.0f);
glClearDepth(1.0f);
glViewport(0, 0, WindowWidth, WindowHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, WindowWidth, WindowHeight, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
game_Init();
return true;
}
int main(int argc, char* argv[]){
scalesEngine = new Engine;
game_preload();
if(OnInit(scalesEngine->WindowHeight(), scalesEngine->WindowWidth()) == false){
return -1;
}
SDL_Event Event;
//Main Game Loop
while(scalesEngine->Running){
while(SDL_PollEvent(&Event)){
scalesEngine->OnEvent(&Event);
}
scalesEngine->Update();
scalesEngine->Render();
}
scalesEngine->OnCleanUp();
delete scalesEngine;
return 0;
}
Upvotes: 1
Views: 337
Reputation: 10720
If you do not get a window, I would suspect that you are not getting your hardware context. Try using SDL_SWSURFACE
instead of SDL_HWSURFACE
.
SDL_SetVideoMode(... SDL_SWSURFACE ...
I've seen this happen when developing in a VM, though I'm sure there are other reasons.
edit:
As noted in the comments, both of these surface flags may be superfluous along with SDL_OPENGL
anyway.
Upvotes: 0
Reputation: 8826
if((Surf_Display = SDL_SetVideoMode(WindowWidth, WindowHeight, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) = NULL){
return false;
}
I'm pretty sure you meant == NULL
, right?
Upvotes: 3