SFML community forums

General => General discussions => Topic started by: molmasepic on January 09, 2011, 06:22:21 pm

Title: Using Directx with SFML
Post by: molmasepic on January 09, 2011, 06:22:21 pm
hello, i have been wondering if i was able to use directx with SFML

if so, then are there any tutorials about this?

also about directx...

im wondering about what linkers i should use in the compiler options


IDE: Code::Blocks
Compiler: MinGW
(if anyone has suggestions let me know)

PS: i have tried SFML with VC++ Express, and i have gotten many errors that im not sure on how to fix...
Title: Using Directx with SFML
Post by: Terrydil on January 09, 2011, 06:38:08 pm
SFML uses OpenGL so it wouldn't know how to tell DirectX to draw stuff.  Using DirectX also wouldn't be portable unless you have a library with both DirectX and OpenGL backends.
Title: Using Directx with SFML
Post by: molmasepic on January 09, 2011, 10:21:58 pm
hmm..i see

then wouldnt that make my game not able to play on certain graphics cards?

my main thing about this game is compatability.

i plan to make it online(wish me luck xD), but im also using windows(i dont like VC++ because its not really portable)

basically im wondering if openGL is going to be graphic card picky...  :?
Title: Using Directx with SFML
Post by: Grimshaw on January 09, 2011, 10:27:08 pm
OpenGL is the only cross-platform solution (at least, a proven, used worldwide), if you want portable, that's what you're looking for.

Every graphic card from these days seems to bring OpenGL drivers natively, and many AAA games have OpenGL rendering, and it's as good as directX.
If im not mistaken, Playstation 3 renders with openGL.

The only if is you must be careful with what features you use, p.e. a graphic card with opengl 1.1 won't be able to draw vbo's. But it can still draw vertex arrays.

Enjoy : )
Title: Using Directx with SFML
Post by: Laurent on January 09, 2011, 10:47:27 pm
Quote
then wouldnt that make my game not able to play on certain graphics cards?

No. Everyone has an OpenGL driver that supports the basic stuff that SFML uses. This will never be a problem.

Quote
i dont like VC++ because its not really portable

Sorry to go slightly off-topic, but this doesn't make sense. The code that you write may or not be portable, but not a compiler.
Title: Using Directx with SFML
Post by: JAssange on January 09, 2011, 10:59:40 pm
Quote from: "Laurent"

Quote
i dont like VC++ because its not really portable

Sorry to go slightly off-topic, but this doesn't make sense. The code that you write may or not be portable, but not a compiler.

VC++ supports some things other compilers don't (/Zw Microsoft Extensions) which he may not want to accidentally use. It's easy enough to just disable though those, I use VC++ on Windows and C:B on Linux and it works fine on both.
Title: Using Directx with SFML
Post by: Laurent on January 09, 2011, 11:02:40 pm
Every compiler has its own set of non-standard extensions, and many of them are enabled by default. VC++ is not special in this regard, use the right options if you want a strictly standard code ;)

Or better: use several compilers (at least gcc & VC++).
Title: Using Directx with SFML
Post by: molmasepic on January 10, 2011, 01:21:06 am
Quote from: "Laurent"


Or better: use several compilers (at least gcc & VC++).


i may go with this idea

Quote from: "Laurent"
Sorry to go slightly off-topic, but this doesn't make sense. The code that you write may or not be portable, but not a compiler.


and sorry, ive been sick so i may not make sense when i try to tell stuff

what i have heard is that not many people have tried installing VC++ express or any of those on a flash drive(i have an external HD if that helps in any way) also when compiling SFML with VC++ i have gotten some wierd errors:

Code: [Select]
Build Log
 
Rebuild started: Project: Carperon, Configuration: Debug|Win32


Command Lines
 
Creating temporary file "c:\Users\Francois\Desktop\Carperon\Carperon\Debug\RSP00000152244820.rsp" with contents
[
/Od /D "SFML-DYNAMIC" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP .\main.cpp
]
Creating command line "cl.exe @c:\Users\Francois\Desktop\Carperon\Carperon\Debug\RSP00000152244820.rsp /nologo /errorReport:prompt"
Creating temporary file "c:\Users\Francois\Desktop\Carperon\Carperon\Debug\TMP00000252244820.tmp" with contents
[
1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\Carperon.exe.embed.manifest"
]
Creating command line "rc.exe /fo".\Debug\Carperon.exe.embed.manifest.res" c:\Users\Francois\Desktop\Carperon\Carperon\Debug\TMP00000252244820.tmp"
Creating temporary file "c:\Users\Francois\Desktop\Carperon\Carperon\Debug\RSP00000352244820.rsp" with contents
[
/OUT:"C:\Users\Francois\Desktop\Carperon\Debug\Carperon.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\Carperon.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\Francois\Desktop\Carperon\Debug\Carperon.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /MACHINE:X86 sfml-system.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

".\Debug\main.obj"

".\Debug\Carperon.exe.embed.manifest.res"
]
Creating command line "link.exe @c:\Users\Francois\Desktop\Carperon\Carperon\Debug\RSP00000352244820.rsp /NOLOGO /ERRORREPORT:PROMPT"
Output Window
 
