Sign in to follow this  
TTT_Dutch

Black Screen with Linux

Recommended Posts

TTT_Dutch    240
Ok well I seem to have a bug somewhere in my system. I have a game engine in development and I get a black window whenever trying to run it on linux. The other programmer on my team can run it perfectly fine on windows. I have a ATI Radeon Mobility HD 4200. The game engine uses C++, OpenGL, GLEW, and SDL. I have installed GLEW from source, the proper drivers from ATI, and SDL from the Debian repositories. I have a high enough version of OpenGL to be running it. Does anyone have any idea what could be wrong? If you need more information please let me know. (I know its not the code btw because it runs on windows fine and our code is cross-OS + I can't paste code here because its such a huge project)

Thanks,
Brent

Share this post


Link to post
Share on other sites
Double check if the portable code can run on linux, because windows and linux store libraries in a different way, windows uses dll and linux ".so" extension... IDk, maybe the game engine is loading a dll, so maybe it's not available in linux...

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='ApochPiQ' timestamp='1311636519' post='4840258']
Error checking is your friend. Use it.
[/quote]

Thanks for your response.

I have used it very extensively. I log almost everything that could go wrong and I have gone through it with a debugger and looked at every piece of possible corrupted memory to see if it is okay throughout the program. Trust, I have definitly found it is my friend.

Thanks for the reply anyway though :),
Brent


[quote name='Mauricio Cinelli' timestamp='1311636922' post='4840263']
Double check if the portable code can run on linux, because windows and linux store libraries in a different way, windows uses dll and linux ".so" extension... IDk, maybe the game engine is loading a dll, so maybe it's not available in linux...
[/quote]


Ok thanks, but I am not sure why it would be loading a DLL since I am using all linux libraries. I am using an IDE but maybe I have to define something when linking a shared library.

Thanks,
Brent

Share this post


Link to post
Share on other sites
ApochPiQ    23006
There are four possibilities.

[list=1][*]You do not do enough error checking, even though you may think you do, and the problem cannot be communicated to you at all.[*]You do in fact do enough error checking, and the problem is being communicated to you but you are failing to pay attention to it.[*]Your error is not in your usage of APIs but elsewhere. For example, did you remember to put textures in your game that [i]aren't [/i]all black? (I kid.)[*]None of this is your fault and everyone else's software in the stack is broken.[/list]

Hint: it's not number 4.

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1311640179' post='4840290']
There are four possibilities.

[list=1][*]You do not do enough error checking, even though you may think you do, and the problem cannot be communicated to you at all.[*]You do in fact do enough error checking, and the problem is being communicated to you but you are failing to pay attention to it.[*]Your error is not in your usage of APIs but elsewhere. For example, did you remember to put textures in your game that [i]aren't [/i]all black? (I kid.)[*]None of this is your fault and everyone else's software in the stack is broken.[/list]

Hint: it's not number 4.
[/quote]

haha, great hint!

Also, make sure that the SDL version that you're using on debian matches the functionality in the code.... because debian releases are really really slow and generally old

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='ApochPiQ' timestamp='1311640179' post='4840290']
There are four possibilities.

[list=1][*]You do not do enough error checking, even though you may think you do, and the problem cannot be communicated to you at all.[*]You do in fact do enough error checking, and the problem is being communicated to you but you are failing to pay attention to it.[*]Your error is not in your usage of APIs but elsewhere. For example, did you remember to put textures in your game that [i]aren't [/i]all black? (I kid.)[*]None of this is your fault and everyone else's software in the stack is broken.[/list]

Hint: it's not number 4.
[/quote]

Ok well I can not do anymore error checking within my program because every single thing that could go wrong is being checked. Is there any other error checking outside of the program that I can do?


[quote name='Mauricio Cinelli' timestamp='1311640756' post='4840297']
[quote name='ApochPiQ' timestamp='1311640179' post='4840290']
There are four possibilities.

[list=1][*]You do not do enough error checking, even though you may think you do, and the problem cannot be communicated to you at all.[*]You do in fact do enough error checking, and the problem is being communicated to you but you are failing to pay attention to it.[*]Your error is not in your usage of APIs but elsewhere. For example, did you remember to put textures in your game that [i]aren't [/i]all black? (I kid.)[*]None of this is your fault and everyone else's software in the stack is broken.[/list]

