VTK vtkStructuredPoints GetPointData() SetScalars - c++

How to set sclar in new version VTK. How to convert new version VTK below code?
StructuredPoints->GetPointData()->SetScalars(scalars);

Without knowing what version you are referring too, I think both methods you are using are still available in VTK:
GetPointData
SetScalars

Related

How do I use Legacy OpenGL calls with QT6?

I'm new to Qt and am trying to import some older C++ openGL code. I'm currently using Qt 6.4. I've subclassed my OpenGL-using class to QOpenGlFunctions.
Many of the glFoo calls "work" but the class also uses calls like glEnableClientState, glVertexPointer, glNormalPointer, glTexCoordPointer, glDisableClientState, glColor4fv, & glMaterialfv which come up with errors like undefined reference to __imp_glTextCoordPointer. Looking at the documentation these appear to no long be supported by "default" but it looks like they are supported using older versions of QOpenGlFunctions such as QOpenGlFunction_1_4 (https://doc-snapshots.qt.io/qt6-dev/qopenglfunctions-1-4.html).
Trying to change my subclass from QOpenGLFunctions to QOpenGLFunctions_1_4 complains that really only QOpenGLFunctions_1_4_CoreBackend and QOpenGLFunctions_1_4_DeprecatedBackend exist but there appears to be no documentation on those and if I subclass to one of them I start seeing complaints about my constructor...
How do I actually access the functions from these older versions of the class?
This question was answered by Chris Kawa over at the Qt Forums and it worked for me! Here is his answer:
OpenGL 3.1 introduced profiles. Core profile does not support these old functions and Compatibility profile does.
So first you have to make sure you have a context in version either lower than 3.1 (which does not support profiles) or 3.1 and up set up to use Compatibility profile. AFAIK Qt does not support OpenGL < 3.1 anymore, so you only have the latter option.
If you're not sure what context you have you can simply do qDebug() << your_context and it will print out all the parameters, or you can query individual fields of it e.g. your_conext->format()->profile(). If your context is not set correctly the simplest way is to set it up like this before any OpenGL is initialized in your app:
QSurfaceFormat fmt;
fmt.setVersion(3,1);
fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
fmt.setOptions(QSurfaceFormat::DeprecatedFunctions);
QSurfaceFormat::setDefaultFormat(fmt);
When you have the correct context you can access the deprecated functions like this:
QOpenGLFunctions_1_4* funcs = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_1_4>(context());
if(funcs)
{
//do OpenGL 1.4. stuff, for example
funcs->glEnableClientState(GL_VERTEX_ARRAY);
}
else
{
// Not a valid context?
}
And for anyone as amateur as I am, context() comes from QOpenGLWidget::context() which returns a QOpenGLContext*

How do I use glCreateBuffers() over glGenBuffers()?

When I was using opengl 3.3, functions such as, glGenBuffers() and glBufferData() Worked Just fine, but now that I am using 4.3 I wish to use the more updated versions of those functions such as glCreateBuffers() and:
glNamedBufferStorage(), glVertexArrayVertexBuffer, glVertexArrayAttribFormat(), glVertexArrayAttribBinding(), glEnableVertexArrayAttrib().
When I implement them in the program I simply get Unhanded expression errors.
The book I am learning from (Superbible) no longer teaches the GenBuffer() Method so I need to make these work.
Thank You!
using 4.3
glCreateBuffers
glCreateBuffers is part of OpenGL 4.5 (and ARB_direct_state_access).

Migrating to vtk6: Is it not necessary to Update() (anymore)?

Migrating some code from VTK 5.10 to 6.1, I have several code pieces like this:
vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
// ... initialize img somehow, e.g. copy from other image:
img->DeepCopy(otherImg);
img->SetInformation(otherImg->getInformation());
// the problematical statement:
img->Update();
At the call to Update(), the compiler now complains that there isn't such a function (anymore).
The migration site from VTK doesn't really tell me too much about that - I believe this falls into the section Removal of Data Objects’ Dependency on the Pipeline , but as it's no Algorithm which is filling my image, I can't call update on an algorithm.
Similar goes for custom-filled vtkPolyData objects.
My question now is: Is the call to Update not necessary (anymore?), can I just remove it? Or by what would I need to replace it?
I have to say I'm relatively new to vtk, so if there's something fundamentally simple that I'm missing I'd be glad if you could point it out to me!
I think you've been meaning to call Modified() on your image rather than Update().
Apparently they already answered your question on VTK:
http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Removal_of_Update

OpenGL Extensions in Qt 4

it's possible enable/use OpenGL (specific version) in Qt 4 (on Desktop) or I have to use glew, etc?
Rather than Glew you can include gl3.h, it's probably the simplest and most pain free way and works with compatibility mode as well as core. It's also well worth checking out GLXX it's a newer lib written in C++ so its more object orientated and provides handy functions for querying capabilities and so on.
You could look at manually binding just the extensions you need, possibly making your own Qt classes.
Other alternatives are Glee (A bit out of date now, only up to OpenGL 3.0) and gl3w (a script to generate header files for you, but only seems to support OpenGL 3/4 core).
Also if you want a object orientated library for OpenGL itself OGLplus looks good, doesn't do extensions though.
Qt has wrappers for some extentions like QPixelBuffers otherwise you can just use glew to enable the extentions
My way to do that (Windows)... You need www.opengl.org/registry/api/glext.h
I'm using this python script to generate glex.h (p_glext.h) and glex.cpp from glext.h
p_glext.h is copy of glext.h without prototypes.
//glex.h
#ifndef GLEX_H
#define GLEX_H
#include "p_glext.h"
extern void glexInit();
extern PFNGLBLENDCOLORPROC glBlendColor;
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
extern PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
...
//glex.cpp
...
void glexInit() {
glBlendColor = (PFNGLBLENDCOLORPROC)wglGetProcAddress("glBlendColor");
glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");
glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)wglGetProcAddress("glDrawRangeElements");
...
}
that's simple enough to me

How to get a list of installed True Type Fonts on Linux using C or C++?

How can my app get a list of the True Type Fonts that are available on Linux.
Is there a standard directory where they are stored across different distributions? Or some other standard way to locate them?
I think fontconfig is the right way to do it. Take a look on the wikipedia article or the fontconfig hompage.
try a function called 'XListFonts'
http://tronche.com/gui/x/xlib/graphics/font-metrics/XListFonts.html
I just did it using something called Pango which is used by GTK+. I found it by looking at the code for the linux 'Character Map' program (gucharmap). Here's the basic idea:
PangoFontFamily **families;
...
pango_context_list_families (
gtk_widget_get_pango_context (GTK_WIDGET (notebook)),
&families, &fontCount);
printf("%d fonts found\n", fontCount);
for(i=0; i<fontCount; i++)
{
printf("[%s]\n", pango_font_family_get_name (families[i]));
}
Not relevent but you can use fontmatrix shows all and there preview (yum -y install fontmatrix)
If you aren't writing proprietary software, or any other licensed software that's incompatible with GPL, you could try looking at the code to xlsfonts to see how to query the font server. (The font server could be X itself, but it won't matter.)
If you're using a high-level toolkit like GTK+ or Qt, there's probably a better function to do it for you; if not, fontconfig is the de-facto way to do it.