Once you've done the setup, you set the active shader to the one you made, "bind" the texture, "bind" the rectangle, then tell OpenGL to render your rectangle. After that, you'll also need to upload your texture that you loaded from some image file to the GPU. Then, make a set of two 3D triangles (each 3 sets of 3 floats) that make a rectangle and upload them to the GPU. Once you've got a rendering context, you'll need to set up a few basic shaders, compile them both, then link them to form a shader program. OpenGL is available on everything, so to use that, you'll have to use some 3rd party library to set up what's called a rendering conext (kind of like a 3D space and state, all the configuration stuff). To put that image on the screen, you'll have to use some graphics library. If you really want to actually load an image and display it yourself, you'll have to use some external library (libjpg, libpng, etc.) to actually open the file and parse the binary tags to get the final result- a plain array of what are most likely unsigned chars, although some formats use floats. You can try out Cairo or SDL 2.0 ( tutorial), both of which use similar concepts as what you're looking for. If you're going to be doing graphics, you'll have to use a completely 3rd party library, there's no standardized graphics system. There's not even the concept of a screen. There's no such thing as a plain pixel on the screen at a certain point. Graphics programming in low level languages doesn't work like that.
if your post does not appear in the new queue, just send a message to the moderators.make your questions relevant to other readers.give your post a meaningful title, i.e., NOT "I have a C++ problem" but, e.g., "Problem with nested for loops".
thoroughly research for an answer first.Tips for improving your chances of getting helpful answers:
Read these guidelines for how to ask smart questions.įor learning books, check The Definitive C++ Book Guide and Listįlair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page. Hasty-sounding questions get hasty answers, or none at all.
New to C++? Learn at READ BEFORE POSTINGīefore you post, please read our sticky on proper code formatting. For general discussion and news about c++ see r/cpp. This is a subreddit for c++ questions with answers.