Other parts work just fine

This commit is contained in:
Vladislav Khorev 2018-09-14 22:27:04 +05:00
parent beaf57a423
commit 5f4fe5e624
7 changed files with 37 additions and 42 deletions

View File

@ -30,6 +30,8 @@
#include "ai.h" #include "ai.h"
#include "localplayer.h" #include "localplayer.h"
#include "log.h"
#define INT2FLOAT_WRLD(c) (float(c >> 6) + float(c % 64) / 64.0f) #define INT2FLOAT_WRLD(c) (float(c >> 6) + float(c % 64) / 64.0f)
#define INT2F_DIV64(v) (float(v) / 64.0f) #define INT2F_DIV64(v) (float(v) / 64.0f)
@ -515,8 +517,7 @@ activeWeapon = chooseWeapon;
void CarSprite::setSirenAnim(bool on) { void CarSprite::setSirenAnim(bool on) {
if (!(assertDeltaById(15) && assertDeltaById(16))) { if (!(assertDeltaById(15) && assertDeltaById(16))) {
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com WARN << "Trying to set siren anim on car-sprite that has no such delta!" << std::endl;
//ERROR << "Trying to set siren anim on car-sprite that has no such delta!" << std::endl;
return; return;
} }
animState.set_item(10, on); animState.set_item(10, on);

View File

@ -234,8 +234,6 @@ namespace OpenGL {
int mx, my; int mx, my;
SDL_GetMouseState(&mx, &my); SDL_GetMouseState(&mx, &my);
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
//SDL_WarpMouse(w, h);
SDL_WarpMouseInWindow(screen.surface, w, h); SDL_WarpMouseInWindow(screen.surface, w, h);
if ((mx == w) && (my == h)) if ((mx == w) && (my == h))

View File

@ -284,7 +284,7 @@ namespace OpenGL {
h = 1; h = 1;
surface = SDL_CreateWindow( surface = SDL_CreateWindow(
"SDL2/OpenGL Demo", 0, 0, w, h, "OpenGTA", 0, 0, w, h,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
// Create an OpenGL context associated with the window. // Create an OpenGL context associated with the window.

8
gl_texturecache.cpp Normal file → Executable file
View File

@ -110,10 +110,14 @@ namespace OpenGL {
GLuint tid = (i->second->texId); GLuint tid = (i->second->texId);
glDeleteTextures(1, &tid); glDeleteTextures(1, &tid);
delete i->second; delete i->second;
cached.erase(i); cached.erase(i++);
numCleared++; numCleared++;
} }
i++; else
{
++i;
}
} }
INFO << m_name << " " << numCleared << " textures recycled" << std::endl; INFO << m_name << " " << numCleared << " textures recycled" << std::endl;
} }

View File

@ -30,8 +30,6 @@
#include "opengta.h" #include "opengta.h"
#include "physfsrwops.h" #include "physfsrwops.h"
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
//#include "SDL_image.h"
#include "m_exceptions.h" #include "m_exceptions.h"
namespace ImageUtil { namespace ImageUtil {
@ -172,28 +170,12 @@ using OpenGL::PagedTexture;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
if (rgba) { if (rgba) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
} }
else { else {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
} }
/*
if (rgba) {
if (mipmapTextures)
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
}
else {
if (mipmapTextures)
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, w, h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
}*/
if (supportedMaxAnisoDegree > 1.0f) if (supportedMaxAnisoDegree > 1.0f)

View File

@ -21,8 +21,6 @@
* distribution. * * distribution. *
************************************************************************/ ************************************************************************/
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
//#include <SDL_keysym.h>
#include "key_handler.h" #include "key_handler.h"
#include "log.h" #include "log.h"

View File

@ -52,6 +52,9 @@
#include "font_cache.h" #include "font_cache.h"
#include "ai.h" #include "ai.h"
#include <SDL_keycode.h>
#define getPedById getPed #define getPedById getPed
#define removePedById removePed #define removePedById removePed
#define addPed add #define addPed add
@ -456,9 +459,6 @@ void run_init(const char* prg_name) {
screen.activate(arg_screen_w, arg_screen_h); screen.activate(arg_screen_w, arg_screen_h);
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
//SDL_EnableKeyRepeat( 0, 0 );
// more setup; that requires an active screen // more setup; that requires an active screen
#ifdef WITH_LUA #ifdef WITH_LUA
OpenGTA::Script::LuaVM & vm = OpenGTA::Script::LuaVMHolder::Instance(); OpenGTA::Script::LuaVM & vm = OpenGTA::Script::LuaVMHolder::Instance();
@ -535,8 +535,8 @@ void print_position() {
} }
/*
void handleKeyUp( SDL_keysym *keysym) { void handleKeyUp(SDL_Keysym* keysym) {
switch ( keysym->sym ) { switch ( keysym->sym ) {
case 'j': case 'j':
OpenGTA::LocalPlayer::Instance().getCtrl().releaseTurnLeft(); OpenGTA::LocalPlayer::Instance().getCtrl().releaseTurnLeft();
@ -564,7 +564,7 @@ void handleKeyUp( SDL_keysym *keysym) {
default: default:
break; break;
} }
}*/ }
void draw_mapmode(); void draw_mapmode();
@ -742,11 +742,12 @@ void car_toggle() {
} }
/*
void handleKeyPress( SDL_keysym *keysym ) { void handleKeyPress( SDL_Keysym *keysym ) {
GLfloat* cp = city->getCamPos(); GLfloat* cp = city->getCamPos();
mapPos[0] = cp[0]; mapPos[1] = cp[1]; mapPos[2] = cp[2]; mapPos[0] = cp[0]; mapPos[1] = cp[1]; mapPos[2] = cp[2];
OpenGL::Camera & cam = OpenGL::CameraHolder::Instance(); OpenGL::Camera & cam = OpenGL::CameraHolder::Instance();
switch ( keysym->sym ) { switch ( keysym->sym ) {
case SDLK_ESCAPE: case SDLK_ESCAPE:
global_Done = 1; global_Done = 1;
@ -792,6 +793,10 @@ void handleKeyPress( SDL_keysym *keysym ) {
texsprite_toggle = (texsprite_toggle ? 0 : 1); texsprite_toggle = (texsprite_toggle ? 0 : 1);
OpenGTA::SpriteManagerHolder::Instance().setDrawTexBorder(texsprite_toggle); OpenGTA::SpriteManagerHolder::Instance().setDrawTexBorder(texsprite_toggle);
break; break;
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
/*
case SDLK_F4: case SDLK_F4:
follow_toggle = (follow_toggle ? 0 : 1); follow_toggle = (follow_toggle ? 0 : 1);
if (follow_toggle) { if (follow_toggle) {
@ -813,7 +818,7 @@ void handleKeyPress( SDL_keysym *keysym ) {
OpenGTA::SpriteManagerHolder::Instance().removeDeadStuff(); OpenGTA::SpriteManagerHolder::Instance().removeDeadStuff();
GUI::remove_ingame_gui(); GUI::remove_ingame_gui();
} }
break; break;*/
case SDLK_RETURN: case SDLK_RETURN:
car_toggle(); car_toggle();
break; break;
@ -954,7 +959,7 @@ void handleKeyPress( SDL_keysym *keysym ) {
city->setVisibleRange(city->getVisibleRange()+1); city->setVisibleRange(city->getVisibleRange()+1);
INFO << " new visible range " << city->getVisibleRange() << std::endl; INFO << " new visible range " << city->getVisibleRange() << std::endl;
break; break;
case SDLK_PRINT: case SDLK_PRINTSCREEN:
OpenGL::ScreenHolder::Instance().makeScreenshot("screenshot.bmp"); OpenGL::ScreenHolder::Instance().makeScreenshot("screenshot.bmp");
break; break;
default: default:
@ -962,7 +967,7 @@ void handleKeyPress( SDL_keysym *keysym ) {
} }
city->setPosition(mapPos[0], mapPos[1], mapPos[2]); city->setPosition(mapPos[0], mapPos[1], mapPos[2]);
}*/ }
void drawScene(Uint32 ticks) { void drawScene(Uint32 ticks) {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -1172,14 +1177,21 @@ void run_main() {
paused = 1; paused = 1;
else else
paused = 0; paused = 0;
break; break;*/
case SDL_KEYDOWN: case SDL_KEYDOWN:
handleKeyPress(&event.key.keysym); if (event.key.repeat == 0)
{
handleKeyPress(&event.key.keysym);
}
break; break;
case SDL_KEYUP: case SDL_KEYUP:
handleKeyUp(&event.key.keysym); if (event.key.repeat == 0)
{
handleKeyUp(&event.key.keysym);
}
break; break;
case SDL_VIDEORESIZE: /* case SDL_VIDEORESIZE:
OpenGL::ScreenHolder::Instance().resize(event.resize.w, event.resize.h); OpenGL::ScreenHolder::Instance().resize(event.resize.w, event.resize.h);
break;*/ break;*/
case SDL_QUIT: case SDL_QUIT: