Jogl crashing in the shader initialization, at the glLinkProgram - glsl

We got a new notebook with an Nvidia 880m
it came with win8.1, we installed the 7 x64
Trying to execute jogl, java is crashing
http://pastebin.com/gv6117NK
it crashes when glLinkProgram is called
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j jogamp.opengl.gl4.GL4bcImpl.dispatch_glLinkProgram1(IJ)V+0
j jogamp.opengl.gl4.GL4bcImpl.glLinkProgram(I)V+46
j javax.media.opengl.DebugGL4bc.glLinkProgram(I)V+9
j glsl.GLSLProgramObject.initializeProgram(Ljavax/media/opengl/GL3;Z)V+113
I am creating the shader using some code that I wrote in past, it always worked and I never got problems, so I am afraid it has something to do with the nvidia opengl driver..
I am initializing the program in this way
public final void initializeProgram(GL3 gl3, boolean cleanUp) {
_progId = gl3.glCreateProgram();
for (int i = 0; i < _vertexShaders.size(); i++) {
gl3.glAttachShader(_progId, _vertexShaders.get(i));
}
for (int i = 0; i < _fragmentShaders.size(); i++) {
gl3.glAttachShader(_progId, _fragmentShaders.get(i));
}
gl3.glLinkProgram(_progId);
int[] params = new int[]{0};
gl3.glGetProgramiv(_progId, GL3.GL_LINK_STATUS, params, 0);
if (params[0] != 1) {
System.err.println("link status: " + params[0]);
gl3.glGetProgramiv(_progId, GL3.GL_INFO_LOG_LENGTH, params, 0);
System.err.println("log length: " + params[0]);
byte[] abInfoLog = new byte[params[0]];
gl3.glGetProgramInfoLog(_progId, params[0], params, 0, abInfoLog, 0);
System.err.println(new String(abInfoLog));
}
gl3.glValidateProgram(_progId);
if (cleanUp) {
for (int i = 0; i < _vertexShaders.size(); i++) {
gl3.glDetachShader(_progId, _vertexShaders.get(i));
gl3.glDeleteShader(_vertexShaders.get(i));
}
for (int i = 0; i < _fragmentShaders.size(); i++) {
gl3.glDetachShader(_progId, _fragmentShaders.get(i));
gl3.glDeleteShader(_fragmentShaders.get(i));
}
}
}
Any tips?
Both 337 and 340 drivers fail

As jmaasing suggested, I had to force the use of the dedicated graphic card
I also had to add "C:\Program Files\Internet Explorer" to the path for the IEShims.dll and update the retail win7 to the sp1 and various updates

Related

CPLEX debug window freezes

I am trying to code my math model in CPLEX language using C++ (Concert Technology). when I run my code in the compiler window read my inputs and freezes. when trying to debug my code, the visual studio shows the following line as a breakpoint.
//constraint 2
for (cc = 0; cc < NumberOfCourses; cc++) {
IloExpr Constraint2(env);
for (rr = 0; rr < AvailableRooms; rr++) {
Constraint2 += RoomCapacity[rr] * Y[cc][rr];
mod.add(Constraint2 >= Students[cc]); // this line
Constraint2.end();
}
}
i have set up the parameters and variables as follow:
double RoomCapacity[AvailableRooms];
double Students[NumberOfCourses];
//Ycr
IloBoolVarArray2 Y(env, NumberOfCourses);
for (cc = 0; cc < NumberOfCourses; cc++)
Y[cc] = IloBoolVarArray(env, AvailableRooms);
I do not understand what is wrong with my constraint!
Your code is wrong: In the very first inner iteration you add Constraint2 to your model and then you end() that variable. So in the second inner iteration, you are doing Constraint2 += ... while the Constraint2 object was already deleted. This will lead to undefined behavior (hang, crash, ...).
I guess what you wanted to write is this (pull add() and end() out of the inner loop):
for (cc = 0; cc < NumberOfCourses; cc++) {
IloExpr Constraint2(env);
for (rr = 0; rr < AvailableRooms; rr++) {
Constraint2 += RoomCapacity[rr] * Y[cc][rr];
}
mod.add(Constraint2 >= Students[cc]);
Constraint2.end();
}

Memory Error using lambda function with array

