What should I do if the OpenGL function can be executed normally but there is no result? Method

Source: Internet
Author: User

When compiling OpenGL functions, many inexplicable problems are caused by unfamiliar or profound understanding.

For example, after you have had a great deal of hard work and finally compiled D successfully, excute it! However, we can see what the cannot read memory is. Obviously, the pointer is out of bounds.

We are unwilling, but we cannot give up. Single-step debugging!

We found that there was a null pointer when using OpenGL to obtain some functions or strings!

For example, when glteximage3d = (pfnglteximage3dproc): wglgetprocaddress ("glteximage3d"), the trail finds that glteximage3d = NULL;

For example, if char * str1 = 0; str1 = (char *) glgetstring (gl_version);, the trace finds that str1 = NULL;

Haha, the problem is found. In this case, accessing glteximage3d or str1 will definitely be out of bounds.


But why? Clearly, the compilation is correct, and the execution can be performed normally, but the output is not correct?


I have been searching for the answer for a long time on the Internet: http://tech.groups.yahoo.com/group/opengl-gamedev-l/message/41013!

One sentence: Before you call these GL functions, You need to initialize the rendering context (rendering context )!!!

Therefore, when you are not using MFC (for example, when using a console Program), first call the relevant GL function to initialize the program and then call the relevant GL function to return the correct value.

In the case of MFC, after wglmakecurrent () is called for initialization, the correct value can be returned.

OK! Solve the problem!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.