OpenGL error 0x0500

OpenGL error 0x0500
0

#1

Hello everyone. I ask the community a question that I can not solve. during the compilation of a project has been a blackout. from then on, if I try to compile any type of project (even a simple helloworld). the compiler gives me the following error.

OpenGL error 0x0500 in …\base\CCConfiguration.cpp cocos2d::Configuration::gatherGPUInfo 145

{
gl.version: 3.2.9756 Compatibility Profile Context
gl.supports_NPOT: true
cocos2d.x.version: cocos2d-x 3.1.1
cocos2d.x.compiled_with_profiler: false
cocos2d.x.build_type: DEBUG
cocos2d.x.compiled_with_gl_state_cache: true
gl.max_texture_size: 8192
gl.vendor: ATI Technologies Inc.
gl.renderer: AMD 760G
gl.max_texture_units: 32
gl.supports_ETC1: false
gl.supports_S3TC: true
gl.supports_ATITC: false
gl.supports_PVRTC: false
gl.supports_BGRA8888: false
gl.supports_discard_framebuffer: false
gl.supports_vertex_array_object: true
}

does anyone know how to fix this?


#2

Does reinstalling/repairing your graphics card driver help?


#3

On which platform does it appear?


#4

I reinstalled the drivers for the graphics card but the problem persists. i use visual studio 2013 platform


#5

I meant the platform on which you are running the game this error occurs on.
Does it appear on Windows, iOS, Android? All of them, just a few of them? Which ones exactly.


#6

Well the error is stated here: https://www.opengl.org/wiki/OpenGL_Error

And there is a SO Post about OpenGL immediate mode calls: http://stackoverflow.com/questions/15464399/opengl-error-0x0500-in-cctextureatlas-drawnumberofquadsfromindex-556


#7

the problem appear when i compile with VS2013 in windows 7 64bit.

now i read the post. the strange thing is that before the blackout this problem never appeared.

Another problem I’ve noticed now, is the support to the multi-resolution. I do not know if this thing may depend to the opengl error. but I change the size of the game screen and try to do the same with the size of the image, this remains small…

example: in the AppDelegate.cpp file

glview->setFrameSize(640, 960);
auto screenSize = glview->getFrameSize();
glview->setDesignResolutionSize(screenSize.width, screenSize.height, ResolutionPolicy::NO_BORDER);

the size of the image does not change… sorry for my poor english


#8

It could be, that your GPU was damaged by the blackout.

Regarding scaling- You have to set the scale factor:

director->setContentScaleFactor(640/960);

#9

you solution not works. i use

Director::getInstance()->setContentScaleFactor(0.5);

and it works. but the physics of the game is ruined. then i use this solution

glview->setFrameSize(640, 960);
auto screenSize = glview->getFrameSize();
glview->setDesignResolutionSize(screenSize.width / 2, screenSize.height / 2, ResolutionPolicy::NO_BORDER);

and it works, but when I transform the project in apk file, this does not work anymore…


#10

My solution was just an example. As it is the same ration as your frame, it will not re scale anything.

Are you using the integrated chipmunk physics or external chipmunk/box2d?

You have to scale your physics accordingly to your devices resolution.


#11

I copied all sources of box2d, int the classes folder. therefore, the sources of the application and the box2d sources are all in the same folder. is a spartan method, but it is the only metod that works with me


#12

Well you have to define some pre processor definitions to get it compiling right. Adding dependencies and references to your program,

The advantage of chipmunk is, that you don’t have to scale, as it’s using pixels as units.


#13

can you explain this passage? how do you define a preprocessor?

new updates

I have discovered that maybe the bug depends only on the conversion in apk. in the debug version if i use this
code

glview->setFrameSize(640, 960);
auto screenSize = glview->getFrameSize();
glview->setDesignResolutionSize(screenSize.width / 2, screenSize.height / 2, ResolutionPolicy::NO_BORDER);

everything works perfectly. just i convert the game in apk. this it is wrecked.I can not get more than a click icons. same thing with simple projects like helloworld.
I am very confused …

To avoid confusion, I make a small summary of my problems:

  1. The problem of the compilator

    OpenGL error 0x0500 in …\base\CCConfiguration.cpp cocos2d::Configuration::gatherGPUInfo 145

    {
    gl.version: 3.2.9756 Compatibility Profile Context
    gl.supports_NPOT: true
    cocos2d.x.version: cocos2d-x 3.1.1
    cocos2d.x.compiled_with_profiler: false
    cocos2d.x.build_type: DEBUG
    cocos2d.x.compiled_with_gl_state_cache: true
    gl.max_texture_size: 8192
    gl.vendor: ATI Technologies Inc.
    gl.renderer: AMD 760G
    gl.max_texture_units: 32
    gl.supports_ETC1: false
    gl.supports_S3TC: true
    gl.supports_ATITC: false
    gl.supports_PVRTC: false
    gl.supports_BGRA8888: false
    gl.supports_discard_framebuffer: false
    gl.supports_vertex_array_object: true
    }

  2. the problem of multiresolution. the multiresolution works in the debug session. but when I convert the game in apk, the multiresolution malfunctioning. the image see on the scale but I can not click on any icon and the screen is not reduced in the dimensions indicated. I just can not understand if the error opengl and multiresolution are related or if everyone is a bug separate from the other

the WARNING during the conversion in apk file:

Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersi
on 9 in ./AndroidManifest.xml
Android NDK: WARNING:C:\Users\User\Desktop\COCOS\cocos2d-x-3.1.1\Project\proj.
android\../cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ig
nored for static libraries
Android NDK: WARNING:C:\Users\User\Desktop\COCOS\cocos2d-x-3.1.1\Project\proj.
android\../cocos2d/cocos/platform/android/Android.mk:cocos2dxandroid_static: LOC
AL_LDLIBS is always ignored for static libraries
make.exe: Entering directory `C:/Users/User/Desktop/COCOS/cocos2d-x-3.1.1/Project/proj.android

#14

If you want to to get physics node integration, chipmunk is used by default. But if you want to use box2d for the PhysicsNode extension, you have to set those variables for the preprocessor stage. Turning off chipmunk and turning on box2d.

CC_ENABLE_CHIPMUNK_INTEGRATION=0
CC_ENABLE_BOX2D_INTEGRATION=1

Where you set these depends on the IDE. You can also set them directly in the compiler options with -D as prefix.
E.g. VS you open the project’s propertie’s: Configuration Properties -> C/C++ -> Preprocessor. On the right winow pane you will see Preprocessor Definitions, where you add them.

I’m just using kResolutionFixedHeight here, of yourse you could also use your ResolutionPolicy::NO_BORDER.

Normally you are just having to do this:

In your main function you set it to your target design resolution, e.g. 640/690

auto glview = director->getOpenGLView();
if (!glview) {
    glview = GLView::createWithRect("BHJ", Rect(0, 0, 640, 690));
    director->setOpenGLView(glview);
}

In AppMacros.h you will find some settings you could use.
Just adopt it, if you want to switch between target design resolutions.

#define TARGET_DESIGN_RESOLUTION_SIZE  DESIGN_RESOLUTION_640X690

#elif (TARGET_DESIGN_RESOLUTION_SIZE == DESIGN_RESOLUTION_640X690)
static cocos2d::Size designResolutionSize = cocos2d::Size::Size(640, 690);

In your delegate you are scaling down your content to the resolution:

// Set the design resolution; kResolutionFixedHeight if you want a fixed height.
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionFixedHeight);

Or just use a fixed one in AppDelegate.cpp:

glview->setDesignResolutionSize(640, 690, kResolutionFixedHeight);

You define different designResolutions for your game: e.g. large, medium, small and then scale it to the screen.
This way your coordinates are always the same, but just your assets are scaled.

vector<string> searchPath;

// In this demo, we select resource according to the frame's height.
// If the resource size is different from design resolution size, you need to set contentScaleFactor.
// We use the ratio of resource's height to the height of design resolution,
// this can make sure that the resource's height could fit for the height of design resolution.

// if the frame's height is larger than the height of medium resource size, select large resource.
if (frameSize.width > mediumResource.size.width)
{
    searchPath.push_back(largeResource.directory);
    director->setContentScaleFactor(largeResource.size.height/designResolutionSize.height);
}
// if the frame's height is larger than the height of small resource size, select medium resource.
else if (frameSize.width > smallResource.size.width)
{
    searchPath.push_back(mediumResource.directory);
    director->setContentScaleFactor(mediumResource.size.height/designResolutionSize.height);
}
// if the frame's height is smaller than the height of medium resource size, select small resource.
else
{
    searchPath.push_back(smallResource.directory);
    director->setContentScaleFactor(smallResource.size.height/designResolutionSize.height);
}
    
// set searching path
FileUtils::sharedFileUtils()->setSearchPaths(searchPath);

Look here for the codesnippets http://www.cocos2d-x.org/wiki/Multi_resolution_support

These warnings are OK. The first one is cause you have set the minimum SDK version to 9, but are using 19. Just set it in your AndroidManifest.xml: <uses-sdk android:minSdkVersion="19"/> to get rid of the warning. But remember, that your game is then only compatible with SDK version 19 at minimum

See here http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

The other warning are because you are including the objects from the lib, and so does not need linking.

Look at the quote from here http://stackoverflow.com/questions/22396294/android-ndk-warning-on-compiling-jni-directory-in-r9d

You probably have include $(BUILD_STATIC_LIBRARY) in your Android.mk: this module does not use linker, therefore it does not need LOCAL_LDLIBS neither LOCAL_LDFLAGS. I would not worry about this warning, if this is the only problem in your build.

And he is totally right. No needs to worry about. Hence it is just a warning, so you get reminded about it.


#15

thanks for the very comprehensive reply. but the problem still remains.
after this step:

glview->setDesignResolutionSize(640, 690, kResolutionFixedHeight);

the image size does not change. remains small. but if I put the normal image size. .

 glview->setDesignResolutionSize(320, 480, kResolutionFixedHeight);

she resizes correctly (640 X 960 size) but it works only in debug mode…I think I’ve tried all the procedures correctly. i try again tomorrow, but I’m afraid it still does not work

i think the “problem” is with this function

void GLViewProtocol::updateDesignResolutionSize()
{
    if (_screenSize.width > 0 && _screenSize.height > 0
        && _designResolutionSize.width > 0 && _designResolutionSize.height > 0)
    {
		_scaleX = (float)_screenSize.width / _designResolutionSize.width;
		_scaleY = (float)_screenSize.height / _designResolutionSize.height;
        
        if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)
        {
            _scaleX = _scaleY = MAX(_scaleX, _scaleY);
        }
        
        else if (_resolutionPolicy == ResolutionPolicy::SHOW_ALL)
        {
            _scaleX = _scaleY = MIN(_scaleX, _scaleY);
        }
        
        else if ( _resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {
            _scaleX = _scaleY;
            _designResolutionSize.width = ceilf(_screenSize.width/_scaleX);
        }
        
        else if ( _resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {
            _scaleY = _scaleX;
            _designResolutionSize.height = ceilf(_screenSize.height/_scaleY);
        }
        
        // calculate the rect of viewport
        float viewPortW = _designResolutionSize.width * _scaleX;
        float viewPortH = _designResolutionSize.height * _scaleY;
        
        _viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH);
        
        // reset director's member variables to fit visible rect
        auto director = Director::getInstance();
        director->_winSizeInPoints = getDesignResolutionSize();
        director->createStatsLabel();
        director->setGLDefaultValues();
    }
}

in this passage

	_scaleX = (float)_screenSize.width / _designResolutionSize.width;
    _scaleY = (float)_screenSize.height  / _designResolutionSize.height;

if I multiply the result by 2 or if I divide the image size to half the size of the window, the image is displayed correctly.
therefore, the image size increases with the result of this operation increase.
ok, could also be a good thing. but, when I convert everything in apk, everything not works…


#16

Can you post the following:

What is your target design resolution(the base resolution, you are building you game for).
What is the resolution of your device you are running it. If running on Windows, the display resolution set.
What is the resolution of one of your assets, you are testing against.


#17

the base resolution of all images is 320x480. But if possible I would like to create a game compatible with all devices (or more possible devices).
i testing the game in bluestacks emulator. the base resolution of bluestacks is 1600x900. but the game window should downsize according to framesize indicated in the programming code. it is here that I have problems. if I try to use any other game, the window of BlueStacks resizes correctly. but with my game the window not resize and and I can not play the game or click any icon. also the image, instead of being placed in the center of the window is positioned on the far left…


#18

As a rule, you should not upscale your assets, as they will look very bad. You should design for the highest resolution you get and downscale, as it will deliver crisp images, or at least way better quality, than upscaling. Or design for some resolution, which is balanced. The upscaling factor should be kept to a minimum.

So, basically you are setting your target design resolution to 320x480. If your device resolution is 900/1600(don’t mix the x and y axis ;)), you calculate the scaling factor, based on the axis you want. Height, width or best fit. I recommend going with a fixed height in portrait mode. Depends if you want the screen to be turned.
E.g. Height: the scaling factor will be 1600/480 = 3.33 periodic now. The engine will scale your assets to those factors and the location. Your coordinates in the code will stay the same tho.

Not the game window is downsized, but the assets and the coordinates will be transformed.

If you want to send me your game code you can do that, and I can take a look at it.


#19

I checked everything with more calm, and finally it seems that I managed to solve the problem of image size.
the definition kResolutionFixedHeight is deprecated. i use

 ResolutionPolicy::FIXED_HEIGHT

still remains the problem of resizing the game window. but now it is much better than before.