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

  • SEARCH
  • Home
  • 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 7030947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:44:19+00:00 2026-05-28T00:44:19+00:00

When I call glXChooseVisual (aka GLX.ChooseVisual in C#) it returns a null IntPtr. Now

  • 0

When I call “glXChooseVisual” (aka GLX.ChooseVisual in C#) it returns a null IntPtr.
Now what confuses me is when I build the NeHe lesson02 basically using the same code it works (the only difference it being written in C).

Also when I step into code from the OpenTK and find when it calls “glXChooseVisual” it returns a valid Visual ptr, and I can’t as of yet find anything im missing.

Also what bugs me is I have had this working in the past like a year ago. The reason i’m doing this is for a cross platform API thats not just limited to OpenGL so any help would be great.

I’ve tried all this on [Ubuntu 11.10 Nvidia 5700] and [Fedora 16 Nvidia 6100] and they both fail. You can copy and past this code in a Mono-C# console App to test it out.

using System;
using System.Runtime.InteropServices;

namespace TestGL
{
    static class GLX
    {
        [DllImport("libX11", EntryPoint = "XOpenDisplay", ExactSpelling = true)]
        public static extern IntPtr XOpenDisplay(IntPtr display_name);

        [DllImport("libX11", EntryPoint = "XDefaultScreen", ExactSpelling = true)]
        public static extern int XDefaultScreen(IntPtr dpy);

        [DllImport("libGL", EntryPoint = "glXChooseVisual", ExactSpelling = true)]
        public static extern IntPtr ChooseVisual(IntPtr dpy, int screen, int[] attribList);

        public const int RGBA   =   4;
        public const int DOUBLEBUFFER   =5;
        public const int RED_SIZE   =   8;
        public const int GREEN_SIZE =   9;
        public const int BLUE_SIZE  =   10;
        public const int ALPHA_SIZE =   11;
        public const int DEPTH_SIZE =   12;
        public const int None = 0x8000;
    }

    class MainClass
    {
        public static void Main (string[] args)
        {
            Console.WriteLine ("Hope this works!");

            //Get DC
            IntPtr dc = GLX.XOpenDisplay(new IntPtr(0));
            int screen = GLX.XDefaultScreen(dc);

            //Set BackBuffer format
            int[] attrListDbl =
            {
                GLX.RGBA,
                GLX.DOUBLEBUFFER,
                GLX.RED_SIZE, 8,
                GLX.GREEN_SIZE, 8,
                GLX.BLUE_SIZE, 8,
                GLX.DEPTH_SIZE, 16,
                0
            };

            IntPtr visual = GLX.ChooseVisual(dc, screen, attrListDbl);
            if (visual == IntPtr.Zero)
            {
                int[] attrListSgl =
                {
                    GLX.RGBA,
                    GLX.RED_SIZE, 8,
                    GLX.GREEN_SIZE, 8,
                    GLX.BLUE_SIZE, 8,
                    GLX.DEPTH_SIZE, 16,
                    0
                };

                visual = GLX.ChooseVisual(dc, screen, attrListSgl);
            }

            if (visual == IntPtr.Zero) 
            {
                Console.WriteLine("Failed to get visual."); 
            }
            else
            {
                Console.WriteLine("Yahoo.");    
            }

            //ctx = GLX.CreateContext(dc, visual, new IntPtr(0), true);
            //GLX.MakeCurrent(dc, handle, ctx);
        }
    }
}
  • 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-05-28T00:44:20+00:00Added an answer on May 28, 2026 at 12:44 am

    I found the issue. Don’t know why I didnt have this issue a year ago but I just had to change “libGL” to “libgl.so.1” and it works.

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

Sidebar

Related Questions

I call a javascript function from a textbox by using OnKeyPress=clickSearchButton() Here is my
Call like: mAsyncRunner.request(me, params,new AsyncFacebookRunner.RequestListener() returns me all info for user /according to permisions/.
i call a controller action in a unit test. ViewResult result = c.Index(null,null) as
I call a Python script from crontab. The script does generates colored output using
I call a service which returns a gzipped file. I have the data as
The call to System.currentTimeMillis() returns always 0 on Motorola Droid, Android 2.0. There is
Example call to copy a book using the Book Copy module in Drupal 6
I call service method using ThreadPool.QueueUserWorkItem(o => service.Method(arg1, arg2)); Service has object 'loggingService' with
Problem: Call to send() , returns Winsock Error 10038 against socket handle Illustration: acceptedSocket
I call a dll from Java using JNI. The DLL calls another thirdparty library

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.