PDCurses resize_term arbitrarily fails or succeeds - c++

I'm trying to resize the terminal window I've been printing in with PDCurses. It only works sometimes. Otherwise it just sets itself to the default size, not even returning an error.
Examples of sizes that work:
resize_term(50, 50);
resize_term(100, 100);
resize_term(51, 100);
resize_term(50, 51);
resize_term(2, 60);
Examples of sizes that don't work:
resize_term(51, 51);
resize_term(51, 50);
resize_term(100, 51);
resize_term(60, 2);
Does anyone know why these certain ranges of sizes don't work?
(Also, bear in mind that resize_term takes the width as the second argument, not the first)

I noticed that curses doesn't resize the terminal when it "thinks" it may go out of the bounds of the (physical, real world) screen.
Sorry for the lack of details, I don't know the underlying mechanics of this behaviour.
EDIT :
Here's a quote from the PDCurses documentation :
"resize_term() is effectively two functions: When called with nonzero values for nlines and ncols, it attempts to resize the screen to the given size.[...]"
Obviously emphasized on the "attempt", but it does not give any further information...

Related

XLib font size too small?

currently I'm using this font in my C++ program:
-misc-fixed-medium-r-normal--12-*-*-*-*-*-iso8859-15
where '12', the size, is also the font size I'm using currently with Linux Mint 18-1.
But when I draw in my program a string it is shown very small! It looks like it has a size of '6'!
Do I need to double the font size for my program, or something like that?
TIA
Regards
Earlybite
I was searching some hours the internet, also here, but I couldn't find an solution. Also in my "pre-version" of my program, I couldn't find the difference, because *there was a normal drawing with XLib and DrawString.
I also noticed, that even size = 40 hadn't a difference to e.g. size = 20. So there had to be a difference in coding.
So I went through the pre-version code line by line and at least I found that little line: XSetFont().
Which makes drawing strings normal.
E.g. like that:
XSetFont(mDisplay, vGC, this->mFontPtr.fid); // <-- HERE!
vGCVal.foreground = mXForeColorA->X_Color.pixel;
XChangeGC(mDisplay,vGC, GCForeground, &vGCVal);
XDrawString(mDisplay, vPix, vGC, x, y, nDrawString.c_str(), (int) nDrawString.length());

DirectX 9 point sprites not scaling

I got point sprites working almost immediately, but I'm only stuck on one thing, they are rendered as probably 2x2 pixel sprites, which is not really very easy to see, especially if there's other motion. Now, I've tried tweaking all the variables, here's the code that probably works best:
void renderParticles()
{
for(int i = 0; i < particleCount; i ++)
{
particlePoints[i] += particleSpeeds[i];
}
void* data;
pParticleBuffer->Lock(0, particleCount*sizeof(PARTICLE_VERTEX), &data, NULL);
memcpy(data, particlePoints, sizeof(particlePoints));
pParticleBuffer->Unlock();
pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_POINTSIZE, (DWORD)1.0f);
//pd3dDevice->SetRenderState(D3DRS_POINTSIZE_MAX, (DWORD)9999.0f);
//pd3dDevice->SetRenderState(D3DRS_POINTSIZE_MIN, (DWORD)0.0f);
pd3dDevice->SetRenderState(D3DRS_POINTSCALE_A, (DWORD)0.0f);
pd3dDevice->SetRenderState(D3DRS_POINTSCALE_B, (DWORD)0.0f);
pd3dDevice->SetRenderState(D3DRS_POINTSCALE_C, (DWORD)1.0f);
pd3dDevice->SetStreamSource(0, pParticleBuffer, 0, sizeof(D3DXVECTOR3));
pd3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, particleCount);
pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);
}
Ok, so when I change POINTSCALE_A and POINTSCALE_B, nothing really changes much, same for C. POINTSIZE also makes no difference. When I try to assign something to POINTSIZE_MAX and _MIN, no matter what I assign, it always stops the rendering of the sprites. I also tried setting POINTSIZE with POINTSCALEENABLE set to false, no luck there either.
This looks like something not many people who looked around found an answer to. An explanation of the mechanism exists on MSDN, while, yes, I did check stackoverflow and found a similar question with no answer. Another source only suggested seting the max and min variables, which as I said, are pretty much making my particles disappear.
ParticlePoints and particleSpeeds are D3DXVector3 arrays, and I get what I expect from them. A book I follow suggested I define a custom vertex with XYZ and diffuse but I see no reason for this to be honest, it just adds a lot more to a long list of declarations.
Any help is welcome, thanks in advance.
Edit: Further tweaking showed than when any of the scale values are above 0.99999997f (at least between that and 0.99999998f I see the effect), I get the tiny version, if I put them there or lower I pretty much get the size of the texture - though that is still not really that good as it may be large, and it pretty much fails the task of being controllable.
Glad to help :) My comment as an answer:
One more problem that I've seen is you float to dword cast. The official documentation suggests the following conversion *((DWORD*)&Variable (doc) to be put into SetRenderState. I'm not very familiar with C++, but I would assume that this makes a difference, because your cast sets a real dword, but the API expects a float in the dwords memory space.

