Seems like I'm getting an unhandled exception related to the graphics when working on my project in Visual Studio.
I updated the graphics drivers recently, due to Windows 10. It seems like since then these problems happen. It's not on my code, as I've been on and on changing it trying to fix it for full days with no avail. This is a devastating problem.
I've eventually downgraded my Intel graphics driver in attempt to fix this issue, but nichts.
What am I doing wrong?
This is the code I get:
Unhandled exception at 0x657F994A (igd10iumd32.dll) in Game.exe: 0xC0000005: Access violation reading location 0x00000158.
Apparently I don't have enough reputation to comment, so I'll just post this as an answer.
I'm having the same issue. I also upgraded from Windows 7 to 10. My laptop has both integrated and dedicated graphics cards, but the preferred graphics card is a NVIDIA GeForce 710m. I thought that I only needed to upgrade my drivers, but after upgrading my driver from 340.52 to the latest (353.62), my problem still persisted.
Below is a sample 'hello world' program that reproduces the program on my machine. It's seemly random - it may happen in the 2nd loop, or the 279th.
#include "sdl/SDL.h"
#include "sdl/SDL_syswm.h"
int main( int argc, char*argv[] )
{
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
return 1;
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 4 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 );
SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 0 );
SDL_Window* sdlWindow = SDL_CreateWindow(
"tac",
30, 60,
1366, 768,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN );
if( !sdlWindow )
return 1;
SDL_GLContext mainContext = SDL_GL_CreateContext( sdlWindow );
if( !mainContext )
return 1;
while( true )
{
SDL_Event mySDLevent;
while( SDL_PollEvent( &mySDLevent ) )
{
}
SDL_GL_SwapWindow( sdlWindow ); // <-- it crashes here
}
SDL_GL_DeleteContext( mainContext );
SDL_DestroyWindow( sdlWindow );
SDL_Quit();
return 0;
}
First-chance exception at 0x5ECB9958 (igd10iumd32.dll) in MyGame.exe: 0xC0000005: Access violation writing location 0x77007B85.
Unhandled exception at 0x5ECB9958 (igd10iumd32.dll) in tacMain.exe: 0xC0000005: Access violation writing location 0x77007B85.
My callstack comes from these dlls
igd10iumd32.dll
nvoglv32.dll
kernel32.dll
ntdll.dll
So I assume it's a driver issue?...
Related
I creating a small renderer using OpenGL and am getting the access violation error only when using that particular function. Other Gl functions work perfectly fine.
What I have tried so far
setting glewExperimental = GL_TRUE before glewInit
using glGenFramebuffersEXT instead of glGenFramebuffers - Same error
Here is the code I am using to initialize SFMLand GLEW
sf::ContextSettings settings;
settings.depthBits = 24;
settings.stencilBits = 8;
settings.majorVersion = 3;
settings.minorVersion = 3;
settings.attributeFlags = sf::ContextSettings::Core;
window = new sf::Window( sf::VideoMode( screenWidth, screenHeight, 32 ), "OpenGL SFML", sf::Style::Titlebar | sf::Style::Close, settings );
glewExperimental = GL_TRUE;
if ( GLEW_OK != glewInit( ) )
{
std::cout << "Failed to initialize GLEW" << std::endl;
return false;
}
System information:
OS: Windows 10
GPU : GTX 1060
GLEW version: 2.1.0
So I am starting with Code Blocks and was following a tutorial online, I made an empty project that had one file.
#include <SDL.h>
#include <stdio.h>
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main( int argc, char* args[] )
{
//The window we'll be rendering to
SDL_Window* window = NULL;
//The surface contained by the window
SDL_Surface* screenSurface = NULL;
//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//Create window
window = SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
if( window == NULL )
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
}
else
{
//Get window surface
screenSurface = SDL_GetWindowSurface( window );
//Fill the surface white
SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0xFF, 0xFF ) );
//Update the surface
SDL_UpdateWindowSurface( window );
//Wait two seconds
SDL_Delay( 2000 );
}
}
//Destroy window
SDL_DestroyWindow( window );
//Quit SDL subsystems
SDL_Quit();
return 0;
}
Linker Settings:
-lmingw32 -lSDL2main -lSDL2
And I get this error,
||=== Build: Debug in Yeet (compiler: GNU GCC Compiler) ===|
D:\Coding\addons\lib\x86\SDL2main.lib(Win32\Release\SDL_windows_main.obj):(.text[_OutOfMemory]+0xf)||undefined reference to `SDL_ShowSimpleMessageBox'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
I'm not sure if this is a memory error, or an undefined reference error if it is a memory error I would not know why since other bigger programs have had enough memory, and the undefined reference is erroring on a piece of code that seems to not be in my code...
Any help would be appreciated. :)
So yeah I was using the wrong libraries, so if anyone else is having a problem make sure you're downloading the correct files for your IDE. Thank you HolyBlackCat :)
Maybe it's just me being dumb, but I'm sure this should work.
#include <SDL2/SDL.h>
#include <GL/glew.h>
struct Display
{
SDL_Window* window;
SDL_GLContext context;
};
Display* init()
{
SDL_Init( SDL_INIT_EVERYTHING );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK , SDL_GL_CONTEXT_PROFILE_CORE );
SDL_Window* window = SDL_CreateWindow( "Ice Engine",
800, 600,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOW_OPENGL );
if ( !window )
{
printf( "%s\n", SDL_GetError() );
return nullptr;
}
SDL_GLContext context = SDL_GL_CreateContext( window );
if ( !context )
{
printf( "%s\n", SDL_GetError() );
return nullptr;
}
glewExperimental = GL_TRUE;
if ( glewInit() != GLEW_OK )
return nullptr;
return new Display{ window, context };
}
int main( int argc, char** argv )
{
Display* display = init();
bool running = true;
SDL_Event e;
while( running )
{
while( SDL_PollEvent( &e ) )
if ( e.type == SDL_QUIT )
running = false;
SDL_GL_SwapWindow( display->window );
}
delete display;
SDL_Quit();
}
I probably shouldn't be using new and delete and such, but this was just a quick setup to get my project going. The problem is it compiles just fine, but when I run it I get this error:
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 1 (X_CreateWindow)
Value in failed request: 0x0
Serial number of failed request: 155
Current serial number in output stream: 168
I've tried without setting the OpenGL context versions, but I just get the same error.
I tried switching to GLFW3 and it all works just fine. It creates me a window and a OpenGL 3.3 core profile context. So it seems to be a problem with SDL2. I'm running ubuntu 15.10 and I installed it via the command line with: sudo apt install libsdl2-dev.
You are calling SDL_CreateWindow incorrectly. You have mixed up the x, y and width, height settings. The right way would be:
SDL_Window* window = SDL_CreateWindow("Ice Engine",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
800,
600,
SDL_WINDOW_OPENGL );
See SDL_CreateWindow reference. Other than that, your code looks fine.
I use vc++ 2010 express and currently working on a project but when I try to use SDL_CreateRenderer function I get this error:
First-chance exception at 0x6c8037be in Oyun Projem.exe: 0xC0000005: Access violation reading location 0x00000010.
Unhandled exception at 0x6c8037be in Oyun Projem.exe: 0xC0000005: Access violation reading location 0x00000010.
The program '[320] Oyun Projem.exe: Native' has exited with code -1073741819 (0xc0000005).
at this line:
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
here is the code
#include "stdafx.h"
int main(int argc, char* argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *window;
SDL_Renderer *renderer;
window = NULL;
window = SDL_CreateWindow("My first RPG!", 100, 100, 100, 100, SDL_WINDOW_SHOWN);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
return 0;
}
Here is what I see when debugging:
SDL_CreateWindow returns NULL if there is a failure. Your code needs to check for this.
// Your code:
window = SDL_CreateWindow("My first RPG!", 100, 100, 100, 100, SDL_WINDOW_SHOWN);
// Add the following:
// Check that the window was successfully made
if (window == NULL) {
// In the event that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
I ran into a strange problem recently. I wrote an application class which uses a very simple renderer to draw some models on screen. The camera is movable.
I ran the program on my laptop. Initially I noticed that nothing was being drawn on screen (the screen was being cleared by the correct color, however). Then I noticed that the screen would update itself IF I clicked on the decoration frame and moved the window: this way, the models became visible, but would not move unless I clicked and moved the decoration frame again.
I tested my program on a desktop computer, and everything worked fine; the camera moved smoothly.
Eventually, I got the program to work on my laptop, but I have to set SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 0 ); and disable buffer swapping.
Below is the main application class. In the execution loop, I call the application state stack to loop & render (the application state actually owns the renderer).
In case it is of any consequence, my laptop has intel HD 4000 graphics, and the desktop has a GTX 670.
App::App() : _running( false ),
_deltaTime( 0u ),
_elapsedTime( 0u ),
_mainWindow( nullptr ),
_glContext(),
_stack() {
//ctor
}
App::~App() {
SDL_GL_DeleteContext( _glContext );
SDL_DestroyWindow( _mainWindow );
SDL_Quit();
}
void App::execute() {
_initialize();
static const float millisecondsPerFrame = 17;
while ( _running ) {
//get the delta time & update elapsed time
uint32_t oldTime = _elapsedTime;
_elapsedTime = SDL_GetTicks();
_deltaTime = _elapsedTime - oldTime;
_processEvents();
_loop( _deltaTime / 1000.0f );
_render();
//apply possible state changes made to the stack
_stack.applyPendingChanges();
int usedTime = SDL_GetTicks() - int ( _elapsedTime );
//sleep the remainder of the cycle if we didn't use the entire update cycle
if ( millisecondsPerFrame - usedTime > 0 ) {
SDL_Delay( uint32_t ( millisecondsPerFrame - usedTime ) );
}
}
}
void App::_initialize() {
//initialize random number generator
nge::srand();
_running = true;
_initializeSDL();
_initializeOpenGL();
SDL_GL_MakeCurrent( _mainWindow, _glContext );
//attempt to set late swap tearing
int res = SDL_GL_SetSwapInterval( -1 );
//returns 0 on success
//returns -1 if swap interval is not supported
if ( res == -1 ) {
std::cout << "App::_initializeSDL> " << SDL_GetError() << "\n\n";
SDL_GL_SetSwapInterval( 1 );
}
_stack.registerState<GameState>( AppStateID::Game );
_stack.pushState( AppStateID::Game );
_stack.applyPendingChanges();
}
void App::_initializeSDL() {
SDL_Init( SDL_INIT_VIDEO );
SDL_Init( SDL_INIT_TIMER );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_CORE );
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
/**
For some reason, on my Samsung Series 9, double buffering does not
work.
*/
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 0 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 );
//anti-aliasing
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 );
_mainWindow = SDL_CreateWindow( "window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
800,
600,
SDL_WINDOW_OPENGL |
SDL_WINDOW_RESIZABLE |
SDL_WINDOW_MAXIMIZED |
SDL_WINDOW_SHOWN );
_glContext = SDL_GL_CreateContext( _mainWindow );
}
void App::_initializeOpenGL() {
//initialize GLEW
glewExperimental = GL_TRUE;
if ( glewInit() != GLEW_OK ) {
std::cerr << "glewInit failed." << std::endl;
std::exit( EXIT_FAILURE );
}
glEnable( GL_DEPTH_TEST );
//enable culling
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
glDepthFunc( GL_LEQUAL );
glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS );
std::cout << "OpenGL version: " << glGetString( GL_VERSION ) << std::endl;
std::cout << "GLSL version: " << glGetString( GL_SHADING_LANGUAGE_VERSION ) << std::endl;
std::cout << "Vendor: " << glGetString( GL_VENDOR ) << std::endl;
std::cout << "Renderer: " << glGetString( GL_RENDERER ) << std::endl << std::endl;
//make sure OpenGL 3.3 is available
ASSERT( GLEW_VERSION_3_3, "OpenGL 3.3 API is not available" );
}
void App::_processEvents() {
SDL_Event event;
while ( SDL_PollEvent( &event ) ) {
if ( event.type == SDL_QUIT ) {
_running = false;
}
}
}
void App::_loop( float delta ) {
_stack.loop( delta );
}
void App::_render() {
_stack.render();
//SDL_GL_SwapWindow( _mainWindow );
}
The first thing that I would check are GPU drivers on the laptop. Make sure that the drivers version matches the drivers version on the desktop.
Second thing is to add error printing. From here :
window = SDL_CreateWindow("OpenGL Window", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL);
if (!window) {
fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
return;
}
context = SDL_GL_CreateContext(window);
if (!context) {
fprintf(stderr, "Couldn't create context: %s\n", SDL_GetError());
return;
}
Third thing to check are requested buffers. Maybe the GPU or drivers do not support double buffering, or depth size of 16 bits, or some other parameter that you requested. So, play with parameters in the initializeSDL() function, and find the one that works on your laptop.