Computer-Ag am WvS Blog der Computer-AG am Werner von Siemens Gymnasium Berlin

11. Februar 2015

11.2.2015

Filed under: Allgemein,go,Schulnetzwerk,SDL,Tagesberichte,Tisch,Websockets — admin @ 15:44

Angelo ist da. Morten noch nicht.

Nach Ausschalten des Proxys konnte ich ein Git-Repository SDL-Clone von neaginx klonen.

Angelo schafft was mit Go und SDL. Go jetzt auf dem Lernserver aktualisert. Und dann noch in „./go/src ./allbash“. Angelo fehlen aber noch die Pointer.

Am Freitag sind wir dann vermutlich wieder mehr, denn das Semester hört auch langsam auf.

23. Januar 2015

23.1.2015

Morten, Johannes und Angelo sind da. Der Code wird perfektioniert:

 

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

typedef struct _Color Color;
struct _Color 
{
    unsigned char r, g, b;
};

typedef struct _Point Point;
struct _Point
{
    int x, y;
};

SDL_Surface *screen;

void
drawPixel(int x, int y, Color c)
{
    *((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch)) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

void
drawLine(Point p1, Point p2, Color c)
{
    int dx, dy;
    int incx, incy;
    float m;
    dx = p2.x - p1.x;
    dy = p2.y - p1.y;
    incx = dx>0 ? 1 : -1;
    incy = dy>0 ? 1 : -1;
    if(dx == 0){
        int y;
        for(y = p1.y; y != p2.y; y += incy)
            drawPixel(p1.x, y, c);
        return;
    }

    if(abs(dx)>abs(dy)){
        int x;
        float y;
        m = (float)dy/(float)abs(dx);
        y = p1.y;
        for(x = p1.x; x != p2.x; x += incx){
            drawPixel(x, y+0.5f, c);
            y += m;
        }
    }else{
        int y;
        float x;
        m = (float)dx/(float)abs(dy);
        x = p1.x;
        for(y = p1.y; y != p2.y; y += incy){
            drawPixel(x+0.5f, y, c);
            x += m;
        }
    }
}

void
drawTriWire(Point p1, Point p2, Point p3, Color c)
{
    drawLine(p1, p2, c);
    drawLine(p2, p3, c);
    drawLine(p3, p1, c);
}

void
drawHorizontalLine(int y, float x1f, float x2f, Color c) {
    int x1, x2, tmp;
    x1 = (x1f == (int)x1f) ? x1f : x1f+1;
    x2 = (x2f == (int)x2f) ? x2f : x2f+1;
    if(x1 > x2){
        tmp = x1;
        x1 = x2;
        x2 = tmp;
    }
    while(x1 < x2)
        drawPixel(x1++, y, c);
}

void
//~ sortPoints(Point **p) ident mit zeile drunter, for educational purpose only 
sortPoints(Point *p[])
{
#define SWAPPOINT(p,q) { \
        tmp = p;      \
        p = q;     \
        q = tmp;      \
    }
    Point *tmp;
    if(p[0]->y > p[1]->y) 
        SWAPPOINT(p[0], p[1]);
    if(p[0]->y > p[2]->y)
        SWAPPOINT(p[0], p[2]);
    if(p[1]->y > p[2]->y) 
        SWAPPOINT(p[1], p[2]);
#undef SWAPPOINT
}

void
drawTriFlat(Point p1, Point p2, Point p3, Color c)
{
    float dx[3];
    int y;
    float x1, x2;
    Point *p[] = {&p1, &p2, &p3};
    sortPoints(p);
#define D(p,q) (q->y - p->y == 0 ? 0.0f : (float) (q->x - p->x) / (q->y - p->y))
    //~ dx[0] = (float) (p[2]->x - p[0]->x) / (p[2]->y - p[0]->y);
    dx[0] = D(p[0], p[2]);
    dx[1] = D(p[0], p[1]);
    dx[2] = D(p[1], p[2]);
#undef D
    y = p[0]->y;
    x1 = x2 = p[0]->x;
    while(y < p[1]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[1];
    }
    x2 = p[1]->x;
    while(y < p[2]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[2];
    }
}



void
drawRect(Point p1, Point p2, Color rgb)
{
    int i, j;
       for(i = p1.x; i < p2.x; i++)
        for(j = p1.y; j < p2.y; j++)
            drawPixel(i, j, rgb);
}

