2D graphic library for windows form application - c++

I need a 2d graphic library for windows form application(Visual studio 2010).I used to work with SDL in console applications.It was really great:simple and powerful.But a friend of mine told me that it won't work in windows form application.Can you please suggest me a good library for 2d drawing in form applications written in C++?Or is there a way to use SDL in windows form applications?
*it would be great if it has these features:
load .bmp and .gif and popular image formats.
Simple to learn.
Draw text and simple 2d shapes.
Thanks.
(Sorry for my bad english)

SDL supports Windows. You should be able to use SDL by just using a Window's Handle from a control in Windows Forms. For example, if you initialize SDL to use the a "panel" by passing the panel->Handle property as the HWND, it should work fine.
Alternatively, you can use Windows Form's built-in drawing in the System.Drawing namespace.

Related

Creating OpenGl Window with c++ in windows using 64 bit + Custom Window Shape (etc smooth corners not rectangular)

Im trying to make a software in c++ using OpenGl & C++ it must be 64 bit and be able to have custom window (frame/"handler") etc no normal windows rectangle around it... and use an opacity on etc corners... so get rounded corners on the window/frame.. Anyone know what libs and how to do this? I know OpenGl & C++ however im not sure how to get the window & 64 bit.. since i tried glut but it fails on the 64 bit version and also do not feature the custom framing that i want... Any advice appreciated (: (I want to not use any extra libs) so creating a opengl context myself and import the opengl32.dll and functions from "windows" rather then using libs like etc glut :3 )
Maybe you want to take a closer look to the winapi (MS Windows only).
The procedure of creating a window is pretty straight forward and "binding" OpenGL to it is not that difficult. There is even a nice tutorial from the khronos-group:
OpenGL Winapi Setup Tutorial
Thats the first step, creating round edges is another.
There are tons of approaches to achieve the desired effect, I assume you want to make your window frame as rounded in the default window 7 scheme.
Enabling Visual Styles
If that is not what you want, you can create a frame by yourself by opening a frameless window with winapi and draw your frame with OpenGL.

Embedding a GLFW window inside windows forms

I'm making an editor for 3d worlds in opengl using the windows forms UI. I'm developing on visual studio 2012 express and i would like to embed a GLFW window/context inside a windows form. just like done in this tutorial http://www.codeproject.com/Articles/16051/Creating-an-OpenGL-view-on-a-Windows-Form except working. And with GLFW for opengl context.
Is this possible? should i use Qt instead? and how would i got about doing this? I'm not bound to using windows forms i just need a simple good-looking functional UI for my project.
That are three different frameworks (Windows Forms, GLFW, Qt) which can all do the same thing, i.e. creating a window and an OpenGL context in it.
See here for an easy example how to create a window with OpenGL context with GLFW.
Or see here for the Qt example.
So, you have to choose between one of them. GLFW and Qt have the advantages that your code will also work on MacOSX and on Linux; with some work even on iPhone.
If you want to do the window creation and event handling and other stuff with GLFW but the GUI still with Qt, there is some way to do offline drawing (some ref here or here or here) the Qt widgets and then draw it onto some OpenGL texture. Or you might also be able to directly draw them via OpenGL (not exactly sure).

Doing graphics and drawings in a C++ Win32 client/frame area

How does one write code to make drawings in the Windows main client area of a Win32 C++ app?
I found an example online that uses the "eclipse" API but when I put it in my program, the IDE complained so it would not compile.
Assuming you mean basic drawing (primitives, rendering bitmaps, stuff like that), then GDI and GDI+ are most likely what you want. I haven't used GDI+ much, but theForger's Win32 API tutorial will show you how to work with bitmaps. Drawing primitives is more GDI+ territory, and I can really only refer you to the MSDN GDI+ documentation for details of those functions.
If you're looking for game-type graphics, on the other hand, then you might need to research DirectX or OpenGL.
By using GDI and/or GDI+ functions in the WM_PAINT handler of the form.
Here is a site with some examples.

Curiosity: Background C++ windows. Difference between SFML/SDL type and Qt (GUI) type

I was wondering what is the difference between the windows that will render images on the screen (such as SDL, SFML or OpenGL) and the classic GUI window (with the gray background by default) where you can implement buttons like in Qt for C++ or AWT/Swing in Java?
What is going on in the background code? Are they the same type? Is there a rendering layer over the graphics window allowing to display such images?
Well first of all they are different APIs. SDL and SFML are libraries directed at making games and quite possibly other applications. OpenGL is a graphics API, it is not a full suite of libraries.
Note also that SFML pretty much uses OpenGL to render to the window. The actual window its self is created via platform specific functions. The Win32 API is used for windows and the X11 Window System is generally used on Linux.
The "classic GUI window" is pretty much the platform specific APIs. The differences in background code is really just defined by the purpose of the API. Note that in the end of the line Qt/SFML/SDL all go down to the platform specific API. OpenGL even requires you to interface with the platform specific API. SFML/SDL/QT essentially do the lower level work for you.
I hope I gave what you are looking for as this question really has a wide range of answers.

How to create an SDL pop up menu?

I've seached around how to create a pop up menu in a SDL window application using c++ ? I haven't found any clues !
I would like to have something that looks like this : http://www.youtube.com/watch?v=Mc_CE9OiHvA
I've tried to use glutMenu, but it doesn't work ...
Thanks
SDL is a low-level graphics library. I don't remember seeing anything like menus, buttons, or other GUI controls in it last time I used it. It's possible that one of the many add-on libraries has menuing functions. Generally, you're expected to build such things yourself from primitives SDL provides.
One add-on library you might want to get is SDL_ttf, for drawing text using TrueType fonts. That and a few lines and mouse handers, et voilĂ , you have a menu.
SDL itself doesn't have any GUI libraries. That video looks like a guy who used SDL to write his own GUI using graphic primitive and font calls.
There are several SDL GUI libraries referenced on http://www.libsdl.org/libraries.php
How usable they are, I have no idea.