New Release D3D9Client Development

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
D3D9Client Beta 23.10 - forRev 55

Here's a new version for testing.

This version contains a brand new Sketchpad2 interface and gcAPI which is a new revision of the old OGCI. So, any application using the ogci need to be slightly edited and recompiled. ogci is obsolete and no longer supported.

New Files:

Include/gcAPI.h
Include/Sketchpad2.h
Lib/gcAPI.lib
Doc/gcAPI.chm

gcAPI.lib is a static link library containing a code to establish a connection with a graphics client. Linking gcAPI.lib to an application does not make it depended on graphics clients. Applications still do work without having client installed.

Sketchpad2 contains blitting functions, mesh rendering, world transformations and some clipping functions. Changes to the Sketchpad2 can still happen and any application using it needs to be recompiled.

gcAPI and Sketchpad2 is still an Alpha state so some bugs may exists.
 

Attachments

  • D3D9ClientBeta23_10-forRev55.zip
    2 MB · Views: 58

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,847
Reaction score
362
Points
83
Hi jarmo,

I can't compile the current trunk. Have you missed to add "D3D9Pad2.cpp" ?
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
Hi jarmo,

I can't compile the current trunk. Have you missed to add "D3D9Pad2.cpp" ?

Yes, it would seem that I have, sorry. It's added now.

EDIT: There seems to be an issue with gcAPI.lib sometimes it's giving some warnings about different compiler settings. What should we do about it ?

