• 10
• 9
• 10
• 9
• 10
• ### Similar Content

• By lxjk
Hi guys,
There are many ways to do light culling in tile-based shading. I've been playing with this idea for a while, and just want to throw it out there.
Because tile frustums are general small compared to light radius, I tried using cone test to reduce false positives introduced by commonly used sphere-frustum test.
On top of that, I use distance to camera rather than depth for near/far test (aka. sliced by spheres).
This method can be naturally extended to clustered light culling as well.
The following image shows the general ideas

Performance-wise I get around 15% improvement over sphere-frustum test. You can also see how a single light performs as the following: from left to right (1) standard rendering of a point light; then tiles passed the test of (2) sphere-frustum test; (3) cone test; (4) spherical-sliced cone test

I put the details in my blog post (https://lxjk.github.io/2018/03/25/Improve-Tile-based-Light-Culling-with-Spherical-sliced-Cone.html), GLSL source code included!

Eric

• Good evening everyone!

I was wondering if there is something equivalent of  GL_NV_blend_equation_advanced for AMD?
Basically I'm trying to find more compatible version of it.

Thank you!

• Hello guys,

How do I know? Why does wavefront not show for me?
I already checked I have non errors yet.

And my download (mega.nz) should it is original but I tried no success...
- Add blend source and png file here I have tried tried,.....

PS: Why is our community not active? I wait very longer. Stop to lie me!
Thanks !

• I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.

• Hello everyone,
I have problem with texture

# OpenGL Font Width Issues

This topic is 4367 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I'm trying my best to code a 1/2 decent Pong remake using OpenGL. I have an engine that is working pretty well, and I have a class for my Bitmap fonts. I have until now simply put the fonts on screen using passed variables (x and y). I would like to center the text on the screen, but I'm not sure how. I'm not sure how wide my fonts are. I have different sized fonts and whatnot, so being able to figure this out when the font is made would be best I'd think. This is my code for my Bitmap font class. Any help is welcome.
/*=================================================================
BitMapFont.cpp
Implementing the BitmapFont class.
==================================================================*/

#include "BitMapFont.h"

BitmapFont::BitmapFont(HDC hDC, int size, char* family)
{
// set font size for later reference when centering
fontSize = size;

if (hDC && family && strlen(family) > 0)
{
HFONT font;     //windows font id
HFONT oldFont;  // housekeeping
base = glGenLists(256);

font = CreateFont(  size * -1,                  //height of font
0,                          //width of font
0,                          //angle of escapement
0,                          //angle of orientation
FW_BOLD,                    //weight of font
FALSE,                      //italic
FALSE,                      //underline
FALSE,                      //strikeout
ANSI_CHARSET,               //character set
OUT_TT_PRECIS,              //output precision
CLIP_DEFAULT_PRECIS,        //clipping precision
ANTIALIASED_QUALITY,        //antialiase the font
FF_DONTCARE|DEFAULT_PITCH,  //Family And Pitch
family);                    //Font name

oldFont = (HFONT)SelectObject(hDC, font);
wglUseFontBitmaps(hDC, 0, 256, base);
SelectObject(hDC, oldFont);
DeleteObject(font);
}
}

BitmapFont::~BitmapFont()
{
glDeleteLists(base, 256);
}

bool BitmapFont::DrawString(int x, int y, const char *text, ...)
{

char    output[256];
va_list ap;

if (text == NULL)
return false;

va_start(ap, text);             // Parses The String For Variables
vsprintf(output, text, ap);     // And Converts Symbols To Actual Numbers
va_end(ap);

glRasterPos3f(x, y, 0.0f);

// Must save/restore the list base.
glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(strlen(output), GL_UNSIGNED_BYTE, output);
glPopAttrib();

return true;
}

bool BitmapFont::DrawCentered(int y, const char *text, ...)
{

float length = 0;
char    output[256];
va_list ap;

if (text == NULL)
return false;

va_start(ap, text);                 // Parses The String For Variables
vsprintf(output, text, ap);         // And Converts Symbols To Actual Numbers
va_end(ap);

// calculate length of string
for(unsigned int i = 0; i < (strlen(output)); i++)
length += fontSize;

glRasterPos3f(SCREEN_WIDTH/2 - length/2, y, 0.0f);  // HELP!!

// Must save/restore the list base.
glPushAttrib(GL_LIST_BIT);
glListBase(base);
glCallLists(strlen(output), GL_UNSIGNED_BYTE, output);
glPopAttrib();

return true;
}



##### Share on other sites
For TrueType fonts:
GetCharABCWidths
For non TrueType fonts:
GetCharWidth32

##### Share on other sites
// Load the widths of the current font (our font)if( !GetCharWidth32(hdc, 32, 127, m_charWidths) ){	util::Message::print("IBitmapFont:: Unable to load character widths for font \"%s\"", name);	return false;	// FIXME: error can't get the width properly, so we assume that there is a problem}

Where m_charWidths is an array[96] of ints, because I believe that in the first set of ascii characters there are 96 printable characters (if I'm wrong please let me know, this would be something I would have to fix).

Then, to get the width of any particular character:
int getCharWidth(char c) const{	return m_charWidths[c-32];	// because we're not using the first 32 characters (non-printable)}

##### Share on other sites
Thanks for the help!!

How would you specify the font to use? I'm not sure exactly how to use this function to do what I need. I'm guessing you'd simply initialize the buffer array in the constructor and then utilize it afterwards when figuring out the length of the string. Correct?

Can anyone supply some more example code that uses the function or initializes it?