Got a new computer and had forgot everything about where to place the various libs and stuff for OpenGL, so I followed Overv's tutorial on open.gl.
However, no matter what I do with the linker settings and the different libs of GLEW, I either get these linker errors:
[code]
error LNK2001: unresolved external symbol __imp____glewGenBuffers
error LNK2001: unresolved external symbol __imp__glewExperimental
error LNK2019: unresolved external symbol __imp__glewInit@0 referenced in function _main
[/code]
or an access violation when I try to run Overv's quick GLEW test code:
[code]
#define GLEW_STATIC
#include "stdafx.h"
#include <GL/glew.h>
int main()
{
glewExperimental = GL_TRUE;
glewInit();
GLuint vertexBuffer;
glGenBuffers( 1, &vertexBuffer );
printf( "%u\n", vertexBuffer );
return 0;
}
[/code]
I am sure that the library has been placed correctly, that the includes are properly included and that everything should be correctly compiled.
Any ideas as to what I am doing wrong? Because that linker error usually states that the linker can't find my glew32s library, but I am 100% certain that it has been compiled, placed and included correctly.
[QUOTE=Capsup;37089178]Got a new computer and had forgot everything about where to place the various libs and stuff for OpenGL, so I followed Overv's tutorial on open.gl.
However, no matter what I do with the linker settings and the different libs of GLEW, I either get these linker errors:
[code]
error LNK2001: unresolved external symbol __imp____glewGenBuffers
error LNK2001: unresolved external symbol __imp__glewExperimental
error LNK2019: unresolved external symbol __imp__glewInit@0 referenced in function _main
[/code]
or an access violation when I try to run Overv's quick GLEW test code:
[code]
#define GLEW_STATIC
#include "stdafx.h"
#include <GL/glew.h>
int main()
{
glewExperimental = GL_TRUE;
glewInit();
GLuint vertexBuffer;
glGenBuffers( 1, &vertexBuffer );
printf( "%u\n", vertexBuffer );
return 0;
}
[/code]
I am sure that the library has been placed correctly, that the includes are properly included and that everything should be correctly compiled.
Any ideas as to what I am doing wrong? Because that linker error usually states that the linker can't find my glew32s library, but I am 100% certain that it has been compiled, placed and included correctly.[/QUOTE]
Your test code fails because no OpenGL functions can be loaded without an active context.
[QUOTE=Overv;37089639]Your test code fails because no OpenGL functions can be loaded without an active context.[/QUOTE]
You're right.
I haven't done anything OpenGL related in like, half a year, so I've forgotten quite a bit about it.
I added in a GLFW context and got it to work with the glew32sd library. Thanks!
I still can't get it to work with the glew32s library though.
I'm using WinForms, and trying to draw an image scaled up but with no interpolation / blurring. I've succeeded in one place, but it doesn't work in another.
This code works, it is in an override of OnPaint in a class extending Panel:
[csharp]e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
RectangleF destRect = new RectangleF( ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height );
RectangleF srcRect = new RectangleF( -0.5f, -0.5f, Image.Width, Image.Height );
e.Graphics.DrawImage( image, destRect, srcRect, GraphicsUnit.Pixel );[/csharp]
This code does not. It is in an override of Paint in a class extending DataGridViewImageCell:
[csharp]RectangleF destRect = new RectangleF( ContentBounds.X, ContentBounds.Y, ContentBounds.Width, ContentBounds.Height );
RectangleF srcRect = new RectangleF( -0.5f, -0.5f, image.Width, image.Height );
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
graphics.DrawImage( image, destRect, srcRect, GraphicsUnit.Pixel );[/csharp]
The first snippet produces the image on the left, and the other makes the image on the right:
[img]http://puu.sh/OTiC[/img]
Why does only one work when they are functionally the same?
[editline]5th August 2012[/editline]
Whoops, I was scaling the second image before drawing. I am at least 7 idiots.
In C++, I need a good way to figure\ out what class of object a void pointer is pointing to.
Really what's going on is I'm making collision handlers for Box2D. Each body has a UserData void pointer that points to an object (which could be a player, wall, or shot). I need different things to happen depending on which two things collided, but all I get is that void pointer. What's the proper way to do this?
Don't use void pointers. Make an Entity class that everything else inherits from, give it a Collide method or something, and then override that method differently for each class. Then store an Entity* instead of a void*.
C++ encourages polymorhpism, which means you should never need to know what kind of object you're pointing to; that object itself should be able to respond differently to a given method based on what class it is.
I can't seem to get 3d acceleration to work in VirtualBox on my Ubuntu vm, so it doesn't let me work with OpenGl.
[QUOTE=Larikang;37094941]In C++, I need a good way to figure\ out what class of object a void pointer is pointing to.
Really what's going on is I'm making collision handlers for Box2D. Each body has a UserData void pointer that points to an object (which could be a player, wall, or shot). I need different things to happen depending on which two things collided, but all I get is that void pointer. What's the proper way to do this?[/QUOTE]
One way of doing it would be to create an interface-type class (in C++ it's really just a class with some virtual functions) and make all your objects implement that. Really, all the interface needs to do is store some (enum?) value describing the 'type' of the object.
Once that is done, it basically means that all of those objects can be casted to the interface type in order to figure out what type of object you're looking at. I don't know if there's a better way, but there's an idea anyway. If you need any example code to help, just ask and I'll see if I can whip something up for you.
[QUOTE=ShaunOfTheLive;37095005]Don't use void pointers. Make an Entity class that everything else inherits from, give it a Collide method or something, and then override that method differently for each class. Then store an Entity* instead of a void*.[/QUOTE]
He has no choice, he is using box2d.
Using void pointers in C++ is even worse than using them in C. In C, you have an excuse: No templates, no inheritance.
[QUOTE=ShaunOfTheLive;37095005]Don't use void pointers. Make an Entity class that everything else inherits from, give it a Collide method or something, and then override that method differently for each class. Then store an Entity* instead of a void*.
C++ encourages polymorhpism, which means you should never need to know what kind of object you're pointing to; that object itself should be able to respond differently to a given method based on what class it is.[/QUOTE]
Essentially this.
[editline]5th August 2012[/editline]
Goddamn ninjas.
[QUOTE=MakeR;37095039]He has no choice, he is using box2d.[/QUOTE]
He could still do that, just convert the void * to Entity * upon retrieval.
[QUOTE=MakeR;37095039]He has no choice, he is using box2d.[/QUOTE]
Ah okay, I don't have specific experience with Box2D. But still, there must be another way.
EDIT: ninjad
[QUOTE=esalaka;37095052]He could still do that, just convert the void * to Entity * upon retrieval.[/QUOTE]
This, but be sure to make the methods in the base class virtual so that the correct ones are called.
[QUOTE=ShaunOfTheLive;37095058]Ah okay, I don't have specific experience with Box2D. But still, there must be another way.
EDIT: ninjad[/QUOTE]
In Bullet, Rigid Bodies have a "motion state", which gets updated only when the physics object moves (so you can update the graphical position). The RB stores a void * that you can use for user-defined objects, or you can implement your own btMotionState and within that store a copy of your CBaseEntity * and override the set/get position functions to make the set automatically do CBaseEntity->SetPosition(...) or something.
It's cool.
Does anyone have a link to a good guide to making a basic 3D game engine using openGL and c++? Before you ask, yes, I've made many 2d applications before (I'm not just diving into this), and I want to move on.
[editline]5th August 2012[/editline]
What I really need is a guide to using OpenGL
[url]http://open.gl[/url]
THANKS!
[editline]5th August 2012[/editline]
oh gOD YES
[editline]5th August 2012[/editline]
I LOVE YOU
[QUOTE=Meatpuppet;37095516]Does anyone have a link to a good guide to making a basic 3D game engine using openGL and c++? Before you ask, yes, I've made many 2d applications before (I'm not just diving into this), and I want to move on.[/QUOTE]
[URL="http://www.amazon.co.uk/Game-Engine-Architecture-Jason-Gregory/dp/1568814135"]http://www.amazon.co.uk/Game-Engine-Architecture-Jason-Gregory/dp/1568814135[/URL]
Here is my code:
[cpp]#define GLEW_STATIC
#include <GL/glew.h>
#include <stdio.h>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
int main()
{
sf::Window window( sf::VideoMode( 800, 600 ), "OpenGL", sf::Style::Close );
glewExperimental = GL_TRUE;
glewInit();
GLuint vertexBuffer;
glGenBuffers( 1, &vertexBuffer );
printf( "%u\n", vertexBuffer );
while ( window.IsOpened() )
{
sf::Event windowEvent;
while ( window.GetEvent ( windowEvent ))
{
switch ( windowEvent.Type )
{
case sf::Event::Closed:
window.Close();
break;
case sf::Event::KeyPressed:
if (windowEvent.Key.Code == sf::Key::Escape )
window.Close();
break;
}
}
}
return 0;
}
[/cpp]
And here are my linker settings:
Search directories/Compiler: E:\glew-1.8.0\include E:\SFML-1.6\include
Search directories/Linker: E:\glew-1.8.0\lib E:\SFML-1.6\lib
And that's it. Now, my errors are:
[cpp]undefined reference to 'glewExperimental'
undefined reference to 'glewInit@0'
undefined reference to '__glewGenBuffers'[/cpp]
[QUOTE=Meatpuppet;37096489]Here is my code:
[cpp]#define GLEW_STATIC
#include <GL/glew.h>
#include <stdio.h>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
int main()
{
sf::Window window( sf::VideoMode( 800, 600 ), "OpenGL", sf::Style::Close );
glewExperimental = GL_TRUE;
glewInit();
GLuint vertexBuffer;
glGenBuffers( 1, &vertexBuffer );
printf( "%u\n", vertexBuffer );
while ( window.IsOpened() )
{
sf::Event windowEvent;
while ( window.GetEvent ( windowEvent ))
{
switch ( windowEvent.Type )
{
case sf::Event::Closed:
window.Close();
break;
case sf::Event::KeyPressed:
if (windowEvent.Key.Code == sf::Key::Escape )
window.Close();
break;
}
}
}
return 0;
}
[/cpp]
And here are my linker settings:
Search directories/Compiler: E:\glew-1.8.0\include E:\SFML-1.6\include
Search directories/Linker: E:\glew-1.8.0\lib E:\SFML-1.6\lib
And that's it. Now, my errors are:
[cpp]undefined reference to 'glewExperimental'
undefined reference to 'glewInit@0'
undefined reference to '__glewGenBuffers'[/cpp][/QUOTE]
Did you actually link with glew32s.lib?
[QUOTE=Overv;37096632]Did you actually link with glew32s.lib?[/QUOTE]
How do I do that? I'm using Code::Blocks.
[editline]6th August 2012[/editline]
Please help, I literally cannot continue.
[QUOTE=Meatpuppet;37096775]How do I do that? I'm using Code::Blocks.
[editline]6th August 2012[/editline]
Please help, I literally cannot continue.[/QUOTE]
Right click on your project on the left column -> Build options... -> Click on project name in left column -> Linker settings tab -> Click Add -> Select glew32s.lib -> Done!
I'm trying to compile my C SDL program but the compiler (GCC/MinGW) can't find the SDL.h
Here:
[img]http://img689.imageshack.us/img689/9058/sdlerror.jpg[/img]
I put all dlls, libs, includes to work, but nothing happen. I want to compile via command line.
Obs.: [i]"-lSDL"[/i] don't change nothing now.
How would I go around making a music visualizer, with the music being played on a music player like Windows Media Player or VLC? I would need to get the music info from the player or something, and then turn it into graphical effects, it would be cool if it was like, a C# library or something.
[QUOTE=Cesar Augusto;37104289]I'm trying to compile my C SDL program but the compiler (GCC/MinGW) can't find the SDL.h
Here:
[img]http://img689.imageshack.us/img689/9058/sdlerror.jpg[/img]
I put all dlls, libs, includes to work, but nothing happen. I want to compile via command line.
Obs.: [i]"-lSDL"[/i] don't change nothing now.[/QUOTE]
And where did you put SDL.h?
[QUOTE=ECrownofFire;37104403]And where did you put SDL.h?[/QUOTE]
C:\CodeBlocks\MinGW\include\SDL\SDL.h <- The directory
[QUOTE=Cesar Augusto;37104511]C:\CodeBlocks\MinGW\include\SDL\SDL.h <- The directory[/QUOTE]
#include <SDL/SDL.h>
Should work if your MinGW include directories are set up properly.
Also couldn't you just compile inside code::blocks?
[QUOTE=ECrownofFire;37105437]#include <SDL/SDL.h>
Should work if your MinGW include directories are set up properly.
Also couldn't you just compile inside code::blocks?[/QUOTE]
Same problem to Code::Blocks. I'll try again...
Sorry, you need to Log In to post a reply to this thread.