Hint: it's not number 4.
[/quote]

haha, great hint!

Also, make sure that the SDL version that you're using on debian matches the functionality in the code.... because debian releases are really really slow and generally old
[/quote]

Ok how do I do that? I just removed all SDL stuff in my system and installed SDL 1.2 from source from their website so would that be ok? I also did the same thing with glew and am now doing the same thing with lua.

Share this post


Link to post
Share on other sites
do you have any way to check if the libraries are loading properly? for example, like using a debugger

If you can't, try to make a really simple app that loads are use a tiny feature of it, so you can test if loading is ok or not

The black screen keeps black? or it closes?

Share this post


Link to post
Share on other sites
ApochPiQ    23006
[quote name='TTT_Dutch' timestamp='1311641300' post='4840304']
Ok well I can not do anymore error checking within my program because every single thing that could go wrong is being checked. Is there any other error checking outside of the program that I can do?[/quote]

I have a tremendously hard time believing this.

Of course, since you refuse to provide any code, I'm not in any position to objectively dispute your claim, so...


Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Mauricio Cinelli' timestamp='1311641608' post='4840308']
do you have any way to check if the libraries are loading properly? for example, like using a debugger

If you can't, try to make a really simple app that loads are use a tiny feature of it, so you can test if loading is ok or not

The black screen keeps black? or it closes?
[/quote]

Ok I will download some test apps for SDL and glew. Also the app runs as if it normally would its just that GL doesn't draw anything to the screen except it does in windows.

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1311641789' post='4840309']
[quote name='TTT_Dutch' timestamp='1311641300' post='4840304']
Ok well I can not do anymore error checking within my program because every single thing that could go wrong is being checked. Is there any other error checking outside of the program that I can do?[/quote]

I have a tremendously hard time believing this.

Of course, since you refuse to provide any code, I'm not in any position to objectively dispute your claim, so...



[/quote]

Only things that can be happening is:

Not loading libraries
Debian with old libraries
Code referencing wrong libraries
Or some other issue in the code that is perfectly legal in Windows but not in linux

EDIT 1

So... test some sample apps and see if you can get GL running. if you can, your code is wrong in the big project, if it's not loading, then you're loading it the wrong way

Good luck[img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1311642108' post='4840315']
And of course all of those things can be tested for trivially.

Dutch insists, however, that he's already testing for every possible error, so...
[/quote]

Oh I see, so really there's nothing we can do, if he said this....
hope he finds out what it is

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Mauricio Cinelli' timestamp='1311641979' post='4840313']
[quote name='ApochPiQ' timestamp='1311641789' post='4840309']
[quote name='TTT_Dutch' timestamp='1311641300' post='4840304']
Ok well I can not do anymore error checking within my program because every single thing that could go wrong is being checked. Is there any other error checking outside of the program that I can do?[/quote]

I have a tremendously hard time believing this.

Of course, since you refuse to provide any code, I'm not in any position to objectively dispute your claim, so...



[/quote]

Only things that can be happening is:

Not loading libraries
Debian with old libraries
Code referencing wrong libraries
Or some other issue in the code that is perfectly legal in Windows but not in linux

EDIT 1

So... test some sample apps and see if you can get GL running. if you can, your code is wrong in the big project, if it's not loading, then you're loading it the wrong way

Good luck[img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]
[/quote]


Ok well I found an SDL + OpenGL app and it works. Still looking for a GLEW + SDL + Shader based OpenGL app though. Also I know its loading libraries because if it doesn't it will throw an error. Debian shouldnt have old libraries since I just compiled the latest source from the libraries websites. What do you mean code referenceing wrong libraries and code that is legal in windows and not in linux?

[quote name='ApochPiQ' timestamp='1311642108' post='4840315']
And of course all of those things can be tested for trivially.

Dutch insists, however, that he's already testing for every possible error, so...
[/quote]


Ok well obviously I am missing something but every if statement that could possibly fail is checked and every function that returns an error code on whether or not it worked is check. Every file is checked when its opened and checked if it is read correctly. Every shader is checked if its compiled then we check the shader compilation log. We have one GL error but it is on both of our systems and it is thrown before there are even any GL calls so we believe that its some GL error or something.

EDIT: If you would like to know what it is, its pMesh = &m_mesh[meshName]; where pMesh is a Geometry * and m_mesh is a map<string,Geometry>. There are no GL calls before this or in Geometry's comstructor and the only thing to do with GL is GLEW at this point.

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='TTT_Dutch' timestamp='1311643925' post='4840328']
[quote name='Mauricio Cinelli' timestamp='1311641979' post='4840313']
[quote name='ApochPiQ' timestamp='1311641789' post='4840309']
[quote name='TTT_Dutch' timestamp='1311641300' post='4840304']
Ok well I can not do anymore error checking within my program because every single thing that could go wrong is being checked. Is there any other error checking outside of the program that I can do?[/quote]

