Search Results

Search found 56 results on 3 pages for 'narek'.

Page 1/3 | 1 2 3  | Next Page >

  • How to define and use a friend function to a temlate class with the same template?

    - by Narek
    I have written the following code: #include <iostream> using namespace std; template <class T> class AA { T a; public: AA() { a = 7; } friend void print(const AA<T> & z); }; template <class T> void print(const AA<T> & z) { cout<<"Print: "<<z.a<<endl; } void main() { AA<int> a; print<int>(a); } And getting the following error: error C2248: 'AA<T>::a' : cannot access private member declared in class 'AA<T>' 1> with 1> [ 1> T=int 1> ] 1> c:\users\narek\documents\visual studio 2008\projects\aaa\aaa\a.cpp(7) : see declaration of 'AA<T>::a' 1> with 1> [ 1> T=int 1> ] 1> c:\users\narek\documents\visual studio 2008\projects\aaa\aaa\a.cpp(30) : see reference to function template instantiation 'void print<int>(const AA<T> &)' being compiled 1> with 1> [ 1> T=int 1> ] What's wrong?

    Read the article

  • Cocos2d-x 3.0 animation frame by frame

    - by Narek
    As I know animations are actions. Now I need to play animation frame by frame. Say I have an animation from N frames. each frame should be played after t delay. Now I want to play animation frame by frame, each frame advance the animation's state. How I can do this? And what about playing actions frame by frame advancing the state in general. I ask because I use ECS, and I deal with frames. P.S. I want to do something like this: Action * a = MoveTo(initialPoint, finalPoint, durationOfAnimation); a->play(0.001 seconds); a->play(0.003 seconds); a->play(0.02 seconds); a->play(0.67 seconds); a->play(0.06 seconds); And see the animation.

    Read the article

  • cocos2d-x simple shader usage [on hold]

    - by Narek
    I want to obtain color ramp effect from this tutorial: http://www.raywenderlich.com/10862/how-to-create-cool-effects-with-custom-shaders-in-opengl-es-2-0-and-cocos2d-2-x Here is my code in cocos2d-x 3: bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } Vec2 origin = Director::getInstance()->getVisibleOrigin(); sprite = Sprite::create("HelloWorld.png"); sprite->setAnchorPoint(Vec2(0, 0)); sprite->setRotation(3); sprite->setPosition(origin); addChild(sprite); std::string str = FileUtils::getInstance()->getStringFromFile("CSEColorRamp.fsh"); const GLchar * fragmentSource = str.c_str(); GLProgram* p = GLProgram::createWithByteArrays(ccPositionTextureA8Color_vert, fragmentSource); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD); p->link(); p->updateUniforms(); sprite->setGLProgram(p); // 3 colorRampUniformLocation = glGetUniformLocation(sprite->getGLProgram()->getProgram(), "u_colorRampTexture"); glUniform1i(colorRampUniformLocation, 1); // 4 colorRampTexture = Director::getInstance()->getTextureCache()->addImage("colorRamp.png"); colorRampTexture->setAliasTexParameters(); // 5 sprite->getGLProgram()->use(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, colorRampTexture->getName()); glActiveTexture(GL_TEXTURE0); return true; } And here is the fragment shader as it is in the tutorial: #ifdef GL_ES precision mediump float; #endif // 1 varying vec2 v_texCoord; uniform sampler2D u_texture; uniform sampler2D u_colorRampTexture; void main() { // 2 vec3 normalColor = texture2D(u_texture, v_texCoord).rgb; // 3 float rampedR = texture2D(u_colorRampTexture, vec2(normalColor.r, 0)).r; float rampedG = texture2D(u_colorRampTexture, vec2(normalColor.g, 0)).g; float rampedB = texture2D(u_colorRampTexture, vec2(normalColor.b, 0)).b; // 4 gl_FragColor = vec4(rampedR, rampedG, rampedB, 1); } As a result I get a black screen with 2 draw calls. What is wrong? Do I miss something?

    Read the article

  • Box2D `ApplyLinearImpulse` is not working whereas `SetLinearVelocity` works

    - by Narek
    I need to mimic jumping behavior for the player in my game. Player consists of two fixtures with circle and rectangle shapes. Rectangle I use to detect ground and it is a sensor. Is some point for jumping I do this: float impulseY = body->GetMass() * PLAYER_JUMPING_VEOCITY / PTM_RATIO * std::sin(PLAYER_JUMPING_ANGLE * PI / 180); body->ApplyLinearImpulse(b2Vec2(0, impulseY), body->GetWorldCenter(), true); and player does not jump. But when I do this: body->SetLinearVelocity(b2Vec2(0, PLAYER_JUMPING_VEOCITY / PTM_RATIO * std::sin(PLAYER_JUMPING_ANGLE * PI / 180))); my player jumps. Also when I change the rectangle shape to be normal (not sensor) shape, its works again. Why? Just in case here are the parameters of my rectangular sensor: b2PolygonShape boxShape; boxShape.SetAsBox(width * 0.5/2/PTM_RATIO, height * 0.2/2/PTM_RATIO, b2Vec2(0, -height * 0.4 /PTM_RATIO), 0); b2FixtureDef boxFixtureDef; boxFixtureDef.friction = 0; boxFixtureDef.restitution = 0; boxFixtureDef.density = 1; boxFixtureDef.isSensor = true; boxFixtureDef.userData = static_cast<void*>(PLAYER_GROUP);

    Read the article

  • How to setup a Wi-Fi 2-computer network with Internet sharing?

    - by Narek
    I have the following devices: Desktop Computer (Windows XP Professional) Laptop Computer (Windows Vista Home Premium) A USB modem that I want to connect to my Desktop computer (so my Desktop has Internet) And a Wi-Fi router (D-Link, model: DIR-300) that I want to use in order to create a connection between mentioned two computers to be able to share files and what is the most important thing to make my laptop to have access to the Internet. What steps I should do to have this system?

    Read the article

  • Qt - change QWidget layout

    - by Narek
    Let's consider we have a QWidget and a layout named general_layout that contains other widgets and layouts. general_layout is set as the QWidget layout (setLayout(general_layout)). Now I should to change the content of QWidget. How should I do? I have tried to delete and create a new layout for QWidget and that new layout set as a layout of the QWidget, but could not complet my intentions successfully.

    Read the article

  • QTableWidget alignement with the borders of its parent QWidget

    - by Narek
    Let's consider we have QWidget that contains QTableWidget (only). So we want to resize the table by resizing the widget, and we dont want to have an indet between the QWidget border and cells of the table. What kind of property is making posible for QTableWidget to be aligned with the borders of it parent widget? Thanks.

    Read the article

  • WebApps tendency

    - by Narek
    There is a strong tendency of making web apps and even seems that very soon a lot of features will be available online so that for every day use people will have all necessary software free online and they will not need to install any software locally. Only specific (professional) tools that usually people don’t use at home will not be available as a web app. So my question, how do you imagine selling software that was necessary for everyday use and was not free (seems they can't make money any more by selling their product – no need of those products). And what disadvantages have web apps, that is to say, what is bad to use software online compared with having the same software locally (please list)? Please do not consider this question not connected with programming, as I would like to have a little statistics from professional programmers who are aware from nowday’s tendency of software and programming. Thanks.

    Read the article

  • Serialization with Qt

    - by Narek
    I am programming a GUI with Qt. In my GUI I have a huge std::map. And "MyType" is a class that has different kinds of filds. So, in a word, I want to serialize the std::map. How can I do that? Does Qt provides us with neccesary features? P.S. I would like to use std::map, NOT QMap.

    Read the article

  • Change table columns width on resizing window or splitter

    - by Narek
    Consider there is a QTablWidget and a QTextEdit. Both of them are in a horisontal QSplitte. Let the QTable widget has 2 columns. The problem is to resize the table columns' width as you do resize operation by moving the splitter with mouse. Are there any options to may colums to be resized synchornosly with the table? Thanks.

    Read the article

  • Qt - Password field

    - by Narek
    Is there any Qt-built-in method to warn user (with pop-up window) that CapsLock is switched on while password field is active? I am using for passford field QLineEdit (is it good?) with setEchoMode(QLineEdit::Password).

    Read the article

  • Qt - A login dialog

    - by Narek
    I want to create a login dialog by inheriting QDialog. I put in subclass named LoginDialog 2 QLineEdits: for login for password. I want to be able to warn the user with a message if the caps lock is ON while he will start to fill passwordLineEdit. Suppose I have a function that tells the current state of CapsLock button. So I want to do eventFiltering in LoginDialog class in order to understand that user starts to fill the password field (i.e. user just stepped into the password field) So for that purpose I wrote the following in the LoginDialog class constructor: m_passwordLineEdit->installEventFilter(this); So the only thing is to do is to implement a function which can understand that user is going to fill the password. Seems is should be done with the following function(??): bool LoginDialog::eventFilter(QObject *target, QEvent *event) { if (target == m_passwordLineEdit) { } return QDialog::eventFilter(target, event); } How to implement this function???

    Read the article

  • FIFO implementation

    - by Narek
    While implementing a FIFO I have used the following structure: struct Node { T info_; Node* link_; Node(T info, Node* link=0): info_(info), link_(link) {} }; I think this a well known trick for lots of STL containers (for example for List). Is this a good practice? What it means for compiler when you say that Node has a member with a type of it's pointer? Is this a kind of infinite loop? And finally, if this is a bad practice, how I could implement a better FIFO. EDIT: People, this is all about implemenation. I am enough familiar with STL library, and know a plenty of containers from several libraries. Just I want to discuss with people who can gave a good implementation or a good advice.

    Read the article

  • An "About" message box for a GUI with QT

    - by Narek
    QMessageBox::about( this, "About Application", "<h4>Application is a one-paragraph blurb</h4>\n\n" "Copyright 1991-2003 Such-and-such. " "For technical support, call 1234-56789 or see\n" "<a href=\"http://www.such-and-such.com\">http://www.such-and-such.com</a>" ); This code is creating the About message box which I wanted to have with two excaptions: 1. I would like to change the icon in the message box with an aaa.png file 2. And I would like to have the link clickable. It looks like hyperlink (it is blue and underlined) but mouse click does not work Any ideas?

    Read the article

1 2 3  | Next Page >