Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Gay OO argh

Name: Anonymous 2009-11-11 7:03

I suppose I better learn one of them gay OO business oriented to be able to code inane custom apps for some corporate...

I come from the C demoscene school, so using OO and especially using stuff like .NET or JVM to me is like pulling my eyes out with a spoon; but the world changes nobody cares about pure performance anymore it seems. I gotta go with the flow...

So, which is the lesser of two evils for someone like me?
C# or Java?
(or any other you might suggest)

Name: Anonymous 2009-11-12 13:15

>>36
FILE*fp=fopen("asd","w");
Saves a lot of memory too.

Name: Anonymous 2009-11-12 13:26

>>36
Yes, that's bloated shit, but at least it's not fucked up beyond any repair shit.

Name: Anonymous 2009-11-12 13:32

>>38
EXPERT LISP-style Java programmer.

Name: Anonymous 2009-11-12 13:34

>>40
Please return to /FV/

Name: Anonymous 2009-11-12 13:35

>>38
I LOVE YOU! I LOVE YOUR POST! I READ IT 5 TIMES! KEEP POSTING!

Name: nullpointer 2009-11-12 17:48

>>36

lol evidently you've never coded LISP. (not (= LISP many-parens)). That's just the visual aspect which anybody and their dog can spot in a snippet of code. LISP is about far more than the visual look of its syntax. It's more about the way it parses and handles that syntax. Just because both java and LISP use the '(' character in their source code does not bring them any closer together.

Also, I'm looking forward to a future where computers are so powerful you can get away with coding LISP as a reasonable systems language. (That is if we don't descend into medieval anarchy and club each other's brains out over the last remaining foodscraps)

Name: Anonymous 2009-11-12 17:54

>>41
Use a modern systems language fer chrissake.

package main

import "bufio"
import "os"

const errorPrefix = "\033[41m\033[37m\033[1m\033[5mCRITICAL FAILURE: "
const errorSuffix = "\033[m\n"

func reportError(err os.Error) {
    os.Stderr.WriteString(errorPrefix + err.String() + errorSuffix)
}

func main() {
    f, err := os.Open("asd", os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0666);
    if err != nil {
        goto fail    // the mighty gofumpt insists this is a 3-line block
    }
    s := bufio.NewWriter(f);
    // no need to worry about out-of-memory,
    // since Go unconditionally crashes in that case.
    err = s.WriteString("blah");
    if err != nil {
        goto fail
    }
    err = s.Flush();
    if err != nil {
        goto fail
    }
    return;
fail:
    reportError(err);
}

Name: Anonymous 2009-11-12 18:01

>>46
Dude was joking, chump.

Name: Anonymous 2009-11-12 18:13

HAXHAXHAXHAXMYANUSANUSANUSANUS

Name: Anonymous 2009-11-12 18:37

>>47
goto <3

Name: Anonymous 2009-11-12 19:01

why do lispfags try to turn every thread into a thread about their toy language?
does lisp cause you some kind of brain damage or something?

Name: Anonymous 2009-11-12 19:27

>>50
I originally wrote an ridiculous chain of if-else blocks, assuming Go was too hip to goto.  But I didn't want to be too harsh, so I checked the spec and it was there, with error handling as the implied purpose.

edit: it seems I broke the rules, though, since the first goto skips across a variable declaration.  Which means I would need an explicit var s bufio.Writer; before that.

Also you can finally use break and continue with label parameters to jump more than one block out.

Name: Anonymous 2009-11-12 19:27

>>51
Read SICP, then you'll UNDERSTAND

Name: Anonymous 2009-11-12 19:41

>>51
It's because you haven't read SICP

Name: Anonymous 2009-11-12 21:01

C++ you fucktards

Name: Anonymous 2009-11-12 23:18

C++ if you're anal
Java if you're insane

Name: Anonymous 2009-11-12 23:49

>>36
FileWriter fw = new FileWriter(new File("asd"));

Name: Anonymous 2009-11-13 2:12

>>1
Question. How does one get into the demoscene?

Name: Anonymous 2009-11-13 6:13

>>33
this is for you my love


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>

#define DEFAULT_XRES             1024
#define DEFAULT_YRES             768

#define MAX_CIRCLE_ANGLE        512
#define HALF_MAX_CIRCLE_ANGLE         (MAX_CIRCLE_ANGLE/2)
#define QUARTER_MAX_CIRCLE_ANGLE     (MAX_CIRCLE_ANGLE/4)
#define MASK_MAX_CIRCLE_ANGLE         (MAX_CIRCLE_ANGLE - 1)
#define PI                 3.14159265358979323846f

float fast_cossin_table[MAX_CIRCLE_ANGLE];

__inline__ float fastcos(float x) {
    int i;
    i = (int)(x * HALF_MAX_CIRCLE_ANGLE / PI);
       if (i < 0) {
        return fast_cossin_table[((-i) + QUARTER_MAX_CIRCLE_ANGLE)&MASK_MAX_CIRCLE_ANGLE];
    } else {
        return fast_cossin_table[(i + QUARTER_MAX_CIRCLE_ANGLE)&MASK_MAX_CIRCLE_ANGLE];
       }
    printf("0");
}

__inline__ float fastsin(float x) {
    int i;
    i = (int)(x * HALF_MAX_CIRCLE_ANGLE / PI);
       if (i < 0) {
              return fast_cossin_table[(-((-i)&MASK_MAX_CIRCLE_ANGLE)) + MAX_CIRCLE_ANGLE];
       } else {
              return fast_cossin_table[i&MASK_MAX_CIRCLE_ANGLE];
       }
}

void buildsincos(void) {
    int i;
    for (i = 0; i < MAX_CIRCLE_ANGLE; i++) {
        fast_cossin_table[i] = (float)sinf(i * PI / HALF_MAX_CIRCLE_ANGLE);
    }
}

SDL_Surface *screen;
int quit = 0;
SDL_Event event;

SDL_Surface *skull = NULL;
SDL_Surface *skull_tmp = NULL;
SDL_Surface *tmp = NULL;
SDL_Surface *wavy = NULL;

int floorLog2(unsigned int n) {
    int pos = 0;
    if (n >= 1<<16) { n >>= 16; pos += 16; }
    if (n >= 1<< 8) { n >>=  8; pos +=  8; }
    if (n >= 1<< 4) { n >>=  4; pos +=  4; }
    if (n >= 1<< 2) { n >>=  2; pos +=  2; }
    if (n >= 1<< 1) {           pos +=  1; }
    return ((n == 0) ? (-1) : pos);
}

SDL_Rect posTmp;
SDL_Rect clipTmp;
inline void mega_super_fast_blit_tmp(int x, int y, SDL_Surface *src, SDL_Surface *dest)
{
    posTmp.x = x;
    posTmp.y = y;
    clipTmp.x = x;
    SDL_BlitSurface(src, &clipTmp, dest, &posTmp);
}

SDL_Rect pos;
SDL_Rect clip;
inline void mega_super_fast_blit(int x, int y, SDL_Surface *src)
{
    pos.y = y;
    pos.x = x;
    clip.y = y;
    SDL_BlitSurface(src, &clip, wavy, &pos);
}

GLuint texture;
GLenum texture_format;
GLint nOfColors;

int main(int argc, char *args[]) {
    assert(SDL_Init(SDL_INIT_VIDEO) != -1);

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    screen = SDL_SetVideoMode(DEFAULT_XRES, DEFAULT_YRES, 32, SDL_OPENGL);
    assert(screen != NULL);
    buildsincos();

    Uint32 colorkey;
    tmp = SDL_LoadBMP("back.bmp");
    assert(tmp != NULL);
    skull = SDL_DisplayFormat(tmp);
    skull_tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, skull->w, skull->h, 32, 0, 0, 0, 0);
    wavy = SDL_CreateRGBSurface(SDL_SWSURFACE, skull->w, skull->h, 32, 0, 0, 0, 0);
    SDL_FreeSurface(tmp);

    SDL_WM_SetCaption("Powah", NULL);

    unsigned int skullw = skull->w;
    unsigned int skullh = skull->h;

    float jit = 0.0f;
    float jitstep = 0.16f;
    float amp = 4.0f;
    float z = 0.0f;
    float x = 0.0f;
    float y = 0.0f;

    unsigned int slice = 1;
    int sliceShift = floorLog2(slice);

    clipTmp.y = 0;
    clipTmp.w = slice;
    clipTmp.h = skullh;

    clip.x = 0;
    clip.w = skullw;
    clip.h = slice;

    int skullws = skullw>>sliceShift;
        int skullhs = skullh>>sliceShift;

    int bandTbl[1024];
    register unsigned int e;
    for (e = 0; e<1024; e++)
            bandTbl[e] = (e<<sliceShift);


    glEnable(GL_TEXTURE_2D);
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);

    // Set the texture's stretching properties
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   
    while (quit == 0) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                quit = 1;
            }
            if (event.type = SDL_KEYDOWN) {
                switch (event.key.keysym.sym) {
                    case SDLK_LEFT:
                        z += 0.2f;
                    break;
                    case SDLK_RIGHT:
                        z -= 0.2f;
                    break;

                    default:
                    break;
                }
            }
        }

        //unsigned int band = 0;

        for(e = 0; e < skullws; e++) {
            mega_super_fast_blit_tmp(bandTbl[e], fastsin(jit)*amp, skull, skull_tmp);
            jit += jitstep;
        }
        for(e = 0; e < skullhs; e++) {
            mega_super_fast_blit(fastcos(jit)*amp, bandTbl[e], skull_tmp);
            jit -= jitstep;
        }

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glClearDepth(1.0f);                            // Depth Buffer Setup
        glEnable(GL_DEPTH_TEST);                        // Enables Depth Testing
        glDepthFunc(GL_LEQUAL);   
        glViewport(0, 0, DEFAULT_XRES, DEFAULT_YRES);
        gluPerspective(45.0f, (GLfloat)DEFAULT_XRES/(GLfloat)DEFAULT_YRES, 0.1f, 100.0f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glLoadIdentity();
        gluLookAt(0, 0, z, 0, 0, 0, 0, 1, 0);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexImage2D(GL_TEXTURE_2D, 0, 4, wavy->w, wavy->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, wavy->pixels);

        glBegin(GL_QUADS);
            glTexCoord2i(0, 0);
            glVertex3f(1.0f, 1.0f, 0.0f);
   
            //Bottom-left vertex (corner)
            glTexCoord2i(1, 0);
            glVertex3f(-1.0f, 1.0f, -5.0f);
   
            //Bottom-right vertex (corner)
            glTexCoord2i(1, 1);
            glVertex3f(-1.0f, -1.0f, -5.0f);
   
            //Top-right vertex (corner)
            glTexCoord2i(0, 1);
            glVertex3f(1.0f, -1.0f, 0.0f);
        glEnd();

        SDL_GL_SwapBuffers();
        SDL_Delay(15);
    }
    SDL_FreeSurface(skull);
    SDL_FreeSurface(wavy);
    SDL_FreeSurface(skull_tmp);
    SDL_Quit();
    return 0;
}

Name: Anonymous 2009-11-13 6:44

>>58
You have to be able to write something like this:
http://www.youtube.com/watch?v=5PZ73nLZaqc

Name: Anonymous 2009-11-13 6:50

Name: Anonymous 2009-11-13 7:30

>>59
assert failed because I have no back.bmp.  What is it supposed to be?

Name: Anonymous 2009-11-13 8:01

>>62
it's a picture of someone's back

Name: Anonymous 2009-11-13 10:19

>>59
I don't know why that code makes me feel nostalgic.

Name: Anonymous 2009-11-13 18:05

>>61
The executable version of this is a 26 mb download. It makes a nice video and all, but it's not very impressive from a technical standpoint.

>>60
Suppose I've written something like this. Now what do I do? OP, how did you get into the demoscene?

Name: Anonymous 2009-11-13 18:13

>>59
Built this and put in a 512x512 checkerboard image for back.bmp. I get a black screen. What am I doing wrong? Also, where does this code come from?

Name: Anonymous 2009-11-13 18:43

>>66
Press the left arrow key to move backwards from this huge ass red rectangle.  You can use the right arrow keys to move further towards it.

Name: Anonymous 2009-11-13 18:47

>>26
mitosis

Name: Anonymous 2009-11-13 21:35

Name: Anonymous 2009-11-14 0:10

>>67
There's no rectangle. Just black.

Name: Anonymous 2011-02-03 1:35

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List