Sign in to follow this  
Vero

Installing GLEW.h libraries for VS express 2010

Recommended Posts

Vero    138
I having some serious issues trying to get the GLEW libraries to compile without linker errors any help would be appreciated.

[code]

#include <Windows.h> // Header File For Windows
//#include <GL/GL.h> // Header file for OpenGL32 Library
//#include <GL/GLU.h> // Header File for GLu32 Library
#include <stdio.h>
#include <stdarg.h>
#include "aMaze_Objects.h"
#include <gl\glew.h>
#include <GL/glut.h>
#include "SOIL.h"
[code]

here's the error log when i try to compile. I've tried numerious folders to place the bin lib and include files

1>------ Build started: Project: aMaze, Configuration: Debug Win32 ------
[b]1>aMaze_Main.obj : error LNK2019: unresolved external symbol __imp__glewInit referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)
1>aMaze_Objects.obj : error LNK2001: unresolved external symbol __imp____glewBlendFuncSeparate[/b]
1>C:\Users\Varonec\Dropbox\Game\aMaze\Debug\aMaze.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have tried searching the internet and I've read this link up and down:
file:///C:/Users/Varonec/Downloads/glew-1.7.0-win64%281%29/glew-1.7.0/doc/install.html

anyway, I'm not sure where I can go from here

Share this post


Link to post
Share on other sites
BitMaster    8651
You need to tell the linker to link glew32.lib (or glew32s.lib if you want to link to the static version of GLEW). If you want to link to GLEW static, remember to define GLEW_STATIC before any place where you include glew.h.

On MSVC you can use
#pragma comment(lib, "glew32s.lib")
to link to the library or Project Properties->Configuration Properties->Linker->Input->Additional Dependencies. I don't have a MSVC 2010 to check right now but it should be similar there. Edited by BitMaster

Share this post


Link to post
Share on other sites
Vero    138
Thank you so much for clearing that up. I'm finally able to get the glew libraries to compile and use the glew functionality.

So, I suppose there is a part two to this sadly. What I'm trying to accomplish is masking. Too Keep things simple the whole thing is done in glOrtho. I'm trying to create a sprite and the first step right now is rendering a texture and making everything outside of the draw part of the image transparent. the following is the draw function so far with no success in masking. there is nothing behind the drawn image only a black background right now. (no rendered quad or anything.)

[code]
GLvoid MPlayer::Draw()
{
glEnable(GL_TEXTURE_2D);
glColor4f(1.0f,1.0f,1.0f,1.0f);
glLoadIdentity();
glTranslatef(fPosition.x,fPosition.y,0.0f);
//glRotatef(spin,0.0f,0.0f,1.0f);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture(GL_TEXTURE_2D,mask[0]);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2i( 3 , interval-2); //start drawing
glTexCoord2f(0,1); glVertex2i( 3 , 3);
glTexCoord2f(1,1); glVertex2i( interval-2, 3);
glTexCoord2f(1,0); glVertex2i( interval-2, interval-2);
glEnd();
// glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D,sprite[0]);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2i( 3 , interval-2); //start drawing
glTexCoord2f(0,1); glVertex2i( 3 , 3);
glTexCoord2f(1,1); glVertex2i( interval-2, 3);
glTexCoord2f(1,0); glVertex2i( interval-2, interval-2);
glEnd();
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ZERO);
}
[/code]

Share this post


Link to post
Share on other sites
BitMaster    8651
First, I do not see a call of glEnable(GL_BLEND).
Second, are you sure the image contains an alpha channel and that the loading function you use loads the alpha channel and uploads it correctly to the texture?
Third, you probably want glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) or the inverse, depending on your alpha setup.

Share this post


Link to post
Share on other sites
Vero    138
Ok, I've created an simple little image it's a 32x32 pixel image with a white background in MSPaint. then I created a second image this one is a copy of the 1st image only any part that had color was replaced with white and the rest of the image was filled in as black.

Do I need to do something special to either image within the image editor? would I need to install something like GIMP to do so? or is MS paint in windows 7 capable of something that advanced? I uploaded the images into the program with SOIL. source: [url="http://www.lonesock.net/soil.html"]http://www.lonesock.net/soil.html[/url]

Image loader function:
[code]
bool MPlayer::LoadObjTexture(char *filename,int slot)
{
char *index = strchr(filename,'.');
char *mask= new char[0];
strncpy(mask,filename,index-filename);
mask[index-filename]='\0';
strcat(mask,"_mask.bmp");

if(MObject::LoadObjTexture(filename,slot,false)&&
MObject::LoadObjTexture(mask,slot,true))
return true;
else
{
MessageBox(NULL,L"Hero Sprite failed to Load",L"GAME ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
}

bool MObject::LoadObjTexture(char *Filename,int slot,bool isMask)
{
if(isMask)
{
mask[slot]=SOIL_load_OGL_texture
(
Filename,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y | SOIL_FLAG_MIPMAPS|SOIL_FLAG_NTSC_SAFE_RGB
);
if(mask[slot]==0)
return false;
else return true;
}
else{
sprite[slot]=SOIL_load_OGL_texture
(
Filename,
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_INVERT_Y | SOIL_FLAG_MIPMAPS|SOIL_FLAG_NTSC_SAFE_RGB
);
if(sprite[slot]==0)
return false;
else return true;
}
return false;
}
[/code]

Edit: glEnable(GL_BLEND) was declared in my initGL() function which is called at the start of the program. currently I've had no reason to disable blending Edited by Vero

Share this post


Link to post
Share on other sites
Vero    138
Just an FYI when getting Glew to compile, if you're comiling a 32bit program use the 32 bit libraries doesn't matter what your machine architecture is. Obvious problem was hidden in plain sight for me spent days banging my head against the keyboard when I couldn't compile and run my code on a different machine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this