I am using the DirectWrite API and I am implementing my own layout and text rendering engine. I have already created my IDWriteTextLayout object successfully. When I make the following call I receive an Access Violation error and I have no idea why:
DWRITE_LINE_METRICS m_lineMetrics;
UINT32 m_lineCount;
DX::ThrowIfFailed(
m_textLayout->GetLineMetrics(&m_lineMetrics,31,&m_lineCount)
);
I figured it out. I guess I was interpreting the documentation for the function incorrectly. You can pass either a pointer to a single DWRITE_LINE_METRICS structure or an array of DWRITE_LINE_METRICS structures.
Related
I am learning C++ and Direct3D11/Direct2D (on top of UWP) for fun, but am struggling getting my little test program to run. It throws an access violation (see below for exact exception) when I call CreateSwapChainForCoreWindow.
I used the D3D Device for other calls and they worked so I don't think that is the issue. The swap chain description is relatively straight-forward and the swap chain itself will be set in the call. So, I assume that the exception is because I am passing an incorrect pointer to the window but I can't solve it.
Exception:
Exception thrown at 0x00007FF8FE44F4E0 (Windows.UI.dll) in UWP D2D example v3.exe: 0xC0000005: Access violation executing location 0x00007FF8FE44F4E0.
Code snippet (https://github.com/cwebb95/Direct2D_cppwinrt):
ComPtr<IDXGISwapChain1> swapChain = nullptr;
DX::ThrowIfFailed(dxgiFactory->CreateSwapChainForCoreWindow(m_d3dDevice.Get(),
reinterpret_cast<IUnknown*>(&CoreWindow::GetForCurrentThread()),
&swapChainDescription,
NULL,
&swapChain));
I was able to solve my problem by changing the second parameter to:
static_cast<::IUnknown*>(winrt::get_abi(CoreWindow::GetForCurrentThread()))
from:
reinterpret_cast<IUnknown*>(&CoreWindow::GetForCurrentThread())
I am not knowledge enough yet to know why that fixed the problem, but I will research and hopefully figure it out (any leads on that question would be much appreciated).
I am working on augmented reality project. So the user should use the Webcam, and to see the captured video with a cube drawn on that frame.
And this is where I get stuck , when I try to use glBindTexture(GL_TEXTURE_2D,texture_background) method, I get error:
(
ArgumentError: argument 2: : wrong type
GLUT Display callback with (),{} failed: returning None argument 2: : wrong type
)
I am completely stuck, have no idea what to do . The project is done in Python 2.7 , am using opencv and PyOpenGl 3.1.0.
You can find code on this link :click here
Thanks in advance.
Interesting error! So I played around with your source code (by the way in the future you should probably just add the code directly to your question instead of as a separate link), and the issue is actually just one of variable scope, not glut or opengl usage. The problem is your texture_background variable does not exist within the scope of the _draw_scene() function. To verify this, simply try calling print texture_background in your _draw_scene() function and you will find it returns None rather than the desired integer texture identifier.
The simple hack-y solution is to just call global texture_background before using it within your _handle_input() function. You will also need to define texture_background = None in the main scope of your program (underneath your ##FOR CUBE FROM OPENGL comment). The same global comment applies for x_axis and z_axis.
That being said, that solution is not really that great. The rigid structure required by GLUT with all of these predefined glut* functions makes it hard to structure code the way you might want to in terms of initializing your app. I would suggest, if you are not forced to use GLUT, to use a more flexible alternative, such as pygame, pysdl2 or pyqt, to create your context instead.
I am attempting to iterate through the forms I have open in my application. I have found the documentation for FMX.Forms.TScreen.Forms, which looks like it can be used to accomplish my goal. However, I am confused on how I am supposed to use it.
At first I tried this in a function within my form's CPP file:
ShowMessage( Forms::TScreen::FormCount );
This produced the error 'Member TScreen::FormCount cannot be used without an object'
I figured that to mean that I need to attempt to access this property from my form, or from the global Application variable. I tried both
this->Forms...
Application->Forms...
and
this->TScreen...
Application->TScreen...
However, neither Forms nor TScreen exist within either of these objects.
How do I go about accessing Forms.TScreen.Forms?
The error gives you a clue:
Member TScreen::FormCount cannot be used without an object
TScreen is a class, not an object. FormCount is not a static member of the class, so you need an object instance of the TScreen class. And such an object is provided for you - the global Screen object:
ShowMessage( Screen->FormCount );
This is stated in the documentation:
FMX.Forms.TScreen
There is a global variable, Screen, of type TScreen, which is instantiated for use by any application with a GUI. Use Screen to obtain information about the current state of the screen in an application.
FMX.Forms.Screen
extern DELPHI_PACKAGE TScreen* Screen;
Here's what works well:
ShowMessage(Screen->FormCount);
Screen is a global object, like Application. The compiler said that FormCount is not static method or smth.
I thought this would be simple but I seem to have myself confused.
I have been learning C++ for some time now and thought I was getting the hang of it. I have moved over to the 'Visual' aspects of it, specifically MFC.
Basically I'm trying to pass a variable from a DLL into a simple static text box on a MFC application.
( This is a plugin for the game rFactor )
This is the code I have in the DLL file ( .hpp )
struct TelemInfoBase
{
float mEngineRPM; // engine RPM
}
And this is the code to put it into the Static text
SetDlgItemText(IDC_DRIVER_NAME, TelemInfoBase::mEngineRPM);
But I'm getting a 'illegal reference to non-static member' error
I assume I have to define a variable for the data to be stored in and then access that variable, but I can't quite get my head around how to do that.
Would anyone care to point me in the correct direction?
I am designing a game engine in DirectX 11 and I had a question about the ID3D11DeviceContext::IASetInputLayout function. From what i can find in the documentation there is no mention of what the function will do if you set an input layout to the device that has been previously set. In context, if i were to do the following:
//this assumes dc is a valid ID3D11DeviceContex interface and that
//ia is a valid ID3D11InputLayout interface.
dc->IASetInputLayout(&ia);
//other program lines: drawing, setting vertex shaders/pixel shaders, etc.
dc->IASetInputLayout(&ia);
//continue execution
would this incur a performance penalty through device state switching, or would the runtime recognize the input layout as being equivalent to the one already set and return?
While I also can not find anything related to if the InputLayout is already set, you could get a pointer to the input layout already bound by calling ID3D11DeviceContext::IAGetInputLayout or by doing an internal check by keeping your own reference, that way you do not have a call to your ID3D11DeviceContext object.
As far as I know, it should detect that there are no changes and so the call is to be ignored. But it can be easily tested - just call this method 10000 times each render and see how bad FPS drop is :)