Loading OpenGL with wgl - c

I have been having issues with the function "gladLoadGLLoader" in which I have been passing (GLADloadproc)wglGetProcAddress. I learned that this is because wglGetProcAddress only does functions from OpenGL 1.1+ and GetProcAddress does functions from OpenGL 1.0 and 1.1. How would one go about loading everything with Glad. And, please, do not suggest something like glfw because I like to manage windowing and input myself. Everything works from creating the context up until loading Glad. And, yes, I have bound the context.

Related

Is a fake context needed to create modern OpenGL context?

According to this page (and several others) you need to create a dummy window, then a dummy legacy context, then use wglCreateContextAttribsARB to create a modern context.
However I tried using the old way with wglCreateContext and loading functions manually:
glCreateShader = wglGetProcAddress("glCreateShader");
glShaderSource = wglGetProcAddress("glShaderSource");
glCompileShader = wglGetProcAddress("glCompileShader");
...etc for all other functions that I need
Then I checked the context version:
int minor;
int major;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
printf("%d.%d\n", major, minor);
And I got "4.6". Why isn't the version something like 2.0 and why is the fake context thing needed?
If you are willing to limit your application to never using WGL extensions (ie: you can't do things like control vsync, use more advanced pixel formats, create robust or debug OpenGL contexts, or any number of other tools) and always using a compatibility context, then yes, you can get away with not using the more modern context creation APIs. But there's no reason to impose such limits on your program.

CEF disable address bar

I am using CEF3 and want to hardcode and disable the address bar of the browser. I am not finding the right place in the code base to do the same. Any pointers would be of great help.
Either through the C++ or Javascript methods would help.
Thanks,
Ashwin
Are you using cefclient? I don't think there's a clean way to turn it off in the standard version of cefclient.
However, in the brackets-shell fork of cefclient there's a #define you can use to toggle it on/off cleanly. Just search for references to SHOW_TOOLBAR_UI (it's only used in four files). I'm guessing it wouldn't be too hard to manually apply those diffs back onto a clean copy of cefclient (you probably don't want to take the brackets-shell fork as-is – it's not very generic).
You can build a CEF application using the binary, just like the WIKI does. Please see the github project for a reference https://github.com/acristoffers/CEF3SimpleSample
I realize this question is old but I had the same question and found the solution.
In the cefclient example, the address bar is drawn within the RootWindowGtk::CreateRootWindow function.
Delete the gtk_container_add function call that adds the GtkToolItem* corresponding to the address bar and the address bar will be gone.

Multisampling (MSAA) for DirectX11/DirectX10 with D3DImage shared resource

I am trying to get MSAA in DX11 using D3DImage, but is seems, it is not possible, since shared multisampling texture are not allowed, as stated here: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476531(v=vs.85).aspx
Actually, I use the SharpDX implementation of the D3DImage, which works fine for DX11 and DX10 as long one can leave without anti alisasing.
Approaches to solve it are described in this thread: http://sharpdx.org/forum/5-api-usage/1000-d3d11-problem-with-usage-of-texture2d which are not successful. There is yet another thread asking a similar question: Multisampling and Direct3D10 / D3DImage interop
Finally, the question is in fact, if anyone can confirm, that it is definitly NOT possible to use D3DImage for rendering of anti-aliased content from DX10/DX11?
As said in the microsoft link (tried several times as well), multisampled shared textures are not allowed (actually texture must also have no mip level(s), as additional info)
The only way to share the texture is to create a non multisampled version (same format/parameters), then use
DeviceContext.ResolveSubresource
in SharpDX to convert the msaa texture into a non multisampled one, then you can share the result of that.

EGL_BAD_CONFIG When Creating A PixelBuffer

I am having trouble creating a PixelBuffer in OpenGL ESv2.
If my config specifies EGL_WINDOW_BIT I can successfully call eglCreateContext. However, when using EGL_PBUFFER_BIT I am getting an EGL_BAD_CONFIG.
I am working with an embedded system where I will be calling OpenGL ESv2 to do some GPGPU. I do not have a windowing system to render to so I feel that I must use PixelBuffers. My rendering calls render directly to a FBO with an attached Texture2D as the color buffer.
I am out of ideas on what's wrong with my configuration or how I can adjust it. Any advice would be great. Thank you.
I ended up writing a function to print out all my possible configurations. It turns out that even though glChooseConfiguration was returning GL_TRUE, it wasn't returning a configuration.
I wasn't getting any configurations.
OpenGL ES emulator apparently does not support PixelBuffers for OpenGL ES v2, only v1

