Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Making 3D SFML  (Read 6603 times)

0 Members and 1 Guest are viewing this topic.

Vovosunt

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Making 3D SFML
« on: May 09, 2013, 04:38:29 pm »
Over the last month or so I have been trying to make a 3D SFML-like thing (with SFML as the base).

Today I ran into a problem with GLEW while making a 3D version of RenderTarget. I'm not sure which libraries to link/ not link.
Currently I'm only linking the extlibs/libs-msvc/glew.lib (and the standard sfml libs), but it still gives linker errors:

Error   2       error LNK2019: unresolved external symbol "void __cdecl sf::priv::ensureGlewInit(void)" (?ensureGlewInit@priv@sf@@YAXXZ) referenced in function "public: void __thiscall RenderTarget3::resetGLStates(void)" (?resetGLStates@RenderTarget3@@QAEXXZ)     C:\Users\SVS\documents\visual studio 11\Projects\Project1\Project1\RenderTarget3.obj    Project1

Error   3       error LNK2001: unresolved external symbol __imp____glewBlendEquation    C:\Users\SVS\documents\visual studio 11\Projects\Project1\Project1\RenderTarget3.obj    Project1

Error   4       error LNK2001: unresolved external symbol __imp____glewUseProgramObjectARB      C:\Users\SVS\documents\visual studio 11\Projects\Project1\Project1\RenderTarget3.obj    Project1

Error   5       error LNK2001: unresolved external symbol __imp____glewBlendFuncSeparateEXT     C:\Users\SVS\documents\visual studio 11\Projects\Project1\Project1\RenderTarget3.obj    Project1

Error   6       error LNK2001: unresolved external symbol __imp____GLEW_EXT_blend_func_separate C:\Users\SVS\documents\visual studio 11\Projects\Project1\Project1\RenderTarget3.obj    Project1

Error   7       error LNK1120: 5 unresolved externals   C:\Users\SVS\documents\visual studio 11\Projects\Project1\Debug\Project1.exe    Project1
 
Any help would be very appreciated :)
« Last Edit: May 09, 2013, 05:09:04 pm by Vovosunt »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Making 3D SFML
« Reply #1 on: May 09, 2013, 04:44:39 pm »
If you integrate the sources directly to your project, or link it statically, you must define the GLEW_STATIC macro in your preprocessor options.
Laurent Gomila - SFML developer

Vovosunt

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Making 3D SFML
« Reply #2 on: May 09, 2013, 05:07:34 pm »
That took care of errors 3-7, but error 2 (sf::priv::ensureGlewInit()) still pops up :(
« Last Edit: May 09, 2013, 05:12:44 pm by Vovosunt »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Making 3D SFML
« Reply #3 on: May 09, 2013, 06:15:28 pm »
That's a private (non exported) SFML function. You mustn't use it.
Laurent Gomila - SFML developer

Vovosunt

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Making 3D SFML
« Reply #4 on: May 09, 2013, 10:00:24 pm »
By removing the ensureGlewInit and by commenting out some openGL ARB functions I managed to get it working.
It's something I guess :P

What should I do with ensureGlewInit then? Try making my own? Is it even needed?
(During debugging I noticed that it's called like 4 or 5 times every time you draw something O.O)

And how can I get those ext ARB functions to work?
(I get a bad memory acces crash when it tries to use glBlendEquation or glUseProgramObjectARB)

BTW thanks Laurent! You're a goddamn wizard as always :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Making 3D SFML
« Reply #5 on: May 09, 2013, 10:13:53 pm »
Quote
What should I do with ensureGlewInit then? Try making my own? Is it even needed?
It's a private implementation detail, so... forget it, do your own stuff ;)

Quote
And how can I get those ext ARB functions to work?
Aren't you using GLEW for this purpose? Don't forget to call glewInit, and everything should work.
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Making 3D SFML
« Reply #6 on: May 10, 2013, 06:40:30 pm »
Yep, I do this too. I use sfml and yet I link to glew too and call glewInit after the window is initialized! :)

It works just fine even though its a little ugly to have the linker warnings all over me.. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Making 3D SFML
« Reply #7 on: May 11, 2013, 09:33:29 am »
What warnings?
Laurent Gomila - SFML developer

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: Making 3D SFML
« Reply #8 on: May 11, 2013, 02:31:23 pm »
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewUseProgram imported
2>nephilim-d.lib(CGL.obj) : warning LNK4217: locally defined symbol _glewInit imported in function "void __cdecl cglPrepareExtensions(void)" (?cglPrepareExtensions@@YAXXZ)
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewGetActiveUniform imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewGetProgramiv imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewDeleteShader imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewGetShaderInfoLog imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewGetShaderiv imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewCompileShader imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewShaderSource imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewCreateShader imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewDeleteProgram imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewGetProgramInfoLog imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewLinkProgram imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewAttachShader imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewBindAttribLocation imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewCreateProgram imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewUniform1i imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewGetUniformLocation imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewUniformMatrix4fv imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewUniform4fv imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewUniform3fv imported
2>nephilim-d.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewUniform1f imported
 

But it is normal I believe as GLEW is being linked twice (statically)

Vovosunt

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: Making 3D SFML
« Reply #9 on: May 11, 2013, 03:19:32 pm »
Well this is weird... I'm not getting any errors/warnings at all.
Besides using multiple glewInit() should just redefine all the bools and function pointers.
The warnings you get are due to export and then reimport of GLEW "symbols" :
Quote from: "msdn"
This warning is generated by the linker when you declare a symbol by using the __declspec(dllexport) storage-class attribute in one object file and reference it by using the __declspec(dllimport) attribute in another.]



It's a private implementation detail, so... forget it, do your own stuff ;)
I don't really understand the point of making functions in glCheck private...
They're pretty simple and are just for error checking anyway :\

Now, ensureGLcontext is another thing :)
It's pretty damn complicated...
setActive is there to make SFML thread safe, istn it?  ???
Anyway...

glewInit() did the trick and it seems that everything is working fine :D
Thanks again Laurent!

BTW can I use GLresource for Vertex/Pixel buffer implementations?
It's basically a thread-safe counter for the openGL resources if I understand everything right.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Making 3D SFML
« Reply #10 on: May 11, 2013, 03:29:11 pm »
Quote
BTW can I use GLresource for Vertex/Pixel buffer implementations?
Yes.
Laurent Gomila - SFML developer

 

anything