Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmeapi.h missing? #4

Open
GDani31 opened this issue Jul 22, 2023 · 4 comments
Open

mmeapi.h missing? #4

GDani31 opened this issue Jul 22, 2023 · 4 comments

Comments

@GDani31
Copy link

GDani31 commented Jul 22, 2023

In the headerfile on line 529, there is the line "#include <mmeapi.h>", but vs code tells me "mmeapi.h: No such file or directory".
sometimes the compiler runs and shows me the window, sometimes the window closes instantly after running and sometimes it does not run. I use the c++ build tools from 2022 to compile it.

@npiegdon
Copy link
Owner

Hmm, strange. This is with the regular/latest Windows SDK installed as part of Visual Studio? I wonder if Microsoft is finally rearranging their Win32 headers after 30 years...

If you get rid of the WIN32_LEAN_AND_MEAN define on line 522 and then remove both of the line 529 and 530 includes, does that get it to compile?

Regarding the window not showing up, is this with code changes between those runs? Or can you literally run the same program more than once and sometimes get the window to appear but other times it won't? And what did you mean by "it does not run"? Is there some error in the IDE? Or do you mean the window simply never appears, even for a quick flicker?

@GDani31
Copy link
Author

GDani31 commented Jul 22, 2023

I have now tried to comment these lines out and now i can see some warning in the console.
It looks like mmeapi is no more in c++17.

Regarding the window:
I mean the Window itself opens but closes in less than a second. That happend with basically no code changes, i only added some spaces between the lines and suddently it does somthing else.

i now have changed in the settings the compiler to c++14 and now everything works fine with the line removal.
no crashes, no windows closing from itself. the only thing is, in the header file there is a warning with line #define NOMINMAX
in 519.
also the lines 1359 to 1361 have also warnings which is very weird since vs code tells me constexpr is a c++17 language extension.
Edit: yes, i am using the latest build tools for c++ but i am actually coding it all in vs code.

@GDani31
Copy link
Author

GDani31 commented Jul 22, 2023

thats the code i was making, just a regular raycaster

#define IMM2D_IMPLEMENTATION
#define IMM2D_WIDTH 1024
#define IMM2D_HEIGHT 512
#define IMM2D_SCALE 1
#include "immediate2d.h"
#include <math.h>
#define PI 3.14159265359

float px = 300;
float py = 300;
float pa = PI;
float pdx = cos(pa)*20;
float pdy = sin(pa)*20;

int mapX = 8;
int mapY = 8;
int mapS = 64;

int map[] = 
{
    1,1,1,1,1,1,1,1,
    1,0,1,0,0,0,0,1,
    1,0,1,0,1,1,0,1,
    1,0,1,0,0,0,0,1,
    1,0,0,0,0,1,0,1,
    1,0,0,0,0,0,0,1,
    1,0,0,0,0,0,0,1,
    1,1,1,1,1,1,1,1,
};

void drawMap2D()
{
    Color tmp = Black;
    int x, y, x0, y0;

    for( y=0; y < mapY; y++ )
    {
        for( x=0; x < mapX; x++ )
        {
            if( map[y*mapX+x] == 1 ){ tmp = White; } else { tmp = Black; }
            x0 = x*mapS;
            y0 = y*mapS;

            DrawRectangle( x0 , y0 , mapS-3 , mapS-3 , tmp , tmp );

        }
    }

}


void drawPlayer()
{
    DrawCircle( (int)px , (int)py , 5 , Yellow , Yellow );
    DrawLine( px , py , px + pdx , pdy + py , 2 , Yellow );
    //DrawLine( px , py , px+50 , py+50 , 2 , Red );
}

void movePlayer()
{
    char c = LastKey();
    if( c == 'w' ){ px += pdx; py += pdy; }
    if( c == 's' ){ px -= pdx; py -= pdy; }
    if( c == 'a' ){ pa -= 0.1; if( pa < 0 )   { pa += 2*PI; } pdx = cos(pa)*20 ; pdy = sin(pa)*20; }
    if( c == 'd' ){ pa += 0.1; if( pa > 2*PI ){ pa -= 2*PI; } pdx = cos(pa)*20 ; pdy = sin(pa)*20; }

    if( c == Esc ) CloseWindow();
}

void drawRays3D()
{
    int r , mx , my , mp , dof;
    float rx, ry , ra , x0 , y0;

    ra = pa;

    for( r = 0 ; r < 1 ; r++ )
    {
        dof = 0;
        float aTan = -1/tan(ra);
        if( ra > PI ){ ry = (((int)py>>6)<<6)-0.0001; rx = (py-ry) * aTan + px; y0 = -64; x0 = -y0 * aTan; }
        if( ra < PI ){ ry = (((int)py>>6)<<6) + 64  ; rx = (py-ry) * aTan + px; y0 =  64; x0 = -y0 * aTan; }
        if( ra == 0 || ra == PI ){ rx = px; ry = py; dof = 8; }
        while( dof < 8 )
        {
            mx = (int)(rx)>>6; my = (int)(ry)>>6; mp = my * mapX + mx;
            if( mp > 0 && mp < mapX * mapY && map[mp] == 1 ){ dof = 8; }
            else{ rx += x0; ry += y0; dof += 1; }
            
        }


        DrawLine( px , py , rx , ry , 2 , Green );
        
    }

}

void run()
{
    while( true )
    {
        Wait(5);
        movePlayer();
        Clear(LightGray);
        drawMap2D();
        drawPlayer();
        drawRays3D();



    }
}

@npiegdon
Copy link
Owner

Interesting, with the latest Visual Studio 2022 with the project set to use the latest version of C++, I still can't reproduce this problem. (I don't have VS Code installed. I wonder if they use a separate toolchain...)

It looks like you've got a good start on that raycaster. If you add UseDoubleBuffering and Present, the little flicker that happens every once in a while will go away. Try this:

void run()
{
    UseDoubleBuffering(true);

    while (true)
    {
        Wait(5);
        movePlayer();
        Clear(LightGray);
        drawMap2D();
        drawPlayer();
        drawRays3D();

        Present();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants