• Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    eliot
    Posts: 633 from 2004/4/15
    Ok bigfoot,

    some good news for you, some bad for me:
    Simple materials tests looks good on r200 and r300 on mos:
    test_materials_mos_r200.png
    test_materials_mos_r300.png

    the code:
    Code:

    #ifdef __APPLE__
    #include <gl.h>
    #include <glu.h>
    #include <glut.h>
    #else

    #include <GL/gl.h>
    #include <GL/glu.h>
    #include <GL/glut.h>

    #endif

    #include <assert.h>


    static char *TITLE = "test_materials";


    void init() {
    GLfloat LP[] = {(GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 10,
    (GLfloat) 1};
    GLfloat A[] = {(GLfloat) 0.1,
    (GLfloat) 0.1,
    (GLfloat) 0.1};
    GLfloat S[] = {(GLfloat) 0.5,
    (GLfloat) 0.5,
    (GLfloat) 0.5};
    GLfloat D[] = {(GLfloat) 0.5,
    (GLfloat) 0.5,
    (GLfloat) 0.5};
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glEnable(GL_FRONT);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glLightfv(GL_LIGHT0, GL_POSITION, LP);
    glLightfv(GL_LIGHT0, GL_AMBIENT, A);
    glLightfv(GL_LIGHT0, GL_SPECULAR, S);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, D);

    glClearColor(0.f, 0.f, 0.f, 1.f);
    }

    void reshape(int width, int height) {
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(65.0, (float) width / (float) height, 1.0, 100);
    }

    void display() {

    static GLfloat RA[] = {(GLfloat) 1,
    (GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 1};
    static GLfloat RS[] = {(GLfloat) 1,
    (GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 1};
    static GLfloat RD[] = {(GLfloat) 1,
    (GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 1};

    static GLfloat GA[] = {(GLfloat) 0,
    (GLfloat) 1,
    (GLfloat) 0,
    (GLfloat) 1};
    static GLfloat GS[] = {(GLfloat) 0,
    (GLfloat) 1,
    (GLfloat) 0,
    (GLfloat) 1};
    static GLfloat GD[] = {(GLfloat) 0,
    (GLfloat) 1,
    (GLfloat) 0,
    (GLfloat) 1};

    static GLfloat BA[] = {(GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 1,
    (GLfloat) 1};
    static GLfloat BS[] = {(GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 1,
    (GLfloat) 1};
    static GLfloat BD[] = {(GLfloat) 0,
    (GLfloat) 0,
    (GLfloat) 1,
    (GLfloat) 1};
    static GLfloat Y = 0;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    gluLookAt(0, 0, 5,
    0, 0, 0,
    0, 1, 0);


    glBegin(GL_QUADS);
    glNormal3d(0, 0, 1);
    glMaterialfv(GL_FRONT, GL_AMBIENT, RA);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, RD);
    glMaterialfv(GL_FRONT, GL_SPECULAR, RS);
    glMaterialf(GL_FRONT, GL_SHININESS, Y);
    glVertex3d(0, 0, 0);
    glVertex3d(1, 0, 0);
    glVertex3d(1, 1, 0);
    glVertex3d(0, 1, 0);
    glEnd();

    glBegin(GL_TRIANGLES);
    glNormal3d(0, 0, 1);
    glMaterialfv(GL_FRONT, GL_AMBIENT, GA);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, GD);
    glMaterialfv(GL_FRONT, GL_SPECULAR, GS);
    glMaterialf(GL_FRONT, GL_SHININESS, Y);
    glVertex3d(1, 0, 0);
    glVertex3d(2, 0, 0);
    glVertex3d(2, 1, 0);
    glEnd();

    glBegin(GL_TRIANGLES);
    glNormal3d(0, 0, 1);
    glMaterialfv(GL_FRONT, GL_AMBIENT, BA);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, BD);
    glMaterialfv(GL_FRONT, GL_SPECULAR, BS);
    glMaterialf(GL_FRONT, GL_SHININESS, Y);
    glVertex3d(0, 0, 0);
    glVertex3d(-1, 1, 0);
    glVertex3d(-1, 0, 0);
    glEnd();

    glutSwapBuffers();
    }

    int main(int argc, char **argv) {
    int window = 0;

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutInitWindowPosition(0, 0);
    window = glutCreateWindow(TITLE);
    assert(window);
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    init();
    glutMainLoop();

    glutDestroyWindow(window);
    return 0;
    }


    compile:
    gcc -o test_materials tests/test_materials.c -ansi -O0 -noixemul -noixemul -lm -lGl -lglut

    The problem is somewhere in my code. Any debugging hints on MorphOs, since there no gdb.

    Thx for your help anyway!
    BTW I am using c++11 in the broken code, is there everything tested on MorphOs?

    [ Edited by eliot 14.10.2016 - 11:52 ]
    regards
    eliot
  • »14.10.16 - 06:32
    Profile