wxWidgets wxPen size changes unexpectedly

I've used the following code to draw on a Image using a wxMemoryDC.
To do so I used a wxPen and changed the settings of the pen as in the following code. The code compiles and runs perfectly in windows environment. But in Ubuntu it draws the lines but the pen size stays correctly for a very little time and then the pen size becomes very low.(As shown in the image) It is not an error of the m_pensize variable because it always prints the correct value. Why does this works so strange in ubuntu when it works correctly in windows?.
(m_graphics is the memoryDC here)
if (x<m_backgroundImage.GetWidth() && y< m_backgroundImage.GetHeight()){
m_graphics.SelectObject(m_maskImage);
wxPen* pen;
if (m_isDrawing){
pen = wxThePenList->FindOrCreatePen(*wxRED, m_penSize);
printf("Pen size is %d", m_penSize);
}
else{
pen = wxThePenList->FindOrCreatePen(*wxBLACK, m_penSize);
}
if (m_pentype != Circle){
pen->SetCap(wxCAP_PROJECTING);
}
m_graphics.SetPen(*pen);
m_graphics.DrawLine(m_lastX,m_lastY,x,y);
m_graphics.SelectObject(wxNullBitmap);
}
In windows it is shown Correctly
In linux The pen size is changed unexpectadly.
Your help is greatly appreciated.
If the same code behaves differently in wxMSW and wxGTK, then it's probably a bug in wxWidgets itself, however to fix it it needs to be reproduced in some simple to test way, ideally by making the smallest possible change to the wxWidgets drawing sample and opening a ticket attaching this change as a patch to it.
To simplify the code as much as possible, I'd recommend:
Getting rid of wxThePenList and just creating the pen directly. It's unlikely that the bug is here, but who knows.
Check if it's not due to SetCap() call, this is the most likely candidate IMHO.

Failure at displaying Bitmaps in wxWidgets

My application has two Pictures embedded in the Frame. My code is as follows:
wxMemoryInputStream istream1(Bild_png, sizeof Bild_png);
wxImage Bild_png(istream1, wxBITMAP_TYPE_PNG);
new wxStaticBitmap(p_img, wxID_ANY, wxBitmap(Bild_png));
vbox->Add(p_img ,0);
(vbox is the Sizer)
When I start the App, I've a "T-" at the left-upper corner in both Bitmaps. When I change the notebookitem("screen") and get back to the first Screen (where the Bitmaps are) the "-T" has disappeared...
How can I fixed it, so that I will never see the failure?
i had to call Layout() at the upmost sizer. That has solved my problem. It means at the end:
vbox->Layout()
#catalin, I don't think that to post aorund 2000 lines of sourcecode is a better way. I had choose this little snipped, because it says all what needed. A expert with wxWidgets had give me - with this four lines - the hint that something is fault with the sizer, not with the pic.
Haven't you been advised before to search the samples? For example widgets; just grep for wxStaticBitmap and I'm sure you'll find something useful.
This is just a poor way of asking a question.
In your c++ snippet you're using Bild_png even before it was declared - really? Then you mention both Bitmaps and notebookitem("screen") which are just unknown items to anyone else but you.
IMO it is just too... wrong to receive a good answer...

Cannot seem to properly add objects to an array in C++

I primarily program in Java but I am taking a graphics course for which I need to use C++. I am trying to create an array of objects in order to loop through them and draw them to the screen, but I can't for the life of me figure out how to create this array. I have code now which does not produce any compiler errors, but it doesn't seem to work correctly either. The following code is at the top of my Main.cpp class:
Platform ground("wallstone.tga", 40, 16, 4, 144);
Platform platform1("wallstone.tga", 10, 16, 4, 20);
Platform platforms[2] = {ground, platform1}
When I try: fprintf(stdout, "Size of platforms array: %d", sizeof(platforms)/sizeof(Platform)); it prints out 0.0.
I've tried several ways of creating this array and they all seem to produce errors or that same output of 0.0, so I'm not sure what's going on. If any more of my code is necessary I will certainly be willing to post it. Of course, if there is a better way of approaching this I am grateful. Thanks!
It looks like you are doing everything right. My only guess is that size_t on your platform is larger than int, so providing a correct format specifier (%z instead of %d) may fix the problem:
fprintf(stdout, "Size of platforms array: %z", sizeof(platforms)/sizeof(Platform));