I have a tremendously hard time believing this.

Of course, since you refuse to provide any code, I'm not in any position to objectively dispute your claim, so...



[/quote]

Only things that can be happening is:

Not loading libraries
Debian with old libraries
Code referencing wrong libraries
Or some other issue in the code that is perfectly legal in Windows but not in linux

EDIT 1

So... test some sample apps and see if you can get GL running. if you can, your code is wrong in the big project, if it's not loading, then you're loading it the wrong way

Good luck[img]http://public.gamedev.net/public/style_emoticons/default/laugh.gif[/img]
[/quote]


Ok well I found an SDL + OpenGL app and it works. Still looking for a GLEW + SDL + Shader based OpenGL app though. Also I know its loading libraries because if it doesn't it will throw an error. Debian shouldnt have old libraries since I just compiled the latest source from the libraries websites. What do you mean code referenceing wrong libraries and code that is legal in windows and not in linux?

[quote name='ApochPiQ' timestamp='1311642108' post='4840315']
And of course all of those things can be tested for trivially.

Dutch insists, however, that he's already testing for every possible error, so...
[/quote]


Ok well obviously I am missing something but every if statement that could possibly fail is checked and every function that returns an error code on whether or not it worked is check. Every file is checked when its opened and checked if it is read correctly. Every shader is checked if its compiled then we check the shader compilation log. We have one GL error but it is on both of our systems and it is thrown before there are even any GL calls so we believe that its some GL error or something.

EDIT: If you would like to know what it is, its pMesh = &m_mesh[meshName]; where pMesh is a Geometry * and m_mesh is a map<string,Geometry>. There are no GL calls before this or in Geometry's comstructor and the only thing to do with GL is GLEW at this point.
[/quote]

Ok so I have looked around and the OpenGL error above is the only error that I have had for awhile and can find.

Share this post


Link to post
Share on other sites
Katie    2244
Can you run it on a linux machine with any other 3D card in it? (This'll tell you if it's the card)