A Guide for Creating your own Library for Cocoa(touch) development

I'm currently using a lot of the same subclassed objects with custom methods. It would be more convenient to create my own library which I can use for several projects.
The goal is to have my own classes being available in the same way classes like UIView, CGRect etc are, including convenient methods like CGRectMake, both with classes and structs. To sum it up, I want to create my own equivalents of:
Classes like UIView
Structs like CGRect
Convenient functions like CGRectMake
Have this available as a library
Have this available as an XCode template, thus, having these custom Objects available as 'new files' in XCode
So basically I'm looking for instructions on how to create classes, structs etc in order to create all the above. What is the best way to do this? The 320 project seems like a good starting point. But it lacks (I think) in:
having the library available in new projects right away
having the new classes available under 'new file'
Even if I would create an own static library, will I be able to release the app on the app store, since linking to 3rd party libraries is not supported on the phone?
For your convenience, these are basically the sub questions, covering the scope of this question:
How can I create my own library for Mac / iPhone development?
How do I create classes, structs and inline function for this library?
How do I create my own Xcode template based on this library?
Will I be able to release iPhone apps using my own static library?
FYI Xcode 3.2 has a new project template called Cocoa Touch Static Library. You might want to go that route.
If you were doing this for a Mac, you'd create a framework. However, you mention UIView, so obviously you're working with the iPhone. Apple doesn't allow iPhone applications to dynamically link against other libraries at runtime, so your only option is to create a static library. A static library is linked into the application executable when it's built.
To my knowledge, there's no static library project template in Xcode. What you'll likely have to do is start with a different iPhone Xcode template and add a Static Library target. Hang on to the default application target; you can use that to build a simple test application to make sure the library actually works.
To actually use the library in an application, you'll need two things: the compiled library (it has a .a extension) and all the header files. In your finished application, you'll link against your static library, and you'll need to #import the header files so that the compiler understands what classes, functions, etc. are available to it. (A common technique is to create one header file that imports all the others. That way, you only need to import a single file in your source files.)
As for creating your own custom templates, there's a simple tutorial here that should get you started: http://www.macresearch.org/custom_xcode_templates You can probably copy the default templates and just customize them to suit your purposes.
The struct syntax looks like this:
typedef struct _MyPoint {
CGFloat x;
CGFloat y;
} MyPoint;
Structs are are declared in header files, so you can (I believe) Command+Double Click on the name of a struct to see how it's declared.
Another little trick for creating structs is to do something like this:
MyPoint aPoint = (MyPoint){ 1.5f, 0.25f };
Because the compiler knows the order of fields in the struct, it can very easily match up the values you provide in the curly braces to the appropriate fields. Of course, it's more convenient to have a function like MyPointMake, so you can write that like this:
MyPoint MyPointMake(CGFloat x, CGFloat y)
return (MyPoint){ x, y };
}
Note that this is a function, not a method, so it lives outside of any #interface or #implementation context. Although I don't think the compiler complains if you define it in an #implementation context.
CGPointMake is defined as what's known as an inline function. You can see the definition for that in the Cocoa header files, too. (The difference between an inline function and a normal function is that the compiler can replace a call to CGPointMake with a copy of CGPointMake, which avoids the overhead of making a function call. It's a pretty minor optimization, but for a function that simple, it makes sense.)
The 320 project is a good example of an iPhone class library. You basically compile your project down into a .a library and then statically link against this in your client projects.
Since this is a community wiki now, I thought it will be helpful to link some resources and tutorials:
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
http://www.clintharris.net/2009/iphone-app-shared-libraries/
Enjoy!
The 320 project seems like a good starting point indeed. But it lacks (I think) in:
having the library available in new projects right away
having the new classes available under 'new file'
Those are project and file templates. For more information, ask the Google.
If you plan on releasing this on the app store, you wont be able to use your library in the way that you would like. As mentioned above, linking to 3rd party libraries is not supported on the phone. I think there is a 'hack' way to make it work, but you'll lose distribution.
The best I could come up with was putting all the relevant code in a directory and sharing it that way. I know its not as elegant, but its their limitation ie. out of our control.

Resources