小编Min*_*wth的帖子

奇怪的 OpenGL 纹理问题?:

这是我尝试加载的纹理:

在此输入图像描述

这是我运行代码时看到的内容:

在此输入图像描述

这是我正在使用的代码:

#include "sdl.h"
#include "sdl_opengl.h"
#include <stdio.h>
#include <gl/GL.h>
#include <gl/GLU.h>

Uint32 loadTexture(char* fileName)
{
    Uint32 id;
    SDL_Surface *img = NULL;

    //load into memory using SDL
    img = SDL_LoadBMP(fileName);
    //generate an id for this texture
    glGenTextures(1, &id);
    //use this texture
    glBindTexture(GL_TEXTURE_2D, id);
    //load the texture into video memory via OpenGL
    glTexImage2D(
        GL_TEXTURE_2D,
        0,
        GL_RGB,
        img->w,
        img->h,
        0,
        GL_RGB,
        GL_UNSIGNED_SHORT_5_6_5,
        img->pixels
        );

    //set mip map settings
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    SDL_FreeSurface(img);

    return id;
}

Uint32 tex;

void …
Run Code Online (Sandbox Code Playgroud)

c opengl textures

3
推荐指数
1
解决办法
328
查看次数

C++删除指针向量

这是我的代码:

#include <vector>
#include <stdio.h>
#include <iostream>

using namespace std;

class Foo 
{
public:
    Foo()
    {
    }
    ~Foo()
    {
    }
    void Bar()
    {
        cout << "bar" << endl;
    }
};

template <class T>
void deleteVectorOfPointers( T * inVectorOfPointers )
{
    typename T::iterator i;
    for ( i = inVectorOfPointers->begin() ; i < inVectorOfPointers->end(); i++ )
    {
        delete * i;
    }
    delete inVectorOfPointers;
}

int main()
{
    //create pointer to a vector of pointers to foo
    vector<Foo*>* pMyVec = new vector<Foo*>();
    //create …
Run Code Online (Sandbox Code Playgroud)

c++ pointers vector

3
推荐指数
1
解决办法
5783
查看次数

反序列化未知类型

我有以下XML:

<property name="someName" value="someValue" />
Run Code Online (Sandbox Code Playgroud)

或者,这可能是:

<property name="someName" value="5" />
Run Code Online (Sandbox Code Playgroud)

要么:

<property name="someName" value="true" />
Run Code Online (Sandbox Code Playgroud)

等等...

[Serializable]
[XmlType("property")]
public class Property
{
    [XmlAttribute("name")]
    public string Name { get; set; }
    [XmlAttribute("value")]
    public object Value { get; set; }

    public Property()
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用.我可以使用字符串或任何特定的东西,只要它始终是特定类型.我希望对象允许任何已知类型的工作.

.net c# xml serialization

3
推荐指数
1
解决办法
1228
查看次数

C++内存泄漏 - 我删除什么,在哪里?

以下函数中存在内存泄漏.我遇到的麻烦是知道删除的方式,时间,地点和内容.这是代码:

#include "stdafx.h"
#include <iostream>

void someFunc(double** ppDoubleArray, int length)
{
    double* pNewDoubleArray = new double[length];

    for(int i = 0; i < length; i++)
    {
        pNewDoubleArray[i] = 3 * i + 2;
    }

    *ppDoubleArray = pNewDoubleArray;
}
int main()
{
    double dbls[] = { 1, 2, 3, 4, 5 };
    double* pArray = dbls;

    int length = sizeof dbls / sizeof dbls[0];

    std::cout << "Before..." << std::endl;

    for(int i = 0; i < length; i++)
    {
        std::cout << pArray[i] << …
Run Code Online (Sandbox Code Playgroud)

c++ pointers memory-leaks memory-management

2
推荐指数
1
解决办法
1836
查看次数

如何将整个数组指针作为const传递,以使值无法更改?C++

如何将整个数组指针作为const传递,以使值无法更改?我将数组传递给这样的函数:

double myArr[] { 1, 2, 3, 4, 5 };
double* pArr = myArr;

double myVal = MyFunc(pArr, 5);
Run Code Online (Sandbox Code Playgroud)

MyFunc的标题现在是:

MyFunc(double* pArr, int length)
Run Code Online (Sandbox Code Playgroud)

我想确保该函数根本无法修改数组中的值.

我该怎么做呢?

c++ arrays const

2
推荐指数
1
解决办法
125
查看次数

什么是 VB6 相当于 .NET Short?

什么是 VB6 相当于 .NET Short?我需要一个 2 字节的数字变量...

.net vb6 short

2
推荐指数
1
解决办法
865
查看次数

获取当前用户ID

我试图获取当前登录用户的UserId,如本文中提到的http://msdn.microsoft.com/en-us/library/aa478949.aspx作为aspnet_Membership表的一部分.

这是我在寻找的地方:

    MembershipUser user = null;

    if (User != null && User.Identity != null && !string.IsNullOrEmpty(User.Identity.Name))
    {
        user = Membership.GetUser(User.Identity.Name);
    }

    if (user != null)
    {
        //int id = user.UserId;
    }
Run Code Online (Sandbox Code Playgroud)

MembershipUser没有UserId.我试图将UserId用作我将创建的其他表的外键.我可以使用UserName,但我认为使用UserId可能更好.

c# membershipuser asp.net-mvc-3

2
推荐指数
2
解决办法
1万
查看次数

函数覆盖本机C++

下面的代码是从派生类的函数调用基类的重写函数的正确方法吗?:

#include "stdafx.h"
#include <iostream>

class BaseClass
{
public:
    virtual void foo()
    {
        std::cout << "BaseClass::foo()" << std::endl;
    }
};
class DerivedClass : BaseClass
{
public:
    virtual void foo()
    {
        __super::foo();

        std::cout << "DerivedClass::foo()" << std::endl;
    }
};
int main()
{
    DerivedClass* dc = new DerivedClass();

    dc->foo();

    delete dc;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ overriding

1
推荐指数
1
解决办法
145
查看次数

VB6中的二进制序列化?

在C#中,我打开一个MemoryStream并使用BinaryFormatter序列化一个对象[].我需要在VB6中做同样的事情,我需要两者完全匹配.这可能吗?

.net c# vb6 serialization

1
推荐指数
1
解决办法
307
查看次数

HttpListener没有在主机外听?

我可以使用HttpListener来监听来自同一台计算机的请求,但我还没弄明白如何让它听取外部请求.

我的前缀是:"http://192.168.103.82:5000/"

我也尝试过:"http://*:5000 /"

我可以在浏览器中输入我的本地网络IP并获得响应.但是,如果我在同一网络上的另一台计算机上做同样的事情,那就没有这样的运气.

我需要做一些额外的配置吗?这是操作系统特定的问题吗?我正在运行Windows 7 Home.

.net c# webserver httplistener

1
推荐指数
1
解决办法
4091
查看次数