void
draw(void)
{
    drawRect((Point){40,140}, (Point){50,150}, (Color) {255, 0, 255});
    drawRect((Point){80,140}, (Point){90,150}, (Color) {255, 0, 255});
    drawRect((Point){62,160}, (Point){68,180}, (Color) {10, 123, 233});
    drawRect((Point){40,195}, (Point){90,200}, (Color) {123, 233, 10});
    
//    drawLine((Point){0, 0}, (Point){50, 30});
//    drawLine((Point){0, 0}, (Point){30, 50});
//    drawLine((Point){50, 0}, (Point){50, 50});
        drawTriFlat((Point){30,120}, (Point){100, 120}, (Point){65, 100}, (Color){25, 85, 155});
}

int
main(void)
{
    int running = 1;
    int w = 640;
    int h = 480;
    SDL_Event event;

    SDL_Init(SDL_INIT_VIDEO);

    screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);

    while(running){
        while(SDL_PollEvent(&event))
            if(event.type == SDL_QUIT)
                running = 0;
        SDL_LockSurface(screen);
        draw();
        SDL_UnlockSurface(screen);
        SDL_UpdateRect(screen, 0, 0, 0, 0);
    }

    SDL_Quit();
    return 0;
}

bringt:

 

test3

 

Angelo will keine Kreise machen.

#include 
#include 
#include 
#include <SDL/SDL.h>
#include 
typedef struct _Color Color;
struct _Color 
{
    unsigned char r, g, b;
};

typedef struct _Point Point;
struct _Point
{
    int x, y;
};

SDL_Surface *screen;

void
drawPixel(int x, int y, Color c)
{
    *((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch)) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

void
drawLine(Point p1, Point p2, Color c)
{
    int dx, dy;
    int incx, incy;
    float m;
    dx = p2.x - p1.x;
    dy = p2.y - p1.y;
    incx = dx>0 ? 1 : -1;
    incy = dy>0 ? 1 : -1;
    if(dx == 0){
        int y;
        for(y = p1.y; y != p2.y; y += incy)
            drawPixel(p1.x, y, c);
        return;
    }

    if(abs(dx)>abs(dy)){
        int x;
        float y;
        m = (float)dy/(float)abs(dx);
        y = p1.y;
        for(x = p1.x; x != p2.x; x += incx){
            drawPixel(x, y+0.5f, c);
            y += m;
        }
    }else{
        int y;
        float x;
        m = (float)dx/(float)abs(dy);
        x = p1.x;
        for(y = p1.y; y != p2.y; y += incy){
            drawPixel(x+0.5f, y, c);
            x += m;
        }
    }
}

void
drawTriWire(Point p1, Point p2, Point p3, Color c)
{
    drawLine(p1, p2, c);
    drawLine(p2, p3, c);
    drawLine(p3, p1, c);
}

void
drawHorizontalLine(int y, float x1f, float x2f, Color c) {
    int x1, x2, tmp;
    x1 = (x1f == (int)x1f) ? x1f : x1f+1;
    x2 = (x2f == (int)x2f) ? x2f : x2f+1;
    if(x1 > x2){
        tmp = x1;
        x1 = x2;
        x2 = tmp;
    }
    while(x1 < x2)         drawPixel(x1++, y, c); } void //~ sortPoints(Point **p) ident mit zeile drunter, for educational purpose only  sortPoints(Point *p[]) { #define SWAPPOINT(p,q) { \         tmp = p;      \         p = q;     \         q = tmp;      \     }     Point *tmp;     if(p[0]->y > p[1]->y) 
        SWAPPOINT(p[0], p[1]);
    if(p[0]->y > p[2]->y)
        SWAPPOINT(p[0], p[2]);
    if(p[1]->y > p[2]->y) 
        SWAPPOINT(p[1], p[2]);
#undef SWAPPOINT
}

void
drawTriFlat(Point p1, Point p2, Point p3, Color c)
{
    float dx[3];
    int y;
    float x1, x2;
    Point *p[] = {&p1, &p2, &p3};
    sortPoints(p);
#define D(p,q) (q->y - p->y == 0 ? 0.0f : (float) (q->x - p->x) / (q->y - p->y))
    //~ dx[0] = (float) (p[2]->x - p[0]->x) / (p[2]->y - p[0]->y);
    dx[0] = D(p[0], p[2]);
    dx[1] = D(p[0], p[1]);
    dx[2] = D(p[1], p[2]);
#undef D
    y = p[0]->y;
    x1 = x2 = p[0]->x;
    while(y < p[1]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[1];
    }
    x2 = p[1]->x;
    while(y < p[2]->y){
        drawHorizontalLine(y, x1, x2, c);
        y++;
        x1 += dx[0];
        x2 += dx[2];
    }
}



