Printing string and variables to glwindow - c++

I have been looking to an answer to this for a while now but I can't really find one.
I'm not using glut so please no glut only answer.
What I am trying to do is send variables and text to the in game screen so I can make an UI with a little feedback for the player, like the amount of money they are carrying at that moment. (So not the debug screen)
I'm using c++ with opengl.
If I need to provide anyone with more information, please ask and I will do my best to provide you with it.
Thank you in advance.

If you can live with GL1.x, use the classic reference on bitmap fonts: http://nehe.gamedev.net/tutorial/bitmap_fonts/17002/
If you need something relevant, modify the sample above to use Vertex Arrays / Vertex Buffer Objects and not the glRasterPos functions.
Advanced way is to use the FreeType to render truetype fonts. Here's a sample.

Related

full screen and zoom in Koolplot

I'm trying to graph some things in C++ and Koolplot seems like a very simple and suitable library to do so with. I'm stuck, however, on finding some documentation about it that allows me to fullscreen the application (or resize it like you can do so on lots of applications, chrome, word, discord...). As well as this, I can't find or see how i can allow the user to drag the graph around with the mouse as well as zooming into a point of a scatterplot or function. If anyone has any ideas about these things i'd appreciate it, thanks.
The short reply is: cannot do.
Koolplot uses for drawings of the charts a modernized version of the venerable BGI driver. It was invented once upon a time, when personal computers were still running on some DOS version. Those times the graphics were full screen, hence of fixed size. This particularity was kept in the modernized WinBGIm library.
Zooming or panning properly a chart present on the screen require access from the drawing/painting routines of Koolplot to the data to be shown. This is not the case. If you look once again in the source code, you will note that in the implementation efforts were made to keep separated data to be plot from the actual drawing on the screen.
In conclusion, to do what you want, you will have to modify WinBGIm such that it manages correctly a drawing surface of variable dimensions and modify koolplot such that data to be shown is owned by (or aggregated with) Plotstream class.

Unity: How would I create the graphics for some elements in C++ to be used by Unity?

First, I know that the 'proper' answer is to just port everything to C#. Please don't bother posting that answer. That's the long-term goal. I don't need to hear it restated.
I have a game I'd like to port to Unity on PC (initially.) It has a very heavy user interface. I'm wondering how I would go about creating the graphics for the UI in C++? My game currently uses GDI to create the dialogs, each in its own buffer, then BitBlts to the screen.
In a 'perfect world' I'd like to try passing those buffers to Unity which would then display them and pass any mouse/gesture events back to C++ for processing. It's a kludge, but much faster than porting everything and would let me do some prototype/testing to see if it's practical. I could then port the screens one at a time to Unity or port the UI Library I wrote.
I did see one post which talked about doing something a little similar where the C++ pushed textures into OpenGL where Unity would then render them. Are there any articles which discuss how to do this on a PC using DirectX before I start hacking away?
It sounds simple, but I'd appreciate some pointers on interfacing between them. The documentation on the unity site is a bit sparse on the details of the interface.
Clarification: My question is really about what I need to do with DirectX in C++ to send a texture back. Do I need to initialize DirectX in C++ as well as Unity, do I need to pass a display handle or something else to C++ along with the texture handle, etc.? Is it as easy as just calling the C++ routine to return the texture? I'm familiar both with how to talk between C# and C++ and how 3D engines work in general, I need to populate a DirectX texture from an HDC and somehow pass that data back to Unity for Display.
Ralph
I think I found it, a starting point at least. I should have RTFMed the manual better, my bad.
https://docs.unity3d.com/Manual/NativePluginInterface.html
refers to this project
https://bitbucket.org/Unity-Technologies/graphicsdemos/src/default/NativeRenderingPlugin/
I hope this helps someone else.

Animated graphics implementation dialog based MFC

Could anyone suggest me a particular way to implement animation in my Dialog-based mfc program? The animation that I am intending to add is like a construction digger machine graphic that would read the values of the machine parameters and change the shape of the graphic accordingly. Most of the information is read from a text file in terms of the parameters, so I just need to be able to get the animation working.
Thanks for your help in advance.
Well, GDI is easy but ugly and quite slow, GDI+ is also easy, but nicer although generally slower. OpenGL or DirectX are much, much faster but quite hard to program. Other libraries, such as cairo, are also available.
I'd suggest to start with the easiest (maybe GDI+) and see if it is fast enough for you.
Do do that, just Invalidate() the control where you are drawing in a timer, (or when you receive new data), and paint the whole graphic in the OnPaint() function. A basic improvement is to Invalidate() only the region where the new data affects the picture.
If then you notice that your code is not fast enough, come back and ask how to improve it. A concrete example will make it easier to get a more useful answer.
there are lot of articles. Most of them based on drawing in device context
http://www.codeproject.com/KB/GDI/flickerfree.aspx
http://www.codeguru.com/cpp/g-m/bitmap/article.php/c4879
http://www.codersource.net/mfc/mfc-gdi-plus/animation-control-mfc.aspx

QTopengl c++ simple 2d app

Im trying to make a simple 2D application, and our image processing professor has told us to use opengl. Im working with c++ and QT.
I want to open a simple window that holds a place where I can draw points of different colors. All by code, there is no user interaction. I cant use any other library, can anyone tell me how to do this?
check out :
http://www.digitalfanatics.org/projects/qt_tutorial/chapter14.html
2D Painting Example using QGLWidget.
OpenGL is a library to render. You need at least one or two more (at least to create a window).
Since that is a homework, take a look at this example on how to do your assignment.
Qt comes with numerous examples of using QGLWidget.

GetwindowoffsetEx in windows XP and up

I have an visaul object up and running
GetwindowoffsetEx moved the canvas around
But I cannot change the size of the canvas to my needs
Like should I not beable to change the canvas size for a A4-A3 printer or to a picture size
can this be done using the windows API
I do not seem to get the instructions to do this.
I take it that if I want a Zoom, I strech draw from another cavuas
am I asking the obvious in all this.
Lex Dean
I'm struggling to understand exactly what I need but you seem to want to map between two coordinate spaces in GDI.
Whilst you can use the fully general SetWorldTransform(), I suspect you are better off with the following functions:
SetWindowOrgEx(), SetWindowExtEx()
SetViewportOrgEx(), SetViewportExtEx()
The MSDN documentation also includes a full list of functions related to coordinate space transformations.