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

Author Topic: MFC and SFML Window problem  (Read 29478 times)

0 Members and 3 Guests are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MFC and SFML Window problem
« Reply #15 on: March 27, 2014, 08:57:01 am »
You didn't understand the idea behind the complete and minimal code ;)

Please read the given links carefully.
Laurent Gomila - SFML developer

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #16 on: March 27, 2014, 09:10:35 am »
I did, but should I also post all 13 files, plus the .sln file? Because in order to have a working complete and minimal code you would need all of these files  ??? ;D

I can't modify the code to be in main(), because that will remove the problem part of the project, which is the MFC CDialog with SFML.

I can post all of the files, but I though it would be easy to understand to simply upload the demo project.
« Last Edit: March 27, 2014, 09:16:22 am by xumepoc »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MFC and SFML Window problem
« Reply #17 on: March 27, 2014, 09:17:04 am »
Quote
I did
I don't think so. The explanations clearly state that there's no point trying to show small parts of your code, because they are incomplete, or the whole thing, because it will be too much. You must write a new code that only reproduces the problem, and nothing else. We don't care about your original project.

Can't you simply declare a CDialog, the corresponding sf::RenderWindow and call SetWindowPos on it? Why would it require more than a few lines of code?
Laurent Gomila - SFML developer

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #18 on: March 27, 2014, 09:32:57 am »
Because it is a CDialog project. Than means that in order to have just a simple Window, you need:

Resource.h
SFML_TEST.h
SFML_TESTDlg.h
stdafx.h
targetver.h

SFML_TEST.rc
SFML_TEST.rc2

SFML_TEST.cpp
SFML_TESTDlg.cpp
stdafx.cpp

All these files are generated by VS when you open a new, clean CDilaog project. On top of that is my simple SFML_CL class.

I can't simply convert that in a few lines of code or in a simple main(), simply because it will not work. And you will not see the problem as it is now.

The explanations states
It is important that:
the code is complete, so people can test it
the code is as simple as possible, the best is one main() with all the code inside -- people don't want to setup a complex project just to test your code
the code reproduces the initial problem
the application doesn'
t depend on external resource files (unless it's related to the problem)

Well if some can explain how to convert a MFC CDialog project in a single simple file I would more then happy to do it. Again the problem is in the interconnection of MFC and SFML, so without the minimal CDilaog project files I can't show you anything useful that will help my problem.

I am really not making an argument here, just want to explain that I can't do what you what from me via a simple 20 lines program.
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MFC and SFML Window problem
« Reply #19 on: March 27, 2014, 12:59:42 pm »
I understand. I had forgotten that MFC was such a hell...

Well, from what you showed previously, everything looks ok. But it will be hard to investigate further, since we can't test your code. Can't you simply switch to a more modern GUI library? You'll save yourself a lot of troubles :P
Laurent Gomila - SFML developer

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #20 on: March 27, 2014, 01:13:12 pm »
Well I am looking at Qt, in order to fully leave MFC, the problem is that project so far is more then 50 classes with average of 2000 - 3000 lines per class. Sure most of them are not related to MFC, except the CString and CArray used in them, but it will still take me too much time to port it at once.

The problem I am having with MFC is that I draw heavily on the screen. I have CArrays with more then 30000 elements on the screen at any one time. So in MFC using GDI it is ok, I get 40-60 fps, but I don't have all the bells and whistle OpenGL and Direct2D. Direct2D's performance is just awful, 15fps.

With SFML I get 70-80 and have all the great stuff like anti-aliasing, alpha and so on so it would have worked just fine, until I port everything to Qt, except the few issues I am having now. I also want to say that I use my one draw interface, so I don't use MFC for the Windows forms or anything like that. I will use SFML the same way, drawing my own windows, buttons and so on.


No to the problem, I can upload on my server a zip with a small demo program with the same problem that I have explain in the first post, if some would want to spend his free time to check it.

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #21 on: March 27, 2014, 01:48:07 pm »
Here is the link to the VS2008 project

https://app.box.com/s/b7s8n0z2lvw4un82wa1l

It is a simple CDialog Window that draws a rectangle using SFML. When you click with the mouse (strangely it requires to click to work) the window is resized and it's position is changed. You can see that the drawn rectangle gets cut in the window. So I am guessing the SFML RenderWindow is not resized.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: MFC and SFML Window problem
« Reply #22 on: March 27, 2014, 01:55:34 pm »
is more then 50 classes with average of 2000 - 3000 lines per class.
Are you reinventing the wheel a hundred times or why do you have 50 classes and they still have 2000-3000 lines of code? If you class exceeds 1000 lines, it's a big indicator that your code needs a heavy refactoring. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #23 on: March 27, 2014, 01:59:38 pm »
Because it is a aviation program generating flight envelope profiles and trajectory predictions. It is not that simple as you think. ;) ;) ;)

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #24 on: March 29, 2014, 08:00:30 am »
As I can see that this may not be overcome I have some questions.

1. I am looking at Qt and it looks quite interesting so I may switch to it, but can I have the following thing:
 I need SFML as a moving map only, I don't need it for the UI it self, just to draw with SFML inside of one window. Is this possible? I can draw my own UI (I am doing that in MFC anyway), but Qt can make it easier if I can use it for the UI and SFML just for the moving map on the main window.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MFC and SFML Window problem
« Reply #25 on: March 29, 2014, 08:39:22 am »
Yes, you can easily embed a sf::RenderWindow into a QWidget.
Laurent Gomila - SFML developer

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: MFC and SFML Window problem
« Reply #26 on: March 29, 2014, 08:42:24 am »
Thanks for the fast reply. Is this tutorial still valid for SFML 2.1 and  Qt 5.2 http://www.sfml-dev.org/tutorials/1.6/graphics-qt.php?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MFC and SFML Window problem
« Reply #27 on: March 29, 2014, 03:03:06 pm »
As far as I know, yes. Of course you have to adapt the naming of SFML functions.
Laurent Gomila - SFML developer

delio

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: MFC and SFML Window problem
« Reply #28 on: March 29, 2014, 03:47:23 pm »
Warning that Qt can't receive any event from SFML. except the mouse click event.

http://www.qtcentre.org/threads/52568-Qt5-native-messages-not-propogated

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: MFC and SFML Window problem
« Reply #29 on: March 29, 2014, 04:39:46 pm »
If you use Qt, use Qt events ;)
Laurent Gomila - SFML developer

 

anything