glActiveTexture crashes program

  • Follow


i try binding three textures for a shader, code compiles now without
errors (some warnings due scanf, but thats ignoreable)

when i run the program i get the following output, then the
application simply closes...

E:\Coding\current\oglLoader\Release>oglLoader.exe bradley.model
SUCCESS found model file [bradley.cmsh] not found
SUCCESS found texture file [bradley.png] found
ERROR 404 - normalmap file [none] not found
ERROR 404 - heightmap file [none] not found
ERROR 404 - vertex shader file [none] not found
ERROR 404 - fragment shader file [none] not found
version: 5
sucessfully loaded texture map [bradley.png]!

E:\Coding\current\oglLoader\Release>

any ideas whats going on there???

thanks in advance

[...]
#include <GL/glew.h>
#include <GL/glut.h>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

#include "myClasses.h" // my private helper classes
#include "Mesh.h" // one mesh class
#include <GL/glext.h>
[...]
	fprintf (stderr, "sucessfully loaded texture map [%s]!\n",
texturemapfile);
	glActiveTexture(GL_TEXTURE0);
	cout << "crash in the line above but why?\n";
	glBindTexture(GL_TEXTURE_2D, textureMap);
	glEnable(GL_TEXTURE_2D);
	glUniform1i(textureMap, 1);
[...]

0
Reply lumo2000 (16) 5/22/2007 5:04:00 PM

lumo2000@gmail.com wrote:

> any ideas whats going on there???

Did you check, if glActiveTexture is a valid pointer after
calling glewInit()? If the extension is not avaliable you'll get
a null pointer, this crashing the program.

Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith@jabber.org, ICQ: 134682867

0
Reply Wolfgang 5/22/2007 5:48:06 PM


> Did you check, if glActiveTexture is a valid pointer after
> calling glewInit()? If the extension is not avaliable you'll get
> a null pointer, this crashing the program.

i am not sure if i understood what you mean
but if you mean this:

[code]
glewInit();
	if (glewIsSupported("GL_VERSION_2_0"))
		printf("Ready for OpenGL 2.0\n");
	else {
		printf("OpenGL 2.0 not supported\n");
		exit(1);
	}
[/code]

then yes, i checked it

0
Reply lumo2000 5/23/2007 12:54:54 PM

> Did you check, if glActiveTexture is a valid pointer after
> calling glewInit()? If the extension is not avaliable you'll get
> a null pointer, this crashing the program.

i think now i understood...
 you meant this?

	if(glActiveTexture==NULL)
	{
		printf("glActiveTexture not supported\n");
		exit(1);
	}

well if i check that in my main.cpp right below glewInit();
its NOT NULL
when i check it where i need it (in mesh.cpp) i get NULL returned...
so ??? why? and what can i do against that problem?

thanks in advance

0
Reply lumo2000 5/23/2007 1:03:25 PM

On May 23, 3:03 pm, lumo2...@gmail.com wrote:
> > Did you check, if glActiveTexture is a valid pointer after
> > calling glewInit()? If the extension is not avaliable you'll get
> > a null pointer, this crashing the program.
>
> i think now i understood...
>  you meant this?
>
>         if(glActiveTexture==NULL)
>         {
>                 printf("glActiveTexture not supported\n");
>                 exit(1);
>         }
>
> well if i check that in my main.cpp right below glewInit();
> its NOT NULL
> when i check it where i need it (in mesh.cpp) i get NULL returned...
> so ??? why? and what can i do against that problem?
>
> thanks in advance

I had the same problem i think.
When i did a call to glActiveTexture my program produced a Invalid
Operation and crashes (under windows).
But i think that my solution was call first glBindTexture and then
glActiveTexture.
I hope that this fix your problem. (and sorry if have some mistakes
writing english) :$

0
Reply ShOtGaN 5/24/2007 7:33:14 AM

lumo2000@gmail.com wrote:

> well if i check that in my main.cpp right below glewInit();
> its NOT NULL when i check it where i need it (in mesh.cpp) i
> get NULL returned... so ??? why? and what can i do against that
> problem? 

The pointers to extension functions are only valid within the
context you initialized them. After changing the context the
function pointers are undefined (which means that they may still
be valid, but you don't know for sure). Simple solution: Just
call glewInit() again.

In a real world applications it's always a good idea to keep the
OpenGL context switches to a minimum.

Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith@jabber.org, ICQ: 134682867

0
Reply Wolfgang 5/24/2007 11:40:07 AM

5 Replies
335 Views

(page loaded in 0.135 seconds)

Similiar Articles:






7/27/2012 3:38:04 PM


Reply: