SFML community forums
Help => Window => Topic started by: Fierce_Dutch on December 07, 2010, 07:14:50 am
-
Here is my code :
#include <SFML\Graphics.hpp>
#include <SFML\OpenGL.hpp>
GLfloat rquad;
void Draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glShadeModel(GL_SMOOTH);
glLoadIdentity(); // Reset The Current Modelview Matrix
glPushMatrix();
glRotatef(rquad,0.0,1.0,0);
glBegin(GL_QUADS);
glColor3f(2.0, 0.0, 0.0); //
glVertex3f(0.30, 0.30, 0.0);
glVertex3f(0.30, 0.70, 0.0);
glVertex3f(0.70, 0.70, 0.0);
glVertex3f(0.70, 0.30, 0.0);
glColor3f(255.0, 0.0, 0.0); //
glVertex3f(0.70, 0.30, 0.3);
glVertex3f(0.70, 0.70, 0.3);
glVertex3f(0.70, 0.70, 0.0);
glVertex3f(0.70, 0.30, 0.0);
glColor3f(0.0, 255.0, 0.0); //
glVertex3f(0.30, 0.70, 0.3);
glVertex3f(0.30, 0.30, 0.3);
glVertex3f(0.70, 0.30, 0.3);
glVertex3f(0.70, 0.70, 0.3);
glColor3f(0.0, 0.0, 255.0); //
glVertex3f(0.30, 0.70, 0.0);
glVertex3f(0.30, 0.30, 0.0);
glVertex3f(0.30, 0.30, 0.3);
glVertex3f(0.30, 0.70, 0.3);
glColor3f(1.0,1.0,1.0); //
glVertex3f(0.30, 0.70, 0.0);
glVertex3f(0.70, 0.70, 0.0);
glVertex3f(0.30, 0.70, 0.3);
glVertex3f(0.70, 0.70, 0.3);
glVertex3f(0.30, 0.30, 0.0);
glVertex3f(0.70, 0.30, 0.0);
glVertex3f(0.30, 0.30, 0.3);
glVertex3f(0.70, 0.30, 0.3);
glEnd();
glPopMatrix();
rquad+=-0.5;
glFlush();
}
void Initialize() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
int main(int iArgc, char** cppArgv) {
sf::Window App(sf::VideoMode(800,800,8), "OpengGL Test");
Initialize();
while(App.IsOpened())
{
glClear(GL_COLOR_BUFFER_BIT);
Draw();
App.Display();
}
return 0;
}
Ok Well I have gotten rid of those errors by creating a new project and trying to do all of this again but now window doesnt display. It doesnt pop up at all...
[/code]
-
You must link to sfml-window.lib and opengl32.lib.
-
You must link to sfml-window.lib and opengl32.lib.
I did. and I also defined sfml static. Still doesnt work...
BTW edited for graphics lib not window lib.
-
it seems you need both graphics and window.
-
it seems you need both graphics and window.
I have linked and included both, still no luck
-
How did you link them?
-
How did you link them?
I have linked all the sfml stuff, Opengl32.lib, and glu32.lib with the additional dependencies linker in vc++. I defined SFML_STATIC. Also I have put the sfml headers and the gl folder with the gl and glu headers in the include folder in the vc folder in the visual c++ folder. Also I included the libs in there for sfml and glu and opengl
BTW can you please help me do this before the weekend because I really want to devote that weekend to learning Opengl.
Btw I think it is a bit hard to talk to each other since we are across the world from eachother.. (US)
-
I defined SFML_STATIC
What revision of SFML 2 are you using? How did you define SFML_STATIC?
-
Laurent wrote:
You must link to sfml-window.lib and opengl32.lib.
Shouldn't it be sfml-window-S.lib if he uses SFML_STATIC?
-
Shouldn't it be sfml-window-S.lib if he uses SFML_STATIC?
Yes. It didn't mention it in his first message.
-
I defined SFML_STATIC
What revision of SFML 2 are you using? How did you define SFML_STATIC?
In the preprocessor directives... I am using the libraries statically...
-
When did you download SFML 2?
-
When did you download SFML 2?
Like two days ago I updated my repository again and rebuilt it. I rebuilt it correctly, dont worry.
Also Please check the first post.
-
Hey, i got a similar issue since the Catalyst driver version 10.10 (10.09 worked). I have the problem with SFML 1.6 and 2.0 using 32 or 64 bit doesn't change anything. I am not sure where the problem started, but it hangs at:
myGLContext = wglCreateContext(myDeviceContext);
on WindowImplWin32.cpp line 629 (or close, tried something). And it literally hangs, there is no error message or anything the call just doesn't return, like its blocking. Downgrading Catalyst also works, but everything else is working fine (e.g Games. Even the nehe tutorials work. Tested lesson2 and 3). Cause the newest OpenCL SDK needs the newest driver version i can no longer use the 10.09 version... hopefully somebody finda a fix ;)
I am using Win7 64 Bit and VS 2010.
-
Ok ok, I get it. You'll have to wait until the global exit crash is fixed (this is the same kind of problem).
-
Ok ok, I get it. You'll have to wait until the global exit crash is fixed (this is the same kind of problem).
Damn, is there a workaround or something? :)
-
Damn, is there a workaround or something?
Using static libraries ;)
-
Damn, is there a workaround or something?
Using static libraries ;)
Works, thanks :)
[edit] But could you try to explain what happens, so the dll version doesn't work?
-
But could you try to explain what happens, so the dll version doesn't work?
I have a global OpenGL context in SFML, which is created at global startup (before main()) and destroyed at global exit (after main()). This is not very clean programming practice, but it's so convenient.
For an unknown reason, when I do this from a DLL it causes a crash in the ATI OpenGL driver. So there's no easy bug, I need to remove this global context but this means adding a manual SFML init() and cleanup(), and I really don't like it.
-
But could you try to explain what happens, so the dll version doesn't work?
I have a global OpenGL context in SFML, which is created at global startup (before main()) and destroyed at global exit (after main()). This is not very clean programming practice, but it's so convenient.
For an unknown reason, when I do this from a DLL it causes a crash in the ATI OpenGL driver. So there's no easy bug, I need to remove this global context but this means adding a manual SFML init() and cleanup(), and I really don't like it.
Could have been the problem I experienced before?
Anyway you could have support for both? And then let us have a SFML object se we can write something like:
#define SFML_NO_GLOBAL
#include <SFML/System.hpp>
int main()
{
sf::SFML *sfml = new sf::SFML(/* Maybe settings here if wanted? */);
delete sfml;
return 0;
}
I just used new and delete to show that we manually decide when we initiate and when we cleanup.
-
Anyway you could have support for both?
No. Why should I do that?
And then let us have a SFML object
Don't know yet.
-
Anyway you could have support for both?
No. Why should I do that?
Don't know just spewing out ideas :P
-
If this case should ever become relevant, I think the most appropriate version would be a RAII wrapper around Init() and Cleanup(), so that there is at least only one line.
int main()
{
sf::GlobalContext context; // Automatic Init()
... // Do SFML stuff here
...
} // Automatic Cleanup() at end of scope
-
Of course :)
-
If this case should ever become relevant, I think the most appropriate version would be a RAII wrapper around Init() and Cleanup(), so that there is at least only one line.
int main()
{
sf::GlobalContext context; // Automatic Init()
... // Do SFML stuff here
...
} // Automatic Cleanup() at end of scope
That's what I meant but I used new and delete to show I meant the constructor and destructor, maybe it wasn't as apparent as I thought.
-
Same problem, ati driver 10.09 works, fail with 10.10, 10.11, 10.12, works fine on Ubuntu 10.10 using HD5850, I'm using temporarily MesaGL using software processing on Windows 7-64, i compiled MesaGL version 7.8.2, you can download libs from HERE (http://rapidshare.com/files/438158885/MesaGL_7.8.2.zip), just copy the libraries in .exe's directory and run your exe.
-
Nice :)