Jump to content

LEAVU development phase, coding MPCD graphics


RvEYoda

Recommended Posts

  • Replies 784
  • Created
  • Last Reply

Top Posters In This Topic

I've tried all sorts of workarounds and different rendering modes, but there

seems to be an issue with Gtx280 and gtx260 cards.

When running lockon on primary monitor and creating a dx9 engine on a second

monitor, these graphics cards show black flickering ingame.

hd4870s and other ATi cards dont seem to show it.

 

RIght now there is no obvious solution. This could be a driver

or architecture issue or something else.

 

Im basically just creating the dx9 device like instructed in the

MIcrosoft DIrectX SDK documentation.

 

I will probably switch to an OpenGL implementation of LEAVU eventually

to avoid things like this tbh....but that might also cause issues if

we are unlucky :P. Right now the advice I have for people with gtx260 or 280

is to run LEAVU on a different machine (like your laptop) and lockon on the main machine.

 

I'm also having trouble recording a video on ingame action.

I havent found any software that lest me record the second monitor at the same

time as fraps records the primary monitor. well....I found one, but it records

wrong colors ;P


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Thanks for the update Yoda. If you continue as is maybe in the future the problem will correct itself with new drivers from Nvidia. So this doesn't happen with other Nvidia cards? Only GT series?

 

honestly, all my friends with nvidia cards that tried LEAVU used GT..2..0 series,

so I cannot tell. But remembering the tests we did, Crunch, you and me,

It would seem any basic Dx9 engine on a second monitor will cause GT..2..0 series

from nvidia to display black flicker in Lo.

 

Another possibility is that instanciation of Dx9 devices from different programs

simply isn't possible if one of them is in full screen. (Note though that

the single app may create multiple devices), or something along these lines.

 

http://msdn.microsoft.com/en-us/library/bb147220(VS.85).aspx

 

Regardless....I am now almost certain I will switch to OpenGL

EDIT: Before fully going OpenGL I ask if anyone has any ideas

or if some dev just accidently saw this page and had any ideas.

 

IF anyone has any suggestions this is how I initialize the device :

 


   DXengine::DXengine(HWND hWnd, const int& _resX, const int& _resY, int* _aaptr):
           oldAA(0),        //Memorize previously selected AA level
           thisWindow(hWnd),//The window handle of our d3d sub window (may update with other calls)
           resX(_resX),    //Resolution of our d3d sub window
           resY(_resY),    //Resolution of our d3d sub window
           AAptr(_aaptr) { //User will select new AA levels from time to time, here to access that info
       make_edge_RECTs();    //Creates the rectangles holding menu names
       initD3D();            //Initializes the d3d object(=interface?) and d3d device    
   }

   void DXengine::initD3D() {
       d3d = Direct3DCreate9(D3D_SDK_VERSION);        // create the Direct3D interface
       ZeroMemory(&d3dpp, sizeof(d3dpp));            // clear out the struct for use
       d3dpp.Windowed = TRUE;                        // program windowed, not fullscreen
       d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;   // discard old frames
       d3dpp.hDeviceWindow = thisWindow;            // set the window to be used by Direct3D
       d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
       d3dpp.BackBufferWidth = resX;
       d3dpp.BackBufferHeight = resY;    
       update_device();
   }

This function is called when the device is created/unminimized/resolution changed

 

   void DXengine::update_device() {        

       // Default to no AA
       bool SupportsAA = false;
       d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;

       if (*AAptr==2 && SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, 
                   D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, TRUE, 
                   D3DMULTISAMPLE_2_SAMPLES, NULL ) ) ) {
           d3dpp.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES;
           SupportsAA = true;
       }
       else if (*AAptr==4 && SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, 
                   D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, TRUE, 
                   D3DMULTISAMPLE_4_SAMPLES, NULL ) ) ) {
           d3dpp.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES;
           SupportsAA = true;
       }
       else if (*AAptr==8 && SUCCEEDED(d3d->CheckDeviceMultiSampleType( D3DADAPTER_DEFAULT, 
                   D3DDEVTYPE_HAL , D3DFMT_X8R8G8B8, TRUE, 
                   D3DMULTISAMPLE_8_SAMPLES, NULL ) ) ) {
           d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;
           SupportsAA = true;
       }

       d3d->CreateDevice(D3DADAPTER_DEFAULT, // create a device class using this information and the info from the d3dpp stuct //D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DCREATE_HARDWARE_VERTEXPROCESSING
                       D3DDEVTYPE_HAL,
                       thisWindow,
                       D3DCREATE_HARDWARE_VERTEXPROCESSING, //HARDWARE,SOFTWARE,D3DCREATE_HARDWARE_VERTEXPROCESSING,D3DCREATE_SOFTWARE_VERTEXPROCESSING
                       &d3dpp,
                       &d3ddev);
