devnewton đŸș a Ă©crit 8266 commentaires

  • # kot kot codec?

    Posté par  (site web personnel) . En rĂ©ponse au journal Cisco paie le h264 en faveur de Mozilla. Évalué à 1.

    PlutÎt que d'aller chercher un binaire louche, pourquoi ne pas utiliser les codecs présents sur le systÚme?

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: Quarantine!

    Posté par  (site web personnel) . En rĂ©ponse au journal Aidez moi Ă  choisir mes licences !. Évalué à 4.

    Le copyleft concernent les utilisateurs, mais il n'empĂȘche pas le dĂ©tenteur du copyright de changer la licence de son code.

    Pour moi la meilleure garantie contre la pwivatisation, c'est la multiplication des dĂ©tenteurs de copyright au sein d'un mĂȘme projet.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • # Quarantine!

    Posté par  (site web personnel) . En rĂ©ponse au journal Aidez moi Ă  choisir mes licences !. Évalué à 6.

    Le problÚme des licences contaminantes, c'est qu'on ne peut pas facilement réutiliser et mixer des bouts de codes différents issus de plusieurs projets.

    De plus elles sont souvent horriblement longues à lire et compliquées.

    Si ton code n'a pas une valeur ajoutĂ©e Ă©norme (un codec vidĂ©o rĂ©volutionnaire par exemple), pourquoi ne pas prendre une licence simple et permissive (MIT, BSD, WTFPL
) ?

    quarantine

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 3.

    De loin, les generics et les traits de Rust semblent faire le boulot des templates en C++. Par contre ça m'étonnerais que le jeune compilateur carbure autant que les meilleurs compilos C++.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 2.

    Je préfÚre une gestion centralisée des événements, mais tu peux utiliser plusieurs types de composants pour les faire traiter par plusieurs systÚmes ou alors mettre en place un systÚme "Poste" qui va distribuer le courrier.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: de la phy 2d

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche Je crĂ©e mon jeu vidĂ©o E04 : Paf ! les collisions. Évalué à 6.

    par exemple une porte, qui nécessite une clef, à la collision, peut-on sortir (callback) du moteur pour savoir si on ne passe pas la porte ou bien si ca passe (on ouvre la porte), idem pour les bonus peut-on faire en sorte que la collision avec celui-ci fasse une action (le prendre).

    Tu peux à tout moment retirer un objet du moteur physique et en faire autre chose: dans Newton Adventure, quand on ramasse une pomme, elle est retiré du moteur physique et remplacer par un simple sprite avec une animation pour la faire rétrécir et rejoindre le sprite de Newton.

    et si je veux faire un ennemie qui marche aux murs/ aux plafonds

    Pour chaque objet du monde, tu peux désactiver la gravité ou en appliquer une différente.

    N’avez-vous jamais essayĂ© un jeu avec des caisses qui rebondissent quand vous les effleurez ?

    C'est le principal problĂšme des moteurs physiques actuels: il est difficile de mixer un gameplay "oldschool" avec une physique rĂ©aliste. J'ai mis beaucoup de temps Ă  trouver les bons paramĂštres pour mon jeu et ça donne des bugs Ă©tranges


    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 4.

    http://static.rust-lang.org/doc/0.8/tutorial.html#generics ?

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 2.

    Le message est une entité, donc elle peut avoir plein de composants :-)

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 4.

    Pour le messaging, je crée des entités avec un composant de type Message :-) Le systÚme qui les traite les jette aprÚs usage.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 3.

    Tu n'es pas obligé de passer tout ton temps dessus. Parfois ajuster un menu, une animation ou un petit effet, ça ajoute une touche pro sans demander trop d'effort.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 3.

    Il y a beaucoup des moteurs de jeu ou de toolkits qui essayent de tout faire, mais pratiquement aucun scenegraph 2d simple. Ce qui s'en rapproche le plus aujourd'hui, c'est la SFML et encore


    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 4.

    Un compilo C++ mets facilement une grosse fessĂ©e cul nu Ă  la jvm pour les jeux. Entre les struct, les templates et l'absence de garbage collector, on n'est pas sur la mĂȘme planĂšte.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 2.

    Dans Newton Adventure, le code est mixte: les objets dynamiques utilisent du glBegin/End et les objets statiques des buffers compacts. Le tout reste en OpenGL 1.x, car le GPU de mon netbook ne va pas au delĂ  d'OpenGL 1.4 :-(

    https://devnewton.bci.im/projects/newton_adventure/artifact/c53890834787812a85a15eb0d0b0b1ff9cf12fb2
    https://devnewton.bci.im/projects/newton_adventure/artifact/86964f35f46532d81660705eb5bffec56c5c0d55

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 2.

    MCMic a un projet qui pourrait te plaire: http://mcmic.haxx.es/index.php?page=geneticinvasion

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 3.

    En fait, dans un précédent projet, je faisais de l'entity system avant que ça s'appelle comme ça! Il faudrait un historien pour savoir à partir de quand et par qui ça a été théorisé.

    Dans le code de Ned et les maki, je n'ai fait que les composants graphiques, pour le reste c'est un autre développeur qui s'en charge, mais je pense que son découpage fin correspond aux rÚgles du jeu sur lequel on travaille.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 2.

    Je me suis surtout fixé un objectif de sortir un proto pour le mois prochain donc je vais au plus vite!

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 1.

    et que c'était codé en c++. Désolé, mais il faut aussi que ça m'amuse un peu ;)

    Si tu ne veux pas rejoindre le cÎté bloated du développement, il y a rewind qui fait un jeu aussi.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 3.

    Oui, mais c'est un dilemme: est-ce que je prends un moteur 3D pour faire un mon jeu 2D? Ca va tout m'optimiser aux petits oignons, mais je vais devoir embarquer un gros cadriciel genre jmonkey, playn ou libgdx qui ne seront pas packagé dans debian avant 2042.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 4.

    C'est là que ta séparation code/donnée est mal faite !

    J'utilise un entity system :

    • la classe Sprite est un composant qu'on peut ajouter/enlever Ă  une entitĂ© pour lui donner une existence visuelle.
    • une autre classe, DrawSystem, se charge de parcourir les entitĂ©s ayant le composant Sprite pour les afficher.

    Si j'ai besoin de perf, je peux remplacer DrawSystem par quelquechose de plus intelligent, mais j'espÚre ne pas avoir à le faire, car sortir un scenegraph qui regroupe les données, minimise les changement d'états et joue avec les shaders pour diminuer la conso CPU, c'est beaucoup pour afficher quelques sprites et je ne suis pas certains de pouvoir battre un bon driver :-)

    https://github.com/devnewton/ned-et-les-maki/tree/master/game/src/main/java/org/geekygoblin/nedetlesmaki/game

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 6.

    AprÚs, on parle d'optimisation ! C'est sur que si tu n'en as pas besoin, et bien ça peut paraitre lourd à faire de cette maniÚre.

    J'en ai besoin, mais je prĂ©fĂšre que le driver s'en charge, car il connaĂźt mieux le GPU que moi! Aujourd'hui, quand tu cherches La bonne façon de faire avec OpenGL, pour la plupart des sujets, il y a trois bonnes façons: celle qui plaĂźt aux GPU intel, celle que prĂ©fĂšre les cartes AMD et celle recommandĂ©e pour les puces NVIDIA. Et encore je ne fais pas de dev mobile


    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 2.

    Disons qu'organiser toutes les données d'une application dans de gros buffers globaux, ce n'est pas naturel en développement objet :-)

    Je trouve que les premiĂšres versions d'opengl avaient rĂ©ussit Ă  abstraire la rĂ©alitĂ© du hardware (gros buffers) avec une api Ă©lĂ©gante (glBegin/glEnd, display lists). Les derniĂšres versions donnent le sentiment de taper directement dans le GPU et la prochaine API d'AMD promets d'ĂȘtre encore plus bas niveau.

    Je pense que ce mouvement qui vise à donner aux développeurs un accÚs direct au hardware est bon pour les performances, mais mauvais pour la concurrence et l'innovation: un nouveau constructeur de carte graphique ne peut que faire comme les autres.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: OpenGL antique

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche EGLX : un petit traducteur GLX-EGL pour Wayland. Évalué à 6.

    Voici le code OpenGL antique que j'utilise pour afficher des sprites avec des effets (rotation, zoom, transparence):

    private void drawSprite(Sprite sprite) {
            GL11.glPushMatrix();
            GL11.glTranslatef(sprite.getPosition().getX(), sprite.getPosition().getY(),0.0f);
            GL11.glRotatef(sprite.getRotate(), 0, 0, 1.0f);
            GL11.glScalef(sprite.getScale(), sprite.getScale(), 1);
            final IAnimationFrame frame = sprite.getPlay().getCurrentFrame();
            final IAnimationImage image = frame.getImage();
            if (image.hasAlpha()) {
                GL11.glEnable(GL11.GL_BLEND);
            }
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getId());
    
            final float u1, u2;
            if (sprite.isMirrorX()) {
                u1 = frame.getU2();
                u2 = frame.getU1();
            } else {
                u1 = frame.getU1();
                u2 = frame.getU2();
            }
    
            final float v1, v2;
            if (sprite.isMirrorY()) {
                v1 = frame.getV1();
                v2 = frame.getV2();
            } else {
                v1 = frame.getV2();
                v2 = frame.getV1();
            }
            final Color color = sprite.getColor();
            GL11.glColor4ub(color.getRedByte(), color.getGreenByte(), color.getBlueByte(), color.getAlphaByte());
            float x1 = -sprite.getWidth() / 2.0f;
            float x2 = sprite.getWidth() / 2.0f;
            float y1 = -sprite.getHeight() / 2.0f;
            float y2 = sprite.getHeight() / 2.0f;
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glTexCoord2f(u1, v1);
            GL11.glVertex2f(x1, y2);
            GL11.glTexCoord2f(u2, v1);
            GL11.glVertex2f(x2, y2);
            GL11.glTexCoord2f(u2, v2);
            GL11.glVertex2f(x2, y1);
            GL11.glTexCoord2f(u1, v2);
            GL11.glVertex2f(x1, y1);
            GL11.glEnd();
            GL11.glColor3f(1f, 1f, 1f);
            if (image.hasAlpha()) {
                GL11.glDisable(GL11.GL_BLEND);
            }
            GL11.glPopMatrix();
        }
    

    Voici l'équivalent en OpenGL moderne:

    public class SpriteBatch {
            public static final String U_TEXTURE = "u_texture";
            public static final String U_PROJ_VIEW = "u_projView";
    
            public static final String ATTR_COLOR = "Color";
            public static final String ATTR_POSITION = "Position";
            public static final String ATTR_TEXCOORD = "TexCoord";
    
            public static final String DEFAULT_VERT_SHADER = "uniform mat4 " + U_PROJ_VIEW + ";\n"
                            + "attribute vec4 " + ATTR_COLOR + ";\n" + "attribute vec2 " + ATTR_TEXCOORD + ";\n"
                            + "attribute vec2 " + ATTR_POSITION + ";\n" + "varying vec4 vColor;\n"
                            + "varying vec2 vTexCoord; \n" + "void main() {\n" + "        vColor = " + ATTR_COLOR + ";\n"
                            + "        vTexCoord = " + ATTR_TEXCOORD + ";\n" + "        gl_Position = " + U_PROJ_VIEW
                            + " * vec4(" + ATTR_POSITION + ".xy, 0.0, 1.0);\n" + "}";
    
            public static final String DEFAULT_FRAG_SHADER = "uniform sampler2D " + U_TEXTURE + ";\n"
                            + "varying vec4 vColor;\n" + "varying vec2 vTexCoord;\n" + "void main() {\n"
                            + "        vec4 texColor = texture2D(" + U_TEXTURE + ", vTexCoord);\n"
                            + "        gl_FragColor = vColor * texColor;\n" + "}";
    
            public static final List<VertexAttrib> ATTRIBUTES = Arrays.asList(new VertexAttrib(0,
                            ATTR_POSITION, 2), new VertexAttrib(1, ATTR_COLOR, 4), new VertexAttrib(2,
                            ATTR_TEXCOORD, 2));
    
            static ShaderProgram defaultShader;
            public static int renderCalls = 0;
    
            protected FloatBuffer buf16;
            protected Matrix4f projMatrix = new Matrix4f();
            protected Matrix4f viewMatrix = new Matrix4f();
            protected Matrix4f transpositionPool = new Matrix4f();
            private Matrix4f projViewMatrix = new Matrix4f(); //only for re-using Matrix4f objects
    
            protected Texture texture;
            protected ShaderProgram program;
    
            protected VertexData data;
    
            private int idx;
            private int maxIndex;
    
            private Color color = new Color();
            private boolean drawing = false;
    
            public static ShaderProgram getDefaultShader() throws LWJGLException {
                    return defaultShader == null ? (defaultShader = new ShaderProgram(DEFAULT_VERT_SHADER, DEFAULT_FRAG_SHADER,
                                    ATTRIBUTES)) : defaultShader;
            }
    
            public SpriteBatch(ShaderProgram program) {
                    this(program, 1000);
            }
    
            public SpriteBatch(ShaderProgram program, int size) {
                    this(program, 1000, true);
            }
    
            public SpriteBatch(ShaderProgram program, int size, boolean updateUniforms) {                
                    this.program = program;
    
                    // later we can do some abstraction to replace this with VBOs...
                    this.data = new VertexArray(size * 6, ATTRIBUTES);
    
                    // max indices before we need to flush the renderer
                    maxIndex = size * 6;
    
                    // default size
                    resize(Display.getWidth(), Display.getHeight());
            }
    
            /**
             * Creates a sprite batch with a default shader, shared across all sprite batches.
             * @param size
             * @throws LWJGLException
             */
            public SpriteBatch(int size) throws LWJGLException {
                    this(getDefaultShader(), size);
            }
    
            public SpriteBatch() throws LWJGLException {
                    this(1000);
            }
    
            public Matrix4f getViewMatrix() {
                    return viewMatrix;
            }
    
            public Matrix4f getProjectionMatrix() {
                    return projMatrix;
            }
    
            public Matrix4f getCombinedMatrix() {
                    Matrix4f.mul(Matrix4f.transpose(projMatrix, transpositionPool),
                                    viewMatrix, projViewMatrix);
                    return projViewMatrix;
            }
    
            /** A convenience method to resize the projection matrix to the given
             * dimensions, using y-down ortho 2D. This will invoke a call to
             * updateMatrices.
             *
             * @param width
             * @param height */
            public void resize(int width, int height) {
                    projMatrix = MathUtil.toOrtho2D(projMatrix, 0, 0, width, height);
                    updateUniforms();
            }
    
            /** Sets this SpriteBatch's color to the RGBA values of the given color
             * object.
             *
             * @param color the RGBA values to use */
            public void setColor(Color color) {
                    setColor(color.r, color.g, color.b, color.a);
            }
    
            /** Sets this SpriteBatch's color to the given RGBA values.
             *
             * @param r the red value
             * @param g the green value
             * @param b the blue value
             * @param a the alpha value */
            public void setColor(float r, float g, float b, float a) {
                    color.set(r, g, b, a);
            }
    
            /** Call to multiply the the projection with the view matrix and save the
             * result in the uniform mat4 {@value #U_PROJ_VIEW}, as well as update the
             * {@value #U_TEXTURE} uniform. */
            public void updateUniforms() {
                    updateUniforms(program);
            }
    
            /** Call to multiply the the projection with the view matrix and save the
             * result in the uniform mat4 {@value #U_PROJ_VIEW}, as well as update the
             * {@value #U_TEXTURE} uniform. */
            public void updateUniforms(ShaderProgram program) {
                    projViewMatrix = getCombinedMatrix();
    
                    // bind the program before sending uniforms
                    program.use();
    
                    boolean oldStrict = ShaderProgram.isStrictMode();
    
                    //disable strict mode so we don't run into any problems
                    ShaderProgram.setStrictMode(false);
    
                    // we can now utilize ShaderProgram's hash map which may be better than
                    // glGetUniformLocation
    
                    // Store the the multiplied matrix in the "projViewMatrix"-uniform:
                    program.setUniformMatrix(U_PROJ_VIEW, false, projViewMatrix);
    
                    // upload texcoord 0
                    program.setUniformi(U_TEXTURE, 0);
    
                    //reset strict mode
                    ShaderProgram.setStrictMode(oldStrict);
            }
    
            /** An advanced call that allows you to change the shader without uploading
             * shader uniforms. This will flush the batch if we are within begin().
             *
             * @param program
             * @param updateUniforms whether to call updateUniforms after changing the
             * programs */
            public void setShader(ShaderProgram program, boolean updateUniforms) {
                    if (program==null)
                            throw new NullPointerException("shader cannot be null; use getDefaultShader instead");
                    if (drawing) //if we are already drawing, flush the batch before switching shaders
                            flush();
                    this.program = program; //now switch the shader
                    if (updateUniforms) //send uniform data to shader
                            updateUniforms();
                    else if (drawing) //if we don't want to update, then just start the program if we are drawing
                            program.use();
            }
    
            /** Changes the shader and updates it with the current texture and projView
             * uniforms. This will flush the batch if we are within begin().
             *
             * @param program the new program to use */
            public void setShader(ShaderProgram program) {
                    setShader(program, true);
            }
    
            public ShaderProgram getShader() {
                    return program;
            }
    
            public void begin() {
                    if (drawing)
                            throw new IllegalStateException("must not be drawing before calling begin()");
                    drawing = true;
                    program.use();
                    idx = 0;
                    renderCalls = 0;
                    texture = null;
            }
    
            public void end() {
                    if (!drawing)
                            throw new IllegalStateException("must be drawing before calling end()");
                    drawing = false;
                    flush();
            }
    
            public void flush() {
                    if (idx > 0) {
                            data.flip();
                            render();
                            idx = 0;
                            data.clear();
                    }
            }
    
            public void drawRegion(Texture tex, float srcX, float srcY, float srcWidth, float srcHeight,
                            float dstX, float dstY) {
                    drawRegion(tex, srcX, srcY, srcWidth, srcHeight, dstX, dstY, srcWidth, srcHeight);
            }
    
            public void drawRegion(Texture tex, float srcX, float srcY, float srcWidth, float srcHeight,
                            float dstX, float dstY, float dstWidth, float dstHeight) {
                    float u = srcX / tex.getWidth();
                    float v = srcY / tex.getHeight();
                    float u2 = (srcX + srcWidth) / tex.getWidth();
                    float v2 = (srcY + srcHeight) / tex.getHeight();
                    draw(tex, dstX, dstY, dstWidth, dstHeight, u, v, u2, v2);
            }
    
            public void drawRegion(TextureRegion region, float srcX, float srcY, float srcWidth, float srcHeight, float dstX, float dstY) {
                    drawRegion(region, srcX, srcY, srcWidth, srcHeight, dstX, dstY, srcWidth, srcHeight);
            }
    
            public void drawRegion(TextureRegion region, float srcX, float srcY, float srcWidth, float srcHeight,
                            float dstX, float dstY, float dstWidth, float dstHeight) {
                    drawRegion(region.getTexture(), region.getRegionX() + srcX, region.getRegionY() + srcY,
                                    srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight);                
            }
    
            public void draw(ITexture tex, float x, float y) {
                    draw(tex, x, y, tex.getWidth(), tex.getHeight());
            }
    
            public void draw(ITexture tex, float x, float y, float width, float height) {
                    draw(tex, x, y, width, height, tex.getU(), tex.getV(), tex.getU2(), tex.getV2());
            }
    
    
            public void draw(ITexture tex, float x, float y, float originX, float originY, float rotationRadians) {
                    draw(tex, x, y, tex.getWidth(), tex.getHeight(), originX, originY, rotationRadians);
            }
    
            public void draw(ITexture tex, float x, float y, float width, float height,
                            float originX, float originY, float rotationRadians) {
                    draw(tex, x, y, width, height, originX, originY, rotationRadians, tex.getU(), tex.getV(), tex.getU2(), tex.getV2());
            }
    
            public void draw(ITexture tex, float x, float y, float width, float height,
                            float originX, float originY, float rotationRadians,
                            float u, float v,
                            float u2, float v2) {
                    checkFlush(tex);
                    final float r = color.r;
                    final float g = color.g;
                    final float b = color.b;
                    final float a = color.a;
    
    
                    float x1,y1, x2,y2, x3,y3, x4,y4;
    
                    if (rotationRadians != 0) {
                            float scaleX = 1f;//width/tex.getWidth();
                            float scaleY = 1f;//height/tex.getHeight();
    
                            float cx = originX*scaleX;
                            float cy = originY*scaleY;
    
                            float p1x = -cx;
                            float p1y = -cy;
                            float p2x = width - cx;
                            float p2y = -cy;
                            float p3x = width - cx;
                            float p3y = height - cy;
                            float p4x = -cx;
                            float p4y = height - cy;
    
                            final float cos = (float) Math.cos(rotationRadians);
                            final float sin = (float) Math.sin(rotationRadians);
    
                            x1 = x + (cos * p1x - sin * p1y) + cx; // TOP LEFT
                            y1 = y + (sin * p1x + cos * p1y) + cy;
                            x2 = x + (cos * p2x - sin * p2y) + cx; // TOP RIGHT
                            y2 = y + (sin * p2x + cos * p2y) + cy;
                            x3 = x + (cos * p3x - sin * p3y) + cx; // BOTTOM RIGHT
                            y3 = y + (sin * p3x + cos * p3y) + cy;
                            x4 = x + (cos * p4x - sin * p4y) + cx; // BOTTOM LEFT
                            y4 = y + (sin * p4x + cos * p4y) + cy;
                    } else {
                            x1 = x;
                            y1 = y;
    
                            x2 = x+width;
                            y2 = y;
    
                            x3 = x+width;
                            y3 = y+height;
    
                            x4 = x;
                            y4 = y+height;
                    }
    
                    // top left, top right, bottom left
                    vertex(x1, y1, r, g, b, a, u, v);
                    vertex(x2, y2, r, g, b, a, u2, v);
                    vertex(x4, y4, r, g, b, a, u, v2);
    
                    // top right, bottom right, bottom left
                    vertex(x2, y2, r, g, b, a, u2, v);
                    vertex(x3, y3, r, g, b, a, u2, v2);
                    vertex(x4, y4, r, g, b, a, u, v2);
            }
    
            public void draw(ITexture tex, float x, float y, float width, float height, float u, float v,
                            float u2, float v2) {
                    draw(tex, x, y, width, height, x, y, 0f, u, v, u2, v2);
            }
    
            /** Renders a texture using custom vertex attributes; e.g. for different
             * vertex colours. This will ignore the current batch color and "x/y translation",
             * as well as the U/V coordinates of the given ITexture.
             *
             * @param tex the texture to use
             * @param vertices an array of 6 vertices, each holding 8 attributes (total
             * = 48 elements)
             * @param offset the offset from the vertices array to start from */
            public void draw(ITexture tex, float[] vertices, int offset) {
                    checkFlush(tex);
                    data.put(vertices, offset, data.getTotalNumComponents() * 6);
                    idx += 6;
            }
    
            VertexData vertex(float x, float y, float r, float g, float b, float a, float u, float v) {
                    data.put(x).put(y).put(r).put(g).put(b).put(a).put(u).put(v);
                    idx++;
                    return data;
            }
    
            protected void checkFlush(ITexture sprite) {
                    if (sprite == null || sprite.getTexture()==null)
                            throw new NullPointerException("null texture");
    
                    // we need to bind a different texture/type. this is
                    // for convenience; ideally the user should order
                    // their rendering wisely to minimize texture binds
                    if (sprite.getTexture() != this.texture || idx >= maxIndex) {
                            // apply the last texture
                            flush();
                            this.texture = sprite.getTexture();
                    }
            }
    
            private void render() {
                    if (texture != null)
                            texture.bind();
                    data.bind();
                    data.draw(GL_TRIANGLES, 0, idx);
                    data.unbind();
                    renderCalls++;
            }
    }
    

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: Configuration requise

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche Humble Bundle 7 pour Android et PC. Évalué à 2. DerniĂšre modification le 28 octobre 2013 Ă  12:04.

    Pour les jeux en Java, pas grand chose sinon qu'il faut installer un environnement d'exécution assez lourd, qui peut dissuader certains utilisateurs.

    Vouloir économiser une centaine de Mo sur des disques de plusieurs centaines Go, quand de toute façon on installe des jeux toujours trÚs consommateurs en espace disque, c'est étrange.

    La réaction « fait chier, c'est du Java, je vais voir s'il n'y a pas une alternative native à ce logiciel » n'est pas un mythe.

    Ça du sens pour un clone de tetris ou pong qu'on veut faire tourner sur un netbook pour patienter pendant un long calcul au boulot, mais pour un jeu original qu'on va jouer de façon exclusive à la maison sur une machine de gamer?

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: Configuration requise

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche Humble Bundle 7 pour Android et PC. Évalué à 2.

    te demande d'installer toi-mĂȘme un plugin proprio et invasif pour un logiciel tiers avant de pouvoir jouer

    Les jeux du indie bundle sont pratiquement tous pwivateurs, ça n'a rien d'étonnant.

    Pour du jeu linux qui sent bon la Liberté, c'est là: https://linuxfr.org/wiki/jeux_libres_linuxfr

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.

  • [^] # Re: Configuration requise

    Posté par  (site web personnel) . En rĂ©ponse Ă  la dĂ©pĂȘche Humble Bundle 7 pour Android et PC. Évalué à 1.

    Et alors? Ils utilisent une techno portable comme python ou perl, ça n'a rien de particulier.

    Le post ci-dessus est une grosse connerie, ne le lisez pas sérieusement.