void
drawRect(Point p1, Point p2, Color rgb)
{
    int i, j;
   	for(i = p1.x; i < p2.x; i++)
		for(j = p1.y; j < p2.y; j++)
			drawPixel(i, j, rgb);
}

void 
drawCircle(Point center, int radius, Color c) {
    Point p;
    int x;
    int y;
    for(x = 0; x < radius; x++){
        y = sqrt(radius*radius - x*x);
        drawLine((Point) {center.x + x, center.y + y}, (Point) {center.x + x, center.y - y}, c); 
        drawLine((Point) {center.x - x, center.y + y}, (Point) {center.x - x, center.y - y}, c); 
    }

}

void
draw(void)
{
    drawCircle((Point){65, 170}, 45, (Color) {128, 128, 0});
    drawRect((Point){40,140}, (Point){50,150}, (Color) {255, 0, 255});
    drawRect((Point){80,140}, (Point){90,150}, (Color) {255, 0, 255});
    drawRect((Point){62,160}, (Point){68,180}, (Color) {10, 123, 233});
    drawRect((Point){40,195}, (Point){90,200}, (Color) {123, 233, 10});
    
//    drawLine((Point){0, 0}, (Point){50, 30});
//    drawLine((Point){0, 0}, (Point){30, 50});
//    drawLine((Point){50, 0}, (Point){50, 50});
        drawTriFlat((Point){30,120}, (Point){100, 120}, (Point){65, 100}, (Color){25, 85, 155});
}

int
main(void)
{
	int running = 1;
	int w = 640;
	int h = 480;
	SDL_Event event;

	SDL_Init(SDL_INIT_VIDEO);

	screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);

	while(running){
		while(SDL_PollEvent(&event))
			if(event.type == SDL_QUIT)
				running = 0;
		SDL_LockSurface(screen);
		draw();
		SDL_UnlockSurface(screen);
		SDL_UpdateRect(screen, 0, 0, 0, 0);
	}

	SDL_Quit();
	return 0;
}

chinese

Nächste Woche ist nicht.

 

Angelo orientiert sich nach dem GS UsersManual für die PS2.

21. Januar 2015

21.1.2015

Morten ist da. Wir reden über Windows ultimate. Und Ableton.

Jetzt sieht der Code so aus:

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

typedef struct _Color Color;
struct _Color 
{
    unsigned char r, g, b;
};

typedef struct _Point Point;
struct _Point
{
    int x, y;
};

SDL_Surface *screen;

void
drawPixel(int x, int y, Color c)
{
    *((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch)) = SDL_MapRGB(screen->format, c.r, c.g, c.b);
}

void
drawLine(Point p1, Point p2, Color c)
{
    int dx, dy;
    int incx, incy;
    float m;
    dx = p2.x - p1.x;
    dy = p2.y - p1.y;
    incx = dx>0 ? 1 : -1;
    incy = dy>0 ? 1 : -1;
    if(dx == 0){
        int y;
        for(y = p1.y; y != p2.y; y += incy)
            drawPixel(p1.x, y, c);
        return;
    }

    if(abs(dx)>abs(dy)){
        int x;
        float y;
        m = (float)dy/(float)abs(dx);
        y = p1.y;
        for(x = p1.x; x != p2.x; x += incx){
            drawPixel(x, y+0.5f, c);
            y += m;
        }
    }else{
        int y;
        float x;
        m = (float)dx/(float)abs(dy);
        x = p1.x;
        for(y = p1.y; y != p2.y; y += incy){
            drawPixel(x+0.5f, y, c);
            x += m;
        }
    }
}

void
drawTriWire(Point p1, Point p2, Point p3, Color c)
{
    drawLine(p1, p2, c);
    drawLine(p2, p3, c);
    drawLine(p3, p1, c);
}

void
drawRect(Point p1, Point p2, Color rgb)
{
    int i, j;
       for(i = p1.x; i < p2.x; i++)
        for(j = p1.y; j < p2.y; j++)
            drawPixel(i, j, rgb);
}

void
draw(void)
{
    drawRect((Point){40,40}, (Point){50,50}, (Color) {255, 0, 255});
    drawRect((Point){80,40}, (Point){90,50}, (Color) {255, 0, 255});
    drawRect((Point){62,60}, (Point){68,80}, (Color) {10, 123, 233});
    drawRect((Point){40,95}, (Point){90,100}, (Color) {123, 233, 10});
    
//    drawLine((Point){0, 0}, (Point){50, 30});
//    drawLine((Point){0, 0}, (Point){30, 50});
//    drawLine((Point){50, 0}, (Point){50, 50});
        drawTriWire((Point){10,10}, (Point){100, 70}, (Point){30, 150}, (Color){255, 255, 255});
}