//Some fonts of mine for mfds
       D3DXCreateFont(d3ddev, 
                       14, 
                       0, 
                       650,  
                       1,   
                       false,  
                       DEFAULT_CHARSET,   
                       OUT_DEFAULT_PRECIS, 
                       DEFAULT_QUALITY, 
                       DEFAULT_PITCH | FF_DONTCARE,   
                       L"Verdana", 
                       &menufont_normal); 
       D3DXCreateFont(d3ddev,
                       12,   
                       0,   
                       450,   
                       1, 
                       false,  
                       DEFAULT_CHARSET,  
                       OUT_DEFAULT_PRECIS,
                       DEFAULT_QUALITY, 
                       DEFAULT_PITCH | FF_DONTCARE,
                       L"Verdana", 
                       &screenfont_normal);   
       D3DXCreateFont(d3ddev,  
                       15,  
                       0,    
                       1000,
                       1,   
                       false,  
                       DEFAULT_CHARSET,   
                       OUT_DEFAULT_PRECIS, 
                       DEFAULT_QUALITY, 
                       DEFAULT_PITCH | FF_DONTCARE,  
                       L"Verdana",  
                       &screenfont_large);   

       if (SupportsAA && d3ddev!=NULL) { d3ddev->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS,TRUE); } //Activate AA

   }

And this is how I draw a frame

 


   // this is the function used to render a single frame
   void DXengine::render_frame(void) {
   
       if (d3ddev==NULL) return;

       //Initialize new back buffer
       d3ddev->BeginScene();    // begins the 3D scene
       d3ddev->SetFVF(CUSTOMFVF);
       
       DXengine* me = this; //Cause the following functions are overloaded by DXengine_MPCD class
       me->paint_black();  // This currently makes one call : d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
       me->paint_backuffer(); //overload this function to draw bottom layer, this function starts the active MFD page's own draw calls

       //Finish drawing this frame
       d3ddev->EndScene();    // ends the 3D scene
       d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen

   }
   

Also replaced the rendering with :

(which also gave same gt 260,280 issues)

 


   // this is the function used to render a single frame
   void DXengine::render_frame(void) {
   
       if (d3ddev==NULL) return;

       //Initialize new back buffer
       d3ddev->BeginScene();    // begins the 3D scene

       d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
       //As you see it doesnt draw anything, just clears buffers, screen, makes it ready for hte next frame
       //problem persists even if I remove the above line write my own naive Clear method that just draws a black 
       // square over the bb to clear it. ANY operatinon BB seems to mess with gt 260 280 in lockon

       //Finish drawing this frame
       d3ddev->EndScene();    // ends the 3D scene
       d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen

   }
   


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

I don't know much Direct X but I do know OpenGL pretty well (although I haven't done WGL for a very long time), so can help a little if you post questions here. First thing to decide is which OpenGL model you'll program to, 1.0 (fixed function pipeline), 2.0 (programmable vertex and fragment[pixel] shaders), or the spanking new 3.0 (which doesn't have great support yet).

 

However, I'm surprised you want to use a 3D library for what appears to be essentially a 2D application. If you want to learn how to do 3D that's one thing, but won't it slow you down getting LEAVU out the door, since it seems there is plenty of other stuff to do? Also, I'll re-iterate that the Java 2D library does very advanced compositing (it was designed by Adobe as well as Sun) - also, ever since Java 1.6.10 it fully and transparently hardware accelerated (DirectX on Windows and OpenGL shaders on all other platforms) - even for stuff like filtering/convolutions etc.

 

I'm not suprised the ATI Radeon HD works better than the GTXes. That's my experience as well (with LockOn at least). Not only fewer visual defects with ATI but also hassle-free ALT-TAB as well. I never miss the opportunity to remind Crunch he should have bought a HD 4870 for less money than his GTX. Ain't you lucky, eh Crunch? :)


Edited by Moa
Link to comment
Share on other sites

Its just that I really like doing it from the bottom up sometimes.

I make a principle way of drawing a line, triangle, box and circle, and then I

make variants of these and make it further high level.

 

Also I want it to use as little CPU power as possible. And I think its fun

to learn the low level controls of these things :). Mostly what worries me

in gui systems is performance. With a HW accellerated 3D engine I was

thinking "if this system can handle thousands of surfaces on screen

at the same time, then just a few 10s should be piece of cake low CPU"

(and yes the gui part of leavu currently is below 1% cpu ;))

 

Also I will not switch from cpp at this point. It would be too much work

