What you want to do is probably make the timeGetTime() function to return the time since the last rendering. So before you do the rendering you set some temporary variable to the current time and then, after the rendering you set a variable, call it updateTime, to the current time subtracted by the temporary time. Then you return the updateTime in the timeGetTime().
Copypasta from WAYWO, no idea what's going wrong.
I think I now have the correct bits of lightmap, for each face that has a lightmap I cache the texture needed at loadtime. Even though this means I have loads of lightmap textures it's not really an issue as they are generally fairly low resolution. I'm still doing something wrong however.
Vertex lit (working):
[IMG]http://i.minus.com/ifoelA2msjJU7.png[/IMG]
Lightmaps (broken):
[IMG]http://i.minus.com/iWghoc9ZELc8y.png[/IMG]
Just lightmaps (broken):
[IMG]http://i.minus.com/iboYLQ3Fn3CNFw.png[/IMG]
Trying to make GLFW work on my new desktop, but opening a window fails when given a later version of OpenGL than 2.0. I checked, and my drivers support 4.1.
Offending code:
[CODE]#include <GL/glfw.h>
#include <stdio.h>
int main() {
glfwInit();
glfwOpenWindowHint( GLFW_OPENGL_VERSION_MAJOR, 3 );
glfwOpenWindowHint( GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
glfwOpenWindowHint( GLFW_WINDOW_NO_RESIZE, GL_TRUE );
printf("%i", glfwOpenWindow( 800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ));
glfwSetWindowTitle( "OpenGL" );
while( glfwGetWindowParam( GLFW_OPENED ) )
{
glfwSwapBuffers();
}
glfwTerminate();
return 0;
}
[/CODE]
I found that it also works if I comment out this line:
[CODE]glfwOpenWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );[/CODE]
I need to do this:
[code]
I=fmod(K, std::pow(P/100, 2)); // I = K / (P/100)^2 - BMI = weight / (length / 100)^2
[/code]
where data type of I, K and P is double. K and P are defined by user through std::cin >> K and std::cin >> P
I get this
[code]
1>c:\users\mart\documents\visual studio 2010\projects\kt2\kt2\test.cpp(9): error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 10.0\vc\include\math.h(497): could be 'double pow(double,int)'
1> c:\program files\microsoft visual studio 10.0\vc\include\math.h(535): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 10.0\vc\include\math.h(583): or 'long double pow(long double,int)'
1> while trying to match the argument list '(int, int)'
[/code]
I can't figure this out. Any ideas what I'm doing wrong ? Also I'm a beginner at this.
I think you need to cast the result of std::pow to a type. Because fmod seems to be able to accept a few types, and std::pow is overloadded enough to have multiple return types.
[cpp]I=fmod(K, (double) std::pow(P / 100.0, 2))); // Or sth like this[/cpp]
[QUOTE=esalaka;38251563][cpp]I=fmod(K, (double) std::pow(P / 100.0, 2))); // Or sth like this[/cpp][/QUOTE]
Disregard everything. I had another source file opened in VS while compiling. It fetched that error from another file.
Fuck and sorry for bothering.
Ok, Im very new to WPF and databinding. And I have been struggling around with this for hours now. (Using C#)
I want to simply add new rows containing 3 values, the value for column 1 is added from a value stored in an array. The value into column 2 is added from another array. And 3rd from a 3rd array. So in other words, each columns values are stored in an array. Together there is 3 different arrays.
[IMG]http://i.imgur.com/c8oRz.png[/IMG]
So my question is, could someone just show an example of what the commands are like to make a new row, and add in values.
The rest I can do. Just need the functions or the base idea of adding values from arrays (Not lists).
I'm currently coding a kind of "Ant Simulator" in C++ with SFML 1.6 and I'm working on the ant class at the moment.
There are 4 different types/states of ants: Egg, larva, queen and adult. Every type has a different image.
My problem is that I don't know how to load the images only once, so every object could still be able to acces them.
Kind of like static functions, that only exist once per class, even though there might be several objects.
It would be stupid to load the images into the RAM everytime I create a new object. so they should exist only once.
I already tried doing the following, but I always get compiling errors:
Header file:
[CODE]
public:
Ant( unsigned short type );
static void preLoadImages();
private:
static sf::Image* _antQueen;
static sf::Image* _antEgg;
static sf::Image* _antLarva;
static sf::Image* _antAdult;
sf::Sprite* _antSprite;
unsigned short _type;
[/CODE]
Cpp File:
[CODE]
void Ant::preLoadImages()
{
_antQueen = new sf::Image();
_antEgg = new sf::Image();
_antLarva = new sf::Image();
_antAdult = new sf::Image();
_antQueen->LoadFromFile( "gfx/queen.png" );
_antEgg->LoadFromFile( "gfx/egg.png" );
_antLarva->LoadFromFile( "gfx/larva.png" );
_antAdult->LoadFromFile( "gfx/adult.png" );
}
Ant::Ant( unsigned short type )
{
_type = type;
switch ( _type )
{
case TYPE_QUEEN:
_antSprite = new sf::Sprite( *_antQueen);
break;
default:
break;
}
}
[/CODE]
Compiling error message:
[QUOTE]obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antQueen'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antQueen'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antQueen'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antEgg'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antLarva'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antAdult'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antQueen'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antEgg'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antLarva'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antAdult'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antQueen'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antEgg'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antLarva'|
obj\Release\Ant.o:Ant.cpp|| undefined reference to `Ant::_antAdult'|
[/QUOTE]
Shouldn't the ant types be a subclass of ant?
[QUOTE=Meatpuppet;38253918]Shouldn't the ant types be a subclass of ant?[/QUOTE]
I'd suggest this too, for reasonability if nothing else.
[QUOTE=AlienCat;38247080]What you want to do is probably make the timeGetTime() function to return the time since the last rendering. So before you do the rendering you set some temporary variable to the current time and then, after the rendering you set a variable, call it updateTime, to the current time subtracted by the temporary time. Then you return the updateTime in the timeGetTime().[/QUOTE]
I don't understand.
[QUOTE=marvinelo;38253102]I'm currently coding a kind of "Ant Simulator" in C++ with SFML 1.6 and I'm working on the ant class at the moment.
There are 4 different types/states of ants: Egg, larva, queen and adult. Every type has a different image.
My problem is that I don't know how to load the images only once, so every object could still be able to acces them.
Kind of like static functions, that only exist once per class, even though there might be several objects.
It would be stupid to load the images into the RAM everytime I create a new object. so they should exist only once.
I already tried doing the following, but I always get compiling errors:
Header file:
[CODE]
public:
Ant( unsigned short type );
static void preLoadImages();
private:
static sf::Image* _antQueen;
static sf::Image* _antEgg;
static sf::Image* _antLarva;
static sf::Image* _antAdult;
sf::Sprite* _antSprite;
unsigned short _type;
[/CODE]
Cpp File:
[CODE]
void Ant::preLoadImages()
{
_antQueen = new sf::Image();
_antEgg = new sf::Image();
_antLarva = new sf::Image();
_antAdult = new sf::Image();
_antQueen->LoadFromFile( "gfx/queen.png" );
_antEgg->LoadFromFile( "gfx/egg.png" );
_antLarva->LoadFromFile( "gfx/larva.png" );
_antAdult->LoadFromFile( "gfx/adult.png" );
}
Ant::Ant( unsigned short type )
{
_type = type;
switch ( _type )
{
case TYPE_QUEEN:
_antSprite = new sf::Sprite( *_antQueen);
break;
default:
break;
}
}
[/CODE]
Compiling error message:[/QUOTE]
Try adding
[code]
sf::Image* Ant::_antQueen = 0;
sf::Image* Ant::_antEgg = 0;
sf::Image* Ant::_antLarva = 0;
sf::Image* Ant:: _antAdult = 0;
[/code]
To your Ant.cpp file, just above your functions.
Another thing that's boggling my mind.
Once again in C.
I declare two ints a and b and assign them the values 17 and 5.
Then I perform the logical and operation && on them.
"printf("Logical and : %i\n", a && b); "
The results?
"Logic and : 1"
How the heck do they become 1? Is there any logical explanation behind this, or is it just me doing something wrong?
why do you have a %i
[QUOTE=Swebonny;38265783]Another thing that's boggling my mind.
Once again in C.
I declare two ints a and b and assign them the values 17 and 5.
Then I perform the logical and operation && on them.
"printf("Logical and : %i\n", a && b); "
The results?
"Logic and : 1"
How the heck do they become 1? Is there any logical explanation behind this, or is it just me doing something wrong?[/QUOTE]
[del]Nope, that's logical AND.
17 is 10001 (16+1), and 5 is 101 (4+1).
So when you AND them, you just get the bits that are the same in both
...10001 (17)
...00101 (5)
--------
...00001 (1)
[/del]
EDIT: Actually, the MSDN wiki says this (I was thinking of the bitwise AND, which is also 1):
[QUOTE]The logical-AND operator produces the value 1 if both operands have nonzero values. If either operand is equal to 0, the result is 0. If the first operand of a logical-AND operation is equal to 0, the second operand is not evaluated.[/QUOTE]
[QUOTE=Swebonny;38265783]Another thing that's boggling my mind.
Once again in C.
I declare two ints a and b and assign them the values 17 and 5.
Then I perform the logical and operation && on them.
"printf("Logical and : %i\n", a && b); "
The results?
"Logic and : 1"
How the heck do they become 1? Is there any logical explanation behind this, or is it just me doing something wrong?[/QUOTE]
Both are non-zero, which means true (in C, where you don't have a separate bool type). true && true = true, 1 in C's case.
[QUOTE=AlienCat;38247080]What you want to do is probably make the timeGetTime() function to return the time since the last rendering. So before you do the rendering you set some temporary variable to the current time and then, after the rendering you set a variable, call it updateTime, to the current time subtracted by the temporary time. Then you return the updateTime in the timeGetTime().[/QUOTE]
Can you show me?
[QUOTE=Swebonny;38265783]Another thing that's boggling my mind.
Once again in C.
I declare two ints a and b and assign them the values 17 and 5.
Then I perform the logical and operation && on them.
"printf("Logical and : %i\n", a && b); "
The results?
"Logic and : 1"
How the heck do they become 1? Is there any logical explanation behind this, or is it just me doing something wrong?[/QUOTE]
I don't even understand what kind of an output you were expecting? a or b? Or neither? Possibly the bitwise a & b?
[QUOTE=ArgvCompany;38266067]Both are non-zero, which means true (in C, where you don't have a separate bool type). true && true = true, 1 in C's case.[/QUOTE]
C is pretty cool that way; if you ever need to clamp a number to 0 or 1, you can just use a double NOT (!!)
[QUOTE=esalaka;38267363]I don't even understand what kind of an output you were expecting? a or b? Or neither? Possibly the bitwise a & b?[/QUOTE]
I was expecting 0, since I assumed it compared the valued 17 with 5.
[QUOTE=Swebonny;38271375]I was expecting 0, since I assumed it compared the valued 17 with 5.[/QUOTE]
17 exists and is not 0, so evaluated logically, it's "true". You're getting a "1" becuase C casts true and false to 1 and 0 when displaying them.
Statements like this don't directly "compare" the two values you give them. The values are evaluated logically, and the results of that are compared.
[php]
17 && 5
17 and 5
(17 exists and 17!=0) and (5 exists and 5!=0)
(true and true) and (true and true)
true and true
true
1
[/php]
Yeah, I have been thinking completely wrong. I kept assuming it had to be identical values for a && operation to pass.
[QUOTE=Swebonny;38271421]Yeah, I have been thinking completely wrong. I kept assuming it had to be identical values for a && operation to pass.[/QUOTE]
That would be ==
I mxed up really bad :v: Thanks to you guys I passed my 4th assignment which was about the C language.
I have an issue with OpenGL shaders.
I have some shaders with 2 attributes in each. Everything works fine, but I need to add another attribute to one of my shaders.
I added "attribute aNameOfMyAttribute;" in my shader code, got its location with GetAttribLocation (the location is either zero or negative, while two stable attributes have location 1 or 2), put some data from an array buffer into the 3rd location with VertexAttribPointer, but DrawArrays gives "attribs not set up correctly", and nothing is drawn (even with other shaders).
What's wrong with my code?
Tried to use glBindAttribLocation, didn't help.
EDIT: fixed by moving Enable/DisableVertexAttribArray from shader creation code to shader selection.
Java question:
Is there a way to start a main method from another class in a new (sub) process?
Why:
My schoolproject is to create a game with multiplayer and spectator features: only 1 game you can join but you can spectate many.
So i want to start a new process of a main class in another package.
I slightly familiar with ProcessBuilder but haven't used it to open another package.
-snip, wrong thread-
I don't know why you'd post the code if it's pretty much unreadable.
[QUOTE=Jookia;38273716]I don't know why you'd post the code if it's pretty much unreadable.[/QUOTE]
Oops, posted it in a wrong thread.
Sorry, you need to Log In to post a reply to this thread.