int
main(void)
{
    int running = 1;
    int w = 640;
    int h = 480;
    SDL_Event event;

    SDL_Init(SDL_INIT_VIDEO);

    screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);

    while(running){
        while(SDL_PollEvent(&event))
            if(event.type == SDL_QUIT)
                running = 0;
        SDL_LockSurface(screen);
        draw();
        SDL_UnlockSurface(screen);
        SDL_UpdateRect(screen, 0, 0, 0, 0);
    }

    SDL_Quit();
    return 0;
}

 

Und das Resutlat so:

 

 

c2

Nächste Mal dann Ausfüllen von Dreiecken, 3D-Rotation und Kreise …;

Morten bastelt daran rum, wie ein Spiel unter Windows startet …;

Diesen Freitag ist noch einmal, dann zwei Wochen Pause.

 

16. Januar 2015

16.1.2015

Filed under: Allgemein,Lernserver,Schulnetzwerk,Termine — admin @ 15:46

Morten, Johannes und Willi sind da. Die Rechner fahren sehr langsam hoch, weil da jetzt Android-Studio installiert ist (sagte und Frau Spyra).

Angelo demonstrierte letzt Mal noch Syntaxhighlighting:

Morten, Johannes und Willi reden über Minecraftserver. Und darüber, mit welcher Tastenkombination sich neue Fenster im Browser öffnen lassen bzw. neue Tabs (strg-T). Mit strg-N geht ein neues Fenster auf. Mit strg-Shift-N geht das zuletzt geschlossene Fenster wieder auf mit der Seite, die dort zuletzt aufgerufen war. Angelo kommt auch.

Wir wollen was mit SDL machen. Geht auch in der TTY-Konsole.

Dieser Code …

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

void
draw(SDL_Surface *screen)
{
    int i, j;
#define P(x,y) ((Uint32*)((char*)screen->pixels + x*screen->format->BytesPerPixel + y*screen->pitch))

    for (i=40; i<50; i++) {
        for (j=40; j<50; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 255, 0, 255);
        }
    }
    for (i=80; i<90; i++) {
        for (j=40; j<50; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 255, 0, 255);
        }
    }
    for (i=62; i<68; i++) {
        for (j=60; j<80; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 10, 123, 233);
        }
    }
    for (i=40; i<90; i++) {
        for (j=95; j<100; j++) {
            *P(i,j) = SDL_MapRGB(screen->format, 123, 233, 10);
        }
    }
#undef P
}

int
main(void)
{
    int running = 1;
    int w = 140;
    int h = 140;
    SDL_Surface *screen;
    SDL_Event event;

    SDL_Init(SDL_INIT_VIDEO);

    screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE);


    while (running) {
        while(SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                running = 0;
            }
        }
        SDL_LockSurface(screen);
        draw(screen);
        SDL_UnlockSurface(screen);
        SDL_UpdateRect(screen, 0, 0, 0, 0);
    }

    SDL_Quit();
    return 0;
}

 

… macht das, wenn man ihn mit cc src.c -lSDL kompiliert:

 

sdl-test

Moritz war auch da. Nächste Woche noch ganz normal, dann zwei Wochen Pause, eine Woche ist Robert weg, dann sind Winterferien.

14. Januar 2015

14.1.2015

Heute ist Tag der offenen Tür. Deshalb vermutlich nicht ganz so lange. Morten hat Probleme mit Pidgin und MSN. Wir reden über Abmahnung. S.a. Infos zu Waldorf Frommer. Angelo nutzt übrigens nicht Pidgin sondern BitlBee. Das übersetzt auf IRC. Angelo arbeitet dann mit Tmux. Damit kann man Terminalsessions teilen und splitten. Angelo nutzt QEmu um Windows laufen zu lassen. Das kann emulieren und virtualisieren (aber auf FreeBSD kann es nur emulieren, das Kernelmodul für Virutalisierung gibt es da noch nicht). Wir sprechen über die Ausnahmlosigkeit der Lautgesetze (Junggrammatiker Ende des 19. Jahrhunderts). Kurz schrammen wir noch am rheinischen Fächer vorbei.

9. Januar 2015

9.1.2015

Filed under: Allgemein,Computer,Lernserver,Schulnetzwerk,Termine,Tisch — admin @ 15:42