Can you run it on the same linux machine with a software renderer? (this'll tell you if its the rest of the stack)

What happens if you run it on the same machine but booted into windows? (this'll tell you if it's that *particular* card).

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Katie' timestamp='1311669684' post='4840419']
Can you run it on a linux machine with any other 3D card in it? (This'll tell you if it's the card)

Can you run it on the same linux machine with a software renderer? (this'll tell you if its the rest of the stack)

What happens if you run it on the same machine but booted into windows? (this'll tell you if it's that *particular* card).
[/quote]


Ok well I can't do the other two because I only have older laptops.

Umm what do you mean by software renderer?

Ok so I was trying to do this on windows with VC++ and it starts up then says: "Error Missing GL Version".

Share this post


Link to post
Share on other sites
[quote name='TTT_Dutch' timestamp='1311691202' post='4840556']
Ok well I can't do the other two because I only have older laptops.

Umm what do you mean by software renderer?

Ok so I was trying to do this on windows with VC++ and it starts up then says: "Error Missing GL Version".


[/quote]

guess you found the error....

About the software rendering

[url="http://en.wikipedia.org/wiki/Software_rendering"]http://en.wikipedia.org/wiki/Software_rendering[/url]

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Mauricio Cinelli' timestamp='1311691595' post='4840558']
[quote name='TTT_Dutch' timestamp='1311691202' post='4840556']
Ok well I can't do the other two because I only have older laptops.

Umm what do you mean by software renderer?

Ok so I was trying to do this on windows with VC++ and it starts up then says: "Error Missing GL Version".


[/quote]

guess you found the error....

About the software rendering

[url="http://en.wikipedia.org/wiki/Software_rendering"]http://en.wikipedia....tware_rendering[/url]
[/quote]

No I have always had that error but never thought it was important since I am only working on linux. I am trying to solve my linux problem at the moment and the only error I have is an error that I have had for awhile where it spits out the OpenGL error: invalid value after I point a pointer at another thing of its same type which had no GL calls in that call or before it.

Share this post


Link to post
Share on other sites
rip-off    10976
Write a really simple program, one that draws a triangle. Get it to work on Linux. Incrementally add each of the technologies you are using. Continue to add code until you have your program. Either you'll get your program working, or you'll find the component that causes the issue. Fix this.

Rinse and repeat.

You can also do this backwards. Take your big project, and start commenting stuff out until it manages to draw something.

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='rip-off' timestamp='1311693171' post='4840575']
Write a really simple program, one that draws a triangle. Get it to work on Linux. Incrementally add each of the technologies you are using. Continue to add code until you have your program. Either you'll get your program working, or you'll find the component that causes the issue. Fix this.

Rinse and repeat.

You can also do this backwards. Take your big project, and start commenting stuff out until it manages to draw something.
[/quote]

Ok well I compiled and ran an SDL + OpenGL application so I know its not either of those things and I am pretty sure its not. And I know glew works so could it be that maybe in GLSL a texture isnt loading or something? Also everything is shader based so I cant really comment it out till I get something working (I have gotten shaders working before). So I guess its something with the shader but what could be wrong but still not report an error? I mean it works on my friends windows :D

EDIT: I went back to basic immediateness mode and I still dont see anything and here is my code:

[code]#include "defines.h"
#include "camera.h"
#include "eventSys.h"
#include "log.h"
#include "shader.h"
#include "program.h"
#include "block.h"
#include "timer.h"
#include "grid.h"



bool SetupWindow(char *winCaption, Uint32 winWidth, Uint32 winHeight, Uint32 screenBPP, bool fullScreen = false);
void UpdateWindow(Uint32 winWidth, Uint32 winHeight);
void Exit();

//Grid grid;
bool bExit = false;

int main(int argc, char* args[])
{

if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
Exit();
return 0;
}

if(!SetupWindow("Biome", 800, 800, 32, false))
bExit = true;

GLenum err = glewInit();
if (GLEW_OK != err)
{
log->WriteToLog("Error: %s\n", glewGetErrorString(err));
Exit();
}


/*blockMgr->LoadBlock();
blockMgr->LoadTextures();

grid.m_xSize = 4;
grid.m_ySize = 4;
grid.m_zSize = 4;

grid.GenerateGrid(10.0f);*/

Timer fps;
//Vector3D pos(0.0f, 0.0f, -10.f);

//camera->SetPosition(pos);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective( /* field of view in degree */ 40.0,
/* aspect ratio */ 1.0,
/* Z near */ 1.0, /* Z far */ 10.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */
0.0, 0.0, 0.0, /* center is at (0,0,0) */
0.0, 1.0, 0.); /* up is in positive Y direction */

float orient = 0.0f;

while(!bExit)
{
fps.Start();
while(SDL_PollEvent(&eventSys->m_event))
{
eventSys->m_eventSubscriber.CallSubscribers();

//If the user has Xed out the window
if(eventSys->m_event.type == SDL_QUIT )
{
//Exit the program
bExit = true;
}

if((eventSys->m_event.type == SDL_KEYDOWN) && (eventSys->m_event.key.keysym.sym == SDLK_ESCAPE))
{
bExit = true;
}
if(eventSys->m_event.type == SDL_VIDEORESIZE)
{
//UpdateWindow(eventSys->m_event.resize.w, eventSys->m_event.resize.h);
}
}

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

glBegin(GL_TRIANGLES);
glColor3f(1,1,1);
glVertex3f(-5,0,-5);
glVertex3f(0,5,-5);
glVertex3f(5,0,-5);
glEnd();

//Vector3D camera_mov(0, 0, -0.05f);
//camera->Move(camera_mov);
//grid.Render();

SDL_GL_SwapBuffers();

#ifdef SHOW_FPS
int frameRate = 1000 / (fps.GetTicks() == 0 ? 1 : fps.GetTicks());
stringstream stream;
stream << "FPS:" << frameRate;

string sFrameRate;
stream >> sFrameRate;
SDL_WM_SetCaption(sFrameRate.c_str(), 0);
#endif
if(fps.GetTicks() < FPS_MILLISEC)
{
SDL_Delay(FPS_MILLISEC - fps.GetTicks());
}
}