rewriting the entire thing. Also I dont have a clue on how to work with JNI

which I would need to create the necessary window styles. I tried some

tutorial of it, but honestly I couldnt even understand half of it .

 

now if you accidently helped me so I wouldnt need to worry about the JNI part,

I MIGHT go back to java for newer versions . But at the same time, given that I need

to use JNI it will be platform dependent anyway (unless someone makes a library

I can load on a diff platform)....so :P.....Tbh......i'd just like to keep cpp

 

Moa, catch me on msn or ICQ if you got time!


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

What are the flags you need to SetWindowPos? Do you want "always on top behaviour" for a window? You don't need JNI for that.

 

If you want always on top then use java.awt.Window.setAlwaysOnTop(true). This works for Swing's JFrame as well (which is derived from awt.Window). If you use Swing you can also use the very attractive Nimbus theme and provided the client's JRE is 1.6.10 or later then it is all accelerated on the video card.

 

Then you get yourself a JoGL rendering context and you're doing OpenGL. All the calls of OpenGL are available. So you're getting Swing for the nice Nimbus themeing, button handling etc (so you don't have to do that work yourself) and integration with JoGL. Plus, with Java, you can have multiple threads going on and you won't leak resources all over the place. Java has come a very long way in client-side support in the last year.

 

Netbeans (free IDE from www.netbeans.org) has a graphical GUI builder and a plugin for JoGL that does syntax highlighting of GLSL (the OpenGL Shading Language, called 'slang').

 

Is Java fast enough? Well, I believe 90% of IL-2 was written in Java and the JVMs today are now very much faster (beating C and approaching Fortran for speed).

 

But if you still wanna stick with C++, no worries.

 

Oh yeah, congratulations on making the ED Testers Team. Its good to see your hard work recognised.


Edited by Moa
Link to comment
Share on other sites

The exception should not be touted as the rule. ;)

 

And no, JVMs aren't going to be beating C nor approaching FORTRAN in applications where overall performance matters. I've worked with HPC projects and Java doesn't cut the mustard ;)

 

Is Java fast enough? Well, I believe 90% of IL-2 was written in Java and the JVMs today are now very much faster (beating C and approaching Fortran for speed).

 

But if you still wanna stick with C++, no worries.

[sIGPIC][/sIGPIC]

Reminder: SAM = Speed Bump :D

I used to play flight sims like you, but then I took a slammer to the knee - Yoda

Link to comment
Share on other sites

The exception should not be touted as the rule. ;)

 

And no, JVMs aren't going to be beating C nor approaching FORTRAN in applications where overall performance matters. I've worked with HPC projects and Java doesn't cut the mustard ;)

 

Let's not start a flamewar, but INRIA (the French scientific supercomputing dudes) disagree with you.

http://blogs.sun.com/jag/entry/current_state_of_java_for

http://hal.inria.fr/inria-00312039/en

 

Plus, what Yoda wants is OpenGL not HPC, in which case JoGL is a thin wrapper. It is a different performance domain GG.

 

I agree Java is not perfect, but it is faster to get stuff done than C and fast enough performance if you know what you're doing.

Link to comment
Share on other sites

No I need a window that does not assume focus when clicked.

(Works fine in current leavu cpp version)

This is so we can have leavu on a diff monitor and click it(touch screen)

without lockon minimizing.

 

Honestly im not sure if setwíndowpos is the one that can do this.

I made a Cwindow (MFC) out of my window and added the extended

style :

 

from afxwin.h I use

 


CWnd::FromHandle(get_HWND(myControl->Handle))->ModifyStyleEx(0,WS_EX_NOACTIVATE,1)

the "myControl" object refers to the .net FORM that I used to make the app.

 

and get_HWND is a bad hack ;) :

 

   HWND get_HWND(IntPtr& _handle) {
       return reinterpret_cast<HWND>(_handle.ToPointer()); //get HWND from IntPtr, hopefully..
   }

Don't know about Java performance though.

I had bad results when I did the minor version of LEAVU (just the RWR sound system).

Now I have like 4-5 systems instegrated here in cpp with 3d

engine and sound system also, and getting nice performance.

 

However what I did enjoy with java was the simplicity of

creating threads, and it actually working according to documentation,

instead of the .net threads I made (yes i was lazy and didnt

look for other wierd thread libraries, shame on me!)

.NET feels like *Microsoft Java*, just that half the shit isnt there ;),

and if it's there it doesnt go by the documentation ...ouch!


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

In Java you call System.gc() This is advisory only (the runtime can choose to run the gc or not).

 

Depending on how recent the Java version is it can either cause a big or small pause (the brand new G1 collector is quite good).

 