Es stürmt. Frau Spyra kam und wir sprachen über die Installation von Android Studio. Überlegung war, eine Portable Version zu benutzen. Außerdem haben wir herausgefunden, was eine Denic-Mitgliedschaft kostet. Nächste und übernächste Woche findet die AG noch statt, die Woche vor den Winterferien, am 28. und 30. Januar, nicht. Moritz programmiert einen Downloadmanager für xdcc in C bzw. in C++. Johannes versucht eine virtuelle Maschine von Windows-XP zu installieren. Robert versucht seine FritzBox von außerhalb zu konfigurieren.

7. Januar 2015

7.1.2015

Morten und Angelo sind da. Frau Kannenberg kam auch, wir haben über Photoshop und grafische Tools gesprochen. Da findet sich bei Photoshop ein Online-Tool. Angelo kann von der PS2 Gebäude auslesen und mit seinem selbst programmierten Grafiktool darstellen lassen. Canvas-Tests liegen im Homefolder von rob bei public_html (s.a. hier). Mortens Arbeiten bezgüglich Datenbank hatten wir hoffentlich schon verlinkt. Roberts Test hoffentlich auch. Morten und Angelo zocken bissel GTA. Am Freitag findet AG statt, normal.

28. November 2014

28.11.2014

Robert hat seinen Ubunutstick verlegt. Musste sich jetzt mit Xming (Download für Windows) einloggen und sich vorher das MagickPacket holen (Download) um den Lernserver (10.31.255.135) per WakeOnLan aufzuwecken. Hat geklappt.

Frau Trümper kam vorbei. Der Kurs Studium-und-Beruf soll eine Ehemaligen-Datenbank aufbauen. Morten bereit da schon mal was vor.

Johannes und Moritz sind auch da und arbeiten an Untertiteln. Angelo liest wieder Vectorunitcode.

Willi ist auch da. Willi programmiert.

Morten kämpft mit der Datenbank. Erst wenn ein Feld mit Id vorhanden ist, kann man editieren. Nächste Woche Mittwoche findet statt. Johannes und Moritz können da nicht. Freitag dann auch wieder.

21. November 2014

21.11.2014

Filed under: Allgemein,Schulnetzwerk,Tagesberichte,Termine,Tisch — admin @ 15:42

Nächsten Mittwoch findet nicht statt. Angelo ist da. Er hat wieder reverse engeneered. Moritz ist auch da. Angelo demonstriert seinen Map-Viewer von GTA/PS2. Mit eine Rolle spielt der IEEE 754. Wir reden über die Taktlänge von Instruktionen bei dem Beispiel. Es geht um Opcodes und ähnliches, s.a. das Sony-Manual für PS2. Johannes ist auch da. S.a. aap bei github. Der OpenGL-Debugger (Profiler) sei auch sehr genial. Angelo muss erst das Wetter einstellen, damit er GTA korrekt spielen kann. Er spielt mit dem Emulator. Notepad++ läuft übrigens nur unter Windows. Und basiert auf Scintilla, genau wie SciTE. Angelo will einen Emulator basteln. Man könnte einen Mips-Emulator schreiben und dann einen Compiler, der Lisp zu Mips kompiliert – das wäre (ganz) witzig. Das Javascript-LISP-Projekt (Lisp Interpreter in Javascript) ist soweit erstmal funktionsfähig.

Angelo hat sich jetzt 4 verschiedene Wettersituationen gedumped, ist wieder rüber zu Linux und analysiert die jetzt.

Nochmal findet nicht statt. Dafür nächsten Freitag wieder.

19. November 2014

19.11.2014

Angelo ist da. Morten kann diese Woche nicht. Julian wollte auch kommen. Moritz kommt Freitag, da kommt Johannes auch. Wir gucken uns Angelos disassemblierten Code der PS2 an. Angelo hat den Emulator so verändert, dass er die Speicher der Unit auslesen kann. Ansonsten reden wir über „tail recursion“ (s.a. http://www.cyclopaedia.de/wiki/Tail-recursion bzw. Lamda-Papers von Guy Steele).

Julian kommt auch, kann aber Freitag nicht und theoretisch nur jeden zweiten Mittwoch. Wir reden über Evolution-Programming, s.a. Video dazu. Julian erzählt von seinen beiden Servern, die er sich grade zugelegt hat.

Angelo kommt nicht auf den WLAN-Router. Wir wundern uns, warum es bei Julian klappt und bei Angelos Gentoo nicht (dafür hat Gentoo ein system.d). Mit „ifconfig interface 0.0.0.0“ klappt es. fritznetz.papnet.eu kann nicht erreicht werden wegen Webfilter. Mit https nämlich geht es …;

Wir reden noch über Mac und Glaubensfragen. Nächsten Freitag findet statt.

 

« Newer PostsOlder Posts »