Exit();

return 1;
}

bool SetupWindow(char *winCaption, Uint32 winWidth, Uint32 winHeight, Uint32 screenBPP, bool fullScreen)
{
SDL_WM_SetCaption(winCaption, 0);

int winFlag = fullScreen ? SDL_FULLSCREEN : SDL_RESIZABLE;

if(SDL_SetVideoMode(winHeight, winWidth, screenBPP, SDL_OPENGL | winFlag) == NULL)
{
return false;
}

UpdateWindow(winWidth, winHeight);

glCullFace(GL_BACK);

glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);

return true;
}

void UpdateWindow(Uint32 winWidth, Uint32 winHeight)
{
glViewport(0, 0, winWidth, winHeight);
camera->SetupCamera(45.0f, (float)winWidth/(float)winHeight, 1, 500);
}

void Exit()
{
log->FinalOut();
SDL_Quit();
bExit = true;
}
[/code]

Share this post


Link to post
Share on other sites
rip-off    10976
We're not psychic. We cannot debug code we cannot see. We also have limited time - we probably won't debug a large project if you were to post it.

The solution is to obtain a simpler project which demonstrates the behaviour. We can then help you debug that. The two approaches I've suggested are ways of generating such a project.

[quote]
Ok well I compiled and ran an SDL + OpenGL application so I know its not either of those things ... And I know glew works ... I have gotten shaders working before.
[/quote]
At some point between your big project and these simpler programs that work something is going wrong. The process I'm proposing you follow lets you iteratively add or remove stuff until you find that point.

[edit:]

These need to go:
[code]
#include "defines.h"
#include "camera.h"
#include "eventSys.h"
#include "log.h"
#include "shader.h"
#include "program.h"
#include "block.h"
#include "timer.h"
#include "grid.h"
[/code]
I'm talking about a minimal example we can actually compile and run.

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='rip-off' timestamp='1311696223' post='4840605']
We're not psychic. We cannot debug code we cannot see. We also have limited time - we probably won't debug a large project if you were to post it.

The solution is to obtain a simpler project which demonstrates the behaviour. We can then help you debug that. The two approaches I've suggested are ways of generating such a project.

[quote]
Ok well I compiled and ran an SDL + OpenGL application so I know its not either of those things ... And I know glew works ... I have gotten shaders working before.
[/quote]
At some point between your big project and these simpler programs that work something is going wrong. The process I'm proposing you follow lets you iteratively add or remove stuff until you find that point.

[edit:]

These need to go:
[code]
#include "defines.h"
#include "camera.h"
#include "eventSys.h"
#include "log.h"
#include "shader.h"
#include "program.h"
#include "block.h"
#include "timer.h"
#include "grid.h"
[/code]
I'm talking about a minimal example we can actually compile and run.
[/quote]

Ok I well are you looking for a GLSL program? Or just an Imidiate mode program?

Share this post


Link to post
Share on other sites
TTT_Dutch    240
Ok so here is that simple program (still don't see anything though)

[code]#include "defines.h"
/*#include "camera.h"
#include "eventSys.h"
#include "log.h"
#include <sstream>
#include "shader.h"
#include "program.h"
#include "block.h"
#include "timer.h"
#include "grid.h"*/



bool SetupWindow(char *winCaption, Uint32 winWidth, Uint32 winHeight, Uint32 screenBPP, bool fullScreen = false);
void UpdateWindow(Uint32 winWidth, Uint32 winHeight);
void Exit();

//Grid grid;
bool bExit = false;

int main(int argc, char* args[])
{

if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
Exit();
return 0;
}

if(!SetupWindow("Biome", 800, 800, 32, false))
bExit = true;

GLenum err = glewInit();
if (GLEW_OK != err)
{
//log->WriteToLog("Error: %s\n", glewGetErrorString(err));
Exit();
}


//blockMgr->LoadBlock();
//blockMgr->LoadTextures();

//grid.m_xSize = 4;
//grid.m_ySize = 4;
//grid.m_zSize = 4;

//grid.GenerateGrid(10.0f);

//Timer fps;
//Vector3D pos(0.0f, 0.0f, -10.f);

//camera->SetPosition(pos);

/* select clearing color */
glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);



