mirror of https://github.com/skeeto/pixelcity.git
Fixed bug where running at low resolutions or on integrated graphics with low texture size limits would end up generating all black textures.
This commit is contained in:
parent
d23e5feac6
commit
11fa52a08c
32
Render.cpp
32
Render.cpp
|
@ -112,8 +112,8 @@ enum
|
|||
EFFECT_NONE,
|
||||
EFFECT_BLOOM,
|
||||
EFFECT_COUNT,
|
||||
EFFECT_DEBUG,
|
||||
EFFECT_DEBUG_OVERBLOOM,
|
||||
EFFECT_DEBUG,
|
||||
EFFECT_BLOOM_RADIAL,
|
||||
EFFECT_COLOR_CYCLE,
|
||||
EFFECT_GLASS_CITY,
|
||||
|
@ -161,8 +161,6 @@ static void do_progress (float center_x, float center_y, float radius, float opa
|
|||
glColor4f (1,1,1, opacity);
|
||||
glBegin (GL_QUAD_STRIP);
|
||||
for (i = 0; i <= 360; i+= 15) {
|
||||
//GLrgba col = glRgbaUnique (i);
|
||||
//glColor3fv (&col.red);
|
||||
angle = (float)i * DEGREES_TO_RADIANS;
|
||||
s = sinf (angle);
|
||||
c = -cosf (angle);
|
||||
|
@ -314,7 +312,7 @@ static void do_effects (int type)
|
|||
case EFFECT_DEBUG_OVERBLOOM:
|
||||
//This will punish that uppity GPU. Good for testing low frame rate behavior.
|
||||
glBegin (GL_QUADS);
|
||||
color = WorldBloomColor () * 0.06f;
|
||||
color = WorldBloomColor () * 0.01f;
|
||||
glColor3fv (&color.red);
|
||||
for (x = -50; x <= 50; x+=5) {
|
||||
for (y = -50; y <= 50; y+=5) {
|
||||
|
@ -351,6 +349,22 @@ static void do_effects (int type)
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
int RenderMaxTextureSize ()
|
||||
{
|
||||
|
||||
int mts;
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mts);
|
||||
mts = MIN (mts, render_width);
|
||||
return MIN (mts, render_height);
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
@ -698,8 +712,13 @@ void RenderUpdate (void)
|
|||
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
|
||||
if (letterbox)
|
||||
glViewport (0, letterbox_offset, render_width, render_height);
|
||||
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (TextureReady () && !EntityReady ()) {
|
||||
do_effects (-1);
|
||||
SwapBuffers (hDC);
|
||||
return;
|
||||
}
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glFogi (GL_FOG_MODE, GL_LINEAR);
|
||||
|
@ -711,7 +730,6 @@ void RenderUpdate (void)
|
|||
glFogfv (GL_FOG_COLOR, &color.red);
|
||||
} else
|
||||
glDisable (GL_FOG);
|
||||
//glEnable (GL_COLOR_MATERIAL);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable (GL_CULL_FACE);
|
||||
|
@ -722,7 +740,6 @@ void RenderUpdate (void)
|
|||
glLoadIdentity();
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
glLoadIdentity();
|
||||
glLineWidth (1.0f);
|
||||
pos = CameraPosition ();
|
||||
|
@ -757,7 +774,6 @@ void RenderUpdate (void)
|
|||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
EntityRender ();
|
||||
}
|
||||
//do_effects (EntityReady () ? effect : -1);
|
||||
do_effects (effect);
|
||||
//Framerate tracker
|
||||
if (GetTickCount () > next_fps) {
|
||||
|
|
1
Render.h
1
Render.h
|
@ -8,6 +8,7 @@ void RenderFogToggle ();
|
|||
void RenderFPSToggle ();
|
||||
void RenderInit ();
|
||||
void RenderLetterboxToggle ();
|
||||
int RenderMaxTextureSize ();
|
||||
void RenderResize ();
|
||||
void RenderTerm ();
|
||||
void RenderUpdate ();
|
||||
|
|
11
Texture.cpp
11
Texture.cpp
|
@ -131,6 +131,7 @@ class CTexture
|
|||
public:
|
||||
int _my_id;
|
||||
unsigned _glid;
|
||||
int _desired_size;
|
||||
int _size;
|
||||
int _half;
|
||||
int _segment_size;
|
||||
|
@ -342,6 +343,7 @@ static void window (int x, int y, int size, int id, GLrgba color)
|
|||
static void do_bloom (CTexture* t)
|
||||
{
|
||||
|
||||
LIMIT_INTERVAL (10);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glViewport(0, 0, t->_size , t->_size);
|
||||
glCullFace (GL_BACK);
|
||||
|
@ -358,7 +360,6 @@ static void do_bloom (CTexture* t)
|
|||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
WorldRender ();
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
EntityRender ();
|
||||
CarRender ();
|
||||
|
@ -381,6 +382,7 @@ CTexture::CTexture (int id, int size, bool mipmap, bool clamp, bool masked)
|
|||
_mipmap = mipmap;
|
||||
_clamp = clamp;
|
||||
_masked = masked;
|
||||
_desired_size = size;
|
||||
_size = size;
|
||||
_half = size / 2;
|
||||
_segment_size = size / SEGMENTS_PER_TEXTURE;
|
||||
|
@ -455,6 +457,7 @@ void CTexture::Rebuild ()
|
|||
int i, j;
|
||||
int x, y;
|
||||
int name_num, prefix_num, suffix_num;
|
||||
int max_size;
|
||||
float radius;
|
||||
GLvector2 pos;
|
||||
GLrgba color;
|
||||
|
@ -472,6 +475,12 @@ void CTexture::Rebuild ()
|
|||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
//Since we make textures by drawing into the viewport, we can't make them bigger
|
||||
//than the current view.
|
||||
_size = _desired_size;
|
||||
max_size = RenderMaxTextureSize ();
|
||||
while (_size > max_size)
|
||||
_size /= 2;
|
||||
//Set up our viewport so that drawing into our texture will be as easy
|
||||
//as possible. We make the viewport and projection simply match the given
|
||||
//texture size.
|
||||
|
|
Loading…
Reference in New Issue