Advertisement Jump to content
  • Advertisement

too_many_stars

Member
  • Content Count

    167
  • Joined

  • Last visited

Community Reputation

337 Neutral

About too_many_stars

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Art
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. too_many_stars

    std::shared_ptr to this pointer question

    Thanks so much for the response. I was just redesigning my spatial grid class and came to wonder if this was allowed in the C++ language. In my implementation I do pass a raw pointer to an ICollidable * pCollidable object which solves the problem above. This is purely for my edification since the C++ language is so complicated. Thank you again, Mike
  2. Hello Everyone, I have a quick question regarding the contrived program below. class Person { public: Person(const std::string & n, int a) : name(n), age(a) {} void DoSomething() { /* Problem here. "this" pointer is not the same as std::shared_ptr<Person>. How can this pointer refer to itsel through the std::shared_ptr<Person> ? */ ThisIsDoingSomething(this); } private: std::string name; int age; }; void ThisIsDoingSomething(std::shared_ptr<Person> pPerson) { std::cout << "here" << std::endl; } int main() { auto pMike = std::shared_ptr<Person>(new Person("Mike", 40)); pMike->DoSomething(); char hold; std::cin >> hold; return 0; } Given a function that passes a std::shared_ptr<T> parameter (in my case ThisIsDoingSomething) Is it possible for a class to refer to it self through the std::shared_ptr by somehow using "this" pointer? Sorry for the word salad but I am not sure how to explain it better. Thanks again, Mike
  3. Thanks for the response guys. That makes sense. I never had anything similar happen on VS2012 but then again that version did not have IntelliSense (as far as I know). Mike
  4. Hello Everyone, I have a problem that I can't figure out. It's on Windows 10 and Visual studio 2017. I have a project folder called E2D_S that has a ridiculous size of 5.01GB. All the *.h and *.cpp files plus a few images don't add up to this amount. When I drill into the folder and compare that with the size of what's inside the E2D_S folder, the size becomes a more reasonable 216MB. Does anyone have any clue what's going on here? Thanks so much for the help, Mike
  5. Good Afternoon, I have a quick question regarding the performance of rendering a texture(sprite) say Super Mario where some pixels have an alpha value = 0. Is it quicker performance wise to render such a texture with the original alpha value = 0 or to use color keying in the fragment shader and discarding say color vec4(0,1,1,1) to arrive at the same transperancy effect. Thanks again for your time, Mike
  6. too_many_stars

    GLSL, Point Sprites, Geometry Shader problem

    I figured it out. The problem was that I was multiplying the vertex by the camera_matrix V and then sen this info to the geometry shader. In the geometry shader, I again multipliled gl_Position by camera_matrix V giving funky results. I only needed to multiply each vertex in the geometry shader by V. Thanks again for the help!
  7. Hello Everyone, I have a problem positioning my point sprites int world cooridnates. This is a strictly 2D system with glm::ortho set to(0, 800, 0, 600) An array of points glm::vec2 are going into the vertex shader which is below. The glm::vec2 are given random values between -400, 400 on the x axis, and -300, 300 on the y axis. #version 330 layout ( location = 0 ) in vec2 vertex_position; uniform mat4 M; uniform mat4 V; void main(){ gl_Position = V * vec4( vertex_position , 0 , 1 ); } V is equal to glm::vec2 ext = GetScreenExtents(); m_ScreenToWorld = glm::translate(m_Ortho, glm::vec3(ext.x - m_Pos.x, ext.y - m_Pos.y , 0.0f)); m_ScreenToWorld = glm::scale(m_ScreenToWorld, glm::vec3(m_fScale, m_fScale, 1.0)); Then then gets passed on to the geometry shader #version 330 layout (points) in; layout (triangle_strip, max_vertices = 4) out; out vec2 tex_coord; uniform mat4 V; uniform mat4 M; const float SIZE = 10.0; void main(){ //bottom left gl_Position = V * (vec4(-SIZE,-SIZE,0,0) + gl_in[0].gl_Position); tex_coord = vec2(0,0); EmitVertex(); //bottom right gl_Position = V * (vec4(SIZE,-SIZE,0,0) + gl_in[0].gl_Position); tex_coord = vec2(1,0); EmitVertex(); //top left gl_Position = V * (vec4(-SIZE,SIZE,0,0) + gl_in[0].gl_Position); tex_coord = vec2(0,1); EmitVertex(); //top right gl_Position = V * (vec4(SIZE,SIZE,0,0) + gl_in[0].gl_Position); tex_coord = vec2(1,1); EmitVertex(); EndPrimitive(); } Of course this then gets passed on to the frag shader and drawn. I am expecting to see random positioned textures on the screen between [-400,400] on x and [-300,300] on y with sprite size = 10.0. Instead the point sprites are clumped together around world center and the values when randomized to[-400,400] on x and [-300,300] on y appear to be between [-1,1] on both x,y axis but the sprite size is equal to 10.0; I am not sure what I am missing. This has something to do with projection but I can't figure it out. If anyone knows what's wrong please let me know. Thanks!
  8. I would for example like to write debugging scrips which means I need to access my renderer class. When making a game, I would like to script most of the ai, for example state machines, goals, variables etc. What I really need is a simple to install script that can access C++ classes/functions ( and vice versa ) ( polymorphic or not ) without having to spend countless hours trying to get the scripting library to work. In my limited experience, with a *.lib and *.dll integrating a library in visual studio is a breeze. So I am justi wondering if there's a solution out there for me. Mike I am sorry I have no idea how to even start this process. Is there a tutorial somewhere? If possible, I am looking for a simple solution. Thanks again, Mike
  9. Hello Everyone, I just have a general question about scripting. Currently I am using Visual Studio and Lua 5.3.3. I need to be able to access C++ classes through Lua, which means I need to be able to use Luabind or Luabridge. For the life of me, I can't get these to work ( with respect to the former, I don't really want to use boost either ). I am wondering if there's another scripting language out there, which is easy to to integrate with Visual Studio so I can move on with my life? Perhaps with existing .dll and .lib files. Thanks so much, Mike
  10. too_many_stars

    Typedefing in a central *.h file

    Can you tell me what the purpose is of putting header file contents in a namespace please? I only ask because I have never heard of this before. The problem with the C++ books I have read (introductory to intermediate) is that often times they don't cover many of the aspects I find here on gamedev.net. Thanks so much for all the replies! Mike
  11. Hello Everyone, I am sure we have all seen things like const glm::vec2 & v or, std::unique_ptr< SomeObject > object; I was wondering if it's a good idea to perhaps make a typedef.h file and sprinkle it through out the project so I can save some typing. #ifndef TYPEDEF_H #define TYPEDEF_H typedef const glm::vec2 c_vec2; typedef std::unique_ptr< SomeObject > ptr_obj; typedef ... #endif Maybe like this... I am using typedefs, but in classes only. However, I would like to access those typedefs globally without having to call SomeClass::typedef. Is there anything wrong with this global approach? Are there some issues that can come crop up down the line which I am not considering? Please let me know, Thanks again, Mike
  12. too_many_stars

    const parameter good practice question

    I think you guys are right. It really does not add any value to const a primitive parameter variable for the sake of documentation to whomever the user might be. I have never seen it done that way but was just wondering if it might be good practice since I have very limited exposure to production level code. Thanks again, Mike
  13. Good Morning, I just have a quick question about good programming practice with parameter arguments in C++. Is it good programming practice to const all parameter arguments that will not be changed internally? For example. void Agent::setHealth( const int h ){ health = h; } However, if I have the same function, but this time wish to signify to users that the parameter value might not be what's assigned to a private/protected variable inside the class I could do something like this void Agent::setHealth( int h ){ health = glm::clamp( h , 0 , INT_MAX ); } I am also talking about primitive types available through C++ not const referenced variables passed as arguments. Is it a waste of time to 'const' and just use the variable with function documentation? Thanks so much for the time, Mike
  14. too_many_stars

    Dealing with Non Center of Mass Translations

    Thanks so much again for the help Randy, I will do as you suggest and try to make some sense out of it. Mike
  15. Hello Everyone, It's very common in 2D and 3D to use the center of mass ( COM ) as the point of rotation. This method additionally make it easy to fit the model into a bounding sphere, AABB, capsule whatever. This is what I have always done. However, now I am trying to model a 3D hinged door. This door, due to the nature of rotation, will not be centered at the COM, instead, it will have to be translated locally either to the left or right depending on where the hinge should be. My question is... What is the best way of dealing with Non-COM rotations? The problem is, once the symmetry is gone from Non-COM model my bounding volumes are thrown off as they rely on COM. And obviously now when I am transforming from local to world co-ords it becomes harder to gauge where the object will be and how it will fit into the rest of the world. Also, I have to introduce some new variables such as glm::vec3 local_position to keep track of the new object center. It makes everything a lot messier. Thanks again for all the help, Mike
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!