Jump to content

  • Log In with Google      Sign In   
  • Create Account


dpadam450

Member Since 18 Nov 2005
Offline Last Active Jul 21 2014 07:23 PM
***--

#5166221 (Super) Smart Pointer

Posted by dpadam450 on 11 July 2014 - 09:42 AM

Imagine an RTS game, you have 20 marines shooting at one building and it blows up. All the marines have AI pointers "targetedEnemy" pointing at the building. The building blows up and is removed from the world and deleted.

Is there any good design for this?----> Updating the 20 marines "targetedEnemy" pointers that is to be NULL so they can go looking for new enemies?

shared_ptr doesn't seem to work because that is reference counted. It WOULD work if I decide that the marine AI checked their enemies health and if health < 0, call reset on the pointer. After the 20 marines all call reset() then the object would officially be deleted.

The other option I thought of was creating a new pointer type (unless one exists), where anytime I deconstruct a copy of the pointer, it has maintainted a list of people pointing to it and sets all pointers in the list to NULL.

Something like this:

 

template <class T>;
class SuperPointer

{

       T*  data;
       vector<T**> owners;
       ~SuperPointer(){ // loop through owners setting them to NULL };

};

Anyone can essentially delete the data, it will update all respective pointers who are pointing to the data. Maybe there is a better way to think about this or there is some other pointer that does this?




#5165735 c++ function pointers

Posted by dpadam450 on 08 July 2014 - 11:38 PM

Going to apply that to my actual code now..........does anyone know what that actually unrolls into? I don't mind typdef's for this case, I just hate typdef everything to a typdef item with a a typdef vector etc. I usually avoid them for readability.
 

// Obviously this doesnt work. Just curious what the signature without the typdef would be
int (*function_type)(int) GiveMeFunctionPointer()

{

}

 

Thanks.




#5165731 c++ function pointers

Posted by dpadam450 on 08 July 2014 - 11:11 PM

8 Years never needed a function pointer and I can't find a good example.

#include <iostream>
using namespace std;

// Basic Function
int AddOne(int a)
{
    return a + 1;
}

// I want a function that returns a pointer to AddOne so I can call it

// This declaration does not work, what is the delcaration to return the function as a pointer.
int (*)(int) GiveMeFunctionPointer()
{
    return &AddOne;
}

void main()
{
    int (*foo)(int) = &AddOne; // Cool foo is a pointer to a function taking an int

    int (*foo2)(int) = GiveMeFunctionPointer(); // This is what I want to use...

    cout << foo(2);
    system("pause");
}




#5140338 Uniform grid traversal

Posted by dpadam450 on 19 March 2014 - 10:04 AM

the ray starts to intersect a wall of a box and exists another wall of that box. Do some ray to plan intersection, determine if its the left up down etc wall, from there you know the next box this ray is going to go into.




#5140330 Assets for tech demos

Posted by dpadam450 on 19 March 2014 - 09:33 AM

 

but me being a good 3D modeller isn't going to improve how good I am at writing an efficient renderer for it, or implementing dynamic illumination effects.

This is wrong thinking. I'm one of the few (skilled) artists and programmers out there. It blows my mind how any graphics engineers or just game engineers have 0 art abilities. They miss the big picture.




#5139110 Debugging Graphics

Posted by dpadam450 on 14 March 2014 - 06:12 PM

 

and debugging by guessing never works out.

It always works out. Beginning graphics is all about guessing

My biggest takeaway from when I started, was never program stuff without source control. Once you break something especially in graphics, it could take hours. Don't have people put everything into the scene. Create a box first, apply a texture second, put 1 more item, put another texture. Verifying each time that it works helps to know exactly what line is breaking it. Then its a matter of taking the breaking code and moving it around to see if it works in different areas.




#5139105 Depth pre-pass: does OpenGL still execute fragment shader if depth not writte...

Posted by dpadam450 on 14 March 2014 - 05:44 PM

 

does OpenGL still execute fragment shader if depth not written and color mask is GL_NONE?

 

And what exactly did I say......... I will add you to the list of people I choose not to help, which will be 1 person for the last 8 years I've been on here.

I gave you some logical thinking which is: who cares. If the GPU does or doesn't run the pixel shader, then whatever shader you have bound wont run anyway (Even if its 1 million executions). If the contrary to that is it does run, then give it the simplest shader possible. Same result, and you don't even need to know the answer to your question................because it doesn't matter. Its either going to execute your 0 or 1 instruction pixel shader or not. Its out of your control, but if you assume it has to run a pixel shader, then you are safe. NOT TO MENTION it could be vendor/card specific under the hood to decide to use the pixel shader or not.

How hard is if for you to write a pixel shader that does 20 texture fetches with glDrawBuffers(GL_NONE) and see if your performance is horrible.....well then its running your pixel shader......

 

Do you have a problem with reading comprehension?

When people (who work in the industry already) reply to you and give you a decent answer and tell them they are too stupid that they can't even read your question, so they shouldn't help you.....




#5139087 Depth pre-pass: does OpenGL still execute fragment shader if depth not writte...

Posted by dpadam450 on 14 March 2014 - 04:45 PM

Kind of a useless question.

If it does execute: then keep your fragment shader as gl_FragColor = vec4(0,0,0,0);  OR you may not even need it. leaving a blank main() that returns immediately even though it is executed.

If it doesn't execute for GL_NONE: then keep the same stripped down fragment shader. It just wont run.....

I don't believe you can have a shader object without a vertex + pixel shader. Not sure though.




#5138147 Same model, different UV's

Posted by dpadam450 on 11 March 2014 - 11:39 AM

Make sure when dealing with GL_TEXTURE matrices, that each texture coord has its own matrix. glActiveTexture(GL_TEXTURE0 - 8) you can set matrices for all of those, so make sure if you do that you reset them or all your textures will get F'd.




#5137981 Having a VBO/VAO for each object.

Posted by dpadam450 on 10 March 2014 - 06:16 PM

 

I'm working on a 2D Game Framework for a college assignment, I need to handle Basic sprite creation and animation, along with text display.

 

You don't need a vbo then. About 7 years ago when I started openGL I used to draw all my models with glBegin()/glEnd() drawing 100,000 some vertices at 60 fps or more I dont know. So for a basic 2D game say mario, then vbo's arent even needed. So whatever you decide to do I wouldn't worry too much about architecture in managing sprites. Managing sprites/particles in a next-gen 3d renderer is when you need to get down to managing sprite vbos.




#5135562 Large textures are really slow...

Posted by dpadam450 on 28 February 2014 - 10:00 PM

Yea I forgot about alpha test. The overlay you missed my point completely.

.5*healthbar + .5*your_background texture   ==  .5*your_background texture + .5*healthbar

If you put the background drawn first, without alpha blending, it will be in the background. If you blend your health bar on top, the amount of pixels you are blending is only the health bar pixels. (A lot less pixels blending).

Your original image, is the background blended on top, or the healthbar blending on top?....... the user won't know because its the same result. This doesn't hold true for 99% of games, but if that is the extent of your games art design, you can pull off doing this order instead(drawing BG without blending first, then applying blending with the BG). The other 99% of games don't work because usually stuff is drawn in front of stuff behind stuff etc, where they would blend and blend and blend, but since you have only BG blending with really 1 sprite at a time(at each pixel), it doesnt matter which of the 2 images is the SRC and which is the DST. Same math.
http://shogun3d.net/images2/looptil/04.jpg




#5135204 Per pixel lighting with GLSL

Posted by dpadam450 on 27 February 2014 - 04:33 PM

So start from here and build up. When I first started shading I had errors all the time.

Validate your data/uniforms etc. Per pixel lighting:
Calculate the normal in the vertex shader (gl_NormalMatrix*gl_Normal),  in the fragment shader, output gl_FragData[0] = vec4(normal, 1); (Normal validated, dont forget negative number will be black so make sure to pass in some non-negative normals to test).

You can calculate the lightVector in the world or camera space and output to fragData, validate that the color makes sense.

To start just post your 2 shaders and we can look at those. Aside from those looking good, there could be a bad code side where you arent setting up or passing a variable properly.




#5135113 Per pixel lighting with GLSL

Posted by dpadam450 on 27 February 2014 - 12:11 PM

Not sure where you are at. So you have a shader running and compiling? Does gl_FragData[0] = vec4(1,0,0,1)   shade your object all red?




#5134236 I feel like a Noob C++ GL 4.1 and GLSL 3.3 help please!

Posted by dpadam450 on 24 February 2014 - 04:49 PM

Is your quad rendered with the shader on? Are you able to output a debug red color to verify the shader is on?

Are you binding the texture and sending the uniform to the shader?




#5128919 Assassin's Creed IV: Black Flag Ocean Technology Talk

Posted by dpadam450 on 04 February 2014 - 10:27 PM



Take a look at this. There is a demo and a paper somewhere. Most realistic water I've seen.






PARTNERS