[QUOTE=Richy19;35699574]The cube[/QUOTE]
-snip-
Didn't realise it was 3d, sorry!
AbstractBase const & is apparently the proper way to do that though
[QUOTE=Nerr;35699638]If you draw the cube first surely you'd be then drawing the sphere on top of it?[/QUOTE]
surelly by that logic if I swap them then looking from the other side the cube will be drawn ontop of the sphere
Alright, so I'm using OpenTK, added some shader lighting and it looks pretty good.
Problem is, whenever I rotate my camera the light sort of 'rotates with it', as illustrated below:
[t]http://i.imgur.com/sTqR7.png[/t][t]http://i.imgur.com/ucdaT.png[/t][t]http://i.imgur.com/SNV5j.png[/t]
If you look at the colours, you can see that the light moves around.
I believe this is a common problem with lighting in OpenGL, since I can find plenty of information on it.
The problem is, the most common answer ( First call all transformations, then set the light's position and then render the scene ) doesn't work for me.
I've tried multiple things but the result, sadly, is always the same.
[editline]derp[/editline]
Ignore this post, I forgot to add the created lights to the list, resulting in an always empty list.. :suicide:
[QUOTE=esalaka;35699607]As said earlier, implement all nonimplemented methods.
[editline]24th April 2012[/editline]
Which means you'll have to implement exactly one: AbstractBase operator+ (AbstractBase)
[editline]24th April 2012[/editline]
(Although frankly I can't see why it isn't AbstractBase operator+ (AbstractBase&) or even AbstractBase operator+ (const AbstractBase&) const[/QUOTE]
But how do I make the link between my overloaded operator+ in my AbstracBase header file and my DerivedClass header file? The thing is that my DerivedClass operator+ returns a DerivedClass object, and in my AbstractBase class it returns an AbstractBase object. They need to have the same argument and return types to be recognized.
So now I have the problem that:
-my AbstractBase class operator+ returns an AbstractBase object (no implementation)
-my DerivedClass class operator+ returns a DerivedClass object
So apparently the implementation of the overloading of an operator is restricted to the argument & return types of the base class?
To make it more clear:
AbstractFruitClass
Fruit* operator+ (Fruit*)
DerivedPearClass
Pear* operator+ (Pear*)
Those two are different, yet I thought that if it returns a pear, it automatically also returns a fruit so it's not an abstract child function because it implements the abstract operator+ from AbstractFruitClass but with different return types...
I'm sorry if this is unclear, if so ignore my post and I'll try to reformulate it in an hour or something...
You need to implement AbstractBase operator+ (AbstractBase) in your child class. With those exact types.
Which is exactly why it should be using references I guess :v:
Try changing it to AbstractBase& operator+ (AbstractBase const &) const or something
because you should be able to implement that in your subclass unless I'm being retarded again
I'll just go check actually
I can't even make the code work
[QUOTE=esalaka;35699987]You need to implement AbstractBase operator+ (AbstractBase) in your child class. With those exact types.
Which is exactly why it should be using references I guess :v:
Try changing it to AbstractBase& operator+ (AbstractBase const &) const or something
because you should be able to implement that in your subclass unless I'm being retarded again
I'll just go check actually
I can't even make the code work[/QUOTE]
Yeah I wrote it without testing so it might be terribly buggy..
Hey guys, I need some help for a Java class assignment.
The problem I've run in to is:
I have an ArrayList of words, and I need to loop through this ArrayList only ONCE and for each word in the ArrayList keep track of its position in the ArrayList. If this word appears more than once, I need to keep track of the word's other positions as well.
For instance: If my ArrayList contains [cats, are, awesome, cats, are, cool] then I need to go through and create a new ArrayList for "cats" that holds the numbers [0, 3], a new ArrayList for "are" that holds the numbers [1, 4], "awesome" that holds the numbers [2], and "cool" that holds the numbers [5].
I just don't know how I could go about doing this by only looping through the ArrayList of words only once.
Thanks for any advice you can give!
[QUOTE=ief014;35701310]Release mode?[/QUOTE]
OH MY GOD YOU'RE A GENIUS THANK YOU SO MUCH I FIXED THAT SHIT THANKS MAN.
Not a clue what the flying fuck is going on. I have a game developed using visual studio. It runs pretty slowly in debug mode as expected (30fps or so), and when I change it to release mode I get around 100fps.
This is fine, but I only get 100fps when I run the release mode executable from visual studio. As soon as I launch it without the debugger attached I get about 20fps. Anyone got a clue what's going on?
[QUOTE=ief014;35701310]Release mode?[/QUOTE]
How does release mode fuck up that much?
It wasn't that part of the code that was bugged, but another that was returning true. I think the release mode was unable to find out exactly what part of the code was returning true, thus giving false positives.
[QUOTE=Hypershadsy;35701753]How does release mode fuck up that much?[/QUOTE]
Release mode isn't exactly "fucked up." It's just debugging optimized code can be a little whacky.
He may have multiple "return true;" statements, and while optimizing during compiling, the compiler will refrain from creating the same code twice, so it will jump to the already compiled "return true;" statement.
That's why the Debug mode exists, so it will compile the exact code that is written without any optimizations.
[QUOTE=Richy19;35699081]Does anyone know what could be causing this?
(The sphere should be behind the cube)
[IMG]http://i.imgur.com/SvVKc.png[/IMG]
I have these enabled:
[cpp]
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[/cpp][/QUOTE]
This should be default, but set it anyway:
glDepthFunc(GL_LEQUAL);
Two things:
1. I was writing some code using Visual C++ 2010 express and I needed to create a local scope so I could use some temporary variables I was using:
[cpp]do {
/*code*/
}while(false);[/cpp]
and it worked fine, but then I accidently backspaced the "do" and I noticed VC++ wasn't highlighting an error, I backspaced the "while(false)" as well so the code looked like:
[cpp]{
/*code here*/
}[/cpp]
and I compiled and it succeeded, when I tried to use the variables in the brackets an error popped up. It seems like this is doing what it should do, however I have never seen this syntax before, is this correct and portable syntax?
2. How would I try directly to a window with the WIN32 API using raw color data for the entire screen. As in I would have an array of RGBA or BGRA or other similair formated color data the size of the window and I would want to draw.
Yes, it is portable. Basically what you're doing is opening a nested scope, there is no conditions needed to enter it. Anything allocated on the stack in that scope will be destroyed when exiting it.
Does anyone have any idea what the error "Error: (0): Texture/surface reference must be simple name" means for opencl?
Seems to be caused by the line
[cpp]float4 colour=read_imagef(texture, image_descriptor, coordtest);[/cpp]
but a backup of the project with similar code works perfectly.
Could somebody please recommend a book to read for a beginner learning C#?
C# 2010 All-In-One for Dummies? I learned C++ from a similar for dummies book.
So I'm JUST starting C++ in Visual Studio with little experience (Python) in programming and I was wondering how to stop the console from exiting out the moment to code finishes.
[QUOTE=theseltsamone;35706033]So I'm JUST starting C++ in Visual Studio with little experience (Python) in programming and I was wondering how to stop the console from exiting out the moment to code finishes.[/QUOTE]
I don't know if there's a setting to automatically do it in Visual Studio (it's automatic in Code::Blocks), but you can put this at the end of main():
[cpp]
cout << "Press any key to exit..." << endl;
cin.getline();
[/cpp]
EDIT:
Sorry, use cin.get() instead. getline needs parameters
EDIT:
Technically, you should do this:
[cpp]
cout << "Press any key to exit..." << endl;
cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
cin.get();
[/cpp]
[QUOTE=shill le 2nd;35706052]
Technically, you should do this:
[cpp]
cout << "Press any key to exit..." << endl;
cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
cin.get();
[/cpp][/QUOTE]
I'll have to save that. Thanks.
I have this problem with collision detection in C++
[cpp]for(iter = objects.begin(); iter != objects.end(); ++iter)
{
if(!(*iter)->Collidable()) continue;
for(iter2 = iter; iter2 != objects.end(); ++iter2)
{
if( !(*iter2)->Collidable()) continue;
if((*iter)->GetID() == (*iter2)->GetID()) continue;
if( (*iter)->CheckCollisions( (*iter2) ))
{
(*iter)->Collided((*iter2)->GetID());
(*iter2)->Collided((*iter)->GetID());
}
}[/cpp]
So I'm using tile based mapping, and I get huge slow down because I think it's trying to cycle through all my tiles, is there a way I can get my level class (that is an iter) to not check itself with all the other level iters and only with another class?
[QUOTE=theseltsamone;35706033]So I'm JUST starting C++ in Visual Studio with little experience (Python) in programming and I was wondering how to stop the console from exiting out the moment to code finishes.[/QUOTE]
system("Pause");
[QUOTE=esalaka;35699987]You need to implement AbstractBase operator+ (AbstractBase) in your child class. With those exact types.
Which is exactly why it should be using references I guess :v:
Try changing it to AbstractBase& operator+ (AbstractBase const &) const or something
because you should be able to implement that in your subclass unless I'm being retarded again
I'll just go check actually
I can't even make the code work[/QUOTE]
Hah our professor decided to leave the overloading out of the task :v: it involved code that was too complex. Dang I'm glad I didn't spend too much time on this.
So I'm trying to make Snakes and Ladders. It works 100% so far, we just need to add in actual Snakes and Ladders, and the other thing is, getting the zig zag pattern to work. So player starts in the bottom left, moves right and instead of going back to the left and up a row, he will move up a row at the right hand side and then go left. How can we do that?
Here is the Snakes class we used: [url]http://pastebin.com/8chwFt2Q[/url]
Would we make it in the move player method or what?
So I want to learn OpenGL. I looked around on the internet for tutorials and stuff, but I only found old stuff about the fixed function pipeline.
Is there any good online tutorials or a good book available for modern OpenGL?
Can someone sheck over this and tell me if I have done something wrong? when ever I have more than 1 drawable I get a segfault
base drawable:
[cpp]void Drawable::Update()
{
if(node != NULL)
node->Model = Model * node->Model;
}
void Drawable::Draw()
{
glUseProgram(shader->shaderID);
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
glUniformMatrix4fv(ModelID, 1, GL_FALSE, &Model[0][0]);
glUniform1i(DrawLinesID, prog->drawLines);
glUniform4fv(ambLightID, 1,&ambientLight[0]);
glUniform4fv(diffLightID, 1,&diffuseLight[0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glUniform1i(textureID, 0);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(positionID);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
positionID, // attribute 0. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(uvID);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glVertexAttribPointer(
uvID, // attribute 0. No particular reason for 0, but must match the layout in the shader.
2, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
glEnableVertexAttribArray(normID);
glBindBuffer(GL_ARRAY_BUFFER, normbuffer);
glVertexAttribPointer(
normID, // attribute 0. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
// Index buffer
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexbuffer);
glDrawElements(
GL_TRIANGLES, // mode
index_data.size(), // count
GL_UNSIGNED_INT, // type
(void*)0 // element array buffer offset
);
glDisableVertexAttribArray(positionID);
glDisableVertexAttribArray(uvID);
glDisableVertexAttribArray(normID);
}[/cpp]
cube which inherits from the drawable:
[cpp]
void Cube::Update()
{
Drawable::Update();
MVP = prog->Projection * prog->View * Model;
}
void Cube::Draw()
{
Drawable::Draw();
}
[/cpp]
Sorry, you need to Log In to post a reply to this thread.