SDL_Event event;


float orient = 0.0f;

while(!bExit)
{
//fps.Start();
while(SDL_PollEvent(/*&eventSys->m_*/&event))
{
/*eventSys->m_eventSubscriber.CallSubscribers();*/

//If the user has Xed out the window
if(/*eventSys->m_*/event.type == SDL_QUIT )
{
//Exit the program
bExit = true;
}

if((/*eventSys->m_*/event.type == SDL_KEYDOWN) && (/*eventSys->m_*/event.key.keysym.sym == SDLK_ESCAPE))
{
bExit = true;
}
if(/*eventSys->m_*/event.type == SDL_VIDEORESIZE)
{
//UpdateWindow(eventSys->m_event.resize.w, eventSys->m_event.resize.h);
}
}

//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

/*Vector3D camera_mov(0, 0, -0.05f);
camera->Move(camera_mov);
grid.Render();*/

/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();

/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();

SDL_GL_SwapBuffers();

/*#ifdef SHOW_FPS
int frameRate = 1000 / (fps.GetTicks() == 0 ? 1 : fps.GetTicks());
stringstream stream;
stream << "FPS:" << frameRate;

string sFrameRate;
stream >> sFrameRate;
SDL_WM_SetCaption(sFrameRate.c_str(), 0);
#endif
if(fps.GetTicks() < FPS_MILLISEC)
{
SDL_Delay(FPS_MILLISEC - fps.GetTicks());
}*/
}

Exit();

return 1;
}

bool SetupWindow(char *winCaption, Uint32 winWidth, Uint32 winHeight, Uint32 screenBPP, bool fullScreen)
{
SDL_WM_SetCaption(winCaption, 0);

int winFlag = fullScreen ? SDL_FULLSCREEN : SDL_RESIZABLE;

if(SDL_SetVideoMode(winHeight, winWidth, screenBPP, SDL_OPENGL | winFlag) == NULL)
{
return false;
}

UpdateWindow(winWidth, winHeight);

glCullFace(GL_BACK);

glEnable(GL_CULL_FACE);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);

return true;
}

void UpdateWindow(Uint32 winWidth, Uint32 winHeight)
{
glViewport(0, 0, winWidth, winHeight);
//camera->SetupCamera(45.0f, (float)winWidth/(float)winHeight, 1, 500);
}

void Exit()
{
//log->FinalOut();
SDL_Quit();
bExit = true;
}

[/code]


And here is defines.h

[code]

#ifndef BIOME_DEFINES
#define BIOME_DEFINES

#include <string>

//GLEW include
#include <GL/glew.h>

//SDL includes
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

//GL include
#include <GL/gl.h>
#include <GL/glu.h>

//STL Library includes
//#include "../math/mathUtil.h"

//Lua includes
extern "C"
{
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}

//Use standard library
using namespace std;

#define BUFFER_OFFSET(i) ((char*)0 + (i))

#define MODEL_PATH "media/models/"
#define TEXTURE_PATH "media/textures/"
#define SHADERS_PATH "media/shaders/"
#define SCRIPT_PATH "media/scripts/"

#define SHOW_FPS
#define FPS_MILLISEC 33

//void ErrorGL();

#endif
[/code]


And here is some very similar code that does work:

[code]/*
* Copyright (c) 1993-1997, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* clause at DFARS 252.227-7013 and/or in similar or successor
* clauses in the FAR or the DOD or NASA FAR Supplement.
* Unpublished-- rights reserved under the copyright laws of the
* United States. Contractor/manufacturer is Silicon Graphics,
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
*
* OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
*/

/*
* hello.c
* This is a simple, introductory OpenGL program.
*/
#include <GL/glut.h>

void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();

/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}

void init (void)
{
/* select clearing color */
glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

/*
* Declare initial window size, position, and display mode

* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}[/code]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this