const int bookBoatNum = 10;
Wt::WPushButton *buttonBookBoat[bookBoatNum];
Wt::WDialog *dialogBookBoat[bookBoatNum];
for (int i = 1; i < bookBoatNum; i++){
dialogBookBoat[i] = new Wt::WDialog("Book Boat");
buttonBookBoat[i] = new Wt::WPushButton();
buttonBookBoat[i]->clicked().connect(std::bind([&dialogBookBoat,i]() {
dialogBookBoat[i]->show();
}));
}
The program compiles and runs. When I click on a WPushButton object, it crashes because of the third last line because of a memory error. This code works perfectly if buttonBookBoat and dialogBookBoat are single objects, rather than an array of objects. show() is a method that displays the dialog object.
Any help is appreciated, this error has been driving me crazy and my life is on the line with this code (not really).
const int bookBoatNum = 10;
Wt::WPushButton *buttonBookBoat[bookBoatNum];
Wt::WDialog *dialogBookBoat[bookBoatNum];
for (int i = 1; i < bookBoatNum; i++){
dialogBookBoat[i] = new Wt::WDialog("Book Boat");
Wt::WDialog * tempDialog=new Wt::WPushButton();
buttonBookBoat[i] = tempDialog;
buttonBookBoat[i]->clicked().connect(std::bind([tempDialog]() {
tempDialog->show();
}));
}
I think dialogBookBoat is an array so it will not exist after the function call.

glBeginQuery GL_OUT_OF_MEMORY error

I'm using glQuery for getting info about FPS count in my application:
CollectDataBegin();
/*all drawing operations with OpenGL*/
CollectDataEnd();
Where:
void RenderingInfo::CollectDataBegin()
{
//FPS begin
available = 0;
GLenum eError;
// UPDATE 1 START
if (!bQueryGenerated){
glGenQueries(1, queries);
bQueryGenerated = true;
}
// UPDATE 1 END
//GL_NO_ERROR from glGetError();
glBeginQuery(GL_TIME_ELAPSED, queries[0]);
//GL_OUT_OF_MEMORY error from glGetError();
//FPS end
}
void RenderingInfo::CollectDataEnd()
{
//FPS begin
glEndQuery(GL_TIME_ELAPSED);
iFramesCount++;
if (iFramesCount == 20)
{
iFramesCount = 0;
while (!available) {
glGetQueryObjectiv(queries[0], GL_QUERY_RESULT_AVAILABLE, &available);
}
glGetQueryObjectui64v(queries[0], GL_QUERY_RESULT, &timeElapsed);
float jeb = static_cast<float>(timeElapsed) / std::pow(10, 9);
xRenderStats.fFPS = static_cast<float>(1.0 / jeb);
sFPS = std::to_string(xRenderStats.fFPS);
// UPDATE 1 START
if (bQueryGenerated){
glDeleteQueries(1, queries);
bQueryGenerated = false;
}
// UPDATE 1 END
}
}
Private members of RenderingInfo class:
GLuint queries[] = {0};
GLint available = 0;
GLuint64 timeElapsed;
int iFramesCount = 0;
bool bQueryGenerated = false; //UPADTE 1
I wrote and tested this code using Nvidia GeForce GTX760 with newest drivers and I had no problems at all.
But after switching to my integrated Intel HD Graphics 4600 I'm recieving GL_OUT_OF_MEMORY after calling glBeginQuery(). Interesting thing is that I'm not getting this error right away but after making some calls to glBeginQuery().
I wasn't been able to find any posts related to this matter so I'm asking for Your help is solving this issue.
UPDATE 1:
I modified my code accoring to #Ike advices, but I'm still recieving an GL_OUT_OF_MEMORY error.
After removing the code associated with glQuery my app no longer produces GL_OUT_OF_MEMORY errors. Since I was using this funcionality for counting time in which single frame is rendered, I replaced it with more reliable method:
void RenderingInfo::CollectDataBegin()
{
//FPS begin
ctTimeBegin = clock();
//FPS end
}
void RenderingInfo::CollectDataEnd()
{
//FPS begin
ctTimeEnd = clock();
dElapsedTime += (static_cast<double>((ctTimeEnd - ctTimeBegin))/CLOCKS_PER_SEC);
iFramesCount++;
if (iFramesCount == 20)
{
if ((dElapsedTime / iFramesCount) < (1.0 / CLOCKS_PER_SEC)){
xRenderStats.fFPS = 60.0f;
}
else{
xRenderStats.fFPS = static_cast<float>(iFramesCount / dElapsedTime);
}
sFPS = std::to_string(xRenderStats.fFPS);
dElapsedTime = 0.0;
iFramesCount = 0;
}
//FPS end
}
Private RenderingInfo members:
int iFramesCount =0;
clock_t ctTimeBegin = 0;
clock_t ctTimeEnd = 0;
double dElapsedTime = 0.0;
This is not the answer for a question why I received GL_OUT_OF_MEMORY, but it's for showing a possible way out when someone will end up with the similar problem.

Can Allegro update the number of joysticks at runtime?

