void@qnet
teeworlds, stålverk80, evil schemer, c, c++
Languages shape the way we think, or don't.
SDL + OGL, svarta texturer utan gluBuild2DMipmaps?
Gör bara glTexImage2D med level satt till 0 (du laddar bara upp max mip). Sedan sätter du din texturfiltrering till att göra linear, inte mipmap linear.
Hm, okey, dock har just loadern till detta filformat ingen sådan funktion. Det jag vill är alltså att kunna använda nedanstående utan mipmap om det är möjligt. Beklagar inklistringen av koden :/
int BuildTexture(string szPathName, GLuint &texid, int * w, int * h) // Load Image And Convert To A Texture
{
HDC hdcTemp; // The DC To Hold Our Bitmap
HBITMAP hbmpTemp; // Holds The Bitmap Temporarily
IPicture *pPicture; // IPicture Interface
OLECHAR wszPath[MAX_PATH+1]; // Full Path To Picture (WCHAR)
char szPath[MAX_PATH+1]; // Full Path To Picture
long lWidth; // Width In Logical Units
long lHeight; // Height In Logical Units
long lWidthPixels; // Width In Pixels
long lHeightPixels; // Height In Pixels
GLint glMaxTexDim ; // Holds Maximum Texture Size
//num_texture++; // The counter of the current texture is increased
glActiveTexture(GL_TEXTURE0 + num_texture);
if (strstr(szPathName.c_str(), "http://")) // If PathName Contains http:// Then...
{
strcpy(szPath, szPathName.c_str()); // Append The PathName To szPath
}
else // Otherwise... We Are Loading From A File
{
//GetCurrentDirectory(MAX_PATH, (LPWSTR)szPath); // Get Our Working Directory
//getcwd(szPath,255);
//strcat(szPath, ""); // Append "\" After The Working Directory
//szPathName.replace(szPathName.begin(),szPathName.end(),""
//Environment::get
strcpy(szPath,szPathName.c_str());// Append The PathName
}
MultiByteToWideChar(CP_ACP, 0, szPath, -1, wszPath, MAX_PATH); // Convert From ASCII To Unicode
HRESULT hr = OleLoadPicturePath(wszPath, 0, 0, 0, IID_IPicture, (void**)&pPicture);
if(FAILED(hr)) // If Loading Failed
return FALSE; // Return False
hdcTemp = CreateCompatibleDC(GetDC(0)); // Create The Windows Compatible Device Context
if(!hdcTemp) // Did Creation Fail?
{
pPicture->Release(); // Decrements IPicture Reference Count
return FALSE; // Return False (Failure)
}
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glMaxTexDim); // Get Maximum Texture Size Supported
pPicture->get_Width(&lWidth); // Get IPicture Width (Convert To Pixels)
lWidthPixels = MulDiv(lWidth, GetDeviceCaps(hdcTemp, LOGPIXELSX), 2540);
pPicture->get_Height(&lHeight); // Get IPicture Height (Convert To Pixels)
lHeightPixels = MulDiv(lHeight, GetDeviceCaps(hdcTemp, LOGPIXELSY), 2540);
*w=lWidthPixels;
*h=lHeightPixels;
// Resize Image To Closest Power Of Two
if (lWidthPixels <= glMaxTexDim) // Is Image Width Less Than Or Equal To Cards Limit
{lWidthPixels = 1 << (int)floor((log((double)lWidthPixels)/log(2.0f)) + 0.5f);
}
else // Otherwise Set Width To "Max Power Of Two" That The Card Can Handle
lWidthPixels = glMaxTexDim;
if (lHeightPixels <= glMaxTexDim) // Is Image Height Greater Than Cards Limit
{lHeightPixels = 1 << (int)floor((log((double)lHeightPixels)/log(2.0f)) + 0.5f);
}
else // Otherwise Set Height To "Max Power Of Two" That The Card Can Handle
lHeightPixels = glMaxTexDim;
// Create A Temporary Bitmap
BITMAPINFO bi = {0}; // The Type Of Bitmap We Request
DWORD *pBits = 0; // Pointer To The Bitmap Bits
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); // Set Structure Size
bi.bmiHeader.biBitCount = 32; // 32 Bit
bi.bmiHeader.biWidth = lWidthPixels; // Power Of Two Width
bi.bmiHeader.biHeight = lHeightPixels; // Make Image Top Up (Positive Y-Axis)
bi.bmiHeader.biCompression = BI_RGB; // RGB Encoding
bi.bmiHeader.biPlanes = 1; // 1 Bitplane
// Creating A Bitmap This Way Allows Us To Specify Color Depth And Gives Us Imediate Access To The Bits
hbmpTemp = CreateDIBSection(hdcTemp, &bi, DIB_RGB_COLORS, (void**)&pBits, 0, 0);
if(!hbmpTemp) // Did Creation Fail?
{
DeleteDC(hdcTemp); // Delete The Device Context
pPicture->Release(); // Decrements IPicture Reference Count
return FALSE; // Return False (Failure)
}
SelectObject(hdcTemp, hbmpTemp); // Select Handle To Our Temp DC And Our Temp Bitmap Object
// Render The IPicture On To The Bitmap
pPicture->Render(hdcTemp, 0, 0, lWidthPixels, lHeightPixels, 0, lHeight, lWidth, -lHeight, 0);
// Convert From BGR To RGB Format And Add An Alpha Value Of 255
for(long i = 0; i < lWidthPixels * lHeightPixels; i++) // Loop Through All Of The Pixels
{
BYTE* pPixel = (BYTE*)(&pBits[i]); // Grab The Current Pixel
BYTE temp = pPixel[0]; // Store 1st Color In Temp Variable (Blue)
pPixel[0] = pPixel[2]; // Move Red Value To Correct Position (1st)
pPixel[2] = temp; // Move Temp Value To Correct Blue Position (3rd)
// This Will Make Any Black Pixels, Completely Transparent (You Can Hardcode The Value If You Wish)
if ((pPixel[0]==0) && (pPixel[1]==0) && (pPixel[2]==0)) // Is Pixel Completely Black
pPixel[3] = 0; // Set The Alpha Value To 0
else // Otherwise
pPixel[3] = 255; // Set The Alpha Value To 255
}
glGenTextures(1, &texid); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texid); // Bind To The Texture ID
// The next commands sets the texture parameters
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // If the u,v coordinates overflow the range 0,1 the image is repeated
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // The magnification function ("linear" produces better results)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//GL_LINEAR_MIPMAP_LINEAR); //The minifying function
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // We don't combine the color with the original surface color, use only the texture map.
// And create 2d mipmaps for the minifying function
//gluBuild2DMipmaps(GL_TEXTURE_2D, MIPMAPS, lWidthPixels, lHeightPixels, GL_RGBA, GL_UNSIGNED_BYTE, pBits);
DeleteObject(hbmpTemp); // Delete The Object
DeleteDC(hdcTemp); // Delete The Device Context
pPicture->Release(); // Decrements IPicture Reference Count
return TRUE; // Return True (All Good)
}
Okey, det löste sig, bytte helt enkelt ut mipmapfunktionen med den du nämnde, tack för hjälpen
- Idag Intel Arc får prestandalyft på 300 procent i Assassin's Creed: Unity 13
- Idag Sony läcker uppgifter i rättegång – så stort är Call of Duty 18
- Igår Nvidia: "Energieffektiva RTX 4060 sparar hundralappar" 39
- Igår MSI Geforce RTX 4060 Ventus 2X OC – bra prestanda vid 1080p men medioker kylare 67
- Igår Noctua släpper monteringsram för "deliddade" Ryzen 7000-processorer 15
- Hej, min fjärrkontroll till Google tv'n har pajat och kan inte synka kontrollen
- Bärbar dator för studier och enklare spel för fattig student - förslag i tråden.
- Köpråd för bärbar dator för 3D-arbete (Maya, Zbrush, Substance Designer, Houdini samt Unreal Engine)
- Köpråd: Laptop för spelande - stram budget
- Speldator 15-18k
- funderade på att köpa ett nytt system: amd eller intel?18
- Diablo IV – den stora tråden2709
- 4G router med simkort1
- Benify-erbjudanden på Samsung-TV [utbruten tråd]1033
- Youtube testar aggressiv taktik mot annonsblockerare90
- Paypal vill ersätta lösenord med passkeys2
- Veckans fråga: Vilket operativsystem föredrar du?120
- Problem att ansluta till mysql via tjänst vid boot.2
- Hej, min fjärrkontroll till Google tv'n har pajat och kan inte synka kontrollen6
- Lagringsdisk - SSD eller HDD 2023?4
- Säljes 2x Noctua NF-A14 Industrial PPC 2000rpm pwm chromax
- Säljes Switchar, RAM och vattenkylning
- Säljes Intel i5 9400f LGA1151-2
- Säljes Meta Quest 2 VR portabelt headset
- Säljes Komplett dator: Ryzen 7 3700x, GTX1080, 32GB DDR4, 1TB M.2 SSD + 1,5TB HDD, 750W PSU mm. Kan säljas med/utan GPU.
- Säljes Intel Core i5 13400F
- Säljes Gamingdator 4080 / 13700KF / 32GB DDR5
- Säljes I5 12500
- Säljes LG 27'' UltraGear 27GP950 4K Nano IPS 160 Hz HDMI 2.1
- Säljes Star Wars Jedi AMD kod
- Paypal vill ersätta lösenord med passkeys2
- Intel Arc får prestandalyft på 300 procent i Assassin's Creed: Unity13
- Youtube testar aggressiv taktik mot annonsblockerare90
- Sony läcker uppgifter i rättegång – så stort är Call of Duty18
- Nvidia: "Energieffektiva RTX 4060 sparar hundralappar"39
- MSI Geforce RTX 4060 Ventus 2X OC – bra prestanda vid 1080p men medioker kylare67
- Veckans fråga: Vilket operativsystem föredrar du?120
- Bilar med smarta inslag ger fler dumma fel78
- Noctua släpper monteringsram för "deliddade" Ryzen 7000-processorer15
- Nvidias nästa arkitektur för Geforce kommer år 202558
Externa nyheter
Spelnyheter från FZ
- Till slut – Football Manager-saves kommer kunna användas i nyare spel idag
- Quiz – Vad kan du om spöken? idag
- Dying Light 2-uppdatering i dag gör nätterna betydligt farligare idag
- Microsofts vd ser gärna att konsolexklusiviteter försvinner idag
- Bloober Team säger sig vara färdiga med psykologisk skräck idag