Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:47:40+00:00 2026-06-13T14:47:40+00:00

I have a small script which is meant to get the user’s screen resolution

  • 0

I have a small script which is meant to get the user’s screen resolution and assign it to a variable but i get an Access Violation error and not sure how to fix it (I’m quite new to this language) so was hoping some one can show me how I should write it.

This is my setup:

//get player's screen info
const SDL_VideoInfo* myScreen = SDL_GetVideoInfo();

//SDL screen
SDL_Surface *screen;
int reso_x = myScreen->current_w; //resolution width (ERROR here)
int reso_y = myScreen->current_h; //resolution height
Uint8  video_bpp = 32;
Uint32 videoflags = SDL_SWSURFACE | SDL_DOUBLEBUF | SDL_ANYFORMAT;// | SDL_FULLSCREEN;

/* Initialize the SDL library */
if ( SDL_Init(videoflags) < 0 ) {
     fprintf(stderr, "Couldn't initialize SDL: %s\n",
     SDL_GetError());
     exit(1);
     }

//setup Screen
screen = SDL_SetVideoMode(reso_x, reso_y, video_bpp, videoflags|SDL_FULLSCREEN);

Does any one know the cause of my mistake?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:47:42+00:00Added an answer on June 13, 2026 at 2:47 pm

    You shouldn’t make any SDL calls before SDL_init. My guess is GetVideoInfo is returning null because you are not in a valid state at that point. Also the flags you are passing to init are wrong, it should be SDL_INIT_VIDEO not what kind of video you want. Your video flags should go to the SetVideoMode function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small script which im using to test PHP mail(), as below:
I have a small python script which draws some turtle graphics. When my script
I have small script in bash, which is generating graphs via gnuplot. Everything works
I have a small ruby script in which I'd like to use ActiveRecord to
I have a small script where you can drag the link, but I also
I have a small php script which allows me to upload image file on
I have shell scripting knowledge. I have written a small shell script which will
I have written a script which is basically a small wysiwyg signature generator for
I have a very small batch script which is extracting a quite amount of
I have a small script which makes an li element click-able and sets the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.