Compiling...
main.cpp
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.
Linking...
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
C:\Users\Francois\Desktop\Carperon\Debug\Carperon.exe : fatal error LNK1120: 1 unresolved externals
Results
 
Build log was saved at "file://c:\Users\Francois\Desktop\Carperon\Carperon\Debug\BuildLog.htm"
Carperon - 2 error(s), 0 warning(s)


^ theres the build log in VC++ if anyone wants to check it out^


also i think im going to try openGL anyways, just wondering about that okay i asked for earlier(compatability)
Title: Using Directx with SFML
Post by: Laurent on January 10, 2011, 08:26:34 am
Quote
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function

You need to have WinMain as the entry point (replacing main), or link to sfml-main.
Title: Using Directx with SFML
Post by: molmasepic on January 10, 2011, 07:03:21 pm
Hi again.

I have decided to use OpenGL with SFML(just because they can go together)

but im having a hard time finding the library itself

anyone know the correct site i can find it at?
Title: Using Directx with SFML
Post by: Laurent on January 10, 2011, 07:07:21 pm
You already have it, just link to GL (Linux) or opengl32 (Windows).
Title: Using Directx with SFML
Post by: molmasepic on January 10, 2011, 07:16:33 pm
wow i feel slow... thanks xD

 :D


EDIT: Hey i have been wondering if there are any good tutorials to use SFMl and OpenGL together. im looking right now, but if anyone has any good ones reply here

thanks :D
Title: Using Directx with SFML
Post by: molmasepic on January 12, 2011, 10:56:12 pm
sorry bout doublepost...

wondering about where i could find a proper tutorial for this(one that includes adding textures/models/etc...

anyone got one let me know :D
Title: Using Directx with SFML
Post by: Nexus on January 12, 2011, 11:43:54 pm
There's an OpenGL example in the SFML SDK. And the OpenGL-specific things can be learned from OpenGL books/tutorials...
Title: Using Directx with SFML
Post by: molmasepic on January 13, 2011, 01:06:23 am
ok so i CAN use opengl tutorials.

and all the libraries i need for that are in the SDK?(just making sure xD)

and ill download that SDK again(lost it before lol)

thanks again
Title: Using Directx with SFML
Post by: eXpl0it3r on January 19, 2011, 03:46:29 pm
I know you don't wanna use DX anymore but since this is the topic I'm still gonna add my 'knowledge'. :D
I've programmed in the past a bit with DX and as far as I know, you won't be able to compile with MinGW for any DX app, since DirectX is based on the whole Microsoft stuff.
But with the VC++ Compiler you would probably still be able to use SFML, since DirectX only needs to know little about the window, which you would have to extract probalby by hand. ;-)
Then again when we look at what SFML provides and what DX can do, I think it doesn't make sense to use both in one application. So you got it right either use SFML + OpenGL and be cross-platform (if you programm right) or use DirectX and stay on Windows. :D

eXpl0it3r
Title: Using Directx with SFML
Post by: Silvah on January 19, 2011, 05:01:24 pm
Quote from: "eXpl0it3r"
I've programmed in the past a bit with DX and as far as I know, you won't be able to compile with MinGW for any DX app, since DirectX is based on the whole Microsoft stuff.
It's not true, MinGW works just fine with the official DirectX SDK.
Title: Using Directx with SFML
Post by: eXpl0it3r on January 19, 2011, 10:00:00 pm
Quote from: "Silvah"
Quote from: "eXpl0it3r"
I've programmed in the past a bit with DX and as far as I know, you won't be able to compile with MinGW for any DX app, since DirectX is based on the whole Microsoft stuff.
It's not true, MinGW works just fine with the official DirectX SDK.


Ah okay didn't know that! ;-)
Title: Using Directx with SFML
Post by: mercurio7891 on January 22, 2011, 06:28:38 pm
To the OP, if you are still really keen on using Directx and windows. You can just create the Win32 code and read the input via RawInput. If you are targeting only a windows platform, DX is as good as in can get. With DX11 it can automatically scale to user hardware base on D3D_FEATURE_LEVEL. So no worries if user is only have DX9 hardware.

On the other hand. If you want to achieve cross platform, then you should use SFML and Opengl. Since opengl is supported on almost all platform, it would be easy to port code. i.e. you don't have to support 2 renderers. :)

However in my opinion, currently opengl is slightly lagging behind DX in terms of capabilities. e.g HLSL can now allow a certain degree of OO-ness in it which reduce the need of uber shaders, along with other stuff. It is not much a big deal since opengl would eventually catch up :)

Opengl and DX are basically just playing a game catch up with each other. To date I think DX is at an edge ever since dx10.1 and dx11 came out. Before that opengl was leading =) I am sure this cycle repeats itself. :D

regards