Code:
1>gcAPI.lib(gcAPI.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:_MSC_VER=1900' encountered; ignored
1>gcAPI.lib(gcAPI.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=0' encountered; ignored
1>gcAPI.lib(gcAPI.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:RuntimeLibrary=MT_StaticRelease' encountered; ignored
1>gcAPI.lib(gcAPI.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0' encountered; ignored

I am working on a few demo applications using the gcAPI but it will take a while.
 
Last edited:

Enjo

Mostly harmless
Addon Developer
Tutorial Publisher
Donator
Joined
Nov 25, 2007
Messages
1,658
Reaction score
6
Points
38
Location
Hildesheim, Germany
Website
www.enderspace.de
Hello Jarmo,

Interfacing and standardizing is always a good thing.
Could you prepare also a demo for my application? My current code is the following:
PHP:
TopoMap::TopoMap(int width, int height)
{
    if (!ogciEnabled())
        ogciInitialize();
    W = width; H = height;
    // W and H must be even, or the surface doesn't get redrawn.
    if (W%2 != 0) W--;
    if (H%2 != 0) H--;
    /*...*/
    //m_surface = oapiCreateSurface(W, H);
    m_surface = ogciCreateSurfaceEx(W, H, OAPISURFACE_TEXTURE|OAPISURFACE_RENDERTARGET); // Using Jarmo's stuff
    if (m_surface)
        oapiColourFill (m_surface, 0);
}
TopoMap::~TopoMap()
{
    if (m_surface)
        oapiDestroySurface(m_surface);
}

void TopoMap::Draw(oapi::Sketchpad *skp)
{
    if (!m_surface)
        return;
    ogciSketchBlt(skp, m_surface, 0, 0); // Jarmo's blitting
    //oapiBlt(skp->GetSurface(), m_surface, 0, 0, 0, 0, W, H); // No effect, as the DC is locked.
}
 

kuddel

Donator
Donator
Joined
Apr 1, 2008
Messages
1,847
Reaction score
362
Points
83
There seems to be an issue with gcAPI.lib sometimes it's giving some warnings about different compiler settings. What should we do about it ?
Providing a static link library that is compatible with (almost) all compiler settings is a problem I was facing too :(
I did not get to a satisfying solution though.
Maybe some other forum member (martins?!) can give hints.

By the way: I don't think that setting the generated libs under svn control is a good idea. Each time you build, these files get changed. There's nothing you can do about it. It is better to keep them out of source-control and add them to the build_release.bat script.
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,010
Reaction score
1,643
Points
188
Website
github.com
Small bug report: the D3D9 sketchpad->Pixel() function has the color components in the wrong order, I say red and it prints blue and vice-versa.

---------- Post added 06-16-16 at 12:39 AM ---------- Previous post was 06-15-16 at 06:30 PM ----------

One thing I can't wrap my head around is why does a rectangle in sketchpad with "0-height" (i.e. y0 = y1) shows up as 2 lines on the screen? In GDI it showed up as nothing. I concede that an argument can be made for such a rectangle to be shown as either 1 or 0 lines, but not for 2.
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,010
Reaction score
1,643
Points
188
Website
github.com
Another bug: Sketchpad::Ellipse() doesn't use the selected brush and just leaves the inside of the shape as it was.
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,010
Reaction score
1,643
Points
188
Website
github.com

I don't think so...
According to the sketchpad documentation:
Code:
/**
	 * \brief Pen constructor.
	 * \param style line style (0=invisible, 1=solid, 2=dashed)
	 * \param width line width [pixel]
	 * \param col line colour ([B]format: 0xBBGGRR[/B])
	 */
	Pen (int style, int width, DWORD col) {}
Code:
/**
	 * \brief Draw a single pixel in a specified colour.
	 * \param x x-coordinate of point [pixel]
	 * \param y y-coordinate of point [pixel]
	 * \param col pixel colour ([B]format: 0xBBGGRR[/B])
	 */
	virtual void Pixel (int x, int y, DWORD col) {}
The component order for the Pixel() function should be the same as the one used for the Pens and Brushes.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
Small bug report: the D3D9 sketchpad->Pixel() function has the color components in the wrong order, I say red and it prints blue and vice-versa.

---------- Post added 06-16-16 at 12:39 AM ---------- Previous post was 06-15-16 at 06:30 PM ----------

One thing I can't wrap my head around is why does a rectangle in sketchpad with "0-height" (i.e. y0 = y1) shows up as 2 lines on the screen? In GDI it showed up as nothing. I concede that an argument can be made for such a rectangle to be shown as either 1 or 0 lines, but not for 2.

These two issues should be fixed now.

Here's a new build that implements a new Sketchpad2::DrawMeshGroup() call to render from a template meshes loaded with oapiLoadMeshGlobal() and should support all mesh editing functions provided by Orbiter API. Although, this function isn't tested yet. DrawSketchMesh() is tested and should be operational.

Also, note that all colors used in Sketchpad are in a format 0xAABBGGRR with an alpha channel. Due to backwards compatibility issues alpha value 00 will be automatically replaced with FF to provide opaque results.

I haven't looked to the Ellipse() issue yet, but soon I will.
 

Attachments

  • D3D9ClientBeta23_11-forRev55.zip
    2 MB · Views: 52

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
Here's a pre-build debug build of the client for Urwumpe to track down a CTD. It would be important to have the module address space visible like in the screen shot and the top most D3D9 related entry selected from the call stack displaying the disassembly for it.

The trick is that I can't do any changes to my local build to keep the build in sync. Otherwise, the address space would change.
 

Attachments

  • D3D9Client_dbg.zip
    920.3 KB · Views: 8
  • debug.png
    debug.png
    85.5 KB · Views: 20

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
36,881
Reaction score
1,537
Points
203
Location
Langendernbach
Soo ... fresh from a test: It clearly seems to be unrelated to the D3D9Client, it looks like a problem in the beta, happening directly in the oapiGetTextureHandle function.

picture.php


I would interpret this as: The texture table of the VC mesh is a NULL pointer in the structure that orbiter beta uses and thus, the 6th element can't be addressed.

Instruction|Comment
mov eax,dword ptr [esp+8]| EAX is set to the DWORD containing the one-based texture index
mov ecx,dword ptr [esp+4]| ECX is set to the MESHHANDLE
dec eax| Make texture index zero-based
cmp eax,dword ptr [ecx+10h]| compare texture index to number of textures in mesh
jae 004A2955 | When bigger or equal, branch beyond the following code lines
mov ecx,dword ptr [ecx+14h]| Load address of texture table
mov eax,dword ptr [ecx+eax*4]|Load address of the texture

I would say, something went AWOL when loading the template mesh of the VC. Nothing found in the log though. Sorry for causing so much wind on your end, it seems like a deeper problem in Orbiter with the old mesh.
 

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
Continuing on the post-process side of things, I got myself a pretty good screen space lens glare shader, using a positional approach rather than a image-based approach: https://www.shadertoy.com/view/MdGSWy (click on the display to change the flare's positions).

The size and brightness can be changed (and size is cycling through 50% to 150% in the shadertoy example), and that way the sun sprite could be removed, as this would replace it with a screen space generated one.
I just need to find out how to transform a global 3D position into a 2D screen space position, and also how to shoot rays (yeah!) to test if the sun is being occluded or not.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
Sorry for causing so much wind on your end, it seems like a deeper problem in Orbiter with the old mesh.

No problem. Might be good idea to report that to Martin.

---------- Post added at 21:19 ---------- Previous post was at 21:01 ----------

I just need to find out how to transform a global 3D position into a 2D screen space position, and also how to shoot rays (yeah!) to test if the sun is being occluded or not.

Where do you need to do that ? Somewhere in a C++ code or in HLSL shader ?

One way to do something like that is to use Sketchpad to draw the glares. You can take a look about the "Orbits" add-on from "Orbits came to Orbiter" thread how it's using Sketchpad to draw in a planetarium view. It's also possible to draw under and over Orbiter's HUD. It would be possible to add a support to draw outside VC (not currently implemented).

I can also make the view-projection matrix available for post-processing shader to compute a screen location from a 3D vector if needed.

To get a screen space coords from a 3D vector you need to multiply 3D vector with View-Proj-Matrix and divide .xy components with .w component.

There also exists gcWorldToScreenSpace() function.

The sun occlusion is the biggest problem especially since the depth-buffer is unreadable.

Hardware occlusion queries could be one solution. Might be possible to add a feature to a Sketchpad to check a visibility of a graphics that was drawn. But it's too early to say for sure.

I was also hoping to take some vocation from the Orbiter during the Summer.
 
Last edited:

SolarLiner

It's necessary, TARS.
Addon Developer
Joined
Jun 14, 2010
Messages
1,847
Reaction score
2
Points
0
Location
404 ROAD NOT FOUND
Where do you need to do that ? Somewhere in a C++ code or in HLSL shader ?
Code is GLSL (seen on the right side in the shadertoy page), so it would be a post-processing HLSL shader.

To get a screen space coords from a 3D vector you need to multiply 3D vector with View-Proj-Matrix and divide .xy components with .w component.
That I think could be done from the module, then a float2 could be sent to the shader.

The sun occlusion is the biggest problem especially since the depth-buffer is unreadable.
Well that would be where ray-shooting be interesting: if it doesn't hit anything then we assume there's nothing blocking sunlight.

I was also hoping to take some vocation from the Orbiter during the Summer.

Well go do that! Real life comes first, I'll try on my own to get a version with the new shader working. That'll take a bit longer though :lol:
 

indy91

Addon Developer
Addon Developer
Joined
Oct 26, 2011
Messages
1,159
Reaction score
457
Points
98
I am using Orbiter 2010 and the most recent (I think) D3D9 Client for it, version 16.4. Recently Orbiter fairly randomly displays the "Connection to Direct3DDevice is lost Exit the simulation with Ctrl+Q and restart." message and I have to close the simulation, in fullscreen and window mode. It really is quite annoying, because it stops me from using Orbiter reliably. The associated error message in the Orbiter.log is:

Invalid Window !! RenderWndProc() called after calling clbkDestroyRenderWindow() uMsg=0x491B20

I have Windows 10 and am using the GTX 970, so it seems like a similar error to this one: http://orbiter-forum.com/showthread.php?p=525781&postcount=3361 Usually it happens when using timewarp and having alt-tabbed to another window, if that is any help.

Maybe a new driver issue? It started happening about a week ago, but I hadn't used this PC for a few weeks, so no idea how long the issue actually has been around.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
Invalid Window !! RenderWndProc() called after calling clbkDestroyRenderWindow() uMsg=0x491B20

I have Windows 10 and am using the GTX 970, so it seems like a similar error to this one: http://orbiter-forum.com/showthread.php?p=525781&postcount=3361

These two issues should have anything to do with your problem. Alt-Tab is not supported in so-called "True Fullscreen" mode but should work in every other mode. I don't recall seeing any reports like this before. Could there be an application running on a background that could interference with the D3DDevice ?

Ctrl + Alt + Del is also known to cause a lose of device in every display mode.

Anyone else having a similar issues ?
 

indy91

Addon Developer
Addon Developer
Joined
Oct 26, 2011
Messages
1,159
Reaction score
457
Points
98
These two issues should have anything to do with your problem. Alt-Tab is not supported in so-called "True Fullscreen" mode but should work in every other mode. I don't recall seeing any reports like this before. Could there be an application running on a background that could interference with the D3DDevice ?

Ctrl + Alt + Del is also known to cause a lose of device in every display mode.

Anyone else having a similar issues ?

Yeah, Ctrl+Alt+Del is a reliable way to trigger it. I am not using the "True Fullscreen" mode and as I said, it's all fairly random and appears when I had Alt-Tabbed to another window and return to Orbiter. I'm not sure what other application would cause it, but maybe it is something Windows 10 specific and similar to why Ctrl+Alt+Del triggers it? All that usually runs at the same time is Firefox, Visual Studio and Adobe Reader...
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,391
Reaction score
466
Points
83
Website
users.kymp.net
First of all, Has anyone noticed a change in a frame rate in latest build compared to 3-4 builds back ? There is significant change in frame rate in my end, not sure where it's coming from. A change in driver settings maybe.


All that usually runs at the same time is Firefox, Visual Studio and Adobe Reader...

That's actually "rings the bell" (not sure if it's said right) Could it be a web browser plugin like add-blocker or something like that. Pop-up windows maybe ?

Nothing as changed in client side and I am out of ideas, so there's nothing I can do.

I am running Orbiter, VS and adobe reader open all the time so they are Ok.
 
Top