C# is derived from a prototype language called 'Cool' that was essentially MS's Java implementation. So the similarity is not accidental.

 

Ok, I'll look into how to do input to window without grabbing focus (JNI if need be) ... will get back to you within 24-hrs from now.

 

If your C++ is working well enough (no leaks) then I can't see a reason to change - I was just suggesting in case you were looking at a change (eg. if you had threading issues).

Link to comment
Share on other sites

I couldn't see a Java way of getting focus without activating a window (there is plenty of focus/input support in the JDK but not activation management).

 

Rather than start with custom JNI I thought I might try out the JNA library (which is cross platform). See https://jna.dev.java.net/

 

Incidentally, it is a shame you got bad performance with sounds. I would suggest JOAL as a solution but haven't used it myself.

 

Will get back to you to let you know how it goes.

Link to comment
Share on other sites

Sounds were not the reason I had bad performance in java

 

And irrklang engine now supports java so I would use that. (its a really cool sound engine ;))

Regardless, ill see what this JNA is.

 

Oh, and if you have time looking into it.

What i need to do is to modify the window to have that extended window style. (see above post).

If you can do that in Java, then bling, I might go java again :P.

(my two main probs are then solved : no window activation when clicking and access to gc)


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

Yeah, I'm looking into it tonight when i get home from work (can't wait!) - last night could not as had to do computer fixit for a mate - you know how it is.

 

Netbeans has a profiler which helps sort out performance bottlenecks in your code (I think Eclipse may have one as well now, but I prefer Netbeans).


Edited by Moa
Link to comment
Share on other sites

Until two months ago the only "Java" I'd ever heard of was in Indonesia. I have absolutely no concept of what you guys are talking about. Just my two cents!

 

:thumbup: Java is a programming language. I agree though that this thread is not for the averige Joe anymore :laugh: I don`t understand what these two are talking about either. But be sure they know what they`re doing and the results are gonna be great. Keep it up!

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

Haven't managed to stop activation being switched yet, even using JNA calling SetWindowPos (in Windows' user32.dll).

 

 

Top get the HWND of the the JFrame I'm made this method which uses the undocumented call WComponentPeer.getHWnd(), since ever since Java 1.4 they disabled the Toolkit.getDefaultToolkit().getNativeWindowHandleFromComponent(component) way of getting it. Maybe I'm not getting the right HWND? I guess the way to test is to try render/print text to that hwnd.

 

/**

* Returns the Windows handle of the user-interface component.

*

* @param component the component to get the handle of.

*

* @return the Windows handle of the component.

*/

public long getWindowHandleFromComponent(Component component) {

ComponentPeer peer = component.getPeer();

WComponentPeer win32Peer = (WComponentPeer) peer;

 

long hwnd = win32Peer.getHWnd();

 

return hwnd;

}

 

I should check my assumptions: get mouse input without changing keyboard focus or z-order for LockOn?

Link to comment
Share on other sites

Ok furthermore,

I am now implementing DirectInput to detect keyboard (and soon also could be

joystick) input globally. I read the keyboard even when the application has no

focus. Remember this has to be done at close to driver level (like directinput) since lockon

assumes control over the keyboard.

 

I have no clue how to make an equivalent in Java.

I actually found some ways earlier to read keyboard globally by importing a DLL,

but like above it didnt do it enough low level, as lockon hooked/stole the keyboard.

 

To make a window not activate for example a forms application you can use afxwin.h and :

 


   HWND get_HWND(IntPtr& _handle) {
       return reinterpret_cast<HWND>(_handle.ToPointer()); //convert void* to HWND, hopefully..
   }

   void Set_NOACTIVATE(Control^ myControl) {
       CWnd::FromHandle(get_HWND(myControl->Handle))->ModifyStyleEx(0,WS_EX_NOACTIVATE,1);
   }

Maybe there is similar control for Java JNA?

 

For the moment, development is continuing in C++ ;).

 

You will also need the application instance in windows to bind directinput to it (if using that road),

for a forms app it can be retreived using for example. (some dangerous casts here)

 


   hInstance = (HINSTANCE)(GetWindowLongPtr( cwin, GWLP_HINSTANCE ));
   if (hInstance!=NULL ) {
       cout << endl << "Application HINSTANCE was retrieved";
   }

 

where cwin is my HWND


Edited by =RvE=Yoda

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

I found this for JNA

 

http://ochafik.free.fr/Java/src/jna/

 

Theck windowutils.java

if you want to try it has some utilities for handles and native calls etc

If you were wondering,

 

#define WS_EX_NOACTIVATE 0x08000000L

S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This generates the ultimate sparse matrix, an m-by-n all zero matrix. - Matlab help on 'sparse'

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...