Is there a way to update the number of joysticks plugged in at run-time other than constantly calling remove_joystick() then install_joystick? This proves to be extremely slow (goes from 60 FPS to around 5).
Allegro 4.2 answers only please...
void Joystick::Update() {
//If joystick input was lost, attempt to reacquire.
if(GetNumJoysticks() == 0) {
throw InputNotAvailableException("Joystick");
}
//If all joysticks were deleted remove input and do nothing.
if(_numjoysticks == 0) {
remove_joystick();
return;
}
//Update state information
if(poll_joystick() < 0) {
throw InputNotAvailableException("Joystick");
}
for(int i = 0; i < _numButtons; ++i) {
_prevButtons[i].b = _curButtons[i].b;
_prevButtons[i].name = _curButtons[i].name;
_curButtons[i].b = joy[_joyNumber].button[i].b;
_curButtons[i].name = joy[_joyNumber].button[i].name;
}
for(int i = 0; i < _numSticks; ++i) {
for(int j = 0; j < joy[_joyNumber].stick[i].num_axis; ++j) {
_prevSticks[i].axis[j].name = _curSticks[i].axis[j].name;
_prevSticks[i].axis[j].pos = _curSticks[i].axis[j].pos;
_prevSticks[i].axis[j].d1 = _curSticks[i].axis[j].d1;
_prevSticks[i].axis[j].d2 = _curSticks[i].axis[j].d2;
_curSticks[i].axis[j].name = joy[_joyNumber].stick[i].axis[j].name;
_curSticks[i].axis[j].pos = joy[_joyNumber].stick[i].axis[j].pos;
_curSticks[i].axis[j].d1 = joy[_joyNumber].stick[i].axis[j].d1;
_curSticks[i].axis[j].d2 = joy[_joyNumber].stick[i].axis[j].d2;
}
_prevSticks[i].flags = _curSticks[i].flags;
_prevSticks[i].name = _curSticks[i].name;
_curSticks[i].flags = joy[_joyNumber].stick[i].flags;
_curSticks[i].name = joy[_joyNumber].stick[i].name;
}
}
int Joystick::GetNumJoysticks() {
remove_joystick();
if(install_joystick(JOY_TYPE_DIRECTX)) {
return 0;
}
return (num_joysticks);
}
The 4.x series does not. The 5.x series does.
You'll have to either listen for native OS events using custom platform specific code (assuming such things exist) and only call the Allegro deinit/init functions when a change is detected, or require the user to initiate joystick refresh manually.
Under Linux, you could inotify_add_watch() /dev/input to check for changes. Looking at the 4.4 Allegro code, looks like you'd want to call the Win32 functions joyGetNumDevs() and joyGetPos(). Something like:
int WIN_MAX_JOYSTICKS = joyGetNumDevs(); // this should never change
JOYINFO ji;
int pluggedin_count = 0;
for (int i = 0; i < WIN_MAX_JOYSTICKS; ++i)
if (joyGetPos(i, &ji) == JOYERR_NOERROR) ++pluggedin_count;
if (pluggedin_count != last_pluggedin_count) /* reinit Allegro */
You'd have to do that every N seconds.
Those joy* functions are Windows functions, so read MSDN docs to learn how to use them.

How to pause a program for a few milliseconds?

How to pause a program for a few milliseconds using C++ managed code?
I tried Sleep() but it didn't work when I included the winbase.h file, I got lots of compile errors!
for(int i=0; i<10; i++)
{
simpleOpenGlControl1->MakeCurrent();
System::Threading::Thread::Sleep(100);
theta_rotated += 2.0* 3.141592653/(double)Model->size()/10.0;
simpleOpenGlControl1->Invalidate();
}
private: System::Void simpleOpenGlControl1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
{
Gl::glMatrixMode(Gl::GL_MODELVIEW);
Gl::glLoadIdentity();
Gl::glClearColor(1, 1, 1, 1);
Gl::glClear(Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT);
camera->Tellgl();
Gl::glRotated(Angle,X,Y,Z);
RenderModels();
}
void RenderModels(void)
{
Points = gcnew System::Collections::Generic::List<Point>();
Point p(0,0) ;
int t = -5;
double r = 5;
double x, z, theta;
for(int i = 0;i < Model->size();i++)
{
theta = i*2* 3.141592653/ (double)Model->size();
x = r*sin(theta + theta_rotated);
z = r*cos(theta + theta_rotated);
Gl::glPushMatrix();
Gl::glTranslated(x,0,z);
Model->at(i).Render();
p.X=x;
p.Y=0;
Points->Add(p);
t +=1;
Gl::glPopMatrix();
}
//simpleOpenGlControl1->Invalidate();
}
You want System::Threading::Thread::Sleep().
http://msdn.microsoft.com/en-us/library/system.threading.thread.sleep.aspx
System::Threading::Thread::Sleep() as mentioned in another answer. But let me warn you, it is not precise, and for small (milliseconds) Sleep is extremely imprecise. consider that your app run together with other apps and threads and they all want processor time.
#include <unistd.h>
main() {
usleep(2000); // 2 msecs
}
Read the man pages ;-)
man 3 usleep