Using opengl on windows

Обновление OpenGL в Windows 7

Пакет файлов под названием OpenGL в большинстве случаев требуется пользователям для корректного запуска определенных игр на компьютере под управлением операционной системы Windows 7. Если данный драйвер отсутствует или его версия устарела, программы просто не будут включаться, а на экране отобразится соответствующее уведомление с просьбой инсталляции или обновления ПО. В этой статье мы максимально развернуто расскажем о загрузке новых библиотек OpenGL.

Обновляем OpenGL в Windows 7

В первую очередь стоит разобраться, каким же образом инсталлируется рассматриваемый компонент на ПК. Все необходимые файлы ставятся вместе с драйверами графического адаптера. Поэтому сперва следует обновить программное обеспечение этого комплектующего, а потом переходить к разбору альтернативного метода.

Когда у вас установлен самый свежий драйвер на видеокарту и обновлений больше нет, при этом все равно появляется уведомление о необходимости обновления OpenGL, сразу переходите к третьему способу. Если и этот вариант не принес никаких результатов, значит, ваше оборудование не поддерживает последние библиотеки. Рекомендуем задуматься о выборе новой видеокарты.

Способ 1: Обновление драйверов видеокарты в Windows 7

Как уже было сказано выше, компоненты OpenGL ставятся вместе с файлами графического адаптера. В Windows 7 присутствует несколько методов их обновления. Каждый из них подходит в разных ситуациях и требует от пользователя выполнения определенных действий. Перейдите к статье по ссылке ниже, чтобы детально ознакомиться со всеми способами. Выберите подходящий и воспользуйтесь предоставленными инструкциями. По завершении процесса достаточно перезагрузить компьютер и проверить работоспособность игр или других программ, которые требовали наличия свежей версии библиотеки.

Способ 2: Обновление компонентов в фирменной утилите видеокарты

Сейчас основными производителями графических адаптеров являются AMD и NVIDIA. У каждого имеется собственный софт, который обеспечивает корректную работу с операционной системой и позволяет обновлять ПО. Обладателям видеокарт NVIDIA советуем обратиться к материалу по следующей ссылке, чтобы разобраться с установкой новой версии драйвера OpenGL в GeForce Experience.

Владельцам карточек от AMD нужно ознакомиться с другими статьями, поскольку в данном случае все действия выполняются в Catalyst Control Center либо в Radeon Software Adrenalin Edition, в зависимости от типа установленного ПО.

Способ 3: Обновление DirectX

Не самым эффективным, но иногда работающим методом является установка новых компонентов библиотеки DirectX. Порой в ней находятся подходящие файлы, которые позволяют нормально функционировать необходимым играм или программам. Сначала нужно узнать, какой DirectX уже установлен на вашем компьютере. Для этого ознакомьтесь с инструкцией в статье ниже.

На данный момент последней версией для ОС Виндовс 7 является DirectX 11. Если у вас инсталлирована более ранняя библиотека, советуем обновить ее и проверить работоспособность ПО. Развернуто на эту тему читайте в другом материале.

Как видите, в обновлении OpenGL нет ничего сложного, главным вопросом остается лишь поддержка свежих файлов данного компонента вашей видеокартой. Мы рекомендуем проверить все способы, поскольку эффективность каждого зависит от разных обстоятельств. Ознакомьтесь с инструкциями и следуйте им, тогда у вас точно все получится.

Using OpenGL extensions On Windows

I want to use the functions exposed under the OpenGL extensions. I’m on Windows, how do I do this?

4 Answers 4

Easy solution: Use GLEW. See how here.

Hard solution: If you have a really strong reason not to use GLEW, here’s how to achieve the same without it:

Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the OpenGL Extension Registry.

Example: I wish to use the capabilities of the EXT_framebuffer_object extension. The APIs I wish to use from this extension are:

Check if your graphic card supports the extension you wish to use. If it does, then your work is almost done! Download and install the latest drivers and SDKs for your graphics card.

Example: The graphics card in my PC is a NVIDIA 6600 GT. So, I visit the NVIDIA OpenGL Extension Specifications webpage and find that the EXT_framebuffer_object extension is supported. I then download the latest NVIDIA OpenGL SDK and install it.

Your graphic card manufacturer provides a glext.h header file (or a similarly named header file) with all the declarations needed to use the supported OpenGL extensions. (Note that not all extensions might be supported.) Either place this header file somewhere your compiler can pick it up or include its directory in your compiler’s include directories list.

Читайте также:  Debian linux amd64 download

Add a #include line in your code to include the header file into your code.

Open glext.h, find the API you wish to use and grab its corresponding ugly-looking declaration.

Example: I search for the above framebuffer APIs and find their corresponding ugly-looking declarations:

All this means is that your header file has the API declaration in 2 forms. One is a wgl-like ugly function pointer declaration. The other is a sane looking function declaration.

For each extension API you wish to use, add in your code declarations of the function name as a type of the ugly-looking string.

Though it looks ugly, all we’re doing is to declare function pointers of the type corresponding to the extension API.

Initialize these function pointers with their rightful functions. These functions are exposed by the library or driver. We need to use wglGetProcAddress() function to do this.

Don’t forget to check the function pointers for NULL. If by chance wglGetProcAddress() couldn’t find the extension function, it would’ve initialized the pointer with NULL.

That’s it, we’re done! You can now use these function pointers just as if the function calls existed.

Reference: Moving Beyond OpenGL 1.1 for Windows by Dave Astle — The article is a bit dated, but has all the information you need to understand why this pathetic situation exists on Windows and how to get around it.

Current state and solutions for OpenGL over Windows Remote [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 12 months ago .

OpenGL and Windows Remote don’t play along nicely.

Solutions for this are dependent on the use case and answers are fragmented across the vast depths of the net. This is a write-up I wish existed when I started researching this, both for coders and non-coders.

Problem:

A RDP session of Windows does not expose the graphics card, at least not directly. For instance you cannot change the desktop resolution and GraphicsCard drivers usually just disable their setting menus. Starting a OpenGL context higher than v1.1 fails because of this. The, especially in support IRCs, often suggested «Don’t use WindowsRemote» is unfortunately not an option for many. In many corporate environments Windows Remote is a constantly used tool and an app has to work there as well.

Non-Coder workarounds

You can start the OpenGL program, allowing it to see the graphics card, create an opengl context and then connect via WindowsRemote. This always works, as Windows remote just transfers the window content. This can be accomplished by:

  • A batch script, that closes the session and starts the program, allowing you to connect to the program already running. (Source)
  • Using VNC or other to remote into the machine, start the program and then switch to Windows Remote. (Simple VNC programm, also with a portable client)

Coder workarounds

(Only for OpenGL ES)Translate OpenGL to DirectX. DirectX works under Windows Remote flawselly and even has a Software rendering fallback built into DX11 if something fails.

  • Use the ANGLE Project to do this at run-time. This is what QT officially suggests you do and how Chrome and Firefox implement WebGL. (Source)

Switch to software rendering as a fall back. Some CAD software like 3dsMax does this for instance:

  • Under SDL2 you can use SDL_CreateSoftwareRenderer (Source)
  • Under GLFW version 3.3 will release OSMesa (Mesa’s off screen rendering), in the mean time you can build the Github version with -DGLFW_USE_OSMESA=TRUE, but I personally still struggle to get that running (Source)
  • Directly use Mesa’s LLVM pipe for a fast OpenGL implementation. (Source)
  • Use OpenGL 1.1: Windows has a built in implementation of OpenGL 1.1 and earlier. Some game engines have a built in fall back to this and thus work under Windows Remote.
  • Apparently there is a middle-ware, that allows for even OpenGL 4 over Windows Remote, but it’s part of a bigger package and is a commercial solution. (Source)
Читайте также:  Acer обновление bios windows 10

Any other solutions or corrections are greatly appreciated.

Getting Started

So you want to take advantage of the power of the OpenGL API? If you are visiting this page because a game or software uses the OpenGL API, you need to install the appropriate graphic driver which enables usage of the functionality provided.

To program using the OpenGL API, you need the driver and the development package (depends on platform and programming language). More platform-specific details are described in the sections below.

Contents

This Wiki maintains a FAQ page for OpenGL.

Downloading OpenGL

In all three major desktop platforms (Linux, macOS, and Windows), OpenGL more or less comes with the system. However, you will need to ensure that you have downloaded and installed a recent driver for your graphics hardware.

Windows

Appropriate Windows driver websites:

Some sites also distribute beta versions of graphics drivers, which may give you access to bug fixes or new functionality before an official driver release from the manufacturer:

Without drivers, you will default to a software version of OpenGL 1.1 (on Win98, ME, and 2000), a Direct3D wrapper that supports OpenGL 1.1 (WinXP), or a Direct3D wrapper that supports OpenGL 1.1 (Windows Vista and Windows 7). None of these options are particularly fast, so installing drivers is always a good idea.

If your system does not contain a GPU, or the GPU vendor delivers graphics drivers providing OpenGL support that’s so old as to be useless to you, you might want to consider installing the Mesa3D OpenGL library on your system. See this wiki link for details:

Linux

Graphics on Linux is almost exclusively implemented using the X windows system. Supporting OpenGL on Linux involves using GLX extensions to the X Server. There is a standard Application Binary Interface defined for OpenGL on Linux that gives application compatibility for OpenGL for a range of drivers. In addition the Direct Rendering Infrastructure (DRI) is a driver framework that allows drivers to be written and interoperate within a standard framework to easily support hardware acceleration, the DRI is included in of XFree86 4.0 but may need a card specific driver to be configured after installation. These days, XFree86 has been rejected in favor of XOrg due to the change in the license of XFree86, so many developers left Xfree86 and joined the XOrg group. Popular Linux distros come with XOrg now.

Vendors have different approaches to drivers on Linux, some support Open Source efforts using the DRI, and others support closed source frameworks but all methods support the standard ABI that will allow correctly written OpenGL applications to run on Linux.

For more information on developing OpenGL applications on Linux, see Platform specifics: Linux

macOS

Unlike other platforms, where the Operating System and OpenGL implementations are often updated separately, OpenGL updates are included as part of macOS system updates. To obtain the latest OpenGL on macOS, users should upgrade to the latest OS release, which can be found at Apple.com.

For developers, a default installation of macOS does not include any OpenGL headers, nor does it include other necessary development tools. These are installed by a separate developer tools package called Xcode. This installer includes the OpenGL headers, compilers (gcc), debuggers (gdb), Apple’s Xcode IDE, and a number of performance tools useful for OpenGL application development.

For more information on developing OpenGL applications on macOS, see Platform specifics: macOS.

Writing an OpenGL Application

The first step is to pick your language. Bindings for OpenGL exist in many languages, from C# and Java to Python and Lua. Some languages have multiple sets of OpenGL bindings, none of them being official. All of them are ultimately based on the C/C++ bindings.

If you are not using C/C++, you must download and install a package or library for your chosen language that includes the OpenGL bindings. Some come pre-installed, but others have separate downloads.

Читайте также:  Best windows open source

If you are using C/C++, then you must first set up a build environment (Visual Studio project, GNU makefile, CMake file, etc) that can link to OpenGL. Under Windows, you need to statically link to a library called OpenGL32.lib (note that you still link to OpenGL32.lib if you’re building a 64-bit executable. The «32» part is meaningless). Visual Studio, and most Windows compilers, come with this library.

On Linux, you need to link to libGL. This is done with a command-line parameter of «-lGL».

Initialization

Before you can actually use OpenGL in a program, you must first initialize it. Because OpenGL is platform-independent, there is not a standard way to initialize OpenGL; each platform handles it differently. Non-C/C++ language bindings can also handle these differently.

There are two phases of OpenGL initialization. The first phase is the creation of an OpenGL Context; the second phase is to load all of the necessary functions to use OpenGL. Some non-C/C++ language bindings merge these into one.

OpenGL Context Creation

An OpenGL context represents all of OpenGL. Creating one is very platform-specific, as well as language-binding specific.

If you are using the C/C++ language binding for OpenGL, then you are strongly advised to use a window toolkit for managing this task. These libraries create a window, attach an OpenGL context to this window, and manage basic input for that window. Once you are comfortable with OpenGL, you can then start learning how to do this manually.

Most non-C/C++ language bindings will provide you with a language-specific mechanism for creating a context.

Getting Functions

If you are using a non-C/C++ language binding, then the maintainer of that binding will already handle this as part of context creation. If you are using C/C++, read on.

In order to use OpenGL, you must get OpenGL API functions. For most libraries you are familiar with, you simply #include a header file, make sure a library is linked into your project or makefile, and it all works. OpenGL doesn’t work that way.

For reasons that are ultimately irrelevant to this discussion, you must manually load functions via a platform-specific API call. This boilerplate work is done with various OpenGL loading libraries; these make this process smooth. You are strongly advised to use one.

If you want to do it manually however, there is a guide as to how to load functions manually. You still should use an extension loader.

Using OpenGL

OpenGL is a rendering library. What OpenGL does not do is retain information about an «object». All OpenGL sees is a ball of triangles and a bag of state with which to render them. It does not remember that you drew a line in one location and a sphere in another.

Because of that, the general way to use OpenGL is to draw everything you need to draw, then show this image with a platform-dependent buffer swapping command. If you need to update the image, you draw everything again, even if you only need to update part of the image. If you want to animate objects moving on the screen, you need a loop that constantly clears and redraws the screen.

There are techniques for only updating a portion of the screen. And you can use OpenGL with these techniques. But OpenGL itself doesn’t do it internally; you must remember where you drew everything. You must figure out what needs updating and clear only that part of the screen. And so forth

There are many tutorials and other materials available for learning how to use OpenGL, both on this wiki and online.

OpenGL Viewers

These are programs that you install and run, and they give you information specific to the OpenGL API your system implements, like the version offered by your system, the vendor, the renderer, the extension list, supported viewport size, line size, point size, plus many other details. Some might include a benchmark. Some are standalone benchmarks.

Tutorials and How To Guides

User contributed tutorials and getting started guides

Оцените статью