Hey,
Nope, I’m not using a matrix at all yet. But that would explain, why the squares’ sides are proportional to the screen resolution.
Here are both fragment and vertex shader:
///////////////////////////////////////////
///////////////////////////////////////////
// Fragment Shader
///////////////////////////////////////////
///////////////////////////////////////////
varying vec4 out_color; // in
void main(void)
{
gl_FragColor = vec4(out_color);
}
and
///////////////////////////////////////////
///////////////////////////////////////////
// Vertex Shader
///////////////////////////////////////////
///////////////////////////////////////////
attribute vec3 in_pos; // in
attribute vec4 in_color; // in
varying vec4 out_color; // out
void main(void)
{
// gl_Position legt die Position für einen Vertex fest
gl_Position = vec4(in_pos.x, in_pos.y, in_pos.z, 1.0);
// übergibt die Eingabefarbe an den nächsten Shader
out_color = in_color;
}
And that’s the game loop:
while(SDL_PollEvent(pApp->get_event()) || (exit_code == EXIT_SUCCESS && state != quit))
{
if(exit_code == EXIT_SUCCESS) // von gm_update
{
exit_code = gm_draw(pApp, &state);
if(exit_code == EXIT_SUCCESS)
{
exit_code = gm_update(pApp, &state);
// Prozessor messen
pApp->cpu_set_timestamp_prev();
pApp->cpu_set_timestamp(SDL_GetTicks());
pApp->cpu_set_timestep((pApp->cpu_get_timestamp() - pApp->cpu_get_timestamp_prev()) * 0.001);
}
}
}
gm_draw.cpp:
int gm_draw(CApp * pApp, Game_State * pstate)
{
int exit_code = EXIT_SUCCESS;
// Background
glClearColor(0.0, 0.0, 0.11, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(pApp->get_window());
// Spielstatus
switch(*pstate)
{
case load_menu:
{
pApp->draw_model(0);
} break;
case quit:
{
} break;
};
return exit_code;
}
gm_update.cpp:
int gm_update(CApp * pApp, Game_State * pstate)
{
int exit_code = EXIT_SUCCESS;
// Events
event_handler(pApp->get_eventx(), pstate);
// Spielzustände
switch(*pstate)
{
case load_menu:
{
} break;
case quit:
{
// Shader entladen
unload_shader(pApp);
} break;
};
return exit_code;
}
I’m not quite sure where in the code the problems might be. so it’s difficult to choose and post the right parts. these are just guesses. If more code is needed, I’ll post it.