FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trouble creating a valid gl context with glfw3

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Mon Sep 03, 2012 3:31 pm    Post subject: Trouble creating a valid gl context with glfw3 Reply with quote

Hi,

Since I updated to dmd 2.060 ( on Win 7 x64 ), I am not able to create a valid OpenGL Context with glfw. I updated all dependencies ( glfw, and created a fresh Derelict git clone ). I use the code from the DerelictGLFW3 announcement thread in this forum, with the new glfw symbols.
DerelictGL3.reload();
throws the no active context exception from gl3.d line 81.


Code:

import std.conv ;
import std.stdio : writeln , writefln ;
import derelict.opengl3.gl3 ;
import derelict.glfw3.glfw3 ;

pragma(lib, "lib\\DerelictUtil.lib");
pragma(lib, "lib\\DerelictGL3.lib");
pragma(lib, "lib\\DerelictGLFW3.lib");


void main()
{
   DerelictGL3.load();
   DerelictGLFW3.load();

   int isInited = glfwInit() ;

   if( isInited == 0 )
      throw new Exception("glfwInit failure: " ~ to!string(glfwErrorString(glfwGetError())));

   scope(exit) glfwTerminate();

   glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
   glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
   glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

   auto window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Hello DerelictGLFW3", null);
   if(!window)
      throw new Exception("Failed to create window.");

   DerelictGL3.reload();

   writefln("OpenGL version string: %s", to!string(glGetString(GL_VERSION)));
   writefln("OpenGL renderer string: %s", to!string(glGetString(GL_RENDERER)));
   writefln("OpenGL vendor string: %s", to!string(glGetString(GL_VENDOR)));

   int count;
   glGetIntegerv(GL_NUM_EXTENSIONS, &count);
   for(int i=0; i<count; ++i)
      writeln(to!string(glGetStringi(GL_EXTENSIONS, i)));

}



If I comment the DerelictGL3.reload(); line I get this output in the console:
Code:

OpenGL version string:
OpenGL renderer string:
OpenGL vendor string:


Any Ideas what I am doing wrong ? Could it be related to the new dmd version or is it just a coincidence ? Have not reinstalled 2.059
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Mon Sep 03, 2012 8:05 pm    Post subject: Reply with quote

It's because of recent changes in glfw. You now have to explicitly make a context current. Immediately after the call to glfwCreateWindow, add this line:

Code:

glfwMakeContextCurrent(window);


Then DerelictGL3.reload will be able to do its thing.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Tue Sep 04, 2012 4:40 am    Post subject: Reply with quote

Hi Aldacron,

thanks, that was the problem. Are those changes documented somewhere or do you just read the repo change log ? I did look into the glfw examples, but must have overseen that piece of code.
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Sep 04, 2012 5:56 am    Post subject: Reply with quote

I've always periodically scanned the glfw commit history to see what's up. This one, though, actually took me by surprise some weeks back. I realized they had added the method, but hadn't looked at it in detail to understand that it was now required. So when I updated and had the same problem you encountered, I headed straight to #glfw for help. So now, when I check up on glfw, I tend to pay more attention to the details of each commit before